source: extensions/download_multi/admin/admin.php @ 15106

Last change on this file since 15106 was 3986, checked in by flipflip, 14 years ago

Initial Import

File size: 7.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Mod Name : Download_multi                                             |
4// | Mod Version : 0.9-1                                                   |
5// | Mod Orignal author: Tboris                                            |
6// | Mod Second author : Cestlodovic                                       |
7// | Mod Version author : FlipFlip <flipflip@free.fr>                      |
8// | Mod description :                                                     |
9// | Ce module est base sur le module existant pour le telechargement,     |
10// | cette version permet le telechargement sur plusieurs pages.           |
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
28
29check_status(ACCESS_ADMINISTRATOR);
30
31$DownloadMulti = get_plugin_data($plugin_id);
32global $template, $lang, $page;
33
34// Si le formulaire est posté
35// alors on écrit la configuration
36if (isset($_POST['downloadmulti_post_form']) == 1) {
37  if (empty($_POST['downloadmulti_group'])) {
38    array_push($page['errors'], $lang['dl_error_group_id']);
39  }
40
41  if (empty($_POST['downloadmulti_archive_size'])) {
42    array_push($page['errors'], $lang['dl_error_file_size']);
43  }
44
45  if(preg_match('/[^0-9]/', $_POST['downloadmulti_archive_size'])) {
46    array_push($page['errors'], $lang['dl_error_file_size_car']);
47  }
48
49  if(preg_match('/[^a-z0-9\-_]/', $_POST['downloadmulti_prefix'])) {
50    array_push($page['errors'], $lang['dl_zip_prefix_car']);
51  }
52
53  if(preg_match('/[^a-z0-9\-_\[\]]/', $_POST['downloadmulti_pattern_name'])) {
54    array_push($page['errors'], $lang['dl_zip_pattern_name_car']);
55  }
56 
57  if (empty($_POST['downloadmulti_pattern_name'])) {
58    array_push($page['errors'], $lang['dl_error_pattern_name']);
59  }
60   
61  if(preg_match('/[^a-z0-9\-_]/', $_POST['downloadmulti_prefix_dir'])) {
62    array_push($page['errors'], $lang['dl_zip_dir_prefix_car']);
63  }
64  // Si il n'y a pas d'erreurs
65  if (count($page['errors']) == 0) {
66    if(isset($_POST['downloadmulti_active_comment'])) {
67      $downloadmulti_active_comment = 'on';
68    } else {
69      $downloadmulti_active_comment = '';
70    }
71   
72    if(isset($_POST['downloadmulti_create_category'])) {
73      $downloadmulti_create_category = 'on';
74    } else {
75      $downloadmulti_create_category = '';
76    }
77       
78    $DownloadMulti->my_config['active_comment'] = $downloadmulti_active_comment;
79    $DownloadMulti->my_config['comment'] = $_POST['downloadmulti_comment'];
80    $DownloadMulti->my_config['group_id'] = $_POST['downloadmulti_group'];   
81    $DownloadMulti->my_config['archive_size'] = $_POST['downloadmulti_archive_size'];
82    $DownloadMulti->my_config['prefix'] = $_POST['downloadmulti_prefix'];
83    $DownloadMulti->my_config['prefix_dir'] = $_POST['downloadmulti_prefix_dir'];
84    $DownloadMulti->my_config['pattern_name'] = $_POST['downloadmulti_pattern_name'];
85    $DownloadMulti->my_config['select_dl'] = $_POST['downloadmulti_select_dl'];
86    $DownloadMulti->my_config['create_category'] = $downloadmulti_create_category;
87    $DownloadMulti->save_config();
88
89    array_push($page['infos'], $lang['dl_backup_config']);
90  }
91}
92
93if(isset($DownloadMulti->my_config['active_comment'])) { $active_comment = $DownloadMulti->my_config['active_comment']; }
94if(isset($DownloadMulti->my_config['comment'])) { $comment = $DownloadMulti->my_config['comment']; }
95if(isset($DownloadMulti->my_config['archive_size'])) { $archive_size = $DownloadMulti->my_config['archive_size']; }
96if(isset($DownloadMulti->my_config['prefix'])) { $prefix = $DownloadMulti->my_config['prefix']; }
97if(isset($DownloadMulti->my_config['prefix_dir'])) { $prefix_dir = $DownloadMulti->my_config['prefix_dir']; }
98if(isset($DownloadMulti->my_config['pattern_name'])) { $pattern_name = $DownloadMulti->my_config['pattern_name']; }
99if(isset($DownloadMulti->my_config['select_dl'])) { $select_dl = $DownloadMulti->my_config['select_dl']; }
100if(isset($DownloadMulti->my_config['group_id'])) { $group_id = $DownloadMulti->my_config['group_id']; }
101if(isset($DownloadMulti->my_config['create_category'])) { $create_category = $DownloadMulti->my_config['create_category']; }
102
103if(!isset($active_comment)) { $active_comment = ''; }
104if(!isset($comment)) { $comment = ''; }
105if(!isset($archive_size)) { $archive_size = ''; }
106if(!isset($prefix)) { $prefix = ''; }
107if(!isset($prefix_dir)) { $prefix_dir = ''; }
108if(!isset($pattern_name)) { $pattern_name = ''; }
109if(!isset($select_dl)) { $select_dl = ''; }
110if(!isset($group_id)) { $group_id = ''; }
111if(!isset($create_category)) { $create_category = ''; }
112
113// +-----------------------------------------------------------------------+
114// |                            template initialization
115// +-----------------------------------------------------------------------+
116$template->set_filenames(array('plugin_admin_content' => $DownloadMulti->plugin_path.'template/admin.tpl'));
117
118if(!class_exists('zipArchive')) {
119  array_push($page['errors'], $lang['dl_class_exist']);
120}
121
122$template->assign(array(
123  'F_ACTION' => PHPWG_ROOT_PATH.'admin.php?page=plugin&amp;section=download_multi%2Fadmin%2Fadmin.php',
124  'DOWNLOADMULTI_ACTIVECOMMENT' => $active_comment ? 'checked="checked"' : '',
125  'DOWNLOADMULTI_COMMENT' => $comment,
126  'DOWNLOADMULTI_ARCHIVE_SIZE' => $archive_size,
127  'DOWNLOADMULTI_PREFIX' => $prefix,
128  'DOWNLOADMULTI_PREFIX_DIR' => $prefix_dir,
129  'DOWNLOADMULTI_PATTERN_NAME' => $pattern_name,
130  'DOWNLOADMULTI_CREATECATEGORY' => $create_category ? 'checked="checked"' : '',
131));
132
133// Gestion des groupes
134$query = '
135SELECT id, name
136  FROM '.$prefixeTable.'groups
137  ORDER BY name ASC
138;';
139$result = pwg_query($query);
140
141while ($row = mysql_fetch_array($result)) {
142  $groupe_id[] = $row['id'];
143  $groupe_name[] = $row['name'];
144}
145
146$template->assign('downloadmulti_group_id', $groupe_id);
147$template->assign('downloadmulti_group_name', $groupe_name);
148$template->assign('downloadmulti_group_select', $group_id);
149
150// Gestion des formats de téléchargement par défaut
151$template->assign('downloadmulti_select_dl',
152              array(
153                  'thumbnail' => $lang['dl_thumbnail'],
154                  'normal' => $lang['dl_normal'],
155                  'high' => $lang['dl_high']
156                  )
157                );
158$template->assign('select_dl', $select_dl);
159                               
160// Chargement de la configuration du serveur
161$DownloadMulti->DmServeurConfiguration();
162
163$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
164?>
Note: See TracBrowser for help on using the repository browser.