[362] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[5196] | 5 | // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
---|
[2297] | 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
[2] | 23 | |
---|
[527] | 24 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
[393] | 25 | { |
---|
[1072] | 26 | die ("Hacking attempt!"); |
---|
[393] | 27 | } |
---|
[527] | 28 | |
---|
[1072] | 29 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[2226] | 30 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
[1072] | 31 | |
---|
| 32 | // +-----------------------------------------------------------------------+ |
---|
| 33 | // | Check Access and exit when user status is not ok | |
---|
| 34 | // +-----------------------------------------------------------------------+ |
---|
| 35 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 36 | |
---|
[512] | 37 | //-------------------------------------------------------- sections definitions |
---|
| 38 | if (!isset($_GET['section'])) |
---|
| 39 | { |
---|
[1894] | 40 | $page['section'] = 'main'; |
---|
[512] | 41 | } |
---|
| 42 | else |
---|
| 43 | { |
---|
| 44 | $page['section'] = $_GET['section']; |
---|
| 45 | } |
---|
[1617] | 46 | |
---|
[1894] | 47 | $main_checkboxes = array( |
---|
[2249] | 48 | 'gallery_locked', |
---|
[2032] | 49 | 'allow_user_registration', |
---|
| 50 | 'obligatory_user_mail_address', |
---|
[1920] | 51 | 'rate', |
---|
| 52 | 'rate_anonymous', |
---|
[1652] | 53 | 'email_admin_on_new_user', |
---|
[5328] | 54 | 'allow_user_customization', |
---|
[1617] | 55 | ); |
---|
| 56 | |
---|
[1884] | 57 | $history_checkboxes = array( |
---|
| 58 | 'log', |
---|
| 59 | 'history_admin', |
---|
| 60 | 'history_guest' |
---|
| 61 | ); |
---|
| 62 | |
---|
[2325] | 63 | $upload_checkboxes = array( |
---|
| 64 | 'upload_link_everytime', |
---|
| 65 | 'email_admin_on_picture_uploaded', |
---|
| 66 | ); |
---|
| 67 | |
---|
[1617] | 68 | $comments_checkboxes = array( |
---|
| 69 | 'comments_forall', |
---|
| 70 | 'comments_validation', |
---|
| 71 | 'email_admin_on_comment', |
---|
| 72 | 'email_admin_on_comment_validation', |
---|
[3445] | 73 | 'user_can_delete_comment', |
---|
| 74 | 'user_can_edit_comment', |
---|
| 75 | 'email_admin_on_comment_edition', |
---|
| 76 | 'email_admin_on_comment_deletion' |
---|
[1617] | 77 | ); |
---|
| 78 | |
---|
[5293] | 79 | $display_checkboxes = array( |
---|
| 80 | 'menubar_filter_icon', |
---|
| 81 | 'index_sort_order_input', |
---|
| 82 | 'index_flat_icon', |
---|
| 83 | 'index_posted_date_icon', |
---|
| 84 | 'index_created_date_icon', |
---|
| 85 | 'index_slideshow_icon', |
---|
| 86 | 'picture_metadata_icon', |
---|
| 87 | 'picture_slideshow_icon', |
---|
| 88 | 'picture_favorite_icon', |
---|
| 89 | 'picture_navigation_icons', |
---|
| 90 | 'picture_navigation_thumb', |
---|
| 91 | ); |
---|
| 92 | |
---|
[5304] | 93 | $display_info_checkboxes = array( |
---|
| 94 | 'author', |
---|
| 95 | 'created_on', |
---|
| 96 | 'posted_on', |
---|
| 97 | 'dimensions', |
---|
| 98 | 'file', |
---|
| 99 | 'filesize', |
---|
| 100 | 'tags', |
---|
| 101 | 'categories', |
---|
| 102 | 'visits', |
---|
| 103 | 'average_rate', |
---|
| 104 | ); |
---|
| 105 | |
---|
[2] | 106 | //------------------------------ verification and registration of modifications |
---|
[1571] | 107 | if (isset($_POST['submit']) and !is_adviser()) |
---|
[2] | 108 | { |
---|
[21] | 109 | $int_pattern = '/^\d+$/'; |
---|
[1926] | 110 | |
---|
[512] | 111 | switch ($page['section']) |
---|
[2] | 112 | { |
---|
[1894] | 113 | case 'main' : |
---|
[130] | 114 | { |
---|
[1044] | 115 | if ( !url_is_remote($_POST['gallery_url']) ) |
---|
| 116 | { |
---|
[5021] | 117 | array_push($page['errors'], l10n('The gallery URL is not valid.')); |
---|
[1044] | 118 | } |
---|
[1894] | 119 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 120 | { |
---|
| 121 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 122 | } |
---|
[512] | 123 | break; |
---|
[130] | 124 | } |
---|
[1884] | 125 | case 'history' : |
---|
| 126 | { |
---|
| 127 | foreach( $history_checkboxes as $checkbox) |
---|
| 128 | { |
---|
| 129 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 130 | } |
---|
| 131 | break; |
---|
| 132 | } |
---|
[512] | 133 | case 'comments' : |
---|
| 134 | { |
---|
| 135 | // the number of comments per page must be an integer between 5 and 50 |
---|
| 136 | // included |
---|
| 137 | if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
---|
| 138 | or $_POST['nb_comment_page'] < 5 |
---|
| 139 | or $_POST['nb_comment_page'] > 50) |
---|
| 140 | { |
---|
[5021] | 141 | array_push($page['errors'], l10n('The number of comments a page must be between 5 and 50 included.')); |
---|
[512] | 142 | } |
---|
[1617] | 143 | foreach( $comments_checkboxes as $checkbox) |
---|
| 144 | { |
---|
| 145 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 146 | } |
---|
[512] | 147 | break; |
---|
| 148 | } |
---|
[2325] | 149 | case 'upload' : |
---|
| 150 | { |
---|
| 151 | foreach( $upload_checkboxes as $checkbox) |
---|
| 152 | { |
---|
| 153 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 154 | } |
---|
| 155 | break; |
---|
| 156 | } |
---|
[512] | 157 | case 'default' : |
---|
| 158 | { |
---|
[1926] | 159 | // Never go here |
---|
[512] | 160 | break; |
---|
| 161 | } |
---|
[5293] | 162 | case 'display' : |
---|
| 163 | { |
---|
| 164 | foreach( $display_checkboxes as $checkbox) |
---|
| 165 | { |
---|
| 166 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 167 | } |
---|
[5304] | 168 | foreach( $display_info_checkboxes as $checkbox) |
---|
| 169 | { |
---|
| 170 | $_POST['picture_informations'][$checkbox] = |
---|
| 171 | empty($_POST['picture_informations'][$checkbox])? false : true; |
---|
| 172 | } |
---|
| 173 | $_POST['picture_informations'] = addslashes(serialize($_POST['picture_informations'])); |
---|
[5293] | 174 | break; |
---|
| 175 | } |
---|
[2] | 176 | } |
---|
[1071] | 177 | |
---|
[528] | 178 | // updating configuration if no error found |
---|
[792] | 179 | if (count($page['errors']) == 0) |
---|
[345] | 180 | { |
---|
[1565] | 181 | //echo '<pre>'; print_r($_POST); echo '</pre>'; |
---|
[1748] | 182 | $result = pwg_query('SELECT param FROM '.CONFIG_TABLE); |
---|
[4325] | 183 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[512] | 184 | { |
---|
| 185 | if (isset($_POST[$row['param']])) |
---|
| 186 | { |
---|
[882] | 187 | $value = $_POST[$row['param']]; |
---|
[1071] | 188 | |
---|
| 189 | if ('gallery_title' == $row['param']) |
---|
[882] | 190 | { |
---|
| 191 | if (!$conf['allow_html_descriptions']) |
---|
| 192 | { |
---|
| 193 | $value = strip_tags($value); |
---|
| 194 | } |
---|
| 195 | } |
---|
[1071] | 196 | |
---|
[528] | 197 | $query = ' |
---|
| 198 | UPDATE '.CONFIG_TABLE.' |
---|
[1926] | 199 | SET value = \''. str_replace("\'", "''", $value).'\' |
---|
| 200 | WHERE param = \''.$row['param'].'\' |
---|
[528] | 201 | ;'; |
---|
[587] | 202 | pwg_query($query); |
---|
[512] | 203 | } |
---|
| 204 | } |
---|
[5021] | 205 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[345] | 206 | } |
---|
[527] | 207 | |
---|
[1748] | 208 | //------------------------------------------------------ $conf reinitialization |
---|
| 209 | load_conf_from_db(); |
---|
[1565] | 210 | } |
---|
| 211 | |
---|
[512] | 212 | //----------------------------------------------------- template initialization |
---|
[2530] | 213 | $template->set_filename('config', 'configuration.tpl'); |
---|
[512] | 214 | |
---|
[2226] | 215 | // TabSheet |
---|
| 216 | $tabsheet = new tabsheet(); |
---|
[1881] | 217 | // TabSheet initialization |
---|
[5021] | 218 | $tabsheet->add('main', l10n('Main'), $conf_link.'main'); |
---|
[5293] | 219 | $tabsheet->add('display', l10n('Display'), $conf_link.'display'); |
---|
[5021] | 220 | $tabsheet->add('history', l10n('History'), $conf_link.'history'); |
---|
| 221 | $tabsheet->add('comments', l10n('Comments'), $conf_link.'comments'); |
---|
| 222 | $tabsheet->add('upload', l10n('Upload'), $conf_link.'upload'); |
---|
[5293] | 223 | $tabsheet->add('default', l10n('Guest Settings'), $conf_link.'default'); |
---|
[2226] | 224 | // TabSheet selection |
---|
| 225 | $tabsheet->select($page['section']); |
---|
[1881] | 226 | // Assign tabsheet to template |
---|
[2226] | 227 | $tabsheet->assign(); |
---|
[1881] | 228 | |
---|
[2249] | 229 | $action = get_root_url().'admin.php?page=configuration'; |
---|
[528] | 230 | $action.= '&section='.$page['section']; |
---|
[21] | 231 | |
---|
[2288] | 232 | $template->assign( |
---|
[528] | 233 | array( |
---|
[2249] | 234 | 'U_HELP' => get_root_url().'popuphelp.php?page=configuration', |
---|
[1004] | 235 | 'F_ACTION'=>$action |
---|
[528] | 236 | )); |
---|
| 237 | |
---|
[527] | 238 | switch ($page['section']) |
---|
[528] | 239 | { |
---|
[1894] | 240 | case 'main' : |
---|
[2] | 241 | { |
---|
[2249] | 242 | $template->assign( |
---|
[1894] | 243 | 'main', |
---|
[528] | 244 | array( |
---|
[2021] | 245 | 'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']), |
---|
| 246 | 'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']), |
---|
[1044] | 247 | 'CONF_GALLERY_URL' => $conf['gallery_url'], |
---|
[528] | 248 | )); |
---|
[1617] | 249 | |
---|
[2325] | 250 | foreach ($main_checkboxes as $checkbox) |
---|
[1617] | 251 | { |
---|
[2249] | 252 | $template->append( |
---|
[1894] | 253 | 'main', |
---|
[1617] | 254 | array( |
---|
[2249] | 255 | $checkbox => $conf[$checkbox] |
---|
| 256 | ), |
---|
| 257 | true |
---|
[1617] | 258 | ); |
---|
| 259 | } |
---|
[528] | 260 | break; |
---|
| 261 | } |
---|
[1884] | 262 | case 'history' : |
---|
| 263 | { |
---|
| 264 | //Necessary for merge_block_vars |
---|
[2325] | 265 | foreach ($history_checkboxes as $checkbox) |
---|
[1884] | 266 | { |
---|
[2249] | 267 | $template->append( |
---|
[1884] | 268 | 'history', |
---|
| 269 | array( |
---|
[2249] | 270 | $checkbox => $conf[$checkbox] |
---|
| 271 | ), |
---|
| 272 | true |
---|
[1884] | 273 | ); |
---|
| 274 | } |
---|
| 275 | break; |
---|
| 276 | } |
---|
[528] | 277 | case 'comments' : |
---|
| 278 | { |
---|
[2249] | 279 | $template->assign( |
---|
[528] | 280 | 'comments', |
---|
| 281 | array( |
---|
| 282 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
| 283 | )); |
---|
[1617] | 284 | |
---|
[2325] | 285 | foreach ($comments_checkboxes as $checkbox) |
---|
[1617] | 286 | { |
---|
[2249] | 287 | $template->append( |
---|
[1617] | 288 | 'comments', |
---|
| 289 | array( |
---|
[2249] | 290 | $checkbox => $conf[$checkbox] |
---|
| 291 | ), |
---|
| 292 | true |
---|
[1617] | 293 | ); |
---|
| 294 | } |
---|
[528] | 295 | break; |
---|
| 296 | } |
---|
[2325] | 297 | case 'upload' : |
---|
| 298 | { |
---|
| 299 | $template->assign( |
---|
| 300 | 'upload', |
---|
| 301 | array( |
---|
| 302 | 'upload_user_access_options'=> get_user_access_level_html_options(ACCESS_GUEST), |
---|
| 303 | 'upload_user_access_options_selected' => array($conf['upload_user_access']) |
---|
| 304 | ) |
---|
| 305 | ); |
---|
| 306 | //Necessary for merge_block_vars |
---|
| 307 | foreach ($upload_checkboxes as $checkbox) |
---|
| 308 | { |
---|
| 309 | $template->append( |
---|
| 310 | 'upload', |
---|
| 311 | array( |
---|
| 312 | $checkbox => $conf[$checkbox] |
---|
| 313 | ), |
---|
| 314 | true |
---|
| 315 | ); |
---|
| 316 | } |
---|
| 317 | break; |
---|
| 318 | } |
---|
[528] | 319 | case 'default' : |
---|
| 320 | { |
---|
[1926] | 321 | $edit_user = build_user($conf['default_user_id'], false); |
---|
| 322 | include_once(PHPWG_ROOT_PATH.'profile.php'); |
---|
[1071] | 323 | |
---|
[1926] | 324 | $errors = array(); |
---|
| 325 | if ( !is_adviser() ) |
---|
[858] | 326 | { |
---|
[1926] | 327 | if (save_profile_from_post($edit_user, $errors)) |
---|
[858] | 328 | { |
---|
[1926] | 329 | // Reload user |
---|
| 330 | $edit_user = build_user($conf['default_user_id'], false); |
---|
[5021] | 331 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[858] | 332 | } |
---|
| 333 | } |
---|
[1926] | 334 | $page['errors'] = array_merge($page['errors'], $errors); |
---|
[541] | 335 | |
---|
[1926] | 336 | load_profile_in_template( |
---|
| 337 | $action, |
---|
| 338 | '', |
---|
| 339 | $edit_user |
---|
| 340 | ); |
---|
[2249] | 341 | $template->assign('default', array()); |
---|
[528] | 342 | break; |
---|
| 343 | } |
---|
[5293] | 344 | case 'display' : |
---|
| 345 | { |
---|
| 346 | foreach ($display_checkboxes as $checkbox) |
---|
| 347 | { |
---|
| 348 | $template->append( |
---|
| 349 | 'display', |
---|
| 350 | array( |
---|
| 351 | $checkbox => $conf[$checkbox] |
---|
| 352 | ), |
---|
| 353 | true |
---|
| 354 | ); |
---|
| 355 | } |
---|
[5304] | 356 | $template->append( |
---|
| 357 | 'display', |
---|
| 358 | array( |
---|
| 359 | 'picture_informations' => unserialize($conf['picture_informations']) |
---|
| 360 | ), |
---|
| 361 | true |
---|
| 362 | ); |
---|
[5293] | 363 | break; |
---|
| 364 | } |
---|
[528] | 365 | } |
---|
[1926] | 366 | |
---|
[2] | 367 | //----------------------------------------------------------- sending html code |
---|
[393] | 368 | $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
---|
[362] | 369 | ?> |
---|