[362] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[1748] | 5 | // | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[362] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[362] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2007-03-12 23:10:35 +0000 (Mon, 12 Mar 2007) $ |
---|
| 10 | // | last modifier : $Author: rub $ |
---|
| 11 | // | revision : $Revision: 1901 $ |
---|
| 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 | // +-----------------------------------------------------------------------+ |
---|
[2] | 27 | |
---|
[527] | 28 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
[393] | 29 | { |
---|
[1072] | 30 | die ("Hacking attempt!"); |
---|
[393] | 31 | } |
---|
[527] | 32 | |
---|
[1072] | 33 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[1881] | 34 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_tabsheet.inc.php'); |
---|
[1072] | 35 | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
| 37 | // | Check Access and exit when user status is not ok | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 40 | |
---|
[512] | 41 | //-------------------------------------------------------- sections definitions |
---|
| 42 | if (!isset($_GET['section'])) |
---|
| 43 | { |
---|
[1894] | 44 | $page['section'] = 'main'; |
---|
[512] | 45 | } |
---|
| 46 | else |
---|
| 47 | { |
---|
| 48 | $page['section'] = $_GET['section']; |
---|
| 49 | } |
---|
[1617] | 50 | |
---|
[1894] | 51 | $main_checkboxes = array( |
---|
[1652] | 52 | 'email_admin_on_new_user', |
---|
| 53 | 'allow_user_registration', |
---|
[1901] | 54 | 'email_admin_on_picture_uploaded', |
---|
[1617] | 55 | ); |
---|
| 56 | |
---|
[1884] | 57 | $history_checkboxes = array( |
---|
| 58 | 'log', |
---|
| 59 | 'history_admin', |
---|
| 60 | 'history_guest' |
---|
| 61 | ); |
---|
| 62 | |
---|
[1617] | 63 | $comments_checkboxes = array( |
---|
| 64 | 'comments_forall', |
---|
| 65 | 'comments_validation', |
---|
| 66 | 'email_admin_on_comment', |
---|
| 67 | 'email_admin_on_comment_validation', |
---|
| 68 | ); |
---|
| 69 | |
---|
[2] | 70 | //------------------------------ verification and registration of modifications |
---|
[1571] | 71 | if (isset($_POST['submit']) and !is_adviser()) |
---|
[2] | 72 | { |
---|
[21] | 73 | $int_pattern = '/^\d+$/'; |
---|
[512] | 74 | switch ($page['section']) |
---|
[2] | 75 | { |
---|
[1894] | 76 | case 'main' : |
---|
[130] | 77 | { |
---|
[1044] | 78 | if ( !url_is_remote($_POST['gallery_url']) ) |
---|
| 79 | { |
---|
| 80 | array_push($page['errors'], $lang['conf_gallery_url_error']); |
---|
| 81 | } |
---|
[1894] | 82 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 83 | { |
---|
| 84 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 85 | } |
---|
[512] | 86 | break; |
---|
[130] | 87 | } |
---|
[1884] | 88 | case 'history' : |
---|
| 89 | { |
---|
| 90 | foreach( $history_checkboxes as $checkbox) |
---|
| 91 | { |
---|
| 92 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 93 | } |
---|
| 94 | break; |
---|
| 95 | } |
---|
[512] | 96 | case 'comments' : |
---|
| 97 | { |
---|
| 98 | // the number of comments per page must be an integer between 5 and 50 |
---|
| 99 | // included |
---|
| 100 | if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
---|
| 101 | or $_POST['nb_comment_page'] < 5 |
---|
| 102 | or $_POST['nb_comment_page'] > 50) |
---|
| 103 | { |
---|
[792] | 104 | array_push($page['errors'], $lang['conf_nb_comment_page_error']); |
---|
[512] | 105 | } |
---|
[1617] | 106 | foreach( $comments_checkboxes as $checkbox) |
---|
| 107 | { |
---|
| 108 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 109 | } |
---|
[512] | 110 | break; |
---|
| 111 | } |
---|
| 112 | case 'default' : |
---|
| 113 | { |
---|
| 114 | // periods must be integer values, they represents number of days |
---|
| 115 | if (!preg_match($int_pattern, $_POST['recent_period']) |
---|
| 116 | or $_POST['recent_period'] <= 0) |
---|
| 117 | { |
---|
[792] | 118 | array_push($page['errors'], $lang['periods_error']); |
---|
[512] | 119 | } |
---|
[869] | 120 | // maxwidth |
---|
| 121 | if (isset($_POST['default_maxwidth']) |
---|
| 122 | and !empty($_POST['default_maxwidth']) |
---|
| 123 | and (!preg_match($int_pattern, $_POST['default_maxwidth']) |
---|
| 124 | or $_POST['default_maxwidth'] < 50)) |
---|
| 125 | { |
---|
| 126 | array_push($page['errors'], $lang['maxwidth_error']); |
---|
| 127 | } |
---|
| 128 | // maxheight |
---|
| 129 | if (isset($_POST['default_maxheight']) |
---|
| 130 | and !empty($_POST['default_maxheight']) |
---|
| 131 | and (!preg_match($int_pattern, $_POST['default_maxheight']) |
---|
| 132 | or $_POST['default_maxheight'] < 50)) |
---|
| 133 | { |
---|
| 134 | array_push($page['errors'], $lang['maxheight_error']); |
---|
| 135 | } |
---|
[512] | 136 | break; |
---|
| 137 | } |
---|
[2] | 138 | } |
---|
[1071] | 139 | |
---|
[528] | 140 | // updating configuration if no error found |
---|
[792] | 141 | if (count($page['errors']) == 0) |
---|
[345] | 142 | { |
---|
[1565] | 143 | //echo '<pre>'; print_r($_POST); echo '</pre>'; |
---|
[1748] | 144 | $result = pwg_query('SELECT param FROM '.CONFIG_TABLE); |
---|
[512] | 145 | while ($row = mysql_fetch_array($result)) |
---|
| 146 | { |
---|
| 147 | if (isset($_POST[$row['param']])) |
---|
| 148 | { |
---|
[882] | 149 | $value = $_POST[$row['param']]; |
---|
[1071] | 150 | |
---|
| 151 | if ('gallery_title' == $row['param']) |
---|
[882] | 152 | { |
---|
| 153 | if (!$conf['allow_html_descriptions']) |
---|
| 154 | { |
---|
| 155 | $value = strip_tags($value); |
---|
| 156 | } |
---|
| 157 | } |
---|
[1071] | 158 | |
---|
[528] | 159 | $query = ' |
---|
| 160 | UPDATE '.CONFIG_TABLE.' |
---|
[882] | 161 | SET value = \''. str_replace("\'", "''", $value).'\' |
---|
[528] | 162 | WHERE param = \''.$row['param'].'\' |
---|
| 163 | ;'; |
---|
[587] | 164 | pwg_query($query); |
---|
[512] | 165 | } |
---|
| 166 | } |
---|
[792] | 167 | array_push($page['infos'], $lang['conf_confirmation']); |
---|
[345] | 168 | } |
---|
[527] | 169 | |
---|
[1748] | 170 | //------------------------------------------------------ $conf reinitialization |
---|
| 171 | load_conf_from_db(); |
---|
[1565] | 172 | } |
---|
| 173 | |
---|
[512] | 174 | //----------------------------------------------------- template initialization |
---|
[1881] | 175 | $template->set_filename('config', 'admin/configuration.tpl'); |
---|
[512] | 176 | |
---|
[1881] | 177 | // TabSheet initialization |
---|
| 178 | $page['tabsheet'] = array |
---|
| 179 | ( |
---|
[1894] | 180 | 'main' => array |
---|
[1881] | 181 | ( |
---|
[1894] | 182 | 'caption' => l10n('conf_main_title'), |
---|
| 183 | 'url' => $conf_link.'main' |
---|
[1881] | 184 | ), |
---|
[1884] | 185 | 'history' => array |
---|
| 186 | ( |
---|
| 187 | 'caption' => l10n('conf_history_title'), |
---|
| 188 | 'url' => $conf_link.'history' |
---|
| 189 | ), |
---|
[1881] | 190 | 'comments' => array |
---|
| 191 | ( |
---|
| 192 | 'caption' => l10n('conf_comments_title'), |
---|
| 193 | 'url' => $conf_link.'comments' |
---|
| 194 | ), |
---|
| 195 | 'default' => array |
---|
| 196 | ( |
---|
[1894] | 197 | 'caption' => l10n('conf_display'), |
---|
[1881] | 198 | 'url' => $conf_link.'default' |
---|
| 199 | ) |
---|
| 200 | ); |
---|
| 201 | |
---|
| 202 | $page['tabsheet'][$page['section']]['selected'] = true; |
---|
| 203 | |
---|
| 204 | // Assign tabsheet to template |
---|
| 205 | template_assign_tabsheet(); |
---|
| 206 | |
---|
[528] | 207 | $action = PHPWG_ROOT_PATH.'admin.php?page=configuration'; |
---|
| 208 | $action.= '&section='.$page['section']; |
---|
[21] | 209 | |
---|
[528] | 210 | $template->assign_vars( |
---|
| 211 | array( |
---|
| 212 | 'L_YES'=>$lang['yes'], |
---|
| 213 | 'L_NO'=>$lang['no'], |
---|
| 214 | 'L_SUBMIT'=>$lang['submit'], |
---|
| 215 | 'L_RESET'=>$lang['reset'], |
---|
[858] | 216 | |
---|
[1250] | 217 | 'U_HELP' => PHPWG_ROOT_PATH.'popuphelp.php?page=configuration', |
---|
[1071] | 218 | |
---|
[1004] | 219 | 'F_ACTION'=>$action |
---|
[528] | 220 | )); |
---|
| 221 | |
---|
[1617] | 222 | $html_check='checked="checked"'; |
---|
| 223 | |
---|
[527] | 224 | switch ($page['section']) |
---|
[528] | 225 | { |
---|
[1894] | 226 | case 'main' : |
---|
[2] | 227 | { |
---|
[1748] | 228 | $lock_yes = ($conf['gallery_locked']==true)?'checked="checked"':''; |
---|
| 229 | $lock_no = ($conf['gallery_locked']==false)?'checked="checked"':''; |
---|
[1071] | 230 | |
---|
[528] | 231 | $template->assign_block_vars( |
---|
[1894] | 232 | 'main', |
---|
[528] | 233 | array( |
---|
[653] | 234 | 'GALLERY_LOCKED_YES'=>$lock_yes, |
---|
| 235 | 'GALLERY_LOCKED_NO'=>$lock_no, |
---|
[1748] | 236 | ($conf['rate']==true?'RATE_YES':'RATE_NO')=>$html_check, |
---|
| 237 | ($conf['rate_anonymous']==true |
---|
[1044] | 238 | ? 'RATE_ANONYMOUS_YES' : 'RATE_ANONYMOUS_NO')=>$html_check, |
---|
[882] | 239 | 'CONF_GALLERY_TITLE' => $conf['gallery_title'], |
---|
[1071] | 240 | 'CONF_PAGE_BANNER' => $conf['page_banner'], |
---|
[1044] | 241 | 'CONF_GALLERY_URL' => $conf['gallery_url'], |
---|
[528] | 242 | )); |
---|
[1617] | 243 | |
---|
[1894] | 244 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 245 | { |
---|
| 246 | $template->merge_block_vars( |
---|
[1894] | 247 | 'main', |
---|
[1617] | 248 | array( |
---|
[1748] | 249 | strtoupper($checkbox) => ($conf[$checkbox]==true)?$html_check:'' |
---|
[1617] | 250 | ) |
---|
| 251 | ); |
---|
| 252 | } |
---|
[528] | 253 | break; |
---|
| 254 | } |
---|
[1884] | 255 | case 'history' : |
---|
| 256 | { |
---|
| 257 | //Necessary for merge_block_vars |
---|
| 258 | $template->assign_block_vars('history', array()); |
---|
| 259 | |
---|
| 260 | foreach( $history_checkboxes as $checkbox) |
---|
| 261 | { |
---|
| 262 | $template->merge_block_vars( |
---|
| 263 | 'history', |
---|
| 264 | array( |
---|
| 265 | strtoupper($checkbox) => ($conf[$checkbox]==true)?$html_check:'' |
---|
| 266 | ) |
---|
| 267 | ); |
---|
| 268 | } |
---|
| 269 | break; |
---|
| 270 | } |
---|
[528] | 271 | case 'comments' : |
---|
| 272 | { |
---|
| 273 | $template->assign_block_vars( |
---|
| 274 | 'comments', |
---|
| 275 | array( |
---|
| 276 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
| 277 | )); |
---|
[1617] | 278 | |
---|
| 279 | foreach( $comments_checkboxes as $checkbox) |
---|
| 280 | { |
---|
| 281 | $template->merge_block_vars( |
---|
| 282 | 'comments', |
---|
| 283 | array( |
---|
[1748] | 284 | strtoupper($checkbox) => ($conf[$checkbox]==true)?$html_check:'' |
---|
[1617] | 285 | ) |
---|
| 286 | ); |
---|
| 287 | } |
---|
[528] | 288 | break; |
---|
| 289 | } |
---|
| 290 | case 'default' : |
---|
| 291 | { |
---|
[1748] | 292 | $show_yes = ($conf['show_nb_comments']==true)?'checked="checked"':''; |
---|
| 293 | $show_no = ($conf['show_nb_comments']==false)?'checked="checked"':''; |
---|
[1763] | 294 | $hits_yes = ($conf['show_nb_hits']==true)?'checked="checked"':''; |
---|
| 295 | $hits_no = ($conf['show_nb_hits']==false)?'checked="checked"':''; |
---|
[1748] | 296 | $expand_yes = ($conf['auto_expand']==true)?'checked="checked"':''; |
---|
| 297 | $expand_no = ($conf['auto_expand']==false)?'checked="checked"':''; |
---|
[1071] | 298 | |
---|
[528] | 299 | $template->assign_block_vars( |
---|
| 300 | 'default', |
---|
| 301 | array( |
---|
| 302 | 'NB_IMAGE_LINE'=>$conf['nb_image_line'], |
---|
| 303 | 'NB_ROW_PAGE'=>$conf['nb_line_page'], |
---|
| 304 | 'CONF_RECENT'=>$conf['recent_period'], |
---|
| 305 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
[869] | 306 | 'MAXWIDTH'=>$conf['default_maxwidth'], |
---|
| 307 | 'MAXHEIGHT'=>$conf['default_maxheight'], |
---|
[528] | 308 | 'EXPAND_YES'=>$expand_yes, |
---|
| 309 | 'EXPAND_NO'=>$expand_no, |
---|
| 310 | 'SHOW_COMMENTS_YES'=>$show_yes, |
---|
[1763] | 311 | 'SHOW_COMMENTS_NO'=>$show_no, |
---|
| 312 | 'SHOW_HITS_YES'=>$hits_yes, |
---|
| 313 | 'SHOW_HITS_NO'=>$hits_no, |
---|
[528] | 314 | )); |
---|
[1071] | 315 | |
---|
[858] | 316 | $blockname = 'default.language_option'; |
---|
[1071] | 317 | |
---|
[858] | 318 | foreach (get_languages() as $language_code => $language_name) |
---|
| 319 | { |
---|
| 320 | if (isset($_POST['submit'])) |
---|
| 321 | { |
---|
| 322 | $selected = |
---|
| 323 | $_POST['default_language'] == $language_code |
---|
| 324 | ? 'selected="selected"' : ''; |
---|
| 325 | } |
---|
| 326 | else if ($conf['default_language'] == $language_code) |
---|
| 327 | { |
---|
| 328 | $selected = 'selected="selected"'; |
---|
| 329 | } |
---|
| 330 | else |
---|
| 331 | { |
---|
| 332 | $selected = ''; |
---|
| 333 | } |
---|
[1071] | 334 | |
---|
[858] | 335 | $template->assign_block_vars( |
---|
| 336 | $blockname, |
---|
| 337 | array( |
---|
| 338 | 'VALUE'=> $language_code, |
---|
| 339 | 'CONTENT' => $language_name, |
---|
| 340 | 'SELECTED' => $selected |
---|
| 341 | )); |
---|
| 342 | } |
---|
[541] | 343 | |
---|
[858] | 344 | $blockname = 'default.template_option'; |
---|
| 345 | |
---|
[1048] | 346 | foreach (get_pwg_themes() as $pwg_template) |
---|
[858] | 347 | { |
---|
| 348 | if (isset($_POST['submit'])) |
---|
| 349 | { |
---|
| 350 | $selected = |
---|
| 351 | $_POST['default_template'] == $pwg_template |
---|
| 352 | ? 'selected="selected"' : ''; |
---|
| 353 | } |
---|
| 354 | else if ($conf['default_template'] == $pwg_template) |
---|
| 355 | { |
---|
| 356 | $selected = 'selected="selected"'; |
---|
| 357 | } |
---|
| 358 | else |
---|
| 359 | { |
---|
| 360 | $selected = ''; |
---|
| 361 | } |
---|
[1071] | 362 | |
---|
[858] | 363 | $template->assign_block_vars( |
---|
| 364 | $blockname, |
---|
| 365 | array( |
---|
| 366 | 'VALUE'=> $pwg_template, |
---|
| 367 | 'CONTENT' => $pwg_template, |
---|
| 368 | 'SELECTED' => $selected |
---|
| 369 | ) |
---|
| 370 | ); |
---|
| 371 | } |
---|
| 372 | |
---|
[1071] | 373 | |
---|
[528] | 374 | break; |
---|
| 375 | } |
---|
| 376 | } |
---|
[2] | 377 | //----------------------------------------------------------- sending html code |
---|
[393] | 378 | $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
---|
[362] | 379 | ?> |
---|