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/index.php

    r9515 r10337  
    22/***************************************\
    33|                       PHP OPTIMISATEUR                        |
    4 |                         Version 1.3.3                         |
     4|                         Version 1.4                           |
    55\***************************************/
    66
    77session_start();
    88set_time_limit(7200);
     9define('ROOT_DIR', dirname(__FILE__).'\\');
    910
    10 $APPversion = '1.3';
     11$APPversion = '1.4';
    1112$TIME_START = microtime(true);
    1213$ERRORS = array();
    1314$CONF = array();
    14 $PAGE_CONTENT = array(0=>null,1=>null,2=>null);
     15$LOG = array();
     16$PAGE = array(
     17        'section' => 'home',
     18        'header' => null,
     19        'content' => null,
     20        'msgs' => null,
     21        'end' => null,
     22);
    1523
    1624include('include/functions.php');
    17 $PAGE = (isset($_GET['page'])) ? $_GET['page'] : 'home';
     25if (isset($_GET['page'])) $PAGE['section'] = $_GET['page'];
    1826
    1927
     
    2129### CONFIGURATION ###
    2230if (!file_exists('config.xml')) {
    23         $ERRORS['fatal']['ErrorConfigFile'] = true;
     31        $ERRORS['fatal'][] = 'ErrorConfigFile';
    2432} else {
    2533        $CONF = load_config('config.xml');
     
    2735
    2836if (!file_exists('include/nconvert.exe')) {
    29         $ERRORS['fatal']['ErrorNconvert'] = true;
     37        $ERRORS['fatal'][] = 'ErrorNconvert';
     38}
     39
     40$CONF = array_merge($CONF, GetLanguage());
     41include('language/'.$CONF['user_lang'].'/common.lang.php');
     42
     43
     44
     45### PROCESSUS ###
     46switch ($PAGE['section']) {
     47        case 'home':
     48                if (!isset($ERRORS['fatal'])) {
     49                        if (!file_exists($CONF['DIRsource'])) {
     50                                mkdir($CONF['DIRsource']);
     51                        }
     52                        if (!file_exists($CONF['DIRsortie'])) {
     53                                mkdir($CONF['DIRsortie']);
     54                        }
     55                        if (is_dir_empty($CONF['DIRsource'])) {
     56                                $ERRORS['fatal'][] = 'ErrorFolderIn';
     57                        }
     58                        if ($CONF['silentORNOT'] == 'block' AND !is_dir_empty($CONF['DIRsortie'])) {
     59                                $ERRORS['fatal'][] = 'ErrorFolderOut';
     60                        } else if ($CONF['silentORNOT'] == 'erase' AND !is_dir_empty($CONF['DIRsortie'])) {
     61                                $ERRORS['notice'][] = 'EraseFolderOut';
     62                        }
     63                }
     64                break;
     65               
     66        case 'setup':
     67                if (isset($_POST['submit'])) {
     68                        include('include/save_config.php');
     69                }
     70                break;
     71       
     72        case 'process':
     73                include('include/main.php');
     74                break;
    3075}
    3176
    3277
    3378
    34 ### HEADER ###
    35 $CONF = array_merge($CONF, GetLanguage());
    36 include('language/'.$CONF['user_lang'].'/'.$CONF['user_lang'].'.php');
    37 include('include/header.php');
     79### AFFICHAGE ###
     80switch ($PAGE['section']) {
     81        case 'home':
     82                include('include/display_config.php');
     83               
     84                if (isset($ERRORS['fatal'])) {
     85                        $PAGE['end'] .= '
     86                        <div class="generic link">
     87                                <a class="input-submit" href="index.php">'.l10n('Reload').'</a>
     88                                <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
     89                        </div>';
    3890
     91                } else {
     92                        $PAGE['end'] .= '
     93                        <div class="generic finish">
     94                                <span id="ready-text">'.l10n('Ready').'</span>
     95                                <span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
     96                        </div>
     97                        <div class="generic link">
     98                                <a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
     99                                <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
     100                        </div>';
     101                }
     102                break;
     103               
     104        case 'setup':
     105                if (isset($ERRORS['fatal'])) {
     106                        $PAGE['end'] .= '
     107                        <div class="generic link">
     108                                <a class="input-submit" href="index.php">'.l10n('Back').'</a>
     109                                <a class="input-submit" href="index.php?page=setup">'.l10n('Reload').'</a>
     110                        </div>';
    39111
     112                } else {
     113                        include('include/setup.php');
     114                }
     115                break;
     116       
     117        case 'process':
     118                ### Affichage des fichiers traités et création du log ###
     119                $nb_files = count($FilesSource);
     120                $time = intval((microtime(true)-$TIME_START));
     121                $logfile = print_log($nb_files, $time);
     122               
     123                $PAGE['content'] .= '
     124                <div class="generic files">
     125                        <h2>'.l10n('Source files').'</h2>
     126                        <ul>';
     127                                foreach ($FilesSource as $value) {
     128                                        $PAGE['content'] .= '<li>'.$value.'</li>';
     129                                }
     130                        $PAGE['content'] .= '</ul>
     131                        <i>'.l10n('%d files', $nb_files).'</i><br>
     132                        <b>Log :</b> <a href="logs/'.$logfile.'">'.$logfile.'</a>
     133                </div>';
     134               
    40135
    41 ### PROCESSUS ###
    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['fatal']['ErrorFolderIn'] = true;
    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         }
    59        
    60 } else if ($PAGE == 'setup') {
    61         if (isset($_GET['ErrorConfig'])) {
    62                 $ERRORS['notice']['ErrorConfig'] = true;
    63         }
    64         if (isset($_POST['DIRsource'])) {
    65                 include('include/save_config.php');
    66         }
    67        
    68 } else if ($PAGE = 'process') {
    69         include('include/main.php');
     136                unset($FilesSource);
     137                unset($FilesSortie);
     138               
     139                $PAGE['end'] .= '
     140                <div class="generic finish">'.l10n('Finish %d seconds', $time).'</div>
     141                <div class="generic link">
     142                        <a class="input-submit" href="index.php">'.l10n('Back').'</a>
     143                        <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
     144                </div>';
     145                break;
    70146}
    71147
     
    73149
    74150### ERREURS ###
     151// erreurs fatales
    75152if (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>';
     153        $PAGE['msgs'] .= '<div class="generic error">';
     154                foreach ($ERRORS['fatal'] as $key) {
     155                        $PAGE['msgs'] .= '<div>'.l10n('fatal.'.$key).'</div>';
    79156                }
    80         $PAGE_CONTENT[1] .= '</div>';
     157        $PAGE['msgs'] .= '</div>';
    81158}
     159// informations
    82160if (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>';
     161        $PAGE['msgs'] .= '<div class="generic notice">';
     162                foreach ($ERRORS['notice'] as $key) {
     163                        $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key).'</div>';
    86164                }
    87         $PAGE_CONTENT[1] .= '</div>';
     165        $PAGE['msgs'] .= '</div>';
     166}
     167// erreurs de configuration
     168if (isset($ERRORS['conf'])) {
     169        $PAGE['msgs'] .= '<div class="generic notice conf">';
     170                foreach ($ERRORS['conf'] as $key) {
     171                        $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key[1].' %s', '<i>'.$key[0].'</i>').'</div>';
     172                }
     173        $PAGE['msgs'] .= '</div>';
    88174}
    89175
    90176
    91177
    92 ### AFFICHAGE ###
    93 if ($PAGE == 'home') {
    94         if (isset($ERRORS['fatal'])) {
    95                 $PAGE_CONTENT[2] .= '
    96                 <div class="generic link">
    97                         <a class="input-submit" href="index.php">'.l10n('Back').'</a>
    98                         <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
    99                 </div>';
    100 
    101         } else {
    102                 include('include/display_config.php');
    103                
    104                 $PAGE_CONTENT[2] .= '
    105                 <div class="generic finish">
    106                         <span id="ready-text">'.l10n('Ready').'</span>
    107                         <span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
    108                 </div>
    109                 <div class="generic link">
    110                         <a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
    111                         <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
    112                 </div>';
    113         }
    114        
    115 } else if ($PAGE == 'setup') {
    116         if (isset($ERRORS['fatal'])) {
    117                 $PAGE_CONTENT[2] .= '<div class="generic link"><a class="input-submit" href="index.php">'.l10n('Back').'</a></div>';
    118 
    119         } else {
    120                 include('include/setup.php');
    121         }
    122        
    123 } else if ($PAGE = 'process') {
    124         ### Affichage des fichiers traités ###
    125         $PAGE_CONTENT[0] .= '
    126         <div class="generic files">
    127                 <h2>'.l10n('Source files').'</h2>
    128                 <ul>';
    129                         foreach ($FilesSource as $value) {
    130                                 $PAGE_CONTENT[0] .= '<li>'.$value.'</li>';
    131                         }
    132                 $PAGE_CONTENT[0] .= '</ul>
    133                 <i>'.l10n('%d files', count($FilesSource)).'</i>
    134         </div>';
    135 
    136         unset($FilesSource);
    137         unset($FilesSortie);
    138        
    139         $PAGE_CONTENT[2] .= '
    140         <div class="generic finish">'.l10n('Finish %d seconds', intval((microtime(true)-$TIME_START))).'</div>
    141         <div class="generic link">
    142                 <a class="input-submit" href="index.php">'.l10n('Back').'</a>
    143                 <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
    144         </div>';
    145 }
    146 
    147 
    148178### FIN ###
    149 echo $PAGE_CONTENT[0];
    150 echo $PAGE_CONTENT[1];
    151 echo $PAGE_CONTENT[2];
     179include('include/header.php');
     180echo $PAGE['content'];
     181echo $PAGE['msgs'];
     182echo $PAGE['end'];
    152183
    153184echo '
Note: See TracChangeset for help on using the changeset viewer.