1 | <?php |
---|
2 | /***************************************\ |
---|
3 | | PHP OPTIMISATEUR | |
---|
4 | | Version 1.1 | |
---|
5 | \***************************************/ |
---|
6 | |
---|
7 | include('files/functions.php'); |
---|
8 | |
---|
9 | ### Création de nouveau fichier de configuration ### |
---|
10 | if (isset($_POST['DIRsource'])) { |
---|
11 | // Quelques traitements avant d'enregistrer |
---|
12 | $_POST['copyCOLOR'] = implode(' ', $_POST['copyCOLOR']); |
---|
13 | $_POST['copyPOS'] = implode('-', $_POST['copyPOS']); |
---|
14 | if(!isset($_POST['PluginsBefore'])) $_POST['PluginsBefore'] = null; |
---|
15 | if(!isset($_POST['PluginsProcess'])) $_POST['PluginsProcess'] = null; |
---|
16 | if(!isset($_POST['PluginsAfter'])) $_POST['PluginsAfter'] = null; |
---|
17 | if (!preg_match('#(.*)/$#', $_POST['DIRsource'])) $_POST['DIRsource'] .= '/'; |
---|
18 | if (!preg_match('#(.*)/$#', $_POST['DIRsortie'])) $_POST['DIRsortie'] .= '/'; |
---|
19 | |
---|
20 | // Contenu du fichier |
---|
21 | $content = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n".'<config>'."\r\n"; |
---|
22 | $content .= XMLcreate($_POST, 0); |
---|
23 | $content .= '</config>'; |
---|
24 | file_put_contents('config.xml', $content); |
---|
25 | |
---|
26 | header('Location:index.php'); |
---|
27 | } |
---|
28 | |
---|
29 | |
---|
30 | include('files/header.php'); |
---|
31 | |
---|
32 | // Fichier de configuration |
---|
33 | if (!file_exists('config.xml')) { |
---|
34 | $Errors['ErrorFile'] = true; |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | |
---|
39 | ### ERREURS ### |
---|
40 | if (isset($Errors)) { |
---|
41 | $i=0; |
---|
42 | foreach ($Errors as $key => $null) { |
---|
43 | // Dégueulasse les ternaires à la suite ! mais j'aime ça |
---|
44 | echo '<div class="error">'.l10n($key).' '.(($i==0)?'<a href="setup.php">'.l10n('Back').'</a></div>':'</div>'); |
---|
45 | $i++; |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | ### EXECUTION ### |
---|
52 | if (!isset($Errors)) { |
---|
53 | // Configuration |
---|
54 | extract(load_config()); |
---|
55 | |
---|
56 | $copyCOLOR = explode(' ', $copyCOLOR); |
---|
57 | $copyPOS = explode('-', $copyPOS); |
---|
58 | |
---|
59 | |
---|
60 | ### Gestion des nouveaux plugins ### |
---|
61 | // Ajoute la configuration des plugins non-installés aux tableaux, il faut valider le formulaire pour les installer |
---|
62 | $Plugins = glob('plugins/*.xml'); |
---|
63 | $NewPlugins = array(); |
---|
64 | |
---|
65 | foreach ($Plugins as $plugin) { |
---|
66 | // nom du plugin |
---|
67 | preg_match('#plugins/(.*).xml#', $plugin, $matches); |
---|
68 | $plugin_name = $matches[1]; |
---|
69 | // configuration du plugin |
---|
70 | $plugin = XMLparse(simplexml_load_file($plugin)); |
---|
71 | // mode du plugin (effacage pour pas l'inscrire dans la config) |
---|
72 | $plugin_mode = $plugin['mode']; |
---|
73 | unset($plugin['mode']); |
---|
74 | |
---|
75 | if (!array_key_exists($plugin_name, ${$plugin_mode})) { |
---|
76 | ${$plugin_mode}[$plugin_name] = $plugin; |
---|
77 | $NewPlugins[$plugin_name] = true; |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | ### Formulaire ### |
---|
83 | echo ' |
---|
84 | <script type="text/javascript"> |
---|
85 | function suivant(enCours, suivant, limite) { |
---|
86 | if (enCours.value.length == limite) { |
---|
87 | enCours.form.elements[suivant].select(); |
---|
88 | } |
---|
89 | } |
---|
90 | </script> |
---|
91 | |
---|
92 | <form action="setup.php" method="post"> |
---|
93 | <div class="config"> |
---|
94 | <h2>'.l10n('Configuration').'</h2> |
---|
95 | <ul> |
---|
96 | <li> |
---|
97 | <span class="title">'.l10n('Folders').'</span> |
---|
98 | <table> |
---|
99 | <tr> |
---|
100 | <td><b>'.l10n('FolderIn').' :</b></td> |
---|
101 | <td><input type="text" name="DIRsource" value="'.$DIRsource.'"/></td> |
---|
102 | </tr> |
---|
103 | <tr> |
---|
104 | <td><b>'.l10n('FolderOut').' :</b></td> |
---|
105 | <td><input type="text" name="DIRsortie" value="'.$DIRsortie.'"/></td> |
---|
106 | </tr> |
---|
107 | </table> |
---|
108 | </li> |
---|
109 | <li> |
---|
110 | <span class="title">'.l10n('Options').'</span> |
---|
111 | <table> |
---|
112 | <tr> |
---|
113 | <td><b>'.l10n('silentORNOT').' :</b></td> |
---|
114 | <td><input type="radio" name="silentORNOT" value="true" '.(($silentORNOT)?'checked':'').'/> '.l10n('yes').' <input type="radio" name="silentORNOT" value="false" '.((!$silentORNOT)?'checked':'').'/> '.l10n('no').'</td> |
---|
115 | </tr> |
---|
116 | <tr> |
---|
117 | <td><b>'.l10n('DIRhighORNOT').' :</b></td> |
---|
118 | <td><input type="radio" name="DIRhighORNOT" value="true" '.(($DIRhighORNOT)?'checked':'').'/> '.l10n('yes').' <input type="radio" name="DIRhighORNOT" value="false" '.((!$DIRhighORNOT)?'checked':'').'/> '.l10n('no').'</td> |
---|
119 | </tr> |
---|
120 | <tr> |
---|
121 | <td><b>'.l10n('DIMhdORNOT').' :</b></td> |
---|
122 | <td><input type="radio" name="DIMhdORNOT" value="true" '.(($DIMhdORNOT)?'checked':'').'/> '.l10n('yes').' <input type="radio" name="DIMhdORNOT" value="false" '.((!$DIMhdORNOT)?'checked':'').'/> '.l10n('no').'</td> |
---|
123 | </tr> |
---|
124 | <tr> |
---|
125 | <td><b>'.l10n('renameORNOT').' :</b></td> |
---|
126 | <td><input type="radio" name="renameORNOT" value="true" '.(($renameORNOT)?'checked':'').'/> '.l10n('yes').' <input type="radio" name="renameORNOT" value="false" '.((!$renameORNOT)?'checked':'').'/> '.l10n('no').'</td> |
---|
127 | </tr> |
---|
128 | <tr> |
---|
129 | <td><b>'.l10n('indexORNOT').' :</b></td> |
---|
130 | <td><input type="radio" name="indexORNOT" value="true" '.(($indexORNOT)?'checked':'').'/> '.l10n('yes').' <input type="radio" name="indexORNOT" value="false" '.((!$indexORNOT)?'checked':'').'/> '.l10n('no').'</td> |
---|
131 | </tr> |
---|
132 | <tr> |
---|
133 | <td><b>'.l10n('prefixe_mini').' :</b></td> |
---|
134 | <td><input type="text" name="prefixe_mini" value="'.$prefixe_mini.'" size="8"/></td> |
---|
135 | </tr> |
---|
136 | </table> |
---|
137 | </li> |
---|
138 | <li> |
---|
139 | <span class="title">'.l10n('Sizes and quality').'</span> |
---|
140 | <table> |
---|
141 | <tr> |
---|
142 | <td><b>'.l10n('DIMhd').' :</b></td> |
---|
143 | <td><input type="text" name="DIMhd" value="'.$DIMhd.'" size="4"/></td> |
---|
144 | </tr> |
---|
145 | <tr> |
---|
146 | <td><b>'.l10n('DIMnormal').' :</b></td> |
---|
147 | <td><input type="text" name="DIMnormal" value="'.$DIMnormal.'" size="3"/></td> |
---|
148 | </tr> |
---|
149 | <tr> |
---|
150 | <td><b>'.l10n('DIMthumbnail').' :</b></td> |
---|
151 | <td><input type="text" name="DIMthumbnail" value="'.$DIMthumbnail.'" size="3"/></td> |
---|
152 | </tr> |
---|
153 | <tr> |
---|
154 | <td><b>'.l10n('Qhd').' :</b></td> |
---|
155 | <td><input type="text" name="Qhd" value="'.$Qhd.'" size="3"/></td> |
---|
156 | </tr> |
---|
157 | <tr> |
---|
158 | <td><b>'.l10n('Qnormal').' :</b></td> |
---|
159 | <td><input type="text" name="Qnormal" value="'.$Qnormal.'" size="3"/></td> |
---|
160 | </tr> |
---|
161 | <tr> |
---|
162 | <td><b>'.l10n('Qthumbnail').' :</b></td> |
---|
163 | <td><input type="text" name="Qthumbnail" value="'.$Qthumbnail.'" size="3"/></td> |
---|
164 | </tr> |
---|
165 | <tr> |
---|
166 | <td><b>'.l10n('DPI').' :</b></td> |
---|
167 | <td><input type="text" name="DPI" value="'.$DPI.'" size="3"/></td> |
---|
168 | </tr> |
---|
169 | </table> |
---|
170 | </li> |
---|
171 | <li> |
---|
172 | <span class="title">'.l10n('Copyright').'</span> |
---|
173 | <table> |
---|
174 | <tr> |
---|
175 | <td><b>'.l10n('Content').' :</b></td> |
---|
176 | <td><input type="text" name="copyright" value="'.$copyright.'"/></td> |
---|
177 | </tr> |
---|
178 | <tr> |
---|
179 | <td><b>'.l10n('copyONhd').' :</b></td> |
---|
180 | <td><input type="radio" name="copyONhd" value="true" '.(($copyONhd)?'checked':'').'/> '.l10n('yes').' <input type="radio" name="copyONhd" value="false" '.((!$copyONhd)?'checked':'').'/> '.l10n('no').'</td> |
---|
181 | </tr> |
---|
182 | <tr> |
---|
183 | <td><b>'.l10n('copyONnormal').' :</b></td> |
---|
184 | <td><input type="radio" name="copyONnormal" value="true" '.(($copyONnormal)?'checked':'').'/> '.l10n('yes').' <input type="radio" name="copyONnormal" value="false" '.((!$copyONnormal)?'checked':'').'/> '.l10n('no').'</td> |
---|
185 | </tr> |
---|
186 | <tr> |
---|
187 | <td><b>'.l10n('copyPOS%s', l10n('copyPOSv')).' :</b></td> |
---|
188 | <td><input type="radio" name="copyPOS[0]" value="top" '.(($copyPOS[0]=='top')?'checked':'').'/> '.l10n('top').' <input type="radio" name="copyPOS[0]" value="center" '.(($copyPOS[0]=='center')?'checked':'').'/> '.l10n('center').' <input type="radio" name="copyPOS[0]" value="bottom" '.(($copyPOS[0]=='bottom')?'checked':'').'/> '.l10n('bottom').'</td> |
---|
189 | </tr> |
---|
190 | <tr> |
---|
191 | <td><b>'.l10n('copyPOS%s', l10n('copyPOSh')).' :</b></td> |
---|
192 | <td><input type="radio" name="copyPOS[1]" value="left" '.(($copyPOS[1]=='left')?'checked':'').'/> '.l10n('left').' <input type="radio" name="copyPOS[1]" value="center" '.(($copyPOS[1]=='center')?'checked':'').'/> '.l10n('center').' <input type="radio" name="copyPOS[1]" value="right" '.(($copyPOS[1]=='right')?'checked':'').'/> '.l10n('right').'</td> |
---|
193 | </tr> |
---|
194 | <tr> |
---|
195 | <td><b>'.l10n('copySIZE').' :</b></td> |
---|
196 | <td><input type="text" name="copySIZE" value="'.$copySIZE.'" size="5"/></td> |
---|
197 | </tr> |
---|
198 | <tr> |
---|
199 | <td><b>'.l10n('copyCOLOR').' :</b></td> |
---|
200 | <td> |
---|
201 | <input type="text" name="copyCOLOR[0]" value="'.$copyCOLOR[0].'" size="3" onFocus="this.select();" onKeyUp="suivant(this,\'copyCOLOR[1]\', 3)"/> |
---|
202 | <input type="text" name="copyCOLOR[1]" value="'.$copyCOLOR[1].'" size="3" onFocus="this.select();" onKeyUp="suivant(this,\'copyCOLOR[2]\', 3)"/> |
---|
203 | <input type="text" name="copyCOLOR[2]" value="'.$copyCOLOR[2].'" size="3" onFocus="this.select();" /> |
---|
204 | </td> |
---|
205 | </tr> |
---|
206 | <tr> |
---|
207 | <td><b>'.l10n('copyFONT').' :</b></td> |
---|
208 | <td><input type="text" name="copyFONT" value="'.$copyFONT.'"/></td> |
---|
209 | </tr> |
---|
210 | </table> |
---|
211 | </li> |
---|
212 | </ul> |
---|
213 | </div> |
---|
214 | |
---|
215 | <div class="config"> |
---|
216 | <h2>'.l10n('Plugins').'</h2> |
---|
217 | <ul> |
---|
218 | <li> |
---|
219 | <span class="title">'.l10n('PluginsBefore').'</span> |
---|
220 | <ul>'; |
---|
221 | foreach ($PluginsBefore as $name => $config) { |
---|
222 | echo '<li> |
---|
223 | <b class="'.((isset($NewPlugins[$name]))?'new':'').'">'.$name.' :</b> |
---|
224 | <table>'; |
---|
225 | foreach ($config as $key => $value) { |
---|
226 | echo '<tr> |
---|
227 | <td>'.$key.' :</td> |
---|
228 | <td><input type="text" name="PluginsBefore['.$name.']['.$key.']" value="'.bool_to_string($value,1).'" size="7"/></td> |
---|
229 | </tr>'; |
---|
230 | } |
---|
231 | echo '</table> |
---|
232 | </li>'; |
---|
233 | } |
---|
234 | echo '</ul> |
---|
235 | </li> |
---|
236 | <li> |
---|
237 | <span class="title">'.l10n('PluginsProcess').'</span> |
---|
238 | <ul>'; |
---|
239 | foreach ($PluginsProcess as $name => $config) { |
---|
240 | echo '<li> |
---|
241 | <b class="'.((isset($NewPlugins[$name]))?'new':'').'">'.$name.' :</b> |
---|
242 | <table>'; |
---|
243 | foreach ($config as $key => $value) { |
---|
244 | echo '<tr> |
---|
245 | <td>'.$key.' :</td> |
---|
246 | <td><input type="text" name="PluginsProcess['.$name.']['.$key.']" value="'.bool_to_string($value,1).'" size="7"/></td> |
---|
247 | </tr>'; |
---|
248 | } |
---|
249 | echo '</table> |
---|
250 | </li>'; |
---|
251 | } |
---|
252 | echo '</ul> |
---|
253 | </li> |
---|
254 | <li> |
---|
255 | <span class="title">'.l10n('PluginsAfter').'</span> |
---|
256 | <ul>'; |
---|
257 | foreach ($PluginsAfter as $name => $config) { |
---|
258 | echo '<li> |
---|
259 | <b class="'.((isset($NewPlugins[$name]))?'new':'').'">'.$name.' :</b> |
---|
260 | <table>'; |
---|
261 | foreach ($config as $key => $value) { |
---|
262 | echo '<tr> |
---|
263 | <td>'.$key.' :</td> |
---|
264 | <td><input type="text" name="PluginsAfter['.$name.']['.$key.']" value="'.bool_to_string($value,1).'" size="7"/></td> |
---|
265 | </tr>'; |
---|
266 | } |
---|
267 | echo '</table> |
---|
268 | </li>'; |
---|
269 | } |
---|
270 | echo '</ul> |
---|
271 | </li> |
---|
272 | </ul> |
---|
273 | </div> |
---|
274 | |
---|
275 | <div class="finish"> |
---|
276 | <input type="submit"/> <input type="reset"/> <a href="index.php">'.l10n('Back').'</a> |
---|
277 | </div> |
---|
278 | </form>'; |
---|
279 | } |
---|
280 | |
---|
281 | echo '</body> |
---|
282 | </html>'; |
---|
283 | ?> |
---|