source: extensions/PHP_Optimisateur/index.php @ 12819

Last change on this file since 12819 was 12819, checked in by mistic100, 12 years ago

fix detection regex and watermark position

File size: 5.1 KB
RevLine 
[7988]1<?php
2/***************************************\
[12819]3|            PHP OPTIMISATEUR           |
4|              Version 1.4              |
[7988]5\***************************************/
6
[9201]7session_start();
[8226]8set_time_limit(7200);
[9201]9
[10337]10$APPversion = '1.4';
[7988]11$TIME_START = microtime(true);
[9201]12$ERRORS = array();
13$CONF = array();
[10337]14$LOG = array();
15$PAGE = array(
[12819]16  'section' => 'home',
17  'header' => null,
18  'content' => null,
19  'msgs' => null,
20  'end' => null,
[10337]21);
[7988]22
[9201]23include('include/functions.php');
[10337]24if (isset($_GET['page'])) $PAGE['section'] = $_GET['page'];
[7988]25
26
[7991]27
[9201]28### CONFIGURATION ###
[7991]29if (!file_exists('config.xml')) {
[12819]30  $ERRORS['fatal'][] = 'ErrorConfigFile';
[7993]31} else {
[12819]32  $CONF = load_config('config.xml');
[9201]33}
[7988]34
[9201]35if (!file_exists('include/nconvert.exe')) {
[12819]36  $ERRORS['fatal'][] = 'ErrorNconvert';
[7991]37}
38
[9201]39$CONF = array_merge($CONF, GetLanguage());
[10337]40include('language/'.$CONF['user_lang'].'/common.lang.php');
[7988]41
42
[7991]43
[9276]44### PROCESSUS ###
[10337]45switch ($PAGE['section']) {
[12819]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;
[9201]74}
[7988]75
76
[9201]77
[10337]78### AFFICHAGE ###
79switch ($PAGE['section']) {
[12819]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>';
[10337]89
[12819]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>';
[10337]110
[12819]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   
[9201]134
[12819]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;
[10337]145}
[7988]146
147
[10337]148
149### ERREURS ###
150// erreurs fatales
151if (isset($ERRORS['fatal'])) {
[12819]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>';
[7988]157}
[10337]158// informations
159if (isset($ERRORS['notice'])) {
[12819]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>';
[10337]165}
166// erreurs de configuration
167if (isset($ERRORS['conf'])) {
[12819]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>';
[10337]173}
[7988]174
[8195]175
[10337]176
[9201]177### FIN ###
[10337]178include('include/header.php');
179echo $PAGE['content'];
180echo $PAGE['msgs'];
181echo $PAGE['end'];
[8195]182
[9276]183echo '
184<div class="generic footer">
[12819]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>
[8195]186</div>
187
188</body>
[7988]189</html>';
190?>
Note: See TracBrowser for help on using the repository browser.