Changeset 10337 for extensions/PHP_Optimisateur/index.php
- Timestamp:
- Apr 12, 2011, 7:45:22 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/PHP_Optimisateur/index.php
r9515 r10337 2 2 /***************************************\ 3 3 | PHP OPTIMISATEUR | 4 | Version 1. 3.3|4 | Version 1.4 | 5 5 \***************************************/ 6 6 7 7 session_start(); 8 8 set_time_limit(7200); 9 define('ROOT_DIR', dirname(__FILE__).'\\'); 9 10 10 $APPversion = '1. 3';11 $APPversion = '1.4'; 11 12 $TIME_START = microtime(true); 12 13 $ERRORS = array(); 13 14 $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 ); 15 23 16 24 include('include/functions.php'); 17 $PAGE = (isset($_GET['page'])) ? $_GET['page'] : 'home';25 if (isset($_GET['page'])) $PAGE['section'] = $_GET['page']; 18 26 19 27 … … 21 29 ### CONFIGURATION ### 22 30 if (!file_exists('config.xml')) { 23 $ERRORS['fatal'][ 'ErrorConfigFile'] = true;31 $ERRORS['fatal'][] = 'ErrorConfigFile'; 24 32 } else { 25 33 $CONF = load_config('config.xml'); … … 27 35 28 36 if (!file_exists('include/nconvert.exe')) { 29 $ERRORS['fatal']['ErrorNconvert'] = true; 37 $ERRORS['fatal'][] = 'ErrorNconvert'; 38 } 39 40 $CONF = array_merge($CONF, GetLanguage()); 41 include('language/'.$CONF['user_lang'].'/common.lang.php'); 42 43 44 45 ### PROCESSUS ### 46 switch ($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; 30 75 } 31 76 32 77 33 78 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 ### 80 switch ($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>'; 38 90 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>'; 39 111 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 40 135 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; 70 146 } 71 147 … … 73 149 74 150 ### ERREURS ### 151 // erreurs fatales 75 152 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>';153 $PAGE['msgs'] .= '<div class="generic error">'; 154 foreach ($ERRORS['fatal'] as $key) { 155 $PAGE['msgs'] .= '<div>'.l10n('fatal.'.$key).'</div>'; 79 156 } 80 $PAGE _CONTENT[1] .= '</div>';157 $PAGE['msgs'] .= '</div>'; 81 158 } 159 // informations 82 160 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>';161 $PAGE['msgs'] .= '<div class="generic notice">'; 162 foreach ($ERRORS['notice'] as $key) { 163 $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key).'</div>'; 86 164 } 87 $PAGE_CONTENT[1] .= '</div>'; 165 $PAGE['msgs'] .= '</div>'; 166 } 167 // erreurs de configuration 168 if (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>'; 88 174 } 89 175 90 176 91 177 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 148 178 ### FIN ### 149 echo $PAGE_CONTENT[0]; 150 echo $PAGE_CONTENT[1]; 151 echo $PAGE_CONTENT[2]; 179 include('include/header.php'); 180 echo $PAGE['content']; 181 echo $PAGE['msgs']; 182 echo $PAGE['end']; 152 183 153 184 echo '
Note: See TracChangeset
for help on using the changeset viewer.