Changeset 2588 for trunk/plugins/LocalFilesEditor/functions.inc.php
- Timestamp:
- Sep 25, 2008, 7:46:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/LocalFilesEditor/functions.inc.php
r2299 r2588 30 30 function eval_syntax($code) 31 31 { 32 $code = str_replace(array('<?php', '?>'), '', $code); 32 $code = str_replace(array('<?php', '?>'), '', $code); 33 if (function_exists('token_get_all')) 34 { 33 35 $b = 0; 34 36 foreach (token_get_all($code) as $token) 35 36 37 37 { 38 if ('{' == $token) ++$b; 39 else if ('}' == $token) --$b; 38 40 } 39 41 if ($b) return false; 40 42 else 41 { 42 ob_start(); 43 $eval = eval('if(0){' . $code . '}'); 44 ob_end_clean(); 45 if ($eval === false) return false; 46 else return '<?php' . $code . '?>'; 43 { 44 ob_start(); 45 $eval = eval('if(0){' . $code . '}'); 46 ob_end_clean(); 47 if ($eval === false) return false; 47 48 } 49 } 50 return '<?php' . $code . '?>'; 48 51 } 49 52 … … 68 71 } 69 72 73 /** 74 * returns bak file for restore 75 * @param string 76 */ 77 function get_bak_file($file) 78 { 79 if (get_extension($file) == 'php') 80 { 81 return substr_replace($file, '.bak', strrpos($file , '.'), 0); 82 } 83 else 84 { 85 return $file . '.bak'; 86 } 87 } 88 89 /** 90 * returns dirs and subdirs 91 * retun array 92 * @param string 93 */ 94 function get_rec_dirs($path='') 95 { 96 $options = array(); 97 if (is_dir($path)) 98 { 99 $fh = opendir($path); 100 while ($file = readdir($fh)) 101 { 102 $pathfile = $path . '/' . $file; 103 if ($file != '.' and $file != '..' and $file != '.svn' and is_dir($pathfile)) 104 { 105 $options[$pathfile] = str_replace(array('./', '/'), array('', ' / '), $pathfile); 106 $options = array_merge($options, get_rec_dirs($pathfile)); 107 } 108 } 109 closedir($fh); 110 } 111 return $options; 112 } 113 70 114 ?>
Note: See TracChangeset
for help on using the changeset viewer.