1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2005-09-03 16:36:05 +0000 (Sat, 03 Sep 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 858 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
29 | { |
---|
30 | die ("Hacking attempt!"); |
---|
31 | } |
---|
32 | |
---|
33 | include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
---|
34 | //-------------------------------------------------------- sections definitions |
---|
35 | if (!isset($_GET['section'])) |
---|
36 | { |
---|
37 | $page['section'] = 'general'; |
---|
38 | } |
---|
39 | else |
---|
40 | { |
---|
41 | $page['section'] = $_GET['section']; |
---|
42 | } |
---|
43 | //------------------------------------------------------ $conf reinitialization |
---|
44 | $result = pwg_query('SELECT param,value FROM '.CONFIG_TABLE); |
---|
45 | while ($row = mysql_fetch_array($result)) |
---|
46 | { |
---|
47 | $conf[$row['param']] = $row['value']; |
---|
48 | // if the parameter is present in $_POST array (if a form is submited), we |
---|
49 | // override it with the submited value |
---|
50 | if (isset($_POST[$row['param']])) |
---|
51 | { |
---|
52 | $conf[$row['param']] = $_POST[$row['param']]; |
---|
53 | } |
---|
54 | } |
---|
55 | //------------------------------ verification and registration of modifications |
---|
56 | if (isset($_POST['submit'])) |
---|
57 | { |
---|
58 | $int_pattern = '/^\d+$/'; |
---|
59 | switch ($page['section']) |
---|
60 | { |
---|
61 | case 'general' : |
---|
62 | { |
---|
63 | break; |
---|
64 | } |
---|
65 | case 'comments' : |
---|
66 | { |
---|
67 | // the number of comments per page must be an integer between 5 and 50 |
---|
68 | // included |
---|
69 | if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
---|
70 | or $_POST['nb_comment_page'] < 5 |
---|
71 | or $_POST['nb_comment_page'] > 50) |
---|
72 | { |
---|
73 | array_push($page['errors'], $lang['conf_nb_comment_page_error']); |
---|
74 | } |
---|
75 | break; |
---|
76 | } |
---|
77 | case 'default' : |
---|
78 | { |
---|
79 | // periods must be integer values, they represents number of days |
---|
80 | if (!preg_match($int_pattern, $_POST['recent_period']) |
---|
81 | or $_POST['recent_period'] <= 0) |
---|
82 | { |
---|
83 | array_push($page['errors'], $lang['periods_error']); |
---|
84 | } |
---|
85 | break; |
---|
86 | } |
---|
87 | } |
---|
88 | |
---|
89 | // updating configuration if no error found |
---|
90 | if (count($page['errors']) == 0) |
---|
91 | { |
---|
92 | echo '<pre>'; print_r($_POST); echo '</pre>'; |
---|
93 | $result = pwg_query('SELECT * FROM '.CONFIG_TABLE); |
---|
94 | while ($row = mysql_fetch_array($result)) |
---|
95 | { |
---|
96 | if (isset($_POST[$row['param']])) |
---|
97 | { |
---|
98 | $query = ' |
---|
99 | UPDATE '.CONFIG_TABLE.' |
---|
100 | SET value = \''. str_replace("\'", "''", $_POST[$row['param']]).'\' |
---|
101 | WHERE param = \''.$row['param'].'\' |
---|
102 | ;'; |
---|
103 | pwg_query($query); |
---|
104 | } |
---|
105 | } |
---|
106 | array_push($page['infos'], $lang['conf_confirmation']); |
---|
107 | } |
---|
108 | } |
---|
109 | |
---|
110 | //----------------------------------------------------- template initialization |
---|
111 | $template->set_filenames( array('config'=>'admin/configuration.tpl') ); |
---|
112 | |
---|
113 | $action = PHPWG_ROOT_PATH.'admin.php?page=configuration'; |
---|
114 | $action.= '&section='.$page['section']; |
---|
115 | |
---|
116 | $template->assign_vars( |
---|
117 | array( |
---|
118 | 'L_YES'=>$lang['yes'], |
---|
119 | 'L_NO'=>$lang['no'], |
---|
120 | 'L_SUBMIT'=>$lang['submit'], |
---|
121 | 'L_RESET'=>$lang['reset'], |
---|
122 | |
---|
123 | 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=configuration', |
---|
124 | |
---|
125 | 'F_ACTION'=>add_session_id($action) |
---|
126 | )); |
---|
127 | |
---|
128 | switch ($page['section']) |
---|
129 | { |
---|
130 | case 'general' : |
---|
131 | { |
---|
132 | $history_yes = ($conf['log']=='true')?'checked="checked"':''; |
---|
133 | $history_no = ($conf['log']=='false')?'checked="checked"':''; |
---|
134 | $lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':''; |
---|
135 | $lock_no = ($conf['gallery_locked']=='false')?'checked="checked"':''; |
---|
136 | |
---|
137 | $template->assign_block_vars( |
---|
138 | 'general', |
---|
139 | array( |
---|
140 | 'HISTORY_YES'=>$history_yes, |
---|
141 | 'HISTORY_NO'=>$history_no, |
---|
142 | 'GALLERY_LOCKED_YES'=>$lock_yes, |
---|
143 | 'GALLERY_LOCKED_NO'=>$lock_no, |
---|
144 | )); |
---|
145 | break; |
---|
146 | } |
---|
147 | case 'comments' : |
---|
148 | { |
---|
149 | $all_yes = ($conf['comments_forall']=='true')?'checked="checked"':''; |
---|
150 | $all_no = ($conf['comments_forall']=='false')?'checked="checked"':''; |
---|
151 | $validate_yes = ($conf['comments_validation']=='true')?'checked="checked"':''; |
---|
152 | $validate_no = ($conf['comments_validation']=='false')?'checked="checked"':''; |
---|
153 | |
---|
154 | $template->assign_block_vars( |
---|
155 | 'comments', |
---|
156 | array( |
---|
157 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
158 | 'COMMENTS_ALL_YES'=>$all_yes, |
---|
159 | 'COMMENTS_ALL_NO'=>$all_no, |
---|
160 | 'VALIDATE_YES'=>$validate_yes, |
---|
161 | 'VALIDATE_NO'=>$validate_no |
---|
162 | )); |
---|
163 | break; |
---|
164 | } |
---|
165 | case 'default' : |
---|
166 | { |
---|
167 | $show_yes = ($conf['show_nb_comments']=='true')?'checked="checked"':''; |
---|
168 | $show_no = ($conf['show_nb_comments']=='false')?'checked="checked"':''; |
---|
169 | $expand_yes = ($conf['auto_expand']=='true')?'checked="checked"':''; |
---|
170 | $expand_no = ($conf['auto_expand']=='false')?'checked="checked"':''; |
---|
171 | |
---|
172 | $template->assign_block_vars( |
---|
173 | 'default', |
---|
174 | array( |
---|
175 | 'NB_IMAGE_LINE'=>$conf['nb_image_line'], |
---|
176 | 'NB_ROW_PAGE'=>$conf['nb_line_page'], |
---|
177 | 'CONF_RECENT'=>$conf['recent_period'], |
---|
178 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
179 | 'EXPAND_YES'=>$expand_yes, |
---|
180 | 'EXPAND_NO'=>$expand_no, |
---|
181 | 'SHOW_COMMENTS_YES'=>$show_yes, |
---|
182 | 'SHOW_COMMENTS_NO'=>$show_no |
---|
183 | )); |
---|
184 | |
---|
185 | $blockname = 'default.language_option'; |
---|
186 | |
---|
187 | foreach (get_languages() as $language_code => $language_name) |
---|
188 | { |
---|
189 | if (isset($_POST['submit'])) |
---|
190 | { |
---|
191 | $selected = |
---|
192 | $_POST['default_language'] == $language_code |
---|
193 | ? 'selected="selected"' : ''; |
---|
194 | } |
---|
195 | else if ($conf['default_language'] == $language_code) |
---|
196 | { |
---|
197 | $selected = 'selected="selected"'; |
---|
198 | } |
---|
199 | else |
---|
200 | { |
---|
201 | $selected = ''; |
---|
202 | } |
---|
203 | |
---|
204 | $template->assign_block_vars( |
---|
205 | $blockname, |
---|
206 | array( |
---|
207 | 'VALUE'=> $language_code, |
---|
208 | 'CONTENT' => $language_name, |
---|
209 | 'SELECTED' => $selected |
---|
210 | )); |
---|
211 | } |
---|
212 | |
---|
213 | $blockname = 'default.template_option'; |
---|
214 | |
---|
215 | foreach (get_templates() as $pwg_template) |
---|
216 | { |
---|
217 | if (isset($_POST['submit'])) |
---|
218 | { |
---|
219 | $selected = |
---|
220 | $_POST['default_template'] == $pwg_template |
---|
221 | ? 'selected="selected"' : ''; |
---|
222 | } |
---|
223 | else if ($conf['default_template'] == $pwg_template) |
---|
224 | { |
---|
225 | $selected = 'selected="selected"'; |
---|
226 | } |
---|
227 | else |
---|
228 | { |
---|
229 | $selected = ''; |
---|
230 | } |
---|
231 | |
---|
232 | $template->assign_block_vars( |
---|
233 | $blockname, |
---|
234 | array( |
---|
235 | 'VALUE'=> $pwg_template, |
---|
236 | 'CONTENT' => $pwg_template, |
---|
237 | 'SELECTED' => $selected |
---|
238 | ) |
---|
239 | ); |
---|
240 | } |
---|
241 | |
---|
242 | |
---|
243 | break; |
---|
244 | } |
---|
245 | } |
---|
246 | //----------------------------------------------------------- sending html code |
---|
247 | $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
---|
248 | ?> |
---|