Ignore:
Timestamp:
Jan 1, 2012, 10:09:17 PM (12 years ago)
Author:
mistic100
Message:

fix detection regex and watermark position

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PHP_Optimisateur/index.php

    r10338 r12819  
    11<?php
    22/***************************************\
    3 |                       PHP OPTIMISATEUR                        |
    4 |                         Version 1.4                           |
     3|            PHP OPTIMISATEUR           |
     4|              Version 1.4              |
    55\***************************************/
    66
     
    1414$LOG = array();
    1515$PAGE = array(
    16         'section' => 'home',
    17         'header' => null,
    18         'content' => null,
    19         'msgs' => null,
    20         'end' => null,
     16  'section' => 'home',
     17  'header' => null,
     18  'content' => null,
     19  'msgs' => null,
     20  'end' => null,
    2121);
    2222
     
    2828### CONFIGURATION ###
    2929if (!file_exists('config.xml')) {
    30         $ERRORS['fatal'][] = 'ErrorConfigFile';
     30  $ERRORS['fatal'][] = 'ErrorConfigFile';
    3131} else {
    32         $CONF = load_config('config.xml');
     32  $CONF = load_config('config.xml');
    3333}
    3434
    3535if (!file_exists('include/nconvert.exe')) {
    36         $ERRORS['fatal'][] = 'ErrorNconvert';
     36  $ERRORS['fatal'][] = 'ErrorNconvert';
    3737}
    3838
     
    4444### PROCESSUS ###
    4545switch ($PAGE['section']) {
    46         case 'home':
    47                 if (!isset($ERRORS['fatal'])) {
    48                         if (!file_exists($CONF['DIRsource'])) {
    49                                 mkdir($CONF['DIRsource']);
    50                         }
    51                         if (!file_exists($CONF['DIRsortie'])) {
    52                                 mkdir($CONF['DIRsortie']);
    53                         }
    54                         if (is_dir_empty($CONF['DIRsource'])) {
    55                                 $ERRORS['fatal'][] = 'ErrorFolderIn';
    56                         }
    57                         if ($CONF['silentORNOT'] == 'block' AND !is_dir_empty($CONF['DIRsortie'])) {
    58                                 $ERRORS['fatal'][] = 'ErrorFolderOut';
    59                         } else if ($CONF['silentORNOT'] == 'erase' AND !is_dir_empty($CONF['DIRsortie'])) {
    60                                 $ERRORS['notice'][] = 'EraseFolderOut';
    61                         }
    62                 }
    63                 break;
    64                
    65         case 'setup':
    66                 if (isset($_POST['submit'])) {
    67                         include('include/save_config.php');
    68                 }
    69                 break;
    70        
    71         case 'process':
    72                 include('include/main.php');
    73                 break;
     46  case 'home':
     47    if (!isset($ERRORS['fatal'])) {
     48      if (!file_exists($CONF['DIRsource'])) {
     49        mkdir($CONF['DIRsource']);
     50      }
     51      if (!file_exists($CONF['DIRsortie'])) {
     52        mkdir($CONF['DIRsortie']);
     53      }
     54      if (is_dir_empty($CONF['DIRsource'])) {
     55        $ERRORS['fatal'][] = 'ErrorFolderIn';
     56      }
     57      if ($CONF['silentORNOT'] == 'block' AND !is_dir_empty($CONF['DIRsortie'])) {
     58        $ERRORS['fatal'][] = 'ErrorFolderOut';
     59      } else if ($CONF['silentORNOT'] == 'erase' AND !is_dir_empty($CONF['DIRsortie'])) {
     60        $ERRORS['notice'][] = 'EraseFolderOut';
     61      }
     62    }
     63    break;
     64   
     65  case 'setup':
     66    if (isset($_POST['submit'])) {
     67      include('include/save_config.php');
     68    }
     69    break;
     70 
     71  case 'process':
     72    include('include/main.php');
     73    break;
    7474}
    7575
     
    7878### AFFICHAGE ###
    7979switch ($PAGE['section']) {
    80         case 'home':
    81                 include('include/display_config.php');
    82                
    83                 if (isset($ERRORS['fatal'])) {
    84                         $PAGE['end'] .= '
    85                         <div class="generic link">
    86                                 <a class="input-submit" href="index.php">'.l10n('Reload').'</a>
    87                                 <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
    88                         </div>';
     80  case 'home':
     81    include('include/display_config.php');
     82   
     83    if (isset($ERRORS['fatal'])) {
     84      $PAGE['end'] .= '
     85      <div class="generic link">
     86        <a class="input-submit" href="index.php">'.l10n('Reload').'</a>
     87        <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
     88      </div>';
    8989
    90                 } else {
    91                         $PAGE['end'] .= '
    92                         <div class="generic finish">
    93                                 <span id="ready-text">'.l10n('Ready').'</span>
    94                                 <span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
    95                         </div>
    96                         <div class="generic link">
    97                                 <a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
    98                                 <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
    99                         </div>';
    100                 }
    101                 break;
    102                
    103         case 'setup':
    104                 if (isset($ERRORS['fatal'])) {
    105                         $PAGE['end'] .= '
    106                         <div class="generic link">
    107                                 <a class="input-submit" href="index.php">'.l10n('Back').'</a>
    108                                 <a class="input-submit" href="index.php?page=setup">'.l10n('Reload').'</a>
    109                         </div>';
     90    } else {
     91      $PAGE['end'] .= '
     92      <div class="generic finish">
     93        <span id="ready-text">'.l10n('Ready').'</span>
     94        <span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
     95      </div>
     96      <div class="generic link">
     97        <a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
     98        <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
     99      </div>';
     100    }
     101    break;
     102   
     103  case 'setup':
     104    if (isset($ERRORS['fatal'])) {
     105      $PAGE['end'] .= '
     106      <div class="generic link">
     107        <a class="input-submit" href="index.php">'.l10n('Back').'</a>
     108        <a class="input-submit" href="index.php?page=setup">'.l10n('Reload').'</a>
     109      </div>';
    110110
    111                 } else {
    112                         include('include/setup.php');
    113                 }
    114                 break;
    115        
    116         case 'process':
    117                 ### Affichage des fichiers traités et création du log ###
    118                 $nb_files = count($FilesSource);
    119                 $time = intval((microtime(true)-$TIME_START));
    120                 $logfile = print_log($nb_files, $time);
    121                
    122                 $PAGE['content'] .= '
    123                 <div class="generic files">
    124                         <h2>'.l10n('Source files').'</h2>
    125                         <ul>';
    126                                 foreach ($FilesSource as $value) {
    127                                         $PAGE['content'] .= '<li>'.$value.'</li>';
    128                                 }
    129                         $PAGE['content'] .= '</ul>
    130                         <i>'.l10n('%d files', $nb_files).'</i><br>
    131                         <b>Log :</b> <a href="logs/'.$logfile.'">'.$logfile.'</a>
    132                 </div>';
    133                
     111    } else {
     112      include('include/setup.php');
     113    }
     114    break;
     115 
     116  case 'process':
     117    ### Affichage des fichiers traités et création du log ###
     118    $nb_files = count($FilesSource);
     119    $time = intval((microtime(true)-$TIME_START));
     120    $logfile = print_log($nb_files, $time);
     121   
     122    $PAGE['content'] .= '
     123    <div class="generic files">
     124      <h2>'.l10n('Source files').'</h2>
     125      <ul>';
     126        foreach ($FilesSource as $value) {
     127          $PAGE['content'] .= '<li>'.$value.'</li>';
     128        }
     129      $PAGE['content'] .= '</ul>
     130      <i>'.l10n('%d files', $nb_files).'</i><br>
     131      <b>Log :</b> <a href="logs/'.$logfile.'">'.$logfile.'</a>
     132    </div>';
     133   
    134134
    135                 unset($FilesSource);
    136                 unset($FilesSortie);
    137                
    138                 $PAGE['end'] .= '
    139                 <div class="generic finish">'.l10n('Finish %d seconds', $time).'</div>
    140                 <div class="generic link">
    141                         <a class="input-submit" href="index.php">'.l10n('Back').'</a>
    142                         <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
    143                 </div>';
    144                 break;
     135    unset($FilesSource);
     136    unset($FilesSortie);
     137   
     138    $PAGE['end'] .= '
     139    <div class="generic finish">'.l10n('Finish %d seconds', $time).'</div>
     140    <div class="generic link">
     141      <a class="input-submit" href="index.php">'.l10n('Back').'</a>
     142      <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
     143    </div>';
     144    break;
    145145}
    146146
     
    150150// erreurs fatales
    151151if (isset($ERRORS['fatal'])) {
    152         $PAGE['msgs'] .= '<div class="generic error">';
    153                 foreach ($ERRORS['fatal'] as $key) {
    154                         $PAGE['msgs'] .= '<div>'.l10n('fatal.'.$key).'</div>';
    155                 }
    156         $PAGE['msgs'] .= '</div>';
     152  $PAGE['msgs'] .= '<div class="generic error">';
     153    foreach ($ERRORS['fatal'] as $key) {
     154      $PAGE['msgs'] .= '<div>'.l10n('fatal.'.$key).'</div>';
     155    }
     156  $PAGE['msgs'] .= '</div>';
    157157}
    158158// informations
    159159if (isset($ERRORS['notice'])) {
    160         $PAGE['msgs'] .= '<div class="generic notice">';
    161                 foreach ($ERRORS['notice'] as $key) {
    162                         $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key).'</div>';
    163                 }
    164         $PAGE['msgs'] .= '</div>';
     160  $PAGE['msgs'] .= '<div class="generic notice">';
     161    foreach ($ERRORS['notice'] as $key) {
     162      $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key).'</div>';
     163    }
     164  $PAGE['msgs'] .= '</div>';
    165165}
    166166// erreurs de configuration
    167167if (isset($ERRORS['conf'])) {
    168         $PAGE['msgs'] .= '<div class="generic notice conf">';
    169                 foreach ($ERRORS['conf'] as $key) {
    170                         $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key[1].' %s', '<i>'.$key[0].'</i>').'</div>';
    171                 }
    172         $PAGE['msgs'] .= '</div>';
     168  $PAGE['msgs'] .= '<div class="generic notice conf">';
     169    foreach ($ERRORS['conf'] as $key) {
     170      $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key[1].' %s', '<i>'.$key[0].'</i>').'</div>';
     171    }
     172  $PAGE['msgs'] .= '</div>';
    173173}
    174174
     
    183183echo '
    184184<div class="generic footer">
    185         2010/2011 - <a href="http://www.strangeplanet.fr">Damien Sorel</a> - <a href="http://fr.piwigo.org/forum/viewtopic.php?id=19117">Forum</a> - <a href="http://fr.piwigo.org/doc/doku.php?id=tools:php_o">Documentation</a>
     185  2010/2011 - <a href="http://www.strangeplanet.fr">Damien Sorel</a> - <a href="http://fr.piwigo.org/forum/viewtopic.php?id=19117">Forum</a> - <a href="http://fr.piwigo.org/doc/doku.php?id=tools:php_o">Documentation</a>
    186186</div>
    187187
Note: See TracChangeset for help on using the changeset viewer.