PHP Optimisateur 1.0
'; include('config.php'); include('files/functions.php'); ### Erreurs fatales ### if (!is_int($DIMhd) || !is_int($DIMnormal) || !is_int($DIMthumbnail) || !is_int($Qhd) || !is_int($Qnormal) || !is_int($Qthumbnail) || !is_bool($silentORNOT) || !is_bool($DIRhighORNOT) || !is_bool($DIMhdORNOT) || !is_bool($renameORNOT) || !is_bool($indexORNOT) || !is_string($prefixe_mini)) { die('
Erreur fatale : Configuration incorrecte. Retour
'); } if (is_dir_empty($DIRsource)) { die('
Erreur fatale : Dossier source vide. Retour
'); } if ($silentORNOT) { rrmdir($DIRsortie); mkdir($DIRsortie); } else if (!is_dir_empty($DIRsortie)) { die('
Erreur fatale : Dossier de sortie non vide. Retour
'); } if (!$silentORNOT AND isset($_GET['Process'])) { ### Supprimer les caractères spéciaux - dossiers & fichiers ### function recursive_delete_special_car($dir) { $dir = rtrim($dir, '/'); $dh = opendir($dir); while (($file = readdir($dh)) !== false ) { //boucle pour parcourir le repertoire if ($file !== '.' && $file !== '..') { $path = $dir.'/'.$file; $new_path = $dir.'/'.delete_special_car($file); rename($path, $new_path); if (is_dir($new_path)) { //si on tombe sur un sous-repertoire recursive_delete_special_car($new_path); // appel recursif pour lire a l'interieur de ce sous-repertoire } } } closedir($dh); } recursive_delete_special_car($DIRsource); ### Copyright ### if ($copyONhd) { $copyHD = '-text_font "'.$copyFONT.'" '.$DIMnormal*$copySIZE.' -text_color '.$copyCOLOR.' -text_flag '.$copyPOS.' -text_pos 0 0 -text "'.$copyright.'"'; } else { $copyHD = null; } if ($copyONnormal) { $copyNormal = '-text_font "'.$copyFONT.'" '.$DIMnormal*$copySIZE.' -text_color '.$copyCOLOR.' -text_flag '.$copyPOS.' -text_pos 0 0 -text "'.$copyright.'"'; } else { $copyNormal = null; } ### Plugins avant execution ### foreach ($PluginsBefore as $name => $config) { if ($config['active']) { include('plugins/'.$name.'.php'); } } ### Processus principal ### // Tableau avec les fichiers source $FilesSource = array(); recursive_readdir($DIRsource, 'FilesSource'); // Tableau avec les fichiers de sortie $FilesSortie = str_replace($DIRsource, $DIRsortie, $FilesSource); for ($i=0; $i $config) { if ($config['active']) { include('plugins/'.$name.'.php'); } } // Compresse les fichiers dans le dossier de sortie if (!isset($BlockNormal)) { exec('nconvert.exe -q '.$Qnormal.' -out jpeg -o "'.$matches[1].'/'.$matches[2].'" -dpi 72 -ratio -rtype lanczos -resize '.$DIMnormal.' '.$DIMnormal.' '.$copyNormal.' "'.$FilesSource[$i].'"'); } if (!isset($BlockThumbnail)) { exec('nconvert.exe -q '.$Qthumbnail.' -out jpeg -o "'.$matches[1].'/thumbnail/'.$prefixe_mini.$matches[2].'" -dpi 72 -ratio -rtype lanczos -rflag decr -resize '.$DIMthumbnail.' '.$DIMthumbnail.' -rmeta -rexifthumb "'.$FilesSource[$i].'"'); } if ($DIRhighORNOT AND !isset($BlockHigh)) { if ($DIMhdORNOT) { exec('nconvert.exe -q '.$Qhd.' -out jpeg -o "'.$matches[1].'/pwg_high/'.$matches[2].'" -dpi '.$DPI.' -ratio -rtype lanczos -rflag decr -resize '.$DIMhd.' '.$DIMhd.' '.$copyHD.' "'.$FilesSource[$i].'"'); } else { copy($FilesSource[$i], $matches[1].'/pwg_high/'.$matches[2]); } } // Réinitialise les bloqueurs unset($BlockNormal); unset($BlockThumbnail); unset($BlockHigh); } if (!$silentORNOT) { echo '

Fichiers source

'.count($FilesSource).' fichiers
'; } unset($FilesSource); unset($FilesSortie); ### Supprime les dossiers vides et copie les fichiers index.php ### // Tableau avec les dossiers de sortie $DirsSortie = array(); recursive_readdir($DIRsortie, 'DirsSortie', true); foreach($DirsSortie as $dir) { if (is_dir_empty($dir)) { rmdir($dir); } else if ($indexORNOT) { copy('files/index.php', $dir.'/index.php'); } } unset($DirsSortie); ### Plugins après execution ### foreach ($PluginsAfter as $name => $config) { if ($config['active']) { include('plugins/'.$name.'.php'); } } echo '
Opération terminée : '.intval((microtime(true)-$TIME_START)) .' secondes. Retour
'; } else { echo '
Prêt à commencer. Exécuter
'; } echo ' '; ?>