Changeset 12819 for extensions/PHP_Optimisateur/include/main.php
- Timestamp:
- Jan 1, 2012, 10:09:17 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PHP_Optimisateur/include/main.php
r10337 r12819 2 2 // Si mode silencieux vidage automatique du dossier de sortie 3 3 if ($CONF['silentORNOT'] == 'erase') { 4 5 4 @rrmdir($CONF['DIRsortie']); 5 @mkdir($CONF['DIRsortie']); 6 6 } 7 7 … … 10 10 // Les caractères '%' et '$' sont systématiquement échappés, ca génère des bugs dans les noms de fichiers 11 11 function recursive_delete_special_car($dir) { 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 12 $dir = rtrim($dir, '/'); 13 $dh = opendir($dir); 14 15 while (($file = readdir($dh)) !== false ) { 16 if ($file !== '.' && $file !== '..') { 17 $path = $dir.'/'.$file; 18 $new_path = $dir.'/'.delete_special_car($file); 19 20 if ($path != $new_path) { 21 rename_log($path, $new_path); 22 } 23 24 if (is_dir($new_path)) { 25 recursive_delete_special_car($new_path); 26 } 27 } 28 } 29 closedir($dh); 30 30 } 31 31 … … 38 38 39 39 if ($CONF['copyONhd']) { 40 40 $CONF['copyHD'] = '-text_font "'.$CONF['copyFONT'].'" '.$CONF['DIMnormal']*$CONF['copySIZE'].' -text_color '.$CONF['copyCOLOR'].' -text_flag '.$CONF['copyPOS'].' -text_pos 0 0 -text "'.$CONF['copyright'].'"'; 41 41 } else { 42 42 $CONF['copyHD'] = null; 43 43 } 44 44 45 45 if ($CONF['copyONnormal']) { 46 46 $CONF['copyNormal'] = '-text_font "'.$CONF['copyFONT'].'" '.$CONF['DIMnormal']*$CONF['copySIZE'].' -text_color '.$CONF['copyCOLOR'].' -text_flag '.$CONF['copyPOS'].' -text_pos 0 0 -text "'.$CONF['copyright'].'"'; 47 47 } else { 48 48 $CONF['copyNormal'] = null; 49 49 } 50 50 … … 55 55 ### Plugins avant execution ### 56 56 foreach ($CONF['Plugins'] as $plugin_id => $plugin_config) { 57 58 59 57 if ($plugin_config['mode'] == 'Before' AND $plugin_config['active']) { 58 include('plugins/'.$plugin_id.'/main.php'); 59 } 60 60 } 61 61 … … 71 71 // Boucle sur tous les fichiers 72 72 for ($i=0; $i<count($FilesSource); $i++) { 73 74 preg_match('#^(.*)/(.*)\.([a-z0-9]{2,4})$#', $FilesSource[$i], $matches);75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 73 // Découpe le nom de fichier : dossier/fichier/extension 74 preg_match('#^(.*)/(.*)\.([a-z0-9]{2,4})$#i', $FilesSource[$i], $matches); 75 $file['folder_src'] = $matches[1].'/'; // dossier d'entrée 76 $file['folder_out'] = str_replace($CONF['DIRsource'], $CONF['DIRsortie'], $file['folder_src']); // dossier de sortie 77 $file['name'] = $matches[2]; // nom final 78 $file['ext'] = $matches[3]; // extension orginale 79 80 // Crée les sous-dossiers de sortie & 'pwg_high' & 'thumbnail' 81 if (!file_exists($file['folder_out'].'pwg_high') AND $CONF['DIRhighORNOT']) { 82 mkdir_log($file['folder_out'].'pwg_high'); 83 } 84 if (!file_exists($file['folder_out'].'thumbnail')) { 85 mkdir_log($file['folder_out'].'thumbnail'); 86 } 87 88 if (!in_arrayi($file['ext'], $CONF['allowedExt'])) { 89 $BlockAll['main'] = true; 90 $LOG[] = 'Not image file : '.$FilesSource[$i]; 91 } 92 93 if (!isset($BlockAll)) { 94 // Informations sur le fichier 95 exec('include\nconvert.exe -info "'.$FilesSource[$i].'"', $FileInfos); 96 97 for ($m=0; $m<=5; $m++) { 98 unset($FileInfos[$m]); 99 } 100 foreach ($FileInfos as $key) { 101 if ($key != '') { 102 $a = explode(':', $key); 103 $FileInfos[trim($a[0])] = trim($a[1]); 104 } 105 } 106 } 107 108 // Plugins pendant l'execution, haute priorité 109 foreach ($CONF['Plugins'] as $plugin_id => $plugin_config) { 110 if ($plugin_config['mode'] == 'ProcessHigh' AND $plugin_config['active']) { 111 include('plugins/'.$plugin_id.'/main.php'); 112 } 113 } 114 115 // Plugins pendant l'execution 116 foreach ($CONF['Plugins'] as $plugin_id => $plugin_config) { 117 if ($plugin_config['mode'] == 'Process' AND $plugin_config['active']) { 118 include('plugins/'.$plugin_id.'/main.php'); 119 } 120 } 121 122 // Compresse les fichiers dans le dossier de sortie 123 if (!isset($BlockNormal) AND !isset($BlockAll)) { 124 nconvert('-q '.$CONF['Qnormal'].' -out jpeg -o "'.$file['folder_out'].$file['name'].'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$CONF['DIMnormal'].' '.$CONF['DIMnormal'].' '.$CONF['copyNormal'].' "'.$FilesSource[$i].'"'); 125 } 126 if (!isset($BlockThumbnail) AND !isset($BlockAll)) { 127 nconvert('-q '.$CONF['Qthumbnail'].' -out jpeg -o "'.$file['folder_out'].'thumbnail/'.$CONF['prefixe_mini'].$file['name'].'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$CONF['DIMthumbnail'].' '.$CONF['DIMthumbnail'].' -rmeta -rexifthumb "'.$FilesSource[$i].'"'); 128 } 129 if (!isset($BlockHigh) AND $CONF['DIRhighORNOT'] AND !isset($BlockAll)) { 130 if ($CONF['DIMhdORNOT']) { 131 nconvert('-q '.$CONF['Qhd'].' -out jpeg -o "'.$file['folder_out'].'pwg_high/'.$file['name'].'.jpg" -dpi '.$CONF['DPI'].' '.$CONF['convOptions'].' -resize '.$CONF['DIMhd'].' '.$CONF['DIMhd'].' '.$CONF['copyHD'].' "'.$FilesSource[$i].'"'); 132 } else if (strtolower($file['ext']) != 'jpg') { 133 nconvert('-q '.$CONF['Qhd'].' -out jpeg -o "'.$file['folder_out'].'pwg_high/'.$file['name'].'.jpg" "'.$FilesSource[$i].'"'); 134 } else { 135 copy_log($FilesSource[$i], $file['folder_out'].'pwg_high/'.$file['name'].'.jpg'); 136 } 137 } 138 139 // Réinitialise les variables 140 unset($file, $FileInfos, $BlockNormal, $BlockThumbnail, $BlockHigh, $BlockAll); 141 $LOG[] = "\r\n"; 142 142 } 143 143 … … 148 148 149 149 foreach($DirsSortie as $dir) { 150 151 152 153 154 150 if (is_dir_empty($dir)) { 151 rmdir($dir); 152 } else if ($CONF['indexORNOT']) { 153 copy_log('include/index.php', $dir.'/index.php'); 154 } 155 155 } 156 156 … … 160 160 ### Plugins après execution ### 161 161 foreach ($CONF['Plugins'] as $plugin_id => $plugin_config) { 162 163 164 162 if ($plugin_config['mode'] == 'After' AND $plugin_config['active']) { 163 include('plugins/'.$plugin_id.'/main.php'); 164 } 165 165 } 166 166 ?>
Note: See TracChangeset
for help on using the changeset viewer.