fileManage.lib.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is the file manage library for Chamilo.
  5. * Include/require it in your code to use its functionality.
  6. * @package chamilo.library
  7. */
  8. /**
  9. * Update the file or directory path in the document db document table
  10. *
  11. * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
  12. * @param - action (string) - action type require : 'delete' or 'update'
  13. * @param - old_path (string) - old path info stored to change
  14. * @param - new_path (string) - new path info to substitute
  15. * @desc Update the file or directory path in the document db document table
  16. *
  17. */
  18. function update_db_info($action, $old_path, $new_path = '') {
  19. $dbTable = Database::get_course_table(TABLE_DOCUMENT);
  20. $course_id = api_get_course_int_id();
  21. /* DELETE */
  22. if ($action == 'delete') {
  23. /* // RH: metadata, update 2004/08/23
  24. these two lines replaced by new code below:
  25. $query = "DELETE FROM $dbTable
  26. WHERE path='".$old_path."' OR path LIKE '".$old_path."/%'";
  27. */
  28. $old_path = Database::escape_string($old_path);
  29. $to_delete = "WHERE c_id = $course_id AND path LIKE BINARY '".$old_path."' OR path LIKE BINARY '".$old_path."/%'";
  30. $query = "DELETE FROM $dbTable " . $to_delete;
  31. $result = Database::query("SELECT id FROM $dbTable " . $to_delete);
  32. if (Database::num_rows($result)) {
  33. require_once api_get_path(INCLUDE_PATH).'../metadata/md_funcs.php';
  34. $mdStore = new mdstore(TRUE); // create if needed
  35. $md_type = (substr($dbTable, -13) == 'scormdocument') ? 'Scorm' : 'Document';
  36. while ($row = Database::fetch_array($result)) {
  37. $eid = $md_type . '.' . $row['id'];
  38. $mdStore->mds_delete($eid);
  39. $mdStore->mds_delete_offspring($eid);
  40. }
  41. }
  42. }
  43. /* UPDATE */
  44. if ($action == 'update') {
  45. //Display::display_normal_message("new_path = $new_path");
  46. if ($new_path[0] == '.') $new_path = substr($new_path, 1);
  47. $new_path = str_replace('//', '/', $new_path);
  48. //Display::display_normal_message("character 0 = " . $new_path[0] . " 1=" . $new_path[1]);
  49. //Display::display_normal_message("new_path = $new_path");
  50. // Older broken version
  51. //$query = "UPDATE $dbTable
  52. //SET path = CONCAT('".$new_path."', SUBSTRING(path, LENGTH('".$old_path."')+1) )
  53. //WHERE path = '".$old_path."' OR path LIKE '".$old_path."/%'";
  54. // Attempt to update - tested & working for root dir
  55. $new_path = Database::escape_string($new_path);
  56. $query = "UPDATE $dbTable
  57. SET path = CONCAT('".$new_path."', SUBSTRING(path, LENGTH('".$old_path."')+1) )
  58. WHERE c_id = $course_id AND path LIKE BINARY '".$old_path."' OR path LIKE BINARY '".$old_path."/%'";
  59. }
  60. Database::query($query);
  61. }
  62. /**
  63. * Cheks a file or a directory actually exist at this location
  64. *
  65. * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
  66. * @param - file_path (string) - path of the presume existing file or dir
  67. * @return - boolean TRUE if the file or the directory exists
  68. * boolean FALSE otherwise.
  69. */
  70. function check_name_exist($file_path) {
  71. clearstatcache();
  72. $save_dir = getcwd();
  73. if (!is_dir(dirname($file_path))) {
  74. return false;
  75. }
  76. chdir(dirname($file_path));
  77. $file_name = basename($file_path);
  78. if (file_exists($file_name)) {
  79. chdir($save_dir);
  80. return true;
  81. } else {
  82. chdir($save_dir);
  83. return false;
  84. }
  85. }
  86. /**
  87. * Deletes a file or a directory
  88. *
  89. * @author - Hugues Peeters
  90. * @param - $file (String) - the path of file or directory to delete
  91. * @return - bolean - true if the delete succeed
  92. * bolean - false otherwise.
  93. * @see - delete() uses check_name_exist() and removeDir() functions
  94. */
  95. function my_delete($file) {
  96. if (check_name_exist($file)) {
  97. if (is_file($file)) { // FILE CASE
  98. unlink($file);
  99. return true;
  100. } elseif (is_dir($file)) { // DIRECTORY CASE
  101. removeDir($file);
  102. return true;
  103. }
  104. } else {
  105. return false; // no file or directory to delete
  106. }
  107. }
  108. /**
  109. * Removes a directory recursively
  110. *
  111. * @returns true if OK, otherwise false
  112. *
  113. * @author Amary <MasterNES@aol.com> (from Nexen.net)
  114. * @author Olivier Brouckaert <oli.brouckaert@skynet.be>
  115. *
  116. * @param string $dir directory to remove
  117. */
  118. function removeDir($dir) {
  119. if (!@$opendir = opendir($dir)) {
  120. return false;
  121. }
  122. while ($readdir = readdir($opendir)) {
  123. if ($readdir != '..' && $readdir != '.') {
  124. if (is_file($dir.'/'.$readdir)) {
  125. if (!@unlink($dir.'/'.$readdir)) {
  126. return false;
  127. }
  128. } elseif (is_dir($dir.'/'.$readdir)) {
  129. if (!removeDir($dir.'/'.$readdir)) {
  130. return false;
  131. }
  132. }
  133. }
  134. }
  135. closedir($opendir);
  136. if (!@rmdir($dir)) {
  137. return false;
  138. }
  139. return true;
  140. }
  141. /**
  142. * Return true if folder is empty
  143. * @author : hubert.borderiou@grenet.fr
  144. * @param string $in_folder : folder path on disk
  145. * @return 1 if folder is empty, 0 otherwise
  146. */
  147. function folder_is_empty($in_folder) {
  148. $tab_folder_content = scandir($in_folder);
  149. $folder_is_empty = 0;
  150. if ((count($tab_folder_content) == 2 && in_array(".", $tab_folder_content) && in_array("..", $tab_folder_content)) || (count($tab_folder_content) < 2)) {
  151. $folder_is_empty = 1;
  152. }
  153. return $folder_is_empty;
  154. }
  155. /**
  156. * Renames a file or a directory
  157. *
  158. * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
  159. * @param - $file_path (string) - complete path of the file or the directory
  160. * @param - $new_file_name (string) - new name for the file or the directory
  161. * @return - boolean - true if succeed
  162. * - boolean - false otherwise
  163. * @see - rename() uses the check_name_exist() and php2phps() functions
  164. */
  165. function my_rename($file_path, $new_file_name) {
  166. $save_dir = getcwd();
  167. $path = dirname($file_path);
  168. $old_file_name = basename($file_path);
  169. $new_file_name = replace_dangerous_char($new_file_name);
  170. // If no extension, take the old one
  171. if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) {
  172. $new_file_name .= substr($old_file_name, $dotpos);
  173. }
  174. // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz'
  175. // This is useful for folder names, where otherwise '.' would be sticky
  176. // Extension PHP is not allowed, change to PHPS
  177. $new_file_name = php2phps($new_file_name);
  178. if ($new_file_name == $old_file_name) {
  179. return $old_file_name;
  180. }
  181. if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) {
  182. return false;
  183. }
  184. // On a Windows server, it would be better not to do the above check
  185. // because it succeeds for some new names resembling the old name.
  186. // But on Unix/Linux the check must be done because rename overwrites.
  187. chdir($path);
  188. $res = rename($old_file_name, $new_file_name) ? $new_file_name : false;
  189. chdir($save_dir);
  190. return $res;
  191. }
  192. /**
  193. * Moves a file or a directory to an other area
  194. *
  195. * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
  196. * @param - $source (String) - the path of file or directory to move
  197. * @param - $target (String) - the path of the new area
  198. * @return - bolean - true if the move succeed
  199. * bolean - false otherwise.
  200. * @see - move() uses check_name_exist() and copyDirTo() functions
  201. */
  202. function move($source, $target) {
  203. if (check_name_exist($source)) {
  204. $file_name = basename($source);
  205. if (check_name_exist($target.'/'.$file_name)) {
  206. return false;
  207. } else {
  208. /* File case */
  209. if (is_file($source)) {
  210. copy($source , $target.'/'.$file_name);
  211. unlink($source);
  212. return true;
  213. }
  214. /* Directory case */
  215. elseif (is_dir($source)) {
  216. // Check to not copy the directory inside itself
  217. if (ereg('^'.$source.'/', $target.'/')) { // TODO: ereg() function is deprecated in PHP 5.3
  218. return false;
  219. } else {
  220. copyDirTo($source, $target);
  221. return true;
  222. }
  223. }
  224. }
  225. } else {
  226. return false;
  227. }
  228. }
  229. /**
  230. * Moves a directory and its content to an other area
  231. *
  232. * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
  233. * @param - $orig_dir_path (string) - the path of the directory to move
  234. * @param - $destination (string) - the path of the new area
  235. * @return - no return
  236. */
  237. function copyDirTo($orig_dir_path, $destination, $move = true) {
  238. $save_dir = getcwd();
  239. // Extract directory name - create it at destination - update destination trail
  240. $dir_name = basename($orig_dir_path);
  241. if (is_dir($orig_dir_path)) {
  242. mkdir($destination.'/'.$dir_name, api_get_permissions_for_new_directories());
  243. $destination_trail = $destination.'/'.$dir_name;
  244. if (is_dir($destination)) {
  245. chdir ($orig_dir_path) ;
  246. $handle = opendir($orig_dir_path);
  247. while ($element = readdir($handle)) {
  248. if ($element == '.' || $element == '..') {
  249. continue; // Skip the current and parent directories
  250. } elseif (is_file($element)) {
  251. copy($element, $destination_trail.'/'.$element);
  252. if ($move) {
  253. unlink($element) ;
  254. }
  255. } elseif (is_dir($element)) {
  256. $dir_to_copy[] = $orig_dir_path.'/'.$element;
  257. }
  258. }
  259. closedir($handle) ;
  260. if (sizeof($dir_to_copy) > 0) {
  261. foreach ($dir_to_copy as $this_dir) {
  262. copyDirTo($this_dir, $destination_trail, $move); // Recursivity
  263. }
  264. }
  265. if ($move) {
  266. rmdir($orig_dir_path) ;
  267. }
  268. chdir($save_dir);
  269. }
  270. }
  271. }
  272. /* NOTE: These functions batch is used to automatically build HTML forms
  273. * with a list of the directories contained on the course Directory.
  274. *
  275. * From a thechnical point of view, form_dir_lists calls sort_dir wich calls index_dir
  276. */
  277. /**
  278. * Gets all the directories and subdirectories
  279. * contented in a given directory
  280. *
  281. * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
  282. * @param - path (string) - directory path of the one to index
  283. * @return - an array containing the path of all the subdirectories
  284. */
  285. function index_dir($path) {
  286. $dir_array = array();
  287. $save_dir = getcwd();
  288. if (is_dir($path)){
  289. chdir($path);
  290. $handle = opendir($path);
  291. // Reads directory content end record subdirectoies names in $dir_array
  292. if ($handle !== false) {
  293. while ($element = readdir($handle)) {
  294. if ($element == '.' || $element == '..') continue; // Skip the current and parent directories
  295. if (is_dir($element)) $dir_array[] = $path.'/'.$element;
  296. }
  297. closedir($handle) ;
  298. }
  299. // Recursive operation if subdirectories exist
  300. $dir_number = sizeof($dir_array);
  301. if ($dir_number > 0) {
  302. for ($i = 0 ; $i < $dir_number ; $i++) {
  303. $sub_dir_array = index_dir($dir_array[$i]); // Function recursivity
  304. $dir_array = array_merge((array)$dir_array, (array)$sub_dir_array); // Data merge
  305. }
  306. }
  307. }
  308. chdir($save_dir) ;
  309. return $dir_array ;
  310. }
  311. /**
  312. * Indexes all the directories and subdirectories
  313. * contented in a given directory, and sort them alphabetically
  314. *
  315. * @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
  316. * @param - path (string) - directory path of the one to index
  317. * @return - an array containing the path of all the subdirectories sorted
  318. * false, if there is no directory
  319. * @see - index_and_sort_dir uses the index_dir() function
  320. */
  321. function index_and_sort_dir($path) {
  322. $dir_list = index_dir($path);
  323. if ($dir_list) {
  324. natsort($dir_list);
  325. return $dir_list;
  326. }
  327. return false;
  328. }
  329. /**
  330. * Builds a html form listing all directories of a given directory
  331. *
  332. */
  333. function form_dir_list($source_type, $source_component, $command, $base_work_dir) {
  334. $dir_list = index_and_sort_dir($base_work_dir);
  335. $dialog_box .= "<form action=\"".api_get_self()."\" method=\"post\">\n" ;
  336. $dialog_box .= "<input type=\"hidden\" name=\"".$source_type."\" value=\"".$source_component."\">\n" ;
  337. $dialog_box .= get_lang('Move').' '.$source_component.' '.get_lang('To');
  338. $dialog_box .= "<select name=\"".$command."\">\n" ;
  339. $dialog_box .= "<option value=\"\" style=\"color:#999999\">".get_lang('Root')."\n";
  340. $bwdLen = strlen($base_work_dir) ; // base directories lenght, used under
  341. /* build html form inputs */
  342. if ($dir_list) {
  343. while (list( , $path_value) = each($dir_list) ) {
  344. $path_value = substr ( $path_value , $bwdLen ); // Truncates cunfidential informations confidentielles
  345. $dirname = basename ($path_value); // Extracts $path_value directory name du nom
  346. /* compute de the display tab */
  347. $tab = ""; // $tab reinitialisation
  348. $depth = substr_count($path_value, '/'); // The number of nombre '/' indicates the directory deepness
  349. for ($h = 0; $h < $depth; $h++) {
  350. $tab .= "&nbsp;&nbsp;";
  351. }
  352. $dialog_box .= "<option value=\"$path_value\">$tab>$dirname\n";
  353. }
  354. }
  355. $dialog_box .= "</select>\n";
  356. $dialog_box .= "<input type=\"submit\" value=\"".get_lang('Ok')."\">";
  357. $dialog_box .= "</form>\n";
  358. return $dialog_box;
  359. }
  360. /**
  361. * Extracting extention of a filename
  362. *
  363. * @returns array
  364. * @param string $filename filename
  365. */
  366. function getextension($filename) {
  367. $bouts = explode('.', $filename);
  368. return array(array_pop($bouts), implode('.', $bouts));
  369. }
  370. /**
  371. * Calculation size of a directory
  372. *
  373. * @returns integer size
  374. * @param string $path path to size
  375. * @param boolean $recursive if true , include subdir in total
  376. */
  377. function dirsize($root, $recursive = true) {
  378. $dir = @opendir($root);
  379. $size = 0;
  380. while ($file = @readdir($dir)) {
  381. if (!in_array($file, array('.', '..'))) {
  382. if (is_dir($root.'/'.$file)) {
  383. $size += $recursive ? dirsize($root.'/'.$file) : 0;
  384. } else {
  385. $size += @filesize($root.'/'.$file);
  386. }
  387. }
  388. }
  389. @closedir($dir);
  390. return $size;
  391. }
  392. /* CLASS FileManager */
  393. /**
  394. This class contains functions that you can access statically.
  395. FileManager::list_all_directories($path)
  396. FileManager::list_all_files($dir_array)
  397. FileManager::compat_load_file($file_name)
  398. FileManager::set_default_settings($upload_path, $filename, $filetype="file", $glued_table, $default_visibility='v')
  399. @author Roan Embrechts
  400. @version 1.1, July 2004
  401. * @package chamilo.library
  402. */
  403. class FileManager
  404. {
  405. /**
  406. Returns a list of all directories, except the base dir,
  407. of the current course. This function uses recursion.
  408. Convention: the parameter $path does not end with a slash.
  409. @author Roan Embrechts
  410. @version 1.0.1
  411. */
  412. function list_all_directories($path) {
  413. $result_array = array();
  414. if (is_dir($path)) {
  415. $save_dir = getcwd();
  416. chdir($path);
  417. $handle = opendir($path);
  418. while ($element = readdir($handle)) {
  419. if ($element == '.' || $element == '..') continue; // Skip the current and parent directories
  420. if (is_dir($element)) {
  421. $dir_array[] = $path.'/'.$element;
  422. }
  423. }
  424. closedir($handle);
  425. // Recursive operation if subdirectories exist
  426. $dir_number = sizeof($dir_array);
  427. if ($dir_number > 0) {
  428. for ($i = 0 ; $i < $dir_number ; $i++) {
  429. $sub_dir_array = FileManager::list_all_directories($dir_array[$i]); // Function recursivity
  430. if (is_array($dir_array) && is_array($sub_dir_array)) {
  431. $dir_array = array_merge($dir_array, $sub_dir_array); // Data merge
  432. }
  433. }
  434. }
  435. $result_array = $dir_array;
  436. chdir($save_dir) ;
  437. }
  438. return $result_array ;
  439. }
  440. /**
  441. This function receives a list of directories.
  442. It returns a list of all files in these directories
  443. @author Roan Embrechts
  444. @version 1.0
  445. */
  446. function list_all_files($dir_array) {
  447. $element_array = array();
  448. if (is_dir($dir_array)) {
  449. $save_dir = getcwd();
  450. foreach ($dir_array as $directory) {
  451. chdir($directory);
  452. $handle = opendir($directory);
  453. while ($element = readdir($handle)) {
  454. if ($element == '.' || $element == '..' || $element == '.htaccess') continue; // Skip the current and parent directories
  455. if (!is_dir($element)) {
  456. $element_array[] = $directory.'/'.$element;
  457. }
  458. }
  459. closedir($handle);
  460. chdir('..');
  461. chdir($save_dir);
  462. }
  463. }
  464. return $element_array;
  465. }
  466. /**
  467. Loads contents of file $filename into memory and returns them as a string.
  468. Function kept for compatibility with older PHP versions.
  469. Function is binary safe (is needed on Windows)
  470. */
  471. function compat_load_file($file_name) {
  472. $buffer = '';
  473. if (file_exists($file_name)) {
  474. $fp = fopen($file_name, 'rb');
  475. $buffer = fread ($fp, filesize($file_name));
  476. fclose ($fp);
  477. }
  478. return $buffer;
  479. }
  480. /**
  481. * Adds file/folder to document table in database
  482. * improvement from set_default_settings (see below):
  483. * take all info from function parameters
  484. * no global variables needed
  485. *
  486. * NOTE $glued_table should already have backticks around it
  487. * (get it from the database library, and it is done automatically)
  488. *
  489. * @param path, filename, filetype,
  490. $glued_table, default_visibility
  491. * action: Adds an entry to the document table with the default settings.
  492. * @author Olivier Cauberghe <olivier.cauberghe@ugent.be>
  493. * @author Roan Embrechts
  494. * @version 1.2
  495. */
  496. function set_default_settings($upload_path, $filename, $filetype = 'file', $glued_table, $default_visibility = 'v') {
  497. if (!$default_visibility) $default_visibility = 'v';
  498. // Make sure path is not wrongly formed
  499. $upload_path = !empty($upload_path) ? "/$upload_path" : '';
  500. $endchar = substr($filename, strlen($filename) - 1, 1);
  501. if ($endchar == "\\" || $endchar == '/') {
  502. $filename = substr($filename, 0, strlen($filename) - 1);
  503. }
  504. $full_file_name = $upload_path.'/'.$filename;
  505. //$upload_path = str_replace("//", '/', $upload_path);
  506. $full_file_name = str_replace("//", '/', $full_file_name);
  507. $sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'";
  508. $sql_result = Database::query($sql_query);
  509. $result = Database::fetch_array($sql_result);
  510. // Determine which query to execute
  511. if ($result['number_existing'] > 0) {
  512. // Entry exists, update
  513. $query = "UPDATE $glued_table SET path='$full_file_name',visibility='$default_visibility', filetype='$filetype' WHERE path='$full_file_name'";
  514. } else {
  515. // No entry exists, create new one
  516. $query = "INSERT INTO $glued_table (path,visibility,filetype) VALUES('$full_file_name','$default_visibility','$filetype')";
  517. }
  518. Database::query($query);
  519. }
  520. } //end class FileManager
  521. /* DEPRECATED FUNCTIONS */
  522. /**
  523. * Like in Java, creates the directory named by this abstract pathname,
  524. * including any necessary but nonexistent parent directories.
  525. *
  526. * @author Hugues Peeters <peeters@ipm.ucl.ac.be>
  527. * @author Christophe Gesche <gesche@ipm.ucl.ac.be>
  528. *
  529. * @param string $path - path to create
  530. * @param string $mode - directory permission (default is '770')
  531. *
  532. * @return boolean TRUE if succeeds FALSE otherwise
  533. */
  534. function mkdirs($path, $mode = '0770') {
  535. if (file_exists($path)) {
  536. return false;
  537. } else {
  538. FileManager :: mkdirs(dirname($path), $mode);
  539. //mkdir($path, $mode);
  540. return true;
  541. }
  542. }
  543. /**
  544. * @deprecated 06-FEB-2010. The function mkdir() is able to create directories recursively.
  545. * @link http://php.net/manual/en/function.mkdir.php
  546. *
  547. * to create missing directory in a gived path
  548. *
  549. * @returns a resource identifier or FALSE if the query was not executed correctly.
  550. * @author KilerCris@Mail.com original function from php manual
  551. * @author Christophe Gesch� gesche@ipm.ucl.ac.be Claroline Team
  552. * @since 28-Aug-2001 09:12
  553. * @param sting $path wanted path
  554. * @param boolean $verbose fix if comments must be printed
  555. * @param string $mode fix if chmod is same of parent or default (Note: This misterious parameter is not used).
  556. * Note string $langCreatedIn string used to say "create in"
  557. */
  558. function mkpath($path, $verbose = false, $mode = 'herit') {
  559. global $langCreatedIn, $_configuration;
  560. $path = str_replace('/', "\\", $path);
  561. $dirs = explode("\\", $path);
  562. $path = $dirs[0];
  563. if ($verbose) {
  564. echo '<ul>';
  565. }
  566. for ($i = 1; $i < sizeof($dirs); $i++) {
  567. $path .= '/'.$dirs[$i];
  568. if (ereg('^'.$path, $_configuration['root_sys']) && strlen($path) < strlen($_configuration['root_sys'])) {
  569. continue;
  570. }
  571. if (!is_dir($path)) {
  572. $ret = mkdir($path, api_get_permissions_for_new_directories());
  573. if ($ret) {
  574. if ($verbose) {
  575. echo '<li><strong>'.basename($path).'</strong><br />'.$langCreatedIn.'<br /><strong>'.realpath($path.'/..').'</strong></li>';
  576. }
  577. } else {
  578. if ($verbose) {
  579. echo '</ul>error : '.$path.' not created';
  580. }
  581. $ret = false;
  582. break;
  583. }
  584. }
  585. }
  586. if ($verbose) {
  587. echo '</ul>';
  588. }
  589. return $ret;
  590. }