Ignore:
Timestamp:
Apr 12, 2011, 7:45:22 PM (13 years ago)
Author:
mistic100
Message:

new version 1.4, new plugin for Charlies Content, NConvert updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PHP_Optimisateur/include/main.php

    r9633 r10337  
    1717                        $path = $dir.'/'.$file;
    1818                        $new_path = $dir.'/'.delete_special_car($file);
    19                         rename($path, $new_path);
     19                       
     20                        if ($path != $new_path) {
     21                                rename_log($path, $new_path);
     22                        }
    2023                       
    2124                        if (is_dir($new_path)) {
     
    4750
    4851$CONF['convOptions'] = '-ratio -rtype lanczos -rflag decr';
    49 $CONF['JPGexts'] = array('jpg', 'JPG'); // extensions admises pour le jpg
     52$CONF['allowedExt'] = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff');
    5053
    5154
     
    6871// Boucle sur tous les fichiers
    6972for ($i=0; $i<count($FilesSource); $i++) {
    70         // Découpe le nom de fichier : dossier/fichier
    71         preg_match('#(.*)/(.*).((?i)[a-z0-9]{3,4})$#', $FilesSortie[$i], $matches);
    72         $FileFolder = $matches[1].'/'; // dossier de sortie
    73         $FileName = $matches[2]; // nom final
    74         $FileExt = $matches[3]; // extension orginale
    75                
     73        // Découpe le nom de fichier : dossier/fichier/extension
     74        preg_match('#^(.*)/(.*)\.([a-z0-9]{2,4})$#', $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                       
    7680        // Crée les sous-dossiers de sortie & 'pwg_high' & 'thumbnail'
    77         if (!file_exists($FileFolder.'pwg_high') AND $CONF['DIRhighORNOT']) {
    78                 mkdir($FileFolder.'pwg_high', 0777, true);
     81        if (!file_exists($file['folder_out'].'pwg_high') AND $CONF['DIRhighORNOT']) {
     82                mkdir_log($file['folder_out'].'pwg_high');
    7983        }
    80         if (!file_exists($FileFolder.'thumbnail')) {
    81                 mkdir($FileFolder.'thumbnail', 0777, true);
     84        if (!file_exists($file['folder_out'].'thumbnail')) {
     85                mkdir_log($file['folder_out'].'thumbnail');
    8286        }
    8387       
    84         // Informations sur le fichier
    85         exec('include\nconvert.exe -info "'.$FilesSource[$i].'"', $FileInfos);
    86         for ($m=0; $m<=5; $m++) {
    87                 unset($FileInfos[$m]);
     88        if (!in_arrayi($file['ext'], $CONF['allowedExt'])) {
     89                $BlockAll['main'] = true;
     90                $LOG[] = 'Not image file : '.$FilesSource[$i];
    8891        }
    89         foreach ($FileInfos as $key) {
    90                 $a = explode(':', $key);
    91                 $FileInfos[trim($a[0])] = trim($a[1]);
     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                }
    92106        }
    93107               
     
    107121       
    108122        // Compresse les fichiers dans le dossier de sortie
    109         if (!isset($BlockNormal)) {
    110                 exec('include\nconvert.exe -q '.$CONF['Qnormal'].' -out jpeg -o "'.$FileFolder.$FileName.'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$CONF['DIMnormal'].' '.$CONF['DIMnormal'].' '.$CONF['copyNormal'].' "'.$FilesSource[$i].'"');
     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].'"');
    111125        }
    112         if (!isset($BlockThumbnail)) {
    113                 exec('include\nconvert.exe -q '.$CONF['Qthumbnail'].' -out jpeg -o "'.$FileFolder.'thumbnail/'.$CONF['prefixe_mini'].$FileName.'.jpg" -dpi 72 '.$CONF['convOptions'].' -resize '.$CONF['DIMthumbnail'].' '.$CONF['DIMthumbnail'].' -rmeta -rexifthumb "'.$FilesSource[$i].'"');
     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].'"');
    114128        }
    115         if (!isset($BlockHigh) AND $CONF['DIRhighORNOT']) {
     129        if (!isset($BlockHigh) AND $CONF['DIRhighORNOT'] AND !isset($BlockAll)) {
    116130                if ($CONF['DIMhdORNOT']) {
    117                         exec('include\nconvert.exe -q '.$CONF['Qhd'].' -out jpeg -o "'.$FileFolder.'pwg_high/'.$FileName.'.jpg" -dpi '.$CONF['DPI'].' '.$CONF['convOptions'].' -resize '.$CONF['DIMhd'].' '.$CONF['DIMhd'].' '.$CONF['copyHD'].' "'.$FilesSource[$i].'"');
    118                 } else if (!in_array($FileExt, $CONF['JPGexts'])) {
    119                         exec('include\nconvert.exe -q '.$CONF['Qhd'].' -out jpeg -o "'.$FileFolder.'pwg_high/'.$FileName.'.jpg" "'.$FilesSource[$i].'"');
     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].'"');
    120134                } else {
    121                         copy($FilesSource[$i], $FileFolder.'pwg_high/'.$FileName.'.jpg');
     135                        copy_log($FilesSource[$i], $file['folder_out'].'pwg_high/'.$file['name'].'.jpg');
    122136                }
    123137        }
    124138       
    125         // Réinitialise les bloqueurs
    126         unset($FileInfos);
    127         unset($BlockNormal);
    128         unset($BlockThumbnail);
    129         unset($BlockHigh);
     139        // Réinitialise les variables
     140        unset($file, $FileInfos, $BlockNormal, $BlockThumbnail, $BlockHigh, $BlockAll);
     141        $LOG[] = "\r\n";
    130142}
    131143
     
    139151                rmdir($dir);
    140152        } else if ($CONF['indexORNOT']) {
    141                 copy('include/index.php', $dir.'/index.php');
     153                copy_log('include/index.php', $dir.'/index.php');
    142154        }
    143155}
Note: See TracChangeset for help on using the changeset viewer.