source: extensions/PHP_Optimisateur/index.php @ 10337

Last change on this file since 10337 was 10337, checked in by mistic100, 13 years ago

new version 1.4, new plugin for Charlies Content, NConvert updated

File size: 4.9 KB
Line 
1<?php
2/***************************************\
3|                       PHP OPTIMISATEUR                        |
4|                         Version 1.4                           |
5\***************************************/
6
7session_start();
8set_time_limit(7200);
9define('ROOT_DIR', dirname(__FILE__).'\\');
10
11$APPversion = '1.4';
12$TIME_START = microtime(true);
13$ERRORS = array();
14$CONF = array();
15$LOG = array();
16$PAGE = array(
17        'section' => 'home',
18        'header' => null,
19        'content' => null,
20        'msgs' => null,
21        'end' => null,
22);
23
24include('include/functions.php');
25if (isset($_GET['page'])) $PAGE['section'] = $_GET['page'];
26
27
28
29### CONFIGURATION ###
30if (!file_exists('config.xml')) {
31        $ERRORS['fatal'][] = 'ErrorConfigFile';
32} else {
33        $CONF = load_config('config.xml');
34}
35
36if (!file_exists('include/nconvert.exe')) {
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;
75}
76
77
78
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>';
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>';
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               
135
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;
146}
147
148
149
150### ERREURS ###
151// erreurs fatales
152if (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>';
158}
159// informations
160if (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
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>';
174}
175
176
177
178### FIN ###
179include('include/header.php');
180echo $PAGE['content'];
181echo $PAGE['msgs'];
182echo $PAGE['end'];
183
184echo '
185<div class="generic footer">
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>
187</div>
188
189</body>
190</html>';
191?>
Note: See TracBrowser for help on using the repository browser.