1 | <?php |
---|
2 | /***************************************\ |
---|
3 | | PHP OPTIMISATEUR | |
---|
4 | | Version 1.2 | |
---|
5 | \***************************************/ |
---|
6 | |
---|
7 | include('files/functions.php'); |
---|
8 | |
---|
9 | |
---|
10 | ### NOUVELLE CONFIGURATION ### |
---|
11 | if (isset($_POST['DIRsource'])) { |
---|
12 | // Quelques traitements |
---|
13 | $_POST['copyPOS'] = implode('-', $_POST['copyPOS']); |
---|
14 | if (!preg_match('#^\#(.*)#', $_POST['copyCOLOR'])) $_POST['copyCOLOR'] = '#'.$_POST['copyCOLOR']; |
---|
15 | |
---|
16 | // Plugins : ensembles existants même si vides & supprime les plugins manquants |
---|
17 | foreach (array('PluginsBefore','PluginsProcess','PluginsAfter') as $mode) { |
---|
18 | if (!isset($_POST[$mode])) { |
---|
19 | $_POST[$mode] = null; |
---|
20 | } else { |
---|
21 | foreach ($_POST[$mode] as $name => $config) { |
---|
22 | if (isset($config['delete'])) unset($_POST[$mode][$name]); |
---|
23 | } |
---|
24 | } |
---|
25 | } |
---|
26 | |
---|
27 | // Ajoute les / en fin d'URI |
---|
28 | if (!preg_match('#(.*)/$#', $_POST['DIRsource'])) $_POST['DIRsource'] .= '/'; |
---|
29 | if (!preg_match('#(.*)/$#', $_POST['DIRsortie'])) $_POST['DIRsortie'] .= '/'; |
---|
30 | |
---|
31 | // Contenu du fichier |
---|
32 | $content = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n".'<config>'."\r\n"; |
---|
33 | $content .= XMLcreate($_POST, 0); |
---|
34 | $content .= '</config>'; |
---|
35 | file_put_contents('config.xml', $content); |
---|
36 | |
---|
37 | header('Location:index.php'); |
---|
38 | } |
---|
39 | |
---|
40 | |
---|
41 | include('files/header.php'); |
---|
42 | |
---|
43 | |
---|
44 | ### CONFIGURATION ### |
---|
45 | if (!file_exists('config.xml')) { |
---|
46 | $Errors['ErrorFile'] = true; |
---|
47 | } else { |
---|
48 | extract(load_config()); |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | ### ERREURS ### |
---|
54 | if (isset($Errors)) { |
---|
55 | foreach ($Errors as $key => $null) { |
---|
56 | echo '<div class="error">'.l10n($key).'</div>'; |
---|
57 | } |
---|
58 | echo '<div class="link"><a href="index.php">>» '.l10n('Back').'</a> <a href="setup.php">>» '.l10n('Config').'</a></div>'; |
---|
59 | } |
---|
60 | |
---|
61 | |
---|
62 | |
---|
63 | ### EXECUTION ### |
---|
64 | if (!isset($Errors)) { |
---|
65 | ### Gestion des nouveaux plugins ### |
---|
66 | // Ajoute la configuration des plugins non-installés aux tableaux, il faut valider le formulaire pour les installer |
---|
67 | $Plugins = glob('plugins/*.xml'); |
---|
68 | |
---|
69 | foreach ($Plugins as $plugin) { |
---|
70 | // nom du plugin |
---|
71 | preg_match('#plugins/(.*).xml#', $plugin, $matches); |
---|
72 | $plugin_name = $matches[1]; |
---|
73 | // configuration du plugin |
---|
74 | $plugin = XMLparse(simplexml_load_file($plugin)); |
---|
75 | // mode du plugin (effacage pour pas l'inscrire dans la config) |
---|
76 | $plugin_mode = $plugin['mode']; |
---|
77 | unset($plugin['mode']); |
---|
78 | |
---|
79 | if (!array_key_exists($plugin_name, ${$plugin_mode})) { |
---|
80 | ${$plugin_mode}[$plugin_name] = $plugin; |
---|
81 | $NewPlugins[$plugin_name] = true; |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | ### Gestion des plugins manquants ### |
---|
87 | foreach (array('PluginsBefore','PluginsProcess','PluginsAfter') as $mode) { |
---|
88 | foreach (${$mode} as $plugin_name => $config) { |
---|
89 | if (!file_exists('plugins/'.$plugin_name.'.php')) { |
---|
90 | $MissingPlugins[$plugin_name] = true; |
---|
91 | } |
---|
92 | } |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | ### Formulaire ### |
---|
97 | $copyPOS = explode('-', $copyPOS); |
---|
98 | |
---|
99 | echo ' |
---|
100 | <script type="text/javascript"> |
---|
101 | function suivant(enCours, suivant, limite) { |
---|
102 | if (enCours.value.length == limite) { |
---|
103 | enCours.form.elements[suivant].select(); |
---|
104 | } |
---|
105 | } |
---|
106 | </script> |
---|
107 | |
---|
108 | <form action="setup.php" method="post"> |
---|
109 | <div class="config"> |
---|
110 | <h2>'.l10n('Configuration').'</h2> |
---|
111 | <ul> |
---|
112 | <li> |
---|
113 | <span class="title">'.l10n('Folders').'</span> |
---|
114 | <table> |
---|
115 | <tr> |
---|
116 | <td><b>'.l10n('FolderIn').' :</b></td> |
---|
117 | <td><input type="text" name="DIRsource" value="'.$DIRsource.'"/></td> |
---|
118 | </tr> |
---|
119 | <tr> |
---|
120 | <td><b>'.l10n('FolderOut').' :</b></td> |
---|
121 | <td><input type="text" name="DIRsortie" value="'.$DIRsortie.'"/></td> |
---|
122 | </tr> |
---|
123 | </table> |
---|
124 | </li> |
---|
125 | <li> |
---|
126 | <span class="title">'.l10n('Options').'</span> |
---|
127 | <table> |
---|
128 | <tr> |
---|
129 | <td><b>'.l10n('silentORNOT').' :</b></td> |
---|
130 | <td> |
---|
131 | <input type="radio" name="silentORNOT" value="erase" '.(($silentORNOT=='erase')?'checked':'').'/> '.l10n('erase').' |
---|
132 | <input type="radio" name="silentORNOT" value="block" '.(($silentORNOT=='block')?'checked':'').'/> '.l10n('block').' |
---|
133 | <input type="radio" name="silentORNOT" value="pass" '.(($silentORNOT=='pass')?'checked':'').'/> '.l10n('pass').' |
---|
134 | </td> |
---|
135 | </tr> |
---|
136 | <tr> |
---|
137 | <td><b>'.l10n('DIRhighORNOT').' :</b></td> |
---|
138 | <td> |
---|
139 | <input type="radio" name="DIRhighORNOT" value="true" '.(($DIRhighORNOT)?'checked':'').'/> '.l10n('yes').' |
---|
140 | <input type="radio" name="DIRhighORNOT" value="false" '.((!$DIRhighORNOT)?'checked':'').'/> '.l10n('no').' |
---|
141 | </td> |
---|
142 | </tr> |
---|
143 | <tr> |
---|
144 | <td><b>'.l10n('DIMhdORNOT').' :</b></td> |
---|
145 | <td> |
---|
146 | <input type="radio" name="DIMhdORNOT" value="true" '.(($DIMhdORNOT)?'checked':'').'/> '.l10n('yes').' |
---|
147 | <input type="radio" name="DIMhdORNOT" value="false" '.((!$DIMhdORNOT)?'checked':'').'/> '.l10n('no').' |
---|
148 | </td> |
---|
149 | </tr> |
---|
150 | <tr> |
---|
151 | <td><b>'.l10n('renameORNOT').' :</b></td> |
---|
152 | <td> |
---|
153 | <input type="radio" name="renameORNOT" value="true" '.(($renameORNOT)?'checked':'').'/> '.l10n('yes').' |
---|
154 | <input type="radio" name="renameORNOT" value="false" '.((!$renameORNOT)?'checked':'').'/> '.l10n('no').' |
---|
155 | </td> |
---|
156 | </tr> |
---|
157 | <tr> |
---|
158 | <td><b>'.l10n('indexORNOT').' :</b></td> |
---|
159 | <td> |
---|
160 | <input type="radio" name="indexORNOT" value="true" '.(($indexORNOT)?'checked':'').'/> '.l10n('yes').' |
---|
161 | <input type="radio" name="indexORNOT" value="false" '.((!$indexORNOT)?'checked':'').'/> '.l10n('no').' |
---|
162 | </td> |
---|
163 | </tr> |
---|
164 | <tr> |
---|
165 | <td><b>'.l10n('prefixe_mini').' :</b></td> |
---|
166 | <td><input type="text" name="prefixe_mini" value="'.$prefixe_mini.'" size="8"/></td> |
---|
167 | </tr> |
---|
168 | </table> |
---|
169 | </li> |
---|
170 | <li> |
---|
171 | <span class="title">'.l10n('Sizes and quality').'</span> |
---|
172 | <table> |
---|
173 | <tr> |
---|
174 | <td><b>'.l10n('DIMhd').' :</b></td> |
---|
175 | <td><input type="text" name="DIMhd" value="'.$DIMhd.'" size="4"/></td> |
---|
176 | </tr> |
---|
177 | <tr> |
---|
178 | <td><b>'.l10n('DIMnormal').' :</b></td> |
---|
179 | <td><input type="text" name="DIMnormal" value="'.$DIMnormal.'" size="3"/></td> |
---|
180 | </tr> |
---|
181 | <tr> |
---|
182 | <td><b>'.l10n('DIMthumbnail').' :</b></td> |
---|
183 | <td><input type="text" name="DIMthumbnail" value="'.$DIMthumbnail.'" size="3"/></td> |
---|
184 | </tr> |
---|
185 | <tr> |
---|
186 | <td><b>'.l10n('Qhd').' :</b></td> |
---|
187 | <td><input type="text" name="Qhd" value="'.$Qhd.'" size="3"/></td> |
---|
188 | </tr> |
---|
189 | <tr> |
---|
190 | <td><b>'.l10n('Qnormal').' :</b></td> |
---|
191 | <td><input type="text" name="Qnormal" value="'.$Qnormal.'" size="3"/></td> |
---|
192 | </tr> |
---|
193 | <tr> |
---|
194 | <td><b>'.l10n('Qthumbnail').' :</b></td> |
---|
195 | <td><input type="text" name="Qthumbnail" value="'.$Qthumbnail.'" size="3"/></td> |
---|
196 | </tr> |
---|
197 | <tr> |
---|
198 | <td><b>'.l10n('DPI').' :</b></td> |
---|
199 | <td><input type="text" name="DPI" value="'.$DPI.'" size="3"/></td> |
---|
200 | </tr> |
---|
201 | </table> |
---|
202 | </li> |
---|
203 | <li> |
---|
204 | <span class="title">'.l10n('Copyright').'</span> |
---|
205 | <table> |
---|
206 | <tr> |
---|
207 | <td><b>'.l10n('Content').' :</b></td> |
---|
208 | <td><input type="text" name="copyright" value="'.$copyright.'"/></td> |
---|
209 | </tr> |
---|
210 | <tr> |
---|
211 | <td><b>'.l10n('copyONhd').' :</b></td> |
---|
212 | <td> |
---|
213 | <input type="radio" name="copyONhd" value="true" '.(($copyONhd)?'checked':'').'/> '.l10n('yes').' |
---|
214 | <input type="radio" name="copyONhd" value="false" '.((!$copyONhd)?'checked':'').'/> '.l10n('no').' |
---|
215 | </td> |
---|
216 | </tr> |
---|
217 | <tr> |
---|
218 | <td><b>'.l10n('copyONnormal').' :</b></td> |
---|
219 | <td> |
---|
220 | <input type="radio" name="copyONnormal" value="true" '.(($copyONnormal)?'checked':'').'/> '.l10n('yes').' |
---|
221 | <input type="radio" name="copyONnormal" value="false" '.((!$copyONnormal)?'checked':'').'/> '.l10n('no').' |
---|
222 | </td> |
---|
223 | </tr> |
---|
224 | <tr> |
---|
225 | <td><b>'.l10n('copyPOS%s', l10n('copyPOSv')).' :</b></td> |
---|
226 | <td> |
---|
227 | <input type="radio" name="copyPOS[0]" value="top" '.(($copyPOS[0]=='top')?'checked':'').'/> '.l10n('top').' |
---|
228 | <input type="radio" name="copyPOS[0]" value="center" '.(($copyPOS[0]=='center')?'checked':'').'/> '.l10n('center').' |
---|
229 | <input type="radio" name="copyPOS[0]" value="bottom" '.(($copyPOS[0]=='bottom')?'checked':'').'/> '.l10n('bottom').' |
---|
230 | </td> |
---|
231 | </tr> |
---|
232 | <tr> |
---|
233 | <td><b>'.l10n('copyPOS%s', l10n('copyPOSh')).' :</b></td> |
---|
234 | <td> |
---|
235 | <input type="radio" name="copyPOS[1]" value="left" '.(($copyPOS[1]=='left')?'checked':'').'/> '.l10n('left').' |
---|
236 | <input type="radio" name="copyPOS[1]" value="center" '.(($copyPOS[1]=='center')?'checked':'').'/> '.l10n('center').' |
---|
237 | <input type="radio" name="copyPOS[1]" value="right" '.(($copyPOS[1]=='right')?'checked':'').'/> '.l10n('right').' |
---|
238 | </td> |
---|
239 | </tr> |
---|
240 | <tr> |
---|
241 | <td><b>'.l10n('copySIZE').' :</b></td> |
---|
242 | <td><input type="text" name="copySIZE" value="'.$copySIZE.'" size="5"/></td> |
---|
243 | </tr> |
---|
244 | <tr> |
---|
245 | <td><b>'.l10n('copyCOLOR').' :</b></td> |
---|
246 | <td><input type="text" name="copyCOLOR" value="'.$copyCOLOR.'" size="6"/></td> |
---|
247 | </tr> |
---|
248 | <tr> |
---|
249 | <td><b>'.l10n('copyFONT').' :</b></td> |
---|
250 | <td><input type="text" name="copyFONT" value="'.$copyFONT.'"/></td> |
---|
251 | </tr> |
---|
252 | </table> |
---|
253 | </li> |
---|
254 | </ul> |
---|
255 | </div> |
---|
256 | |
---|
257 | <div class="config"> |
---|
258 | <h2>'.l10n('Plugins').'</h2> |
---|
259 | <ul>'; |
---|
260 | |
---|
261 | // Affichage des plugins, un bloc par mode |
---|
262 | foreach (array('PluginsBefore','PluginsProcess','PluginsAfter') as $mode) { |
---|
263 | echo '<li> |
---|
264 | <span class="title">'.l10n($mode).'</span> |
---|
265 | <ul>'; |
---|
266 | // Un bloc par plugin |
---|
267 | foreach (${$mode} as $name => $config) { |
---|
268 | echo '<li>'; |
---|
269 | echo '<b>'.$name.' :</b>'; |
---|
270 | |
---|
271 | // Cas spéciaux dans le titre(nouveau, manquant) |
---|
272 | if (isset($NewPlugins[$name])) { |
---|
273 | echo ' <b class="new">'.l10n('New !').'</b>'; |
---|
274 | } else if (isset($MissingPlugins[$name])) { |
---|
275 | echo ' <b class="miss">'.l10n('Missing !').'</b>'; |
---|
276 | } |
---|
277 | |
---|
278 | echo '<table>'; |
---|
279 | // Si il est manquant on ne met que la checkbox de suppression |
---|
280 | if (isset($MissingPlugins[$name])) { |
---|
281 | echo '<tr> |
---|
282 | <td>'.l10n('erase').' :</td> |
---|
283 | <td><input type="checkbox" name="'.$mode.'['.$name.'][delete]" value="true" checked/></td> |
---|
284 | </tr>'; |
---|
285 | // sinon on affiche sa configuration |
---|
286 | } else { |
---|
287 | foreach ($config as $key => $value) { |
---|
288 | $value = bool_to_string($value,1); |
---|
289 | echo '<tr> |
---|
290 | <td>'.$key.' :</td> |
---|
291 | <td><input type="text" name="'.$mode.'['.$name.']['.$key.']" value="'.$value.'" size="'.strlen($value).'"/></td> |
---|
292 | </tr>'; |
---|
293 | } |
---|
294 | } |
---|
295 | echo '</table> |
---|
296 | </li>'; |
---|
297 | } |
---|
298 | echo '</ul> |
---|
299 | </li>'; |
---|
300 | } |
---|
301 | |
---|
302 | echo '</ul> |
---|
303 | </div> |
---|
304 | |
---|
305 | <div class="finish"><input type="submit" value="'.l10n('Valid').'"/> <input type="reset" value="'.l10n('Reset').'"/></div> |
---|
306 | <div class="link"><a href="index.php">» '.l10n('Back').'</a></div> |
---|
307 | </form>'; |
---|
308 | } |
---|
309 | |
---|
310 | |
---|
311 | |
---|
312 | ### FIN ### |
---|
313 | echo '<div class="footer"> |
---|
314 | 2010 - <a href="http://www.strangeplanet.fr">Damien Sorel</a> - <a href="http://fr.piwigo.org/forum/viewtopic.php?id=19117">Forum</a> |
---|
315 | </div> |
---|
316 | |
---|
317 | </body> |
---|
318 | </html>'; |
---|
319 | ?> |
---|