Alternc  latest
Alternc logiel libre pour l'hébergement
m_bro.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  ----------------------------------------------------------------------
5  LICENSE
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License (GPL)
9  as published by the Free Software Foundation; either version 2
10  of the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  To read the license please visit http://www.gnu.org/copyleft/gpl.html
18  ----------------------------------------------------------------------
19 */
20 
21 /* Add the mime type list */
22 @include("mime.php");
23 
24 /**
25  * This class manage the file browser of AlternC
26  * allow the file and directory management in the user account web folder
27  *
28  * @copyright AlternC-Team 2000-2017 https://alternc.com/
29  */
30 class m_bro {
31 
32  /** How we draw the file in column */
33  var $l_mode;
34 
35  /** download mode of a compressed folder */
36  var $l_tgz;
37 
38  /** Shall we show icons or just names? */
39  var $l_icons;
40 
41  /** What do we do after creating a file? */
43 
44  /** internal cache */
45  var $mime_desc = array();
46  var $mime_icon = array();
47  var $mime_type = array();
48  var $cacheurl = array();
49 
50  /** Font choice in the editor */
51  var $l_editor_font = array("Arial, Helvetica, Sans-serif", "Times, Bookman, Serif", "Courier New, Courier, Fixed");
52 
53  /** font size in the editor */
54  var $l_editor_size = array("18px", "14px", "12px", "10px", "8px", "0.8em", "0.9em", "1em", "1.1em", "1.2em");
55 
56 
57  /**
58  * Constructor
59  * */
60  function m_bro() {
61  $this->l_mode = array(0 => _("1 column, detailed"), 1 => _("2 columns, short"), 2 => _("3 columns, short"));
62  $this->l_tgz = array(0 => _("tgz (Linux)"), 1 => _("tar.bz2 (Linux)"), 2 => _("zip (Windows/Dos)"), 3 => _("tar.Z (Unix)"));
63  $this->l_icons = array(0 => _("No"), 1 => _("Yes"));
64  $this->l_createfile = array(0 => _("Go back to the file manager"), 1 => _("Edit the newly created file"));
65  }
66 
67 
68  /**
69  * Hook called by the menu class to add menus to the left panel
70  * @return array
71  */
72  function hook_menu() {
73  $obj = array(
74  'title' => _("File browser"),
75  'ico' => 'images/folder.png',
76  'link' => 'bro_main.php',
77  'pos' => 40,
78  );
79 
80  return $obj;
81  }
82 
83 
84  /**
85  * Verifie un dossier relatif au dossier de l'utilisateur courant
86  *
87  * @param string $dir
88  * @global m_mem $mem
89  * @param string $dir Dossier absolu que l'on souhaite vérifier
90  * @param boolean $strip
91  * @return false|string Retourne le nom du dossier vérifié, relatif au
92  * dossier de l'utilisateur courant, éventuellement corrigé.
93  * ou FALSE si le dossier n'est pas dans le dossier de l'utilisateur.
94  */
95  function convertabsolute($dir, $strip = true) {
96  global $mem;
97  $root = $this->get_user_root($mem->user["login"]);
98  // Sauvegarde du chemin de base.
99  $root_alternc = $root;
100  // Passage du root en chemin rel (diffrent avec un lien)
101  $root = realpath($root);
102  // separer le chemin entre le repertoire et le fichier
103  $file = basename($dir);
104  $dir = dirname($dir);
105  $dir = realpath($root . "/" . $dir);
106  // verifier que le repertoire est dans le home de l'usager
107  if (substr($dir, 0, strlen($root)) != $root) {
108  return false;
109  }
110 
111  // recomposer le chemin
112  $dir = $dir . '/' . $file;
113 
114  # Si on tente de mettre un '..' alors erreur
115  if (preg_match("/\/\.\.\//", $dir) || preg_match("/\/\.\.$/", $dir)) {
116  return false;
117  }
118 
119  if ($strip) {
120  $dir = substr($dir, strlen($root));
121  } else {
122  // si on ne strip pas, il faut enlever le chemin rel
123  // et mettre la racine d'alternc pour viter les
124  // problmes de lien depuis /var /alternc !
125  $dir = $root_alternc . substr($dir, strlen($root));
126  }
127  if (substr($dir, -1) == "/") {
128  return substr($dir, 0, strlen($dir) - 1);
129  } else {
130  return $dir;
131  }
132  }
133 
134 
135  /**
136  * Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
137  *
138  * Returns the complete path to the root of the user's directory.
139  *
140  * @param string $login Username
141  * @return string Returns the complete path to the root of the user's directory.
142  */
143  function get_user_root($login) {
144  return getuserpath();
145  }
146 
147 
148  /**
149  * Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
150  * Returns the complete path to the root of the user's directory.
151  *
152  * @todo [ML] Comment faire ca correctement?
153  * C'est utilise' dans class/m_dom.php quand un utilisateur ajoute un domaine dans son compte
154  * et nous devons savoir quel est le chemin complet vers la racine de son compte..
155  *
156  * @global m_admin $admin
157  * @param int $uid User id.
158  * @return string Returns the complete path to the root of the user's directory.
159  */
160  function get_userid_root($uid) {
161  global $admin;
162 
163  $old_enabled = $admin->enabled;
164  $admin->enabled = true;
165  $member = $admin->get($uid);
166  $admin->enabled = $old_enabled;
167 
168  return $this->get_user_root($member['login']);
169  }
170 
171 
172  /**
173  * Retourne un tableau contenant la liste des fichiers du dossier courant
174  *
175  * Ce tableau contient tous les paramtres des fichiers du dossier courant
176  * sous la forme d'un tableau index de tableaux associatifs comme suit :
177  * $a["name"]=nom du fichier / dossier
178  * $a["size"]=Taille totale du fichier / dossier + sous-dossier
179  * $a["date"]=Date de dernire modification
180  * $a["type"]=Type du fichier (1 pour fichier, 0 pour dossier)
181  *
182  * @global m_mysql $db
183  * @global int $cuid
184  * @global m_messages $msg
185  * @param string $dir Dossier relatif au dossier racine du compte du membre courant
186  * @param boolean $showdirsize
187  * @return array Le tableau contenant les fichiers de $dir, et
188  */
189  function filelist($dir = "", $showdirsize = false) {
190  global $db, $cuid, $msg;
191  $db->query("UPDATE browser SET lastdir= ? WHERE uid= ?;", array($dir, $cuid));
192  $absolute = $this->convertabsolute($dir, false);
193  if (!$absolute || !file_exists($absolute)) {
194  $msg->raise("ERROR", 'bro', _("This directory does not exist."));
195  return false;
196  }
197  if (!is_readable($absolute)) {
198  $msg->raise("ERROR", 'bro', _("This directory is not readable."));
199  return false;
200  }
201  clearstatcache(true);
202  $c = array();
203  if ($dir = @opendir($absolute)) {
204  while (($file = readdir($dir)) !== false) {
205  if ($file != "." && $file != "..") {
206  $stat=stat($absolute . "/" . $file);
207  $c[] = array("name" => $file, "size" => $this->fsize($absolute . "/" . $file, $showdirsize),
208  "date" => filemtime($absolute . "/" . $file), "type" => (!is_dir($absolute . "/" . $file)),
209  "permissions" => $stat[2] );
210  }
211  }
212  closedir($dir);
213  }
214  usort($c, array("m_bro", "_sort_filelist_name"));
215  return $c;
216  }
217 
218 
219  /**
220  * Retourne un tableau contenant les prfrences de l'utilisateur courant
221  *
222  * Ce tableau associatif contient les valeurs des champs de la table "browser"
223  * pour l'utilisateur courant.
224  *
225  * @global m_mysql $db
226  * @global int $cuid
227  * @return array Tableau des prfrences de l'utilisateur courant.
228  */
229  function GetPrefs() {
230  global $db, $cuid;
231  $db->query("SELECT * FROM browser WHERE uid= ?;", array($cuid));
232  if ($db->num_rows() == 0) {
233  $db->query("INSERT INTO browser (editsizex, editsizey, listmode, showicons, downfmt, createfile, showtype, uid, editor_font, editor_size) VALUES (70, 21, 0, 0, 0, 0, 0, ?,'Arial, Helvetica, Sans-serif','12px');", array($cuid));
234  $db->query("SELECT * FROM browser WHERE uid= ?;", array($cuid));
235  }
236  $db->next_record();
237  return $db->Record;
238  }
239 
240 
241  /**
242  Modifie les prfrences de l'utilisateur courant.
243  *
244  * @global m_mysql $db
245  * @global int $cuid
246  * @param integer $editsizex Taille de l'diteur (nombre de colonnes)
247  * @param integer $editsizey Taille de l'diteur (nombre de lignes)
248  * @param integer $listmode Mode d'affichage de la liste des fichiers
249  * @param integer $showicons Faut-il afficher / cacher les icones des fichiers
250  * @param integer $downfmt Dans quel format faut-il tlcharger les dossiers compresss
251  * @param integer $createfile Faut-il editer/revenir au browser aprs cration d'un fichier
252  * @param integer $showtype Faut-il afficher le type mime des fichiers
253  * @param integer $editor_font Quelle police faut-il utiliser pour l'diteur
254  * @param integer $editor_size Quelle taille de police faut-il utiliser pour l'diteur
255  * @param integer $golastdir Faut-il revenir la racine ou au dernier dossier visit ?
256  * @return boolean
257  */
258  function SetPrefs($editsizex, $editsizey, $listmode, $showicons, $downfmt, $createfile, $showtype, $editor_font, $editor_size, $golastdir) {
259  global $db, $cuid;
260  $editsizex = intval($editsizex);
261  $editsizey = intval($editsizey);
262  $listmode = intval($listmode);
263  $showicons = intval($showicons);
264  $showtype = intval($showtype);
265  $downfmt = intval($downfmt);
266  $createfile = intval($createfile);
267  $golastdir = intval($golastdir);
268  $db->query("SELECT * FROM browser WHERE uid= ?;", array(intval($cuid)));
269  if ($db->num_rows() == 0) {
270  $db->query("INSERT INTO browser (editsizex, editsizey, listmode, showicons, downfmt, createfile, showtype, uid, editor_font, editor_size, golastdir) VALUES (70, 21, 0, 0, 0, 0, 0, ?,'Arial, Helvetica, Sans-serif','12px',1);", array(intval($cuid)));
271  }
272  $db->query("UPDATE browser SET editsizex= ?, editsizey= ?, listmode= ?, showicons= ?, downfmt= ?, createfile= ?, showtype= ?, editor_font= ?, editor_size= ?, golastdir= ? WHERE uid= ?;", array($editsizex, $editsizey, $listmode, $showicons, $downfmt, $createfile, $showtype, $editor_font, $editor_size, $golastdir, intval($cuid)));
273  return true;
274  }
275 
276 
277  /**
278  * Retourne le nom du fichier icone associ au fichier donc le nom est $file
279  * <b>Note</b>: Les fichiers icones sont mis en cache sur la page courante.
280  *
281  * @global array $bro_icon
282  * @param string $file Fichier dont on souhaite connaitre le fichier icone
283  * @return string Fichier icone correspondant.
284  */
285  function icon($file) {
286  global $bro_icon;
287  if (!strpos($file, ".") && substr($file, 0, 1) != ".") {
288  return "file.png";
289  }
290  $t = explode(".", $file);
291  if (!is_array($t)) {
292  $ext = $t;
293  } else {
294  $ext = $t[count($t) - 1];
295  }
296  // Now seek the extension
297  if (!isset($bro_icon[$ext]) || !$bro_icon[$ext]) {
298  return "file.png";
299  } else {
300  return $bro_icon[$ext] . ".png";
301  }
302  }
303 
304 
305  /**
306  * Retourne le type mime associé au fichier donc le nom est $file
307  * <b>Note</b>: Les types mimes sont mis en cache sur la page courante.
308  * Le type mime est dtermin d'aprs l'extension du fichier.
309  *
310  * @global array $bro_type
311  * @param string $file Fichier dont on souhaite connaitre le type mime
312  * @return string Type mime / Sous type du fichier demand
313  */
314  function mime($file) {
315  global $bro_type;
316  if (!strpos($file, ".") && substr($file, 0, 1) != ".") {
317  return "File";
318  }
319  $t = explode(".", $file);
320  if (!is_array($t)) {
321  $ext = $t;
322  } else {
323  $ext = $t[count($t) - 1];
324  }
325  // Now seek the extension
326  if (empty($bro_type[$ext])) {
327  return "File";
328  } else {
329  return $bro_type[$ext];
330  }
331  }
332 
333 
334  /**
335  * Retourne la taille du fichier $file
336  * si $file est un dossier, retourne la taille de ce dossier et de tous
337  * ses sous dossiers.
338  *
339  * @param string $file Fichier dont on souhaite connaitre la taille
340  * @param boolean $showdirsize Recursively compute the directory size.
341  * @return integer Taille du fichier en octets.
342  * @return int|string
343  */
344  function fsize($file, $showdirsize = false) {
345  if (is_dir($file)) {
346  if ($showdirsize) {
347  return $this->dirsize($file);
348  } else {
349  return "-";
350  }
351  } else {
352  return filesize($file);
353  }
354  }
355 
356 
357  /**
358  * Returns the size of a directory, by adding all it's files sizes
359  *
360  * @param string $dir The directory whose size we want to compute
361  * @return integer The total size in bytes.
362  */
363  function dirsize($dir) {
364  $totalsize = 0;
365 
366  if (($handle = opendir($dir))) {
367  while (false !== ($file = readdir($handle))) {
368  $nextpath = $dir . '/' . $file;
369 
370  if ($file != '.' && $file != '..' && !is_link($nextpath)) {
371  if (is_dir($nextpath)) {
372  $totalsize += $this->dirsize($nextpath);
373  } elseif (is_file($nextpath)) {
374  $totalsize += filesize($nextpath);
375  }
376  }
377  }
378  closedir($handle);
379  }
380  return $totalsize;
381  }
382 
383 
384  /**
385  * Crée le dossier $file dans le dossier (parent) $dir
386  *
387  * @global m_mysql $db
388  * @global int $cuid
389  * @global m_messages $msg
390  * @param string $dir Dossier dans lequel on veut crer un sous-dossier
391  * @param string $file Nom du dossier à créer
392  * @return boolean TRUE si le dossier a été créé, FALSE si une erreur s'est produite.
393  */
394  function CreateDir($dir, $file) {
395  global $db, $cuid, $msg;
396  $file = ssla($file);
397  $absolute = $this->convertabsolute($dir . "/" . $file, false);
398  if ($absolute && (!file_exists($absolute))) {
399  if (!mkdir($absolute, 00777, true)) {
400  $msg->raise("ERROR", "bro", _("Cannot create the requested directory. Please check the permissions"));
401  return false;
402  }
403  $db->query("UPDATE browser SET crff=1 WHERE uid= ?;", array($cuid));
404  return true;
405  } else {
406  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
407  return false;
408  }
409  }
410 
411 
412  /**
413  * Crée un fichier vide dans un dossier
414  *
415  * @global m_mysql $db
416  * @global m_messages $msg
417  * @global int $cuid
418  * @param string $dir Dossier dans lequel on veut crer un sous-dossier
419  * @param string $file Nom du dossier à créer
420  * @return boolean TRUE si le dossier a été créé, FALSE si une erreur s'est produite.
421  */
422  function CreateFile($dir, $file) {
423  global $db, $msg, $cuid;
424  $file = ssla($file);
425  $absolute = $this->convertabsolute($dir . "/" . $file, false);
426  if (!$absolute || file_exists($absolute)) {
427  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
428  return false;
429  }
430  if (!file_exists($absolute)) {
431  if (!@touch($absolute)) {
432  $msg->raise("ERROR", "bro", _("Cannot create the requested file. Please check the permissions"));
433  return false;
434  }
435  }
436  $db->query("UPDATE browser SET crff=0 WHERE uid= ?;", array($cuid));
437  return true;
438  }
439 
440 
441  /**
442  * Efface les fichiers du tableau $file_list dans le dossier $R
443  *
444  * @global m_messages $msg
445  * @global m_mem $mem
446  * @param array $file_list Liste des fichiers effacer.
447  * @param string $R Dossier dans lequel on efface les fichiers
448  * @return boolean TRUE si les fichiers ont t effacs, FALSE si une erreur s'est produite.
449  */
450  function DeleteFile($file_list, $R) {
451  global $msg;
452  $root = realpath(getuserpath());
453  $absolute = $this->convertabsolute($R, false);
454  if (!$absolute && strpos($root, $absolute) === 0 && strlen($absolute) > (strlen($root) + 1)) {
455  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
456  return false;
457  }
458  for ($i = 0; $i < count($file_list); $i++) {
459  $file_list[$i] = ssla($file_list[$i]);
460  if (!strpos($file_list[$i], "/") && file_exists($absolute . "/" . $file_list[$i])) { // Character / forbidden in a FILE name
461  $this->_delete($absolute . "/" . $file_list[$i]);
462  }
463  }
464  return true;
465  }
466 
467 
468  /**
469  * Renomme les fichier de $old du dossier $R en $new
470  *
471  * @global m_messages $msg
472  * @param string $R Dossier dans lequel se trouve les fichiers renommer.
473  * @param array $old Ancien nom des fichiers
474  * @param array $new Nouveau nom des fichiers
475  * @return boolean TRUE si les fichiers ont t renomms, FALSE si une erreur s'est produite.
476  */
477  function RenameFile($R, $old, $new) {
478  global $msg;
479  $absolute = $this->convertabsolute($R, false);
480  if (!$absolute) {
481  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
482  return false;
483  }
484  $alea = "." . time() . mt_rand(1000, 9999);
485  for ($i = 0; $i < count($old); $i++) {
486  $old[$i] = ssla($old[$i]); // strip slashes if needed
487  $new[$i] = ssla($new[$i]);
488  if (!strpos($old[$i], "/") && !strpos($new[$i], "/")) { // caractre / interdit dans old ET dans new...
489  @rename($absolute . "/" . $old[$i], $absolute . "/" . $old[$i] . $alea);
490  }
491  }
492  for ($i = 0; $i < count($old); $i++) {
493  if (!strpos($old[$i], "/") && !strpos($new[$i], "/")) { // caractre / interdit dans old ET dans new...
494  @rename($absolute . "/" . $old[$i] . $alea, $absolute . "/" . $new[$i]);
495  }
496  }
497 
498  return true;
499  }
500 
501 
502  /**
503  * Déplace les fichier de $d du dossier $old vers $new
504  *
505  * @global m_messages $msg
506  * @param array $d Liste des fichiers du dossier $old dplacer
507  * @param string $old Dossier dans lequel se trouve les fichiers dplacer.
508  * @param string $new Dossier vers lequel seront dplacs les fichiers.
509  * @return boolean TRUE si les fichiers ont t renomms, FALSE si une erreur s'est produite.
510  */
511  function MoveFile($d, $old, $new) {
512  global $msg;
513  $old = $this->convertabsolute($old, false);
514  if (!$old) {
515  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
516  return false;
517  }
518 
519  if ($new[0] != '/') {
520  $new = $old . '/' . $new;
521  }
522  $new = $this->convertabsolute($new, false);
523 
524  if (!$new) {
525  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
526  return false;
527  }
528  if ($old == $new) {
529  $msg->raise("ERROR", "bro", _("You cannot move or copy a file to the same folder"));
530  return false;
531  }
532  for ($i = 0; $i < count($d); $i++) {
533  $d[$i] = ssla($d[$i]); // strip slashes if needed
534  if (!strpos($d[$i], "/") && file_exists($old . "/" . $d[$i]) && !file_exists($new . "/" . $d[$i])) {
535  if (!rename($old . "/" . $d[$i], $new . "/" . $d[$i])) {
536  $msg->raise("ERROR", "bro", "error renaming $old/$d[$i] -> $new/$d[$i]");
537  }
538  }
539  }
540  return true;
541  }
542 
543 
544  /**
545  * Change les droits d'acces aux fichier de $d du dossier $R en $p
546  *
547  * @param string $R Dossier dans lequel se trouve les fichiers renommer.
548  * @param string $d list of files whose permission must be changed
549  * @param string $perm the permission to change
550  * @param boolean $verbose Shall we 'echo' what we did ?
551  * @return boolean TRUE Si les fichiers ont t renomms, FALSE si une erreur s'est produite.
552  */
553  function ChangePermissions($R, $d, $perm) {
554  global $msg, $action;
555  $absolute = $this->convertabsolute($R, false);
556  if (!$absolute) {
557  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
558  return false;
559  }
560  for ($i = 0; $i < count($d); $i++) {
561  $d[$i] = ssla($d[$i]); // strip slashes if needed
562  // If the form checkboxes are not checked, PHP will not fill in a
563  // value at all for the permissions. Set the default to unwriteable
564  // unless explicitly marked as writable.
565  if (!isset($perm[$i])) {
566  $perm[$i]['w'] = False;
567  }
568  if (!strpos($d[$i], "/")) { // caractre / interdit dans le nom du fichier
569  $m = fileperms($absolute . "/" . $d[$i]);
570 
571  // pour l'instant on se limite a "write" pour owner, puisque c'est le seul
572  // cas interessant compte tenu de la conf de Apache pour AlternC..
573  if ($perm[$i]['w']) {
574  $m = $m | 0220; // ug+w
575  } else {
576  $m = $m & (~ 0222); // ugo-w
577  }
578  $action->chmod($absolute . "/" . $d[$i], $m);
579  }
580  }
581  // We'd like to *wait* for this to complete, but since this is essentially asynchronous, we can't be sure easily
582  // So we chose to wait a little bit (2 sec) at the end of the loop...
583  sleep(2);
584  return true;
585  }
586 
587 
588  /**
589  * Recoit un champ file upload (Global) et le stocke dans le dossier $R
590  * Le champ file-upload originel doit s'appeler "userfile" et doit
591  * bien être un fichier d'upload.
592  *
593  *
594  * @global array $_FILES
595  * @global m_messages $msg
596  * @global int $cuid
597  * @global m_action $action
598  * @param string $R Dossier dans lequel on upload le fichier
599  * @returns string The path where the file resides or false if upload failed
600  */
601  function UploadFile($R) {
602  global $_FILES, $msg, $cuid, $action;
603  $absolute = $this->convertabsolute($R, false);
604  if (!$absolute) {
605  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
606  return false;
607  }
608  if (!strpos($_FILES['userfile']['name'], "/")) {
609  if ($_FILES['userfile']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['userfile']['tmp_name'])) {
610  if (!file_exists($absolute . "/" . $_FILES['userfile']['name'])) {
611  @touch($absolute . "/" . $_FILES['userfile']['name']);
612  }
613  if (@move_uploaded_file($_FILES['userfile']['tmp_name'], $absolute . "/" . $_FILES['userfile']['name'])) {
614  $action->fix_file($absolute . "/" . $_FILES['userfile']['name']);
615  return $absolute . "/" . $_FILES['userfile']['name'];
616  } else {
617  $msg->raise("ERROR", "bro", _("Cannot create the requested file. Please check the permissions"));
618  return false;
619  }
620  } else {
621  // there was an error, raise it
622  $msg->log("bro", "uploadfile", "Problem when uploading a file");
623  switch ($_FILES['userfile']['error']) {
624  case UPLOAD_ERR_INI_SIZE:
625  $erstr = _("The uploaded file exceeds the max file size allowed");
626  break;
627  case UPLOAD_ERR_FORM_SIZE:
628  case UPLOAD_ERR_PARTIAL:
629  case UPLOAD_ERR_NO_FILE:
630  case UPLOAD_ERR_NO_TMP_DIR:
631  case UPLOAD_ERR_CANT_WRITE:
632  case UPLOAD_ERR_EXTENSION:
633  default:
634  $erstr = _("Undefined error ") . $_FILES['userfile']['error'];
635  break;
636  }
637  $msg->raise("ERROR", "bro", _("Error during the upload of the file: ") . $erstr);
638  return false;
639  }
640  }
641  return $absolute . "/" . $_FILES['userfile']['name'];
642  }
643 
644 
645  /**
646  * Extract an archive by using GNU and non-GNU tools
647  *
648  * @global m_messages $msg
649  * @global int $cuid
650  * @global m_mem $mem
651  * @global m_action $action
652  * @param string $file Full or relative path to the archive
653  * @param string $dest Path of the extract destination, the
654  * same directory as the archive by default
655  * @return integer|null != 0 on error
656  */
657  function ExtractFile($file, $dest = null) {
658  global $msg, $action;
659  $file = $this->convertabsolute($file, false);
660  if (is_null($dest)) {
661  $dest = dirname($file);
662  } else {
663  $dest = $this->convertabsolute($dest, false);
664  }
665  if (!$file || !$dest || !is_readable($file)) {
666  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
667  return 1;
668  }
669  $lfile = strtolower($file);
670  if (substr($lfile, -4) == ".tar" || substr($lfile, -8) == ".tar.bz2" || substr($lfile, -7) == ".tar.gz" || substr($lfile, -6) == ".tar.z" || substr($lfile, -4) == ".tgz" || substr($lfile, -4) == ".tbz" || substr($lfile, -5) == ".tbz2" ) {
671  // TODO new version of tar supports `tar xf ...` so there is no
672  // need to specify the compression format
673  echo "<p>" . _("Uncompressing through TAR") . "</p><pre style=\"overflow: scroll; height: 200px\">";
674  $ret = 0;
675  passthru("tar -xvf " . escapeshellarg($file) . " --numeric-owner -C " . escapeshellarg($dest) . " 2>&1", $ret);
676  }
677  elseif (substr($lfile, -4) == ".zip") {
678  echo "<p>" . _("Uncompressing through UNZIP") . "</p><pre style=\"overflow: scroll; height: 200px\">";
679  $cmd = "unzip -o " . escapeshellarg($file) . " -d " . escapeshellarg($dest) . " 2>&1";
680  passthru($cmd, $ret);
681  }
682  elseif (substr($lfile, -3) == ".gz" || substr($lfile, -2) == ".Z") {
683  echo "<p>" . _("Uncompressing through GUNZIP") . "</p><pre style=\"overflow: scroll; height: 200px\">";
684  $cmd = "gunzip " . escapeshellarg($file) . " 2>&1";
685  passthru($cmd, $ret);
686  }
687  elseif (substr($lfile, -3) == ".bz" || substr($lfile, -4) == ".bz2") {
688  echo "<p>" . _("Uncompressing through bunzip2") . "</p><pre style=\"overflow: scroll; height: 200px\">";
689  $cmd = "bunzip2 " . escapeshellarg($file) . " 2>&1";
690  passthru($cmd, $ret);
691  }
692  echo "</pre>";
693 
694  // fix the perms of the extracted archive TODO: does it work??? | note: it was using a wrong variable name !
695  $action->fix_dir($dest);
696 
697  if ($ret) {
698  $msg->raise("ERROR", "bro", _("I cannot find a way to extract the file %s, it is an unsupported compressed format"), $file);
699  return false;
700  }
701  return true;
702  }
703 
704 
705  /**
706  * Copy many files from point A to point B
707  *
708  * @global m_messages $msg
709  * @param array $d List of files to move
710  * @param string $old
711  * @param string $new
712  * @return boolean
713  */
714  function CopyFile($d, $old, $new) {
715  global $msg;
716  $old = $this->convertabsolute($old, false);
717  if (!$old) {
718  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
719  return false;
720  }
721  $new = $this->convertabsolute($new, false);
722  if (!$new) {
723  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
724  return false;
725  }
726  if ($old == $new) {
727  $msg->raise("ERROR", "bro", _("You cannot move or copy a file to the same folder"));
728  return false;
729  }
730  for ($i = 0; $i < count($d); $i++) {
731  $d[$i] = ssla($d[$i]); // strip slashes if needed
732  if (!strpos($d[$i], "/") && file_exists($old . "/" . $d[$i]) && !file_exists($new . "/" . $d[$i])) {
733  $this->CopyOneFile($old . "/" . $d[$i], $new);
734  }
735  }
736  return true;
737  }
738 
739 
740  /**
741  * Copy a source to a destination by either copying recursively a
742  * directory or by downloading a file with a URL (only http:// is
743  * supported)
744  *
745  * Note that we assume that the inputs have been convertabsolute()'d
746  *
747  * @global m_messages $msg
748  * @param string $src Path or URL
749  * @param string $dest Absolute path inside the users directory
750  * @return boolean false on error
751  */
752  function CopyOneFile($src, $dest) {
753  global $msg;
754  exec("cp -Rpf " . escapeshellarg($src) . " " . escapeshellarg($dest), $void, $ret);
755  if ($ret) {
756  $msg->raise("ERROR", "bro", "Errors happened while copying the source to destination. cp return value: %d", $ret);
757  return false;
758  }
759  return true;
760  }
761 
762 
763  /**
764  * Affiche le chemin et les liens de la racine au dossier $path
765  * Affiche autant de liens HTML (anchor) que le chemin $path contient de
766  * niveaux de dossier. Chaque lien est associ la page web $action
767  * laquelle on ajoute le paramtre R=+Le nom du dossier courant.
768  *
769  * @param string $path Dossier vers lequel on trace le chemin
770  * @param string $action Page web de destination des liens
771  * @param boolean $justparent
772  * @return string Le code HTML ainsi obtenu.
773  */
774  function PathList($path, $action, $justparent = false) {
775  $path = $this->convertabsolute($path, true);
776  $a = explode("/", $path);
777  if (!is_array($a)) {
778  $a = array($a);
779  }
780  $c = '';
781  $R = '';
782  if ($justparent) {
783  return "<a href=\"$action?R=" . urlencode($a[count($a) - 2] . '/') . "\">&uarr;</a>";
784  }
785  for ($i = 0; $i < count($a); $i++) {
786  if ($a[$i]) {
787  $R.=$a[$i] . "/";
788  $c.="<a href=\"$action?R=" . urlencode($R) . "\">" . $a[$i] . "</a>&nbsp;/&nbsp;";
789  }
790  }
791  return $c;
792  }
793 
794 
795  /**
796  * Affiche le contenu d'un fichier pour un champ VALUE de textarea
797  *
798  * Affiche le contenu du fichier $file dans le dossier $R. Le contenu
799  * du fichier est reformat pour pouvoir entrer dans un champs TextArea
800  *
801  * @global m_messages $msg
802  * @param string $R Dossier dans lequel on cherche le fichier
803  * @param string $file Fichier dont on souhaite obtenir le contenu.
804  * @return string|false TRUE si le fichier a bien été mis sur
805  * echo, ou FALSE si une erreur est survenue.
806  */
807  function content($R, $file) {
808  global $msg;
809  $absolute = $this->convertabsolute($R, false);
810  if (!strpos($file, "/")) {
811  $absolute.="/" . $file;
812  if (file_exists($absolute)) {
813  $std = str_replace("<", "&lt;", str_replace("&", "&amp;", file_get_contents($absolute)));
814  return $std;
815  } else {
816  $msg->raise("ERROR", "bro", _("Cannot read the requested file. Please check the permissions"));
817  return false;
818  }
819  } else {
820  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
821  return false;
822  }
823  }
824 
825 
826  /**
827  * Retourne une url de navigation pour le fichier $name du dossier $dir
828  * Les url sont mises en caches. Il se peut qu'aucune url n'existe, ou que
829  * celle-ci soit protge par un .htaccess.
830  *
831  * Return a browsing url if available.
832  * Maintain a url cache (positive AND negative(-) cache)
833  *
834  * @global m_mysql $db
835  * @global int $cuid
836  *
837  * @param string $dir Dossier concerné
838  * @param string $name Fichier dont on souhaite obtenir une URL
839  * @return string URL concerne, ou FALSE si aucune URL n'est disponible pour ce fichier
840  */
841  function viewurl($dir, $name) {
842  global $db, $cuid;
843  // Is it in cache ?
844  if (substr($dir, 0, 1) == "/") {
845  $dir = substr($dir, 1);
846  }
847  if (substr($dir, -1) == "/") {
848  $dir = substr($dir, 0, -1);
849  }
850  $dir = str_replace("%2F", "/", urlencode($dir));
851  $name = urlencode($name);
852  if (!@$this->cacheurl["d" . $dir]) {
853  // On parcours $dir en remontant les /
854  $end = "";
855  $beg = $dir;
856  $tofind = true;
857  while ($tofind) {
858  $db->query("SELECT sub,domaine FROM sub_domaines WHERE compte= ? AND type=0 AND (valeur= ? or valeur= ?);", array($cuid, "/".$beg."/", "/".$beg));
859  $db->next_record();
860  if ($db->num_rows()) {
861  $tofind = false;
862  $this->cacheurl["d" . $dir] = "http://" . $db->f("sub") . ife($db->f("sub"), ".") . $db->f("domaine") . $end;
863  }
864  if (!$beg && $tofind) {
865  $tofind = false;
866  $this->cacheurl["d" . $dir] = "-";
867  // We did not find it ;(
868  }
869  if (($tt = strrpos($beg, "/")) !== false) {
870  $end = substr($beg, $tt) . $end; //=/topdir$end so $end starts AND ends with /
871  $beg = substr($beg, 0, $tt);
872  } else {
873  $end = "/" . $beg . $end;
874  $beg = "/";
875  }
876  }
877  }
878  if ($this->cacheurl["d" . $dir] && $this->cacheurl["d" . $dir] != "-") {
879  return $this->cacheurl["d" . $dir] . "/" . $name;
880  } else {
881  return false;
882  }
883  }
884 
885 
886  /**
887  *
888  * @global m_mem $mem
889  * @global m_messages $msg
890  * @param string $dir
891  * @param string $name
892  * @return null|boolean
893  */
894  function can_edit($dir, $name) {
895  global $msg;
896  $absolute = "$dir/$name";
897  $absolute = $this->convertabsolute($absolute, false);
898  if (!$absolute) {
899  $msg->raise("ERROR", 'bro', _("File not in authorized directory"));
900  include('foot.php');
901  exit;
902  }
903  $stat=stat($absolute);
904  if (!($stat[2] & 0000200)) return false;
905  $finfo = finfo_open(FILEINFO_MIME_TYPE);
906  $mime = finfo_file($finfo, $absolute);
907  if (substr($mime, 0, 5) == "text/" || $mime == "application/x-empty" || $mime == "inode/x-empty") {
908  return true;
909  }
910  return false;
911  }
912 
913 
914  /**
915  * Return a HTML snippet representing an extraction function only if the mimetype of $name is supported
916  *
917  * @param string $name
918  * @return boolean
919  */
920  function is_extractable($name) {
921  if (($parts = explode(".", $name))) {
922  $ext = array_pop($parts);
923  switch ($ext) {
924  case "gz":
925  case "bz":
926  case "bz2":
927  $ext = array_pop($parts) . $ext;
928  /* FALLTHROUGH */
929  case "tar.gz":
930  case "tar.bz":
931  case "tar.bz2":
932  case "tgz":
933  case "tbz":
934  case "tbz2":
935  case "tar":
936  case "Z":
937  case "zip":
938  return true;
939  }
940  }
941  return false;
942  }
943 
944 
945  /**
946  * return true if file is a sql dump (end with .sql or .sql.gz)
947  *
948  * @param type $dir
949  * @param type $name
950  * @return boolean
951  */
952  function is_sqlfile($name) {
953  if (($parts = explode(".", $name))) {
954  $ext = array_pop($parts);
955  $ext2 = array_pop($parts) . '.' . $ext;
956  if ($ext == 'sql' or $ext2 == 'sql.gz') {
957  return true;
958  }
959  }
960  return false;
961  }
962 
963 
964  /**
965  *
966  * @global m_messages $msg
967  * @param string $dir
968  * @param string $file
969  */
970  function download_link($dir, $file) {
971  global $msg;
972  $msg->log("bro", "download_link");
973  header("Content-Disposition: attachment; filename=$file");
974  header("Content-Type: application/force-download");
975  header("Content-Transfer-Encoding: binary");
976  $this->content_send($dir, $file);
977  }
978 
979 
980  /**
981  * Echoes the content of the file $file located in directory $R
982  *
983  * @global m_messages $msg
984  * @param string $R
985  * @param string $file
986  * @return null|false
987  */
988  function content_send($R, $file) {
989  global $msg;
990  $absolute = $this->convertabsolute($R, false);
991  if (!strpos($file, "/")) {
992  $absolute.="/" . $file;
993  if (file_exists($absolute)) {
994  readfile($absolute);
995  }
996  } else {
997  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
998  return false;
999  }
1000  }
1001 
1002 
1003  /**
1004  * Sauve le fichier $file dans le dossier $R avec pour contenu $texte
1005  * le contenu est issu d'un textarea, et ne DOIT PAS contenir de \ ajouts
1006  * automatiquement par addslashes
1007  *
1008  * @global m_messages $msg
1009  * @param string $file Nom du fichier sauver. S'il existe déjà, il sera
1010  * écrasé sans confirmation.
1011  * @param string $R Dossier dans lequel on modifie le fichier
1012  * @param string $texte Texte du fichier à sauver dedans
1013  * @return false|null TRUE si tout s'est bien pass, FALSE si une erreur s'est produite.
1014  */
1015  function save($file, $R, $texte) {
1016  global $msg;
1017  $absolute = $this->convertabsolute($R, false);
1018  if (!strpos($file, "/")) {
1019  $absolute.="/" . $file;
1020  if (file_exists($absolute)) {
1021  if (!file_put_contents($absolute, $texte)) {
1022  $msg->raise("ERROR", "bro", _("Cannot edit the requested file. Please check the permissions"));
1023  return false;
1024  }
1025  }
1026  } else {
1027  $msg->raise("ERROR", "bro", _("File or folder name is incorrect"));
1028  return false;
1029  }
1030  return true;
1031  }
1032 
1033 
1034  /**
1035  * Echo d'un flux .tar.Z contenant tout le contenu du dossier $dir
1036  *
1037  * @global m_mem $mem
1038  * @param string $dir Dossier à dumper, relatif la racine du compte du membre.
1039  * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
1040  */
1041  function DownloadZ($dir = "") {
1042  global $mem;
1043  header("Content-Disposition: attachment; filename=" . $mem->user["login"] . ".Z");
1044  header("Content-Type: application/x-Z");
1045  header("Content-Transfer-Encoding: binary");
1046  $d = escapeshellarg("." . $this->convertabsolute($dir, true));
1047  set_time_limit(0);
1048  passthru("/bin/tar -cZ -C " . getuserpath() . "/" . $mem->user["login"] . "/ $d");
1049  }
1050 
1051 
1052  /**
1053  * Echo d'un flux .tgz contenant tout le contenu du dossier $dir
1054  *
1055  * @global type $mem
1056  * @param string $dir Dossier à dumper, relatif la racine du compte du membre.
1057  * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
1058  */
1059  function DownloadTGZ($dir = "") {
1060  global $mem;
1061  header("Content-Disposition: attachment; filename=" . $mem->user["login"] . ".tgz");
1062  header("Content-Type: application/x-tgz");
1063  header("Content-Transfer-Encoding: binary");
1064  $d = escapeshellarg("." . $this->convertabsolute($dir, true));
1065  set_time_limit(0);
1066  passthru("/bin/tar -cz -C " . getuserpath() . "/ $d");
1067  }
1068 
1069 
1070  /**
1071  * Echo d'un flux .tar.bz2 contenant tout le contenu du dossier $dir
1072  *
1073  * @global type $mem
1074  * @param string $dir Dossier à dumper, relatif la racine du compte du membre.
1075  * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
1076  */
1077  function DownloadTBZ($dir = "") {
1078  global $mem;
1079  header("Content-Disposition: attachment; filename=" . $mem->user["login"] . ".tar.bz2");
1080  header("Content-Type: application/x-bzip2");
1081  header("Content-Transfer-Encoding: binary");
1082  $d = escapeshellarg("." . $this->convertabsolute($dir, true));
1083  set_time_limit(0);
1084  passthru("/bin/tar -cj -C " . getuserpath() . "/ $d");
1085  }
1086 
1087 
1088  /**
1089  * Echo d'un flux .ZIP contenant tout le contenu du dossier $dir
1090  *
1091  * @global type $mem
1092  * @param string $dir Dossier à dumper, relatif la racine du compte du membre.
1093  * @return void NE RETOURNE RIEN, et il faut Quitter le script immdiatement aprs
1094  */
1095  function DownloadZIP($dir = "") {
1096  global $mem;
1097  header("Content-Disposition: attachment; filename=" . $mem->user["login"] . ".zip");
1098  header("Content-Type: application/x-zip");
1099  header("Content-Transfer-Encoding: binary");
1100  $d = $this->convertabsolute($dir, false);
1101  set_time_limit(0);
1102  chdir(dirname($d));
1103  passthru("/usr/bin/zip -r - ".escapeshellarg(basename($d)));
1104  }
1105 
1106 
1107  /**
1108  * Fonction de tri perso utilis par filelist.
1109  *
1110  * @access private
1111  * @param string $a
1112  * @param string $b
1113  * @return int
1114  */
1115  function _sort_filelist_name($a, $b) {
1116  if ($a["type"] && !$b["type"]) {
1117  return 1;
1118  }
1119  if ($b["type"] && !$a["type"]) {
1120  return -1;
1121  }
1122  return $a["name"] > $b["name"];
1123  }
1124 
1125 
1126  /**
1127  * Efface $file et tous ses sous-dossiers s'il s'agit d'un dossier
1128  * A UTILISER AVEC PRECAUTION !!!
1129  * @param string $file Fichier ou dossier supprimer.
1130  * @access private
1131  */
1132  function _delete($file,$depth=0) {
1133  global $msg;
1134  // permet d'effacer de nombreux fichiers
1135  @set_time_limit(0);
1136  //chmod($file,0777);
1137  $msg->log("bro", "_delete($file)");
1138  if ($depth>20) {
1139  $msg->log("bro", "CANCELING _delete($file) TOO DEEP");
1140  }
1141  if (is_dir($file)) {
1142  $handle = opendir($file);
1143  if (!$handle) {
1144  rmdir($file); // let's try it anyway...
1145  return; // skip unreacheable folders
1146  }
1147  while (($filename = readdir($handle)) !== false) {
1148  if ($filename != "." && $filename != "..") {
1149  $this->_delete($file . "/" . $filename,$depth+1);
1150  }
1151  }
1152  closedir($handle);
1153  rmdir($file);
1154  } else {
1155  unlink($file);
1156  }
1157  }
1158 
1159 
1160  /**
1161  * Function d'exportation de configuration appelé par la classe m_export via un hooks
1162  * Produit en sorti un tableau formatté ( pour le moment) en HTML
1163  *
1164  * @global m_mysql $db
1165  * @global m_messages $msg
1166  * @return string
1167  */
1168  function alternc_export_conf() {
1169  global $msg;
1170  $msg->log("bro", "export_conf");
1171  $str = "<table border=\"1\"><caption> Browser </caption>\n";
1172  $str.=" <browser>\n";
1173  $pref = $this->GetPrefs();
1174 
1175  $i = 1;
1176  foreach ($pref as $k => $v) {
1177  if (($i % 2) == 0) {
1178  $str.=" <$k>$v</$k>\n";
1179  }
1180  $i++;
1181  }
1182  $str.=" </browser>\n";
1183 
1184  return $str;
1185  }
1186 
1187 
1188  /**
1189  * Function d'exportation des données appelé par la classe m_export via un hooks
1190  *
1191  * @global m_mem $mem
1192  * @global m_messages $msg
1193  * @param string $dir Le chemin destination du tarball produit
1194  * @return boolean|null
1195  */
1196  function alternc_export_data($dir) {
1197  global $mem, $msg;
1198  $msg->log("bro", "export_data");
1199  $dir.="html/";
1200  if (!is_dir($dir)) {
1201  if (!mkdir($dir))
1202  $msg->raise("ERROR", "bro", _("Cannot create the requested directory. Please check the permissions"));
1203  }
1204  $timestamp = date("H:i:s");
1205 
1206  if (exec("/bin/tar cvf - " . escapeshellarg(getuserpath() . "/") . "| gzip -9c > " . escapeshellarg($dir . "/" . $mem->user['login'] . "_html_" . $timestamp . ".tar.gz"))) {
1207  $msg->log("bro", "export_data_succes");
1208  } else {
1209  $msg->log("bro", "export_data_failed");
1210  }
1211  }
1212 
1214  return min(ini_get('post_max_size'), ini_get('upload_max_filesize'));
1215  }
1216 
1217 } /* Class m_bro */
exit
Definition: adm_doadd.php:70
global $db
Definition: bootstrap.php:26
$mem
Definition: bootstrap.php:71
$msg
Definition: bootstrap.php:75
$root
Definition: bootstrap.php:20
$c
Definition: bootstrap.php:47
$cuid
Definition: bootstrap.php:43
$d
$texte
Definition: bro_editor.php:43
$R
Definition: bro_editor.php:45
This class manage the file browser of AlternC allow the file and directory management in the user acc...
Definition: m_bro.php:30
MoveFile($d, $old, $new)
Déplace les fichier de $d du dossier $old vers $new.
Definition: m_bro.php:511
DownloadTBZ($dir="")
Echo d'un flux .tar.bz2 contenant tout le contenu du dossier $dir.
Definition: m_bro.php:1077
GetPrefs()
Retourne un tableau contenant les prfrences de l'utilisateur courant.
Definition: m_bro.php:229
$l_icons
Shall we show icons or just names?
Definition: m_bro.php:39
get_userid_root($uid)
Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
Definition: m_bro.php:160
CreateDir($dir, $file)
Crée le dossier $file dans le dossier (parent) $dir.
Definition: m_bro.php:394
UploadFile($R)
Recoit un champ file upload (Global) et le stocke dans le dossier $R Le champ file-upload originel do...
Definition: m_bro.php:601
$mime_type
Definition: m_bro.php:47
$l_editor_font
Font choice in the editor.
Definition: m_bro.php:51
$mime_icon
Definition: m_bro.php:46
SetPrefs($editsizex, $editsizey, $listmode, $showicons, $downfmt, $createfile, $showtype, $editor_font, $editor_size, $golastdir)
Modifie les prfrences de l'utilisateur courant.
Definition: m_bro.php:258
hook_menu()
Hook called by the menu class to add menus to the left panel.
Definition: m_bro.php:72
m_bro()
Constructor.
Definition: m_bro.php:60
filelist($dir="", $showdirsize=false)
Retourne un tableau contenant la liste des fichiers du dossier courant.
Definition: m_bro.php:189
PathList($path, $action, $justparent=false)
Affiche le chemin et les liens de la racine au dossier $path Affiche autant de liens HTML (anchor) qu...
Definition: m_bro.php:774
RenameFile($R, $old, $new)
Renomme les fichier de $old du dossier $R en $new.
Definition: m_bro.php:477
DownloadTGZ($dir="")
Echo d'un flux .tgz contenant tout le contenu du dossier $dir.
Definition: m_bro.php:1059
save($file, $R, $texte)
Sauve le fichier $file dans le dossier $R avec pour contenu $texte le contenu est issu d'un textarea,...
Definition: m_bro.php:1015
can_edit($dir, $name)
Definition: m_bro.php:894
download_link($dir, $file)
Definition: m_bro.php:970
getMaxAllowedUploadSize()
Definition: m_bro.php:1213
content_send($R, $file)
Echoes the content of the file $file located in directory $R.
Definition: m_bro.php:988
DownloadZ($dir="")
Echo d'un flux .tar.Z contenant tout le contenu du dossier $dir.
Definition: m_bro.php:1041
_delete($file, $depth=0)
Efface $file et tous ses sous-dossiers s'il s'agit d'un dossier A UTILISER AVEC PRECAUTION !...
Definition: m_bro.php:1132
ChangePermissions($R, $d, $perm)
Change les droits d'acces aux fichier de $d du dossier $R en $p.
Definition: m_bro.php:553
$l_mode
How we draw the file in column.
Definition: m_bro.php:33
get_user_root($login)
Retourne le chemin complet vers la racine du repertoire de l'utilisateur.
Definition: m_bro.php:143
is_sqlfile($name)
return true if file is a sql dump (end with .sql or .sql.gz)
Definition: m_bro.php:952
DeleteFile($file_list, $R)
Efface les fichiers du tableau $file_list dans le dossier $R.
Definition: m_bro.php:450
CopyOneFile($src, $dest)
Copy a source to a destination by either copying recursively a directory or by downloading a file wit...
Definition: m_bro.php:752
$l_createfile
What do we do after creating a file?
Definition: m_bro.php:42
viewurl($dir, $name)
Retourne une url de navigation pour le fichier $name du dossier $dir Les url sont mises en caches.
Definition: m_bro.php:841
is_extractable($name)
Return a HTML snippet representing an extraction function only if the mimetype of $name is supported.
Definition: m_bro.php:920
$mime_desc
internal cache
Definition: m_bro.php:45
fsize($file, $showdirsize=false)
Retourne la taille du fichier $file si $file est un dossier, retourne la taille de ce dossier et de t...
Definition: m_bro.php:344
CreateFile($dir, $file)
Crée un fichier vide dans un dossier.
Definition: m_bro.php:422
alternc_export_conf()
Function d'exportation de configuration appelé par la classe m_export via un hooks Produit en sorti u...
Definition: m_bro.php:1168
DownloadZIP($dir="")
Echo d'un flux .ZIP contenant tout le contenu du dossier $dir.
Definition: m_bro.php:1095
CopyFile($d, $old, $new)
Copy many files from point A to point B.
Definition: m_bro.php:714
convertabsolute($dir, $strip=true)
Verifie un dossier relatif au dossier de l'utilisateur courant.
Definition: m_bro.php:95
mime($file)
Retourne le type mime associé au fichier donc le nom est $file Note: Les types mimes sont mis en cach...
Definition: m_bro.php:314
dirsize($dir)
Returns the size of a directory, by adding all it's files sizes.
Definition: m_bro.php:363
_sort_filelist_name($a, $b)
Fonction de tri perso utilis par filelist.
Definition: m_bro.php:1115
$cacheurl
Definition: m_bro.php:48
alternc_export_data($dir)
Function d'exportation des données appelé par la classe m_export via un hooks.
Definition: m_bro.php:1196
icon($file)
Retourne le nom du fichier icone associ au fichier donc le nom est $file Note: Les fichiers icones so...
Definition: m_bro.php:285
$l_editor_size
font size in the editor
Definition: m_bro.php:54
content($R, $file)
Affiche le contenu d'un fichier pour un champ VALUE de textarea.
Definition: m_bro.php:807
ExtractFile($file, $dest=null)
Extract an archive by using GNU and non-GNU tools.
Definition: m_bro.php:657
$l_tgz
download mode of a compressed folder
Definition: m_bro.php:36
ife($test, $tr, $fa="")
Definition: functions.php:416
ssla($str)
Strip slashes if needed :
Definition: functions.php:519
getuserpath($user=null)
get the home of the user
Definition: functions.php:329
$uid
if(empty($site_name)) elseif($piwik->site_add( $site_name, $site_urls))
$totalsize
Definition: quota_show.php:45
foreach($domaines_user as $domaine) $t
$login
$i