source: extensions/PHP_Optimisateur/index.php @ 9251

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

[[tools] PHP Optimisateur :

  • Suppression de la doc locale, voir le wiki
File size: 4.2 KB
Line 
1<?php
2/***************************************\
3|                       PHP OPTIMISATEUR                        |
4|                          Version 1.3                          |
5\***************************************/
6
7session_start();
8set_time_limit(7200);
9
10$APPversion = '1.3';
11$TIME_START = microtime(true);
12$ERRORS = array();
13$CONF = array();
14$PAGE_CONTENT = array(0=>null,1=>null,2=>null);
15
16include('include/functions.php');
17$PAGE = (isset($_GET['page'])) ? $_GET['page'] : 'home';
18
19
20
21### CONFIGURATION ###
22if (!file_exists('config.xml')) {
23        $ERRORS['fatal']['ErrorConfigFile'] = true;
24} else {
25        $CONF = load_config('config.xml');
26}
27
28if (!file_exists('include/nconvert.exe')) {
29        $ERRORS['fatal']['ErrorNconvert'] = true;
30}
31
32
33
34### HEADER ###
35$CONF = array_merge($CONF, GetLanguage());
36include('language/'.$CONF['user_lang'].'/'.$CONF['user_lang'].'.php');
37include('include/header.php');
38
39
40
41### VERIFICATIONS ###
42if ($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['ErrorFolderIn'] = 'fatal';
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');
70}
71
72
73
74### ERREURS ###
75if (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>';
79                }
80        $PAGE_CONTENT[1] .= '</div>';
81}
82if (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>';
86                }
87        $PAGE_CONTENT[1] .= '</div>';
88}
89
90
91
92### AFFICHAGE ###
93if ($PAGE == 'home') {
94        if (isset($ERRORS['fatal'])) {
95                $PAGE_CONTENT[2] .= '<div class="generic link"><a class="input-submit" href="index.php">'.l10n('Back').'</a> <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a></div>';
96
97        } else {
98                include('include/display_config.php');
99               
100                $PAGE_CONTENT[2] .= '<div class="generic finish">
101                        <span id="ready-text">'.l10n('Ready').'</span>
102                        <span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
103                </div>
104                <div class="generic link">
105                        <a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
106                        <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
107                </div>';
108        }
109       
110} else if ($PAGE == 'setup') {
111        if (isset($ERRORS['fatal'])) {
112                $PAGE_CONTENT[2] .= '<div class="generic link"><a class="input-submit" href="index.php">'.l10n('Back').'</a></div>';
113
114        } else {
115                include('include/setup.php');
116        }
117       
118} else if ($PAGE = 'process') {
119        ### Affichage des fichiers traités ###
120        $PAGE_CONTENT[0] .= '<div class="generic files">
121                <h2>'.l10n('Source files').'</h2>
122                <ul>';
123                        foreach ($FilesSource as $value) {
124                                $PAGE_CONTENT[0] .= '<li>'.$value.'</li>';
125                        }
126                $PAGE_CONTENT[0] .= '</ul>
127                <i>'.l10n('%d files', count($FilesSource)).'</i>
128        </div>';
129
130        unset($FilesSource);
131        unset($FilesSortie);
132       
133        $PAGE_CONTENT[2] .= '<div class="generic finish">'.l10n('Finish %d seconds', intval((microtime(true)-$TIME_START))).'</div>
134        <div class="generic link">
135                <a class="input-submit" href="index.php">'.l10n('Back').'</a>
136                <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
137        </div>';
138}
139
140
141### FIN ###
142echo $PAGE_CONTENT[0];
143echo $PAGE_CONTENT[1];
144echo $PAGE_CONTENT[2];
145
146echo '<div class="generic footer">
147        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>
148</div>
149
150</body>
151</html>';
152?>
Note: See TracBrowser for help on using the repository browser.