Changeset 27506 for documentation/trunk
- Timestamp:
- 2013-05-29T12:46:27+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentation/trunk/php/common.php
r25051 r27506 2 2 3 3 $base_path = getcwd(); 4 if (strpos($base_path, 'greenstone') === false) 5 { 6 printError('Failed to determine base path...'); 7 } 4 8 5 9 // The dokuwiki directory is always in the same place, relative to the PHP … … 113 117 /** generateID($text) **/ 114 118 115 function mkAllDir($destination_dir , $mode)116 { 117 echo '<p> * Make all directories: ' . $destination_dir . '</p>' . "\n";119 function mkAllDir($destination_dir) 120 { 121 ///cho '<p> * Make all directories: ' . $destination_dir . '</p>' . "\n"; 118 122 $dirs_to_create = array(); 119 123 $dir = $destination_dir; 120 124 while (!empty($dir) && !file_exists($dir)) 121 125 { 122 echo 'Does not exist - create...<br/>';126 ///cho 'Does not exist - create...<br/>'; 123 127 array_unshift($dirs_to_create, $dir); 124 128 $dir = substr($dir, 0, strrpos($dir, '/')); 125 echo 'Testing for the existance of: ' . $dir . '<br/>';129 ///cho 'Testing for the existance of: ' . $dir . '<br/>'; 126 130 } 127 131 foreach ($dirs_to_create as $dir) … … 129 133 if (!file_exists($dir)) 130 134 { 131 mkdir($dir, 07 55);135 mkdir($dir, 0775); 132 136 } 133 137 } … … 151 155 $_REQUEST[$matches[1]] = $_SERVER['argv'][$i]; 152 156 } 157 else if (preg_match('/^\-+l/i', $_SERVER['argv'][$i])) 158 { 159 $i++; 160 $_REQUEST['l'] = $_SERVER['argv'][$i]; 161 } 153 162 else 154 163 { … … 177 186 /** printError($message) **/ 178 187 188 189 /** 190 */ 191 function recursiveRemove($dir, $base_dir, $remove_this_dir=false) 192 { 193 ///cho "<h2>recursiveRemove(\"$dir\", \"$base_dir\", $remove_this_dir)</h2>"; 194 // Ensure that base_dir is within_dir - safety first! 195 if (strpos($dir, $base_dir) === false) 196 { 197 printError('Can\'t delete directory as is isn\'t within project'); 198 } 199 if (is_dir($dir)) 200 { 201 if ($dh = opendir($dir)) 202 { 203 while (($file = readdir($dh)) !== false) 204 { 205 if (preg_match('/^\./', $file)) 206 { 207 // Skip dot files 208 } 209 else 210 { 211 $path = fileCat(array($dir, $file)); 212 if (is_dir($path)) 213 { 214 recursiveRemove($path, $base_dir, true); 215 } 216 else 217 { 218 unlink($path); 219 if (file_exists($path)) 220 { 221 printError('Failed to delete file: ' . $path); 222 } 223 } 224 } 225 } 226 closedir($dh); 227 } 228 else 229 { 230 printError('Failed to open directory for reading: ' . $dir); 231 } 232 // Now that the directory is (hopefully) empty, we can delete it if 233 // required to 234 if ($remove_this_dir) 235 { 236 rmdir($dir); 237 if (file_exists($dir)) 238 { 239 printError('Failed to remove directory: ' . $dir); 240 } 241 } 242 } 243 else 244 { 245 printError('Can\'t recursive delete - not a directory: ' . $dir); 246 } 247 } 248 /** recursiveRemove() **/ 249 179 250 ?>
Note:
See TracChangeset
for help on using the changeset viewer.