Changeset 9201 for extensions
- Timestamp:
- Feb 13, 2011, 3:53:51 PM (14 years ago)
- Location:
- extensions/PHP_Optimisateur
- Files:
-
- 74 added
- 12 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PHP_Optimisateur/config.xml
r8226 r9201 1 1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <config> 3 <DIRsource> ./in/</DIRsource>4 <DIRsortie> ./out/</DIRsortie>3 <DIRsource>in/</DIRsource> 4 <DIRsortie>out/</DIRsortie> 5 5 <silentORNOT>block</silentORNOT> 6 6 <DIRhighORNOT>true</DIRhighORNOT> … … 21 21 <copyPOS>bottom-right</copyPOS> 22 22 <copySIZE>0.05</copySIZE> 23 <copyCOLOR> #000000</copyCOLOR>23 <copyCOLOR>000000</copyCOLOR> 24 24 <copyFONT>Arial</copyFONT> 25 <PluginsBefore></PluginsBefore> 26 <PluginsProcess></PluginsProcess> 27 <PluginsAfter></PluginsAfter> 25 <Plugins></Plugins> 28 26 </config> -
extensions/PHP_Optimisateur/index.php
r8226 r9201 2 2 /***************************************\ 3 3 | PHP OPTIMISATEUR | 4 | Version 1. 2|4 | Version 1.3 | 5 5 \***************************************/ 6 6 7 session_start(); 7 8 set_time_limit(7200); 9 10 $APPversion = '1.3'; 8 11 $TIME_START = microtime(true); 12 $ERRORS = array(); 13 $CONF = array(); 14 $PAGE_CONTENT = array(0=>null,1=>null,2=>null); 9 15 10 include(' files/functions.php');11 include('files/header.php');16 include('include/functions.php'); 17 $PAGE = (isset($_GET['page'])) ? $_GET['page'] : 'home'; 12 18 13 19 14 20 15 ### DEMARRAGE ### 16 // Fichier de configuration 21 ### CONFIGURATION ### 17 22 if (!file_exists('config.xml')) { 18 $Errors['ErrorFile'] = true; 23 $ERRORS['fatal']['ErrorConfigFile'] = true; 24 } else { 25 $CONF = load_config('config.xml'); 26 } 27 28 if (!file_exists('include/nconvert.exe')) { 29 $ERRORS['fatal']['ErrorNconvert'] = true; 30 } 31 32 33 34 ### HEADER ### 35 $CONF = array_merge($CONF, GetLanguage()); 36 include('language/'.$CONF['user_lang'].'/'.$CONF['user_lang'].'.php'); 37 include('include/header.php'); 38 39 40 41 ### VERIFICATIONS ### 42 if ($PAGE == 'home') { 43 if (!isset($ERRORS['fatal'])) { 44 if (!file_exists($CONF['DIRsource'])) { 45 mkdir($CONF['DIRsource']); 46 } 47 if (!file_exists($CONF['DIRsortie'])) { 48 mkdir($CONF['DIRsortie']); 49 } 50 if (is_dir_empty($CONF['DIRsource'])) { 51 $ERRORS['ErrorFolderIn'] = 'fatal'; 52 } 53 if ($CONF['silentORNOT'] == 'block' AND !is_dir_empty($CONF['DIRsortie'])) { 54 $ERRORS['fatal']['ErrorFolderOut'] = true; 55 } else if ($CONF['silentORNOT'] == 'erase' AND !is_dir_empty($CONF['DIRsortie'])) { 56 $ERRORS['notice']['EraseFolderOut'] = true; 57 } 58 } 19 59 20 } else { 21 // Configuration 22 extract(load_config()); 23 24 // Afficher la configuration 25 include('files/display_config.php'); 26 27 // Dossiers 28 if (!file_exists($DIRsource)) { 29 mkdir($DIRsource); 60 } else if ($PAGE == 'setup') { 61 if (isset($_GET['ErrorConfig'])) { 62 $ERRORS['notice']['ErrorConfig'] = true; 30 63 } 31 if ( !file_exists($DIRsortie)) {32 mkdir($DIRsortie);64 if (isset($_POST['DIRsource'])) { 65 include('include/save_config.php'); 33 66 } 34 if (is_dir_empty($DIRsource)) { 35 $Errors['ErrorFolderIn'] = true; 36 } 37 if (!is_dir_empty($DIRsortie) AND $silentORNOT == 'block') { 38 $Errors['ErrorFolderOut'] = true; 39 } 40 if (!file_exists('files\nconvert.exe')) { 41 $Errors['ErrorNconvert'] = true; 42 } 67 68 } else if ($PAGE = 'process') { 69 include('include/main.php'); 43 70 } 44 71 … … 46 73 47 74 ### ERREURS ### 48 if (isset($Errors)) { 49 foreach ($Errors as $key => $null) { 50 echo '<div class="error">'.l10n($key).'</div>'; 51 } 52 echo '<div class="link"><a href="index.php">» '.l10n('Back').'</a> <a href="setup.php">» '.l10n('Config').'</a></div>'; 75 if (isset($ERRORS['fatal'])) { 76 $PAGE_CONTENT[1] .= '<div class="generic error">'; 77 foreach ($ERRORS['fatal'] as $key => $i) { 78 $PAGE_CONTENT[1] .= '<div>'.l10n('fatal.'.$key).'</div>'; 79 } 80 $PAGE_CONTENT[1] .= '</div>'; 81 } 82 if (isset($ERRORS['notice'])) { 83 $PAGE_CONTENT[1] .= '<div class="generic notice">'; 84 foreach ($ERRORS['notice'] as $key => $i) { 85 $PAGE_CONTENT[1] .= '<div>'.l10n('notice.'.$key).'</div>'; 86 } 87 $PAGE_CONTENT[1] .= '</div>'; 53 88 } 54 89 55 90 56 91 57 ### EXECUTION ### 58 if (isset($_GET['Process']) AND !isset($Errors)) { 59 // Si mode silencieux vidage automatique du dossier de sortie 60 if ($silentORNOT == 'erase') { 61 rrmdir($DIRsortie); 62 mkdir($DIRsortie); 63 } 92 ### AFFICHAGE ### 93 if ($PAGE == 'home') { 94 if (isset($ERRORS['fatal'])) { 95 $PAGE_CONTENT[2] .= '<div class="generic link"><a class="input-submit" href="index.php">'.l10n('Back').'</a> <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a></div>'; 64 96 65 66 ### Supprimer les caractères spéciaux - dossiers & fichiers ### 67 // Les caractères '%' et '$' sont systématiquement échappés, ca génère des bugs dans les noms de fichiers 68 function recursive_delete_special_car($dir) { 69 $dir = rtrim($dir, '/'); 70 $dh = opendir($dir); 97 } else { 98 include('include/display_config.php'); 71 99 72 while (($file = readdir($dh)) !== false ) { 73 if ($file !== '.' && $file !== '..') { 74 $path = $dir.'/'.$file; 75 $new_path = $dir.'/'.delete_special_car($file); 76 rename($path, $new_path); 77 78 if (is_dir($new_path)) { 79 recursive_delete_special_car($new_path); 80 } 81 } 82 } 83 closedir($dh); 84 } 85 86 recursive_delete_special_car($DIRsource); 87 88 89 ### Copyright & Options générales des conversion ### 90 $copyright = utf8_decode($copyright); 91 $copyCOLOR = hex2RGB(substr($copyCOLOR,1), true, ' '); 92 93 if ($copyONhd) { 94 $copyHD = '-text_font "'.$copyFONT.'" '.$DIMnormal*$copySIZE.' -text_color '.$copyCOLOR.' -text_flag '.$copyPOS.' -text_pos 0 0 -text "'.$copyright.'"'; 95 } else { 96 $copyHD = null; 100 $PAGE_CONTENT[2] .= '<div class="generic finish"> 101 <span id="ready-text">'.l10n('Ready').'</span> 102 <span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span> 103 </div> 104 <div class="generic link"> 105 <a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a> 106 <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a> 107 </div>'; 97 108 } 98 109 99 if ($copyONnormal) { 100 $copyNormal = '-text_font "'.$copyFONT.'" '.$DIMnormal*$copySIZE.' -text_color '.$copyCOLOR.' -text_flag '.$copyPOS.' -text_pos 0 0 -text "'.$copyright.'"'; 110 } else if ($PAGE == 'setup') { 111 if (isset($ERRORS['fatal'])) { 112 $PAGE_CONTENT[2] .= '<div class="generic link"><a class="input-submit" href="index.php">'.l10n('Back').'</a></div>'; 113 101 114 } else { 102 $copyNormal = null;115 include('include/setup.php'); 103 116 } 104 117 105 $convOptions = '-ratio -rtype lanczos -rflag decr'; 106 107 108 ### Plugins avant execution ### 109 foreach ($PluginsBefore as $name => $config) { 110 if ($config['active']) { 111 include('plugins/'.$name.'.php'); 112 } 113 } 114 115 116 ### Processus principal ### 117 // Tableau avec les fichiers source 118 $FilesSource = array(); 119 recursive_readdir($DIRsource, 'FilesSource'); 120 121 // Tableau avec les fichiers de sortie 122 $FilesSortie = str_replace($DIRsource, $DIRsortie, $FilesSource); 123 124 // Boucle sur tous les fichiers 125 for ($i=0; $i<count($FilesSource); $i++) { 126 // Découpe le nom de fichier : dossier/fichier 127 preg_match('#(.*)/(.*)$#', $FilesSortie[$i], $matches); 128 $FileFolder = $matches[1]; // dossier de sortie 129 $FileName = $matches[2]; // nom+ext fichier 130 131 // Crée les sous-dossiers de sortie & 'pwg_high' & 'thumbnail' 132 if (!file_exists($FileFolder.'/pwg_high') AND $DIRhighORNOT) { 133 mkdir($FileFolder.'/pwg_high', 0777, true); 134 } 135 if (!file_exists($FileFolder.'/thumbnail')) { 136 mkdir($FileFolder.'/thumbnail', 0777, true); 137 } 138 139 // Informations sur le fichier 140 exec('files\nconvert.exe -info "'.$FilesSource[$i].'"', $FileInfos); 141 for ($m=0; $m<=5; $m++) { 142 unset($FileInfos[$m]); 143 } 144 foreach ($FileInfos as $key) { 145 $a = explode(':', $key); 146 $FileInfos[trim($a[0])] = trim($a[1]); 147 } 148 149 // Plugins pendant l'execution 150 foreach ($PluginsProcess as $name => $config) { 151 if ($config['active']) { 152 include('plugins/'.$name.'.php'); 153 } 154 } 155 156 // Compresse les fichiers dans le dossier de sortie 157 if (!isset($BlockNormal)) { 158 exec('files\nconvert.exe -q '.$Qnormal.' -out jpeg -o "'.$FileFolder.'/'.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$DIMnormal.' '.$DIMnormal.' '.$copyNormal.' "'.$FilesSource[$i].'"'); 159 } 160 if (!isset($BlockThumbnail)) { 161 exec('files\nconvert.exe -q '.$Qthumbnail.' -out jpeg -o "'.$FileFolder.'/thumbnail/'.$prefixe_mini.$FileName.'" -dpi 72 '.$convOptions.' -resize '.$DIMthumbnail.' '.$DIMthumbnail.' -rmeta -rexifthumb "'.$FilesSource[$i].'"'); 162 } 163 if (!isset($BlockHigh) AND $DIRhighORNOT) { 164 if ($DIMhdORNOT) { 165 exec('files\nconvert.exe -q '.$Qhd.' -out jpeg -o "'.$FileFolder.'/pwg_high/'.$FileName.'" -dpi '.$DPI.' '.$convOptions.' -resize '.$DIMhd.' '.$DIMhd.' '.$copyHD.' "'.$FilesSource[$i].'"'); 166 } else { 167 copy($FilesSource[$i], $FileFolder.'/pwg_high/'.$FileName); 168 } 169 } 170 171 // Réinitialise les bloqueurs 172 unset($FileInfos); 173 unset($BlockNormal); 174 unset($BlockThumbnail); 175 unset($BlockHigh); 176 } 177 178 118 } else if ($PAGE = 'process') { 179 119 ### Affichage des fichiers traités ### 180 echo '<div class="files">120 $PAGE_CONTENT[0] .= '<div class="generic files"> 181 121 <h2>'.l10n('Source files').'</h2> 182 122 <ul>'; 183 123 foreach ($FilesSource as $value) { 184 echo'<li>'.$value.'</li>';124 $PAGE_CONTENT[0] .= '<li>'.$value.'</li>'; 185 125 } 186 echo'</ul>126 $PAGE_CONTENT[0] .= '</ul> 187 127 <i>'.l10n('%d files', count($FilesSource)).'</i> 188 128 </div>'; … … 190 130 unset($FilesSource); 191 131 unset($FilesSortie); 192 193 194 ### Supprime les dossiers vides et copie les fichiers index.php ###195 $DirsSortie = array();196 recursive_readdir($DIRsortie, 'DirsSortie', true);197 198 foreach($DirsSortie as $dir) {199 if (is_dir_empty($dir)) {200 rmdir($dir);201 } else if ($indexORNOT) {202 copy('files/index.php', $dir.'/index.php');203 }204 }205 206 unset($DirsSortie);207 208 209 ### Plugins après execution ###210 foreach ($PluginsAfter as $name => $config) {211 if ($config['active']) {212 include('plugins/'.$name.'.php');213 }214 }215 216 217 ### Message final ###218 echo '<div class="finish">'.l10n('Finish %d seconds', intval((microtime(true)-$TIME_START))).'</div>219 <div class="link"><a href="index.php">» '.l10n('Back').'</a> <a href="setup.php">» '.l10n('Config').'</a></div>';220 221 132 222 223 ### READY ### 224 } else if (!isset($Errors)) { 225 echo '<div class="finish">'.l10n('Ready').' <span id="loader" style="display:none;float:right;margin:-8px 0 -10px 0;"><img src="files/loader.gif" /></span></div>226 < div class="link"><a href="index.php?Process=true" onClick="document.getElementById(\'loader\').style.display=\'block\';">» '.l10n('Launch').'</a> <a href="setup.php">» '.l10n('Config').'</a></div>';133 $PAGE_CONTENT[2] .= '<div class="generic finish">'.l10n('Finish %d seconds', intval((microtime(true)-$TIME_START))).'</div> 134 <div class="generic link"> 135 <a class="input-submit" href="index.php">'.l10n('Back').'</a> 136 <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a> 137 </div>'; 227 138 } 228 139 229 140 141 ### FIN ### 142 echo $PAGE_CONTENT[0]; 143 echo $PAGE_CONTENT[1]; 144 echo $PAGE_CONTENT[2]; 230 145 231 ### FIN ### 232 echo '<div class="footer"> 146 echo '<div class="generic footer"> 233 147 2010 - <a href="http://www.strangeplanet.fr">Damien Sorel</a> - <a href="http://fr.piwigo.org/forum/viewtopic.php?id=19117">Forum</a> 234 148 </div> -
extensions/PHP_Optimisateur/language/en/en.php
r8226 r9201 1 1 <?php 2 /***************************************\3 | PHP OPTIMISATEUR |4 | Version 1.2 |5 \***************************************/6 7 2 $Lang['ErrorFile'] = "Fatal error : Configuration file missing."; 8 3 $Lang['ErrorFolderIn'] = "Fatal error : Input folder empty."; 9 4 $Lang['ErrorFolderOut'] = "Fatal error : Output folder not empty."; 10 $Lang['ErrorNconvert'] = "The program nconvert.exe is not found."; 5 $Lang['ErrorNconvert'] = "Fatal error : The program <i>nconvert.exe</i> is not found."; 6 $Lang['ErrorConfig'] = "Some configuration errors have been fixed, please check your parameters."; 11 7 $Lang['Source files'] = "Handled files"; 12 8 $Lang['%d files'] = "%d files"; 13 9 $Lang['Finish %d seconds'] = "Process done : %d seconds."; 14 10 $Lang['Ready'] = "Ready to launch."; 11 $Lang['Processing'] = "Processing."; 15 12 $Lang['Launch'] = "Launch"; 16 13 $Lang['Config'] = "Configure"; … … 46 43 $Lang['copyFONT'] = "Font"; 47 44 $Lang['Plugins'] = "Plugins"; 48 $Lang['PluginsBefore'] = "Plugins pre-processing";49 $Lang['PluginsProcess'] = "Plugins processing";50 $Lang['PluginsAfter'] = "Plugins post-processing";51 45 $Lang['yes'] = "yes"; 52 46 $Lang['no'] = "no"; … … 63 57 $Lang['Reset'] = "Reset"; 64 58 $Lang['Valid'] = "Validate"; 59 $Lang['Active'] = "Active"; 60 $Lang['Inactive'] = "Inactive"; 65 61 ?> -
extensions/PHP_Optimisateur/language/fr/fr.php
r8226 r9201 1 1 <?php 2 /***************************************\ 3 | PHP OPTIMISATEUR | 4 | Version 1.2 | 5 \***************************************/ 6 7 $Lang['ErrorFile'] = "Erreur fatale : Fichier de configuration introuvable."; 8 $Lang['ErrorFolderIn'] = "Erreur fatale : Dossier source vide."; 9 $Lang['ErrorFolderOut'] = "Erreur fatale : Dossier de sortie non vide."; 10 $Lang['ErrorNconvert'] = "Le programme nconvert.exe est introuvable."; 2 $Lang['fatal.ErrorConfigFile'] = "Erreur fatale : Fichier de configuration introuvable."; 3 $Lang['fatal.ErrorFolderIn'] = "Erreur fatale : Dossier source vide."; 4 $Lang['fatal.ErrorFolderOut'] = "Erreur fatale : Dossier de sortie non vide."; 5 $Lang['fatal.ErrorNconvert'] = "Erreur fatale : Le programme <i>nconvert.exe</i> est introuvable."; 6 $Lang['fatal.ErrorConfig'] = "Erreur fatale : Configuration incorrecte."; 7 $Lang['notice.EraseFolderOut'] = "Attention : Le dossier de sortie va être entièrement vidé."; 8 $Lang['notice.ErrorConfig'] = "Des erreurs de configuration ont été corrigées, veuillez vérifier les réglages."; 11 9 $Lang['Source files'] = "Fichiers traités"; 12 10 $Lang['%d files'] = "%d fichiers"; 13 11 $Lang['Finish %d seconds'] = "Opération terminée : %d secondes."; 14 12 $Lang['Ready'] = "Prêt à commencer."; 13 $Lang['Processing'] = "En cours de traitement."; 15 14 $Lang['Launch'] = "Exécuter"; 16 15 $Lang['Config'] = "Configurer"; … … 46 45 $Lang['copyFONT'] = "Police"; 47 46 $Lang['Plugins'] = "Plugins"; 48 $Lang['PluginsBefore'] = "Plugins pré-processing";49 $Lang['PluginsProcess'] = "Plugins processing";50 $Lang['PluginsAfter'] = "Plugins post-processing";51 47 $Lang['yes'] = "oui"; 52 48 $Lang['no'] = "non"; … … 63 59 $Lang['Reset'] = "Réinitialiser"; 64 60 $Lang['Valid'] = "Valider"; 61 $Lang['Active'] = "Activé"; 62 $Lang['Inactive'] = "Désactivé"; 65 63 ?>
Note: See TracChangeset
for help on using the changeset viewer.