source: extensions/PHP_Optimisateur/index.php @ 9515

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

[tools] PHP Optimisateur :

  • add es_ES thanks to jpr928
  • correct an error in messages
File size: 4.2 KB
Line 
1<?php
2/***************************************\
3|                       PHP OPTIMISATEUR                        |
4|                         Version 1.3.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### PROCESSUS ###
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['fatal']['ErrorFolderIn'] = true;
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] .= '
96                <div class="generic link">
97                        <a class="input-submit" href="index.php">'.l10n('Back').'</a>
98                        <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
99                </div>';
100
101        } else {
102                include('include/display_config.php');
103               
104                $PAGE_CONTENT[2] .= '
105                <div class="generic finish">
106                        <span id="ready-text">'.l10n('Ready').'</span>
107                        <span id="loader"><img src="template/favicon.png" alt="PHP OPT"/></span>
108                </div>
109                <div class="generic link">
110                        <a class="input-submit" href="index.php?page=process" onclick="Load();">'.l10n('Launch').'</a>
111                        <a class="input-submit" href="index.php?page=setup">'.l10n('Config').'</a>
112                </div>';
113        }
114       
115} else if ($PAGE == 'setup') {
116        if (isset($ERRORS['fatal'])) {
117                $PAGE_CONTENT[2] .= '<div class="generic link"><a class="input-submit" href="index.php">'.l10n('Back').'</a></div>';
118
119        } else {
120                include('include/setup.php');
121        }
122       
123} else if ($PAGE = 'process') {
124        ### Affichage des fichiers traités ###
125        $PAGE_CONTENT[0] .= '
126        <div class="generic files">
127                <h2>'.l10n('Source files').'</h2>
128                <ul>';
129                        foreach ($FilesSource as $value) {
130                                $PAGE_CONTENT[0] .= '<li>'.$value.'</li>';
131                        }
132                $PAGE_CONTENT[0] .= '</ul>
133                <i>'.l10n('%d files', count($FilesSource)).'</i>
134        </div>';
135
136        unset($FilesSource);
137        unset($FilesSortie);
138       
139        $PAGE_CONTENT[2] .= '
140        <div class="generic finish">'.l10n('Finish %d seconds', intval((microtime(true)-$TIME_START))).'</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}
146
147
148### FIN ###
149echo $PAGE_CONTENT[0];
150echo $PAGE_CONTENT[1];
151echo $PAGE_CONTENT[2];
152
153echo '
154<div class="generic footer">
155        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>
156</div>
157
158</body>
159</html>';
160?>
Note: See TracBrowser for help on using the repository browser.