Changeset 10337 for extensions/PHP_Optimisateur/include/functions.php
- Timestamp:
- Apr 12, 2011, 7:45:22 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PHP_Optimisateur/include/functions.php
r9265 r10337 1 1 <?php 2 2 3 // Affiche les textes localisés 3 4 function l10n($code) { … … 22 23 while ($file = readdir($dh)) { 23 24 if ($file !== '.' && $file !== '..' && is_dir('language/'.$file)) { 24 $name = (file_exists('language/'.$file.'/ '.$file.'.txt')) ? file_get_contents('language/'.$file.'/'.$file.'.txt') : $file;25 $name = (file_exists('language/'.$file.'/iso.txt')) ? file_get_contents('language/'.$file.'/iso.txt') : $file; 25 26 $languages[$file] = $name; 26 27 } … … 66 67 return preg_replace($search, $replace, $string); 67 68 } else { 68 return str_replace(array('%','$' ), '_', $string);69 return str_replace(array('%','$',' '), '_', $string); 69 70 } 70 71 } … … 121 122 $content = array(); 122 123 foreach ($xml as $nom => $elem) { 123 if (trim($elem) == '' ) {124 if (trim($elem) == '' AND $elem != '') { 124 125 $content[$nom] = XMLParse($elem->children()); 125 126 } else { … … 165 166 $array[$key] = true; 166 167 } else if ($value === 'false') { 167 $array[$key] = false; 168 $array[$key] = false; 169 } else if ($value == null) { 170 // rien à faire ^^ 168 171 } else if (preg_match('#^([0-9]*)$#', $value)) { 169 172 settype($array[$key], 'int'); … … 247 250 // Verifie si une chaine est un nombre décimal (plus strict que is_numeric qui fonctionne avec les hexadecimaux) 248 251 function is_decimal($num) { 249 if( is_numeric($num) === true AND (float)$num == $num) {252 if((is_numeric($num) === true AND (float)$num == $num) OR $num === '0') { 250 253 return true; 251 254 } else { … … 257 260 function load_plugin_lang($plugin_id) { 258 261 global $CONF, $Lang; 259 if (file_exists('plugins/'.$plugin_id.'/lang/'.$CONF['user_lang'].'.php')) { 260 include('plugins/'.$plugin_id.'/lang/'.$CONF['user_lang'].'.php'); 261 } else { 262 include('plugins/'.$plugin_id.'/lang/en_UK.php'); 263 } 264 } 262 if (file_exists('plugins/'.$plugin_id.'/language/'.$CONF['user_lang'].'.php')) { 263 include('plugins/'.$plugin_id.'/language/'.$CONF['user_lang'].'.php'); 264 } else { 265 include('plugins/'.$plugin_id.'/language/en_UK.php'); 266 } 267 } 268 269 // fonction nconvert avec gestion du log 270 function nconvert($param, $log=true) { 271 global $LOG; 272 273 exec('include\nconvert.exe '. $param .' 2>&1', $out); 274 275 if ($log) { 276 for ($i=0; $i<=3; $i++) 277 unset($out[$i]); 278 if (count($out)) $LOG[] = array_values($out); 279 //$LOG[] = "\t" . $param; 280 } else { 281 return $out; 282 } 283 } 284 285 // fonction mkdir avec gestion du log 286 function mkdir_log($dir) { 287 global $LOG; 288 mkdir($dir, 0777, true); 289 $LOG[] = 'Dir '.$dir.' created'; 290 } 291 292 // fonction copy avec gestion du log 293 function copy_log($src, $dest) { 294 global $LOG; 295 copy($src, $dest); 296 $LOG[] = 'Copy '.$src.' to '.$dest; 297 } 298 299 // fonction rename avec gestion du log 300 function rename_log($path, $new_path, $move=false) { 301 global $LOG; 302 rename($path, $new_path); 303 if ($move) 304 $LOG[] = 'Move '.$path.' to '.$new_path; 305 else 306 $LOG[] = 'Rename '.$path.' into '.$new_path; 307 } 308 309 // enregistre le log dans un fichier 310 function print_log($nb, $s) { 311 global $APPversion, $LOG; 312 313 $config = file_get_contents('config.xml'); 314 315 $string = 316 "PHP Optimisateur " . $APPversion . "\r\n". 317 date('r') . "\r\n". 318 $nb . " files in " . $s . " seconds" . "\r\n\r\n". 319 320 $config . "\r\n\r\n"; 321 322 foreach ($LOG as $event) { 323 if (is_array($event)) { 324 $string .= implode("\r\n", $event) . "\r\n"; 325 } else { 326 $string .= $event . "\r\n"; 327 } 328 } 329 330 if (!file_exists('logs')) { 331 mkdir('logs', 0777, true); 332 } 333 334 $filename = 'log_' . date('Y-m-d_H-i-s') . '.txt'; 335 file_put_contents('logs/'.$filename, $string); 336 return $filename; 337 } 338 339 // case insentive version of in_array 340 function in_arrayi($needle, $haystack) { 341 $needle = strtolower($needle); 342 $haystack = array_map('strtolower', $haystack); 343 return in_array($needle, $haystack); 344 } 345 265 346 ?>
Note: See TracChangeset
for help on using the changeset viewer.