source: extensions/PHP_Optimisateur/include/save_config.php @ 9201

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

[tools] PHP Optimisateur :

  • Correction de bugs
  • La plupart des types de fichiers sont supportés (testé avec jpg, png et gif)
  • Réécriture de la gestion des plugins
  • Nouvelle apparence
File size: 2.0 KB
Line 
1<?php
2// Quelques traitements
3$_POST['copyPOS'] = implode('-', $_POST['copyPOS']);
4$_POST['copyCOLOR'] = str_replace('#','', $_POST['copyCOLOR']);
5$_POST['prefixe_mini'] = delete_special_car($_POST['prefixe_mini']);
6if (!preg_match('#(.*)/$#', $_POST['DIRsource'])) $_POST['DIRsource'] .= '/';
7if (!preg_match('#(.*)/$#', $_POST['DIRsortie'])) $_POST['DIRsortie'] .= '/';
8
9// Vérifications
10if (!is_decimal($_POST['Qhd']) OR $_POST['Qhd'] > 100) {
11        $_POST['Qhd'] = 100;
12        $Errors['ErrorConfig'] = 'notice';
13}
14if (!is_decimal($_POST['Qnormal']) OR $_POST['Qnormal'] > 100) {
15        $_POST['Qnormal'] = 100;
16        $Errors['ErrorConfig'] = 'notice';
17}
18if (!is_decimal($_POST['Qthumbnail']) OR $_POST['Qthumbnail'] > 100) {
19        $_POST['Qthumbnail'] = 100;
20        $Errors['ErrorConfig'] = 'notice';
21}
22if (!is_decimal($_POST['DIMhd'])) {
23        $_POST['DIMhd'] = 2560;
24        $Errors['ErrorConfig'] = 'notice';
25}
26if (!is_decimal($_POST['DIMnormal']) OR $_POST['DIMnormal'] > $_POST['DIMhd']) {
27        $_POST['DIMnormal'] = 800;
28        $Errors['ErrorConfig'] = 'notice';
29}
30if (!is_decimal($_POST['DIMthumbnail']) OR $_POST['DIMthumbnail'] > $_POST['DIMnormal']) {
31        $_POST['DIMthumbnail'] = 120;
32        $Errors['ErrorConfig'] = 'notice';
33}
34if (!is_decimal($_POST['DPI'])) {
35        $_POST['DPI'] = 72;
36        $Errors['ErrorConfig'] = 'notice';
37}
38       
39
40// Plugins : supprime les plugins manquants & charge les actions de configuration
41$PLUGIN_ACTION = 'save_config';
42
43foreach ($_POST['Plugins'] as $plugin_id => $plugin_config) {
44        if (isset($plugin_config['delete'])) {
45                unset($_POST['Plugins'][$plugin_id]);
46        } else if (file_exists('plugins/'.$plugin_id.'/setup.php')) {
47                include('plugins/'.$plugin_id.'/setup.php');
48        }
49}
50
51// Contenu du fichier
52$content = '<?xml version="1.0" encoding="UTF-8"?>'."\r\n".'<config>'."\r\n";
53$content .= XMLcreate($_POST);
54$content .= '</config>';
55file_put_contents('config.xml', $content);
56
57if (isset($Errors['ErrorConfig'])) {
58        header('Location:index.php?page=setup&ErrorConfig='.$Errors['ErrorConfig']);
59} else {
60        header('Location:index.php');
61}
62?>
Note: See TracBrowser for help on using the repository browser.