source: extensions/PHP_Optimisateur/index.php @ 13741

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

fix detection regex and watermark position

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