[7988] | 1 | <?php |
---|
| 2 | /***************************************\ |
---|
| 3 | | PHP OPTIMISATEUR | |
---|
[10337] | 4 | | Version 1.4 | |
---|
[7988] | 5 | \***************************************/ |
---|
| 6 | |
---|
[9201] | 7 | session_start(); |
---|
[8226] | 8 | set_time_limit(7200); |
---|
[10337] | 9 | define('ROOT_DIR', dirname(__FILE__).'\\'); |
---|
[9201] | 10 | |
---|
[10337] | 11 | $APPversion = '1.4'; |
---|
[7988] | 12 | $TIME_START = microtime(true); |
---|
[9201] | 13 | $ERRORS = array(); |
---|
| 14 | $CONF = array(); |
---|
[10337] | 15 | $LOG = array(); |
---|
| 16 | $PAGE = array( |
---|
| 17 | 'section' => 'home', |
---|
| 18 | 'header' => null, |
---|
| 19 | 'content' => null, |
---|
| 20 | 'msgs' => null, |
---|
| 21 | 'end' => null, |
---|
| 22 | ); |
---|
[7988] | 23 | |
---|
[9201] | 24 | include('include/functions.php'); |
---|
[10337] | 25 | if (isset($_GET['page'])) $PAGE['section'] = $_GET['page']; |
---|
[7988] | 26 | |
---|
| 27 | |
---|
[7991] | 28 | |
---|
[9201] | 29 | ### CONFIGURATION ### |
---|
[7991] | 30 | if (!file_exists('config.xml')) { |
---|
[10337] | 31 | $ERRORS['fatal'][] = 'ErrorConfigFile'; |
---|
[7993] | 32 | } else { |
---|
[9201] | 33 | $CONF = load_config('config.xml'); |
---|
| 34 | } |
---|
[7988] | 35 | |
---|
[9201] | 36 | if (!file_exists('include/nconvert.exe')) { |
---|
[10337] | 37 | $ERRORS['fatal'][] = 'ErrorNconvert'; |
---|
[7991] | 38 | } |
---|
| 39 | |
---|
[9201] | 40 | $CONF = array_merge($CONF, GetLanguage()); |
---|
[10337] | 41 | include('language/'.$CONF['user_lang'].'/common.lang.php'); |
---|
[7988] | 42 | |
---|
| 43 | |
---|
[7991] | 44 | |
---|
[9276] | 45 | ### PROCESSUS ### |
---|
[10337] | 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 | } |
---|
[7988] | 63 | } |
---|
[10337] | 64 | break; |
---|
| 65 | |
---|
| 66 | case 'setup': |
---|
| 67 | if (isset($_POST['submit'])) { |
---|
| 68 | include('include/save_config.php'); |
---|
[9201] | 69 | } |
---|
[10337] | 70 | break; |
---|
[7994] | 71 | |
---|
[10337] | 72 | case 'process': |
---|
| 73 | include('include/main.php'); |
---|
| 74 | break; |
---|
[9201] | 75 | } |
---|
[7988] | 76 | |
---|
| 77 | |
---|
[9201] | 78 | |
---|
[10337] | 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>'; |
---|
| 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>'; |
---|
[7991] | 101 | } |
---|
[10337] | 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>'; |
---|
| 111 | |
---|
| 112 | } else { |
---|
| 113 | include('include/setup.php'); |
---|
[9201] | 114 | } |
---|
[10337] | 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> |
---|
[9276] | 133 | </div>'; |
---|
[10337] | 134 | |
---|
[9201] | 135 | |
---|
[10337] | 136 | unset($FilesSource); |
---|
| 137 | unset($FilesSortie); |
---|
[8195] | 138 | |
---|
[10337] | 139 | $PAGE['end'] .= ' |
---|
| 140 | <div class="generic finish">'.l10n('Finish %d seconds', $time).'</div> |
---|
[9201] | 141 | <div class="generic link"> |
---|
[10337] | 142 | <a class="input-submit" href="index.php">'.l10n('Back').'</a> |
---|
[9201] | 143 | <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a> |
---|
| 144 | </div>'; |
---|
[10337] | 145 | break; |
---|
| 146 | } |
---|
[7988] | 147 | |
---|
| 148 | |
---|
[10337] | 149 | |
---|
| 150 | ### ERREURS ### |
---|
| 151 | // erreurs fatales |
---|
| 152 | if (isset($ERRORS['fatal'])) { |
---|
| 153 | $PAGE['msgs'] .= '<div class="generic error">'; |
---|
| 154 | foreach ($ERRORS['fatal'] as $key) { |
---|
| 155 | $PAGE['msgs'] .= '<div>'.l10n('fatal.'.$key).'</div>'; |
---|
| 156 | } |
---|
| 157 | $PAGE['msgs'] .= '</div>'; |
---|
[7988] | 158 | } |
---|
[10337] | 159 | // informations |
---|
| 160 | if (isset($ERRORS['notice'])) { |
---|
| 161 | $PAGE['msgs'] .= '<div class="generic notice">'; |
---|
| 162 | foreach ($ERRORS['notice'] as $key) { |
---|
| 163 | $PAGE['msgs'] .= '<div>'.l10n('notice.'.$key).'</div>'; |
---|
| 164 | } |
---|
| 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>'; |
---|
| 174 | } |
---|
[7988] | 175 | |
---|
[8195] | 176 | |
---|
[10337] | 177 | |
---|
[9201] | 178 | ### FIN ### |
---|
[10337] | 179 | include('include/header.php'); |
---|
| 180 | echo $PAGE['content']; |
---|
| 181 | echo $PAGE['msgs']; |
---|
| 182 | echo $PAGE['end']; |
---|
[8195] | 183 | |
---|
[9276] | 184 | echo ' |
---|
| 185 | <div class="generic footer"> |
---|
[9202] | 186 | 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> |
---|
[8195] | 187 | </div> |
---|
| 188 | |
---|
| 189 | </body> |
---|
[7988] | 190 | </html>'; |
---|
| 191 | ?> |
---|