[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', |
---|
[5618] | 89 | 'picture_download_icon', |
---|
[5293] | 90 | 'picture_navigation_icons', |
---|
| 91 | 'picture_navigation_thumb', |
---|
| 92 | ); |
---|
| 93 | |
---|
[5304] | 94 | $display_info_checkboxes = array( |
---|
| 95 | 'author', |
---|
| 96 | 'created_on', |
---|
| 97 | 'posted_on', |
---|
| 98 | 'dimensions', |
---|
| 99 | 'file', |
---|
| 100 | 'filesize', |
---|
| 101 | 'tags', |
---|
| 102 | 'categories', |
---|
| 103 | 'visits', |
---|
| 104 | 'average_rate', |
---|
[5723] | 105 | 'privacy_level', |
---|
[5304] | 106 | ); |
---|
| 107 | |
---|
[2] | 108 | //------------------------------ verification and registration of modifications |
---|
[1571] | 109 | if (isset($_POST['submit']) and !is_adviser()) |
---|
[2] | 110 | { |
---|
[21] | 111 | $int_pattern = '/^\d+$/'; |
---|
[1926] | 112 | |
---|
[512] | 113 | switch ($page['section']) |
---|
[2] | 114 | { |
---|
[1894] | 115 | case 'main' : |
---|
[130] | 116 | { |
---|
[1044] | 117 | if ( !url_is_remote($_POST['gallery_url']) ) |
---|
| 118 | { |
---|
[5021] | 119 | array_push($page['errors'], l10n('The gallery URL is not valid.')); |
---|
[1044] | 120 | } |
---|
[1894] | 121 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 122 | { |
---|
| 123 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 124 | } |
---|
[512] | 125 | break; |
---|
[130] | 126 | } |
---|
[1884] | 127 | case 'history' : |
---|
| 128 | { |
---|
| 129 | foreach( $history_checkboxes as $checkbox) |
---|
| 130 | { |
---|
| 131 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 132 | } |
---|
| 133 | break; |
---|
| 134 | } |
---|
[512] | 135 | case 'comments' : |
---|
| 136 | { |
---|
| 137 | // the number of comments per page must be an integer between 5 and 50 |
---|
| 138 | // included |
---|
| 139 | if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
---|
| 140 | or $_POST['nb_comment_page'] < 5 |
---|
| 141 | or $_POST['nb_comment_page'] > 50) |
---|
| 142 | { |
---|
[5021] | 143 | array_push($page['errors'], l10n('The number of comments a page must be between 5 and 50 included.')); |
---|
[512] | 144 | } |
---|
[1617] | 145 | foreach( $comments_checkboxes as $checkbox) |
---|
| 146 | { |
---|
| 147 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 148 | } |
---|
[512] | 149 | break; |
---|
| 150 | } |
---|
[2325] | 151 | case 'upload' : |
---|
| 152 | { |
---|
| 153 | foreach( $upload_checkboxes as $checkbox) |
---|
| 154 | { |
---|
| 155 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 156 | } |
---|
| 157 | break; |
---|
| 158 | } |
---|
[512] | 159 | case 'default' : |
---|
| 160 | { |
---|
[1926] | 161 | // Never go here |
---|
[512] | 162 | break; |
---|
| 163 | } |
---|
[5293] | 164 | case 'display' : |
---|
| 165 | { |
---|
| 166 | foreach( $display_checkboxes as $checkbox) |
---|
| 167 | { |
---|
| 168 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 169 | } |
---|
[5304] | 170 | foreach( $display_info_checkboxes as $checkbox) |
---|
| 171 | { |
---|
| 172 | $_POST['picture_informations'][$checkbox] = |
---|
| 173 | empty($_POST['picture_informations'][$checkbox])? false : true; |
---|
| 174 | } |
---|
| 175 | $_POST['picture_informations'] = addslashes(serialize($_POST['picture_informations'])); |
---|
[5293] | 176 | break; |
---|
| 177 | } |
---|
[2] | 178 | } |
---|
[1071] | 179 | |
---|
[528] | 180 | // updating configuration if no error found |
---|
[792] | 181 | if (count($page['errors']) == 0) |
---|
[345] | 182 | { |
---|
[1565] | 183 | //echo '<pre>'; print_r($_POST); echo '</pre>'; |
---|
[1748] | 184 | $result = pwg_query('SELECT param FROM '.CONFIG_TABLE); |
---|
[4325] | 185 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[512] | 186 | { |
---|
| 187 | if (isset($_POST[$row['param']])) |
---|
| 188 | { |
---|
[882] | 189 | $value = $_POST[$row['param']]; |
---|
[1071] | 190 | |
---|
| 191 | if ('gallery_title' == $row['param']) |
---|
[882] | 192 | { |
---|
| 193 | if (!$conf['allow_html_descriptions']) |
---|
| 194 | { |
---|
| 195 | $value = strip_tags($value); |
---|
| 196 | } |
---|
| 197 | } |
---|
[1071] | 198 | |
---|
[528] | 199 | $query = ' |
---|
| 200 | UPDATE '.CONFIG_TABLE.' |
---|
[1926] | 201 | SET value = \''. str_replace("\'", "''", $value).'\' |
---|
| 202 | WHERE param = \''.$row['param'].'\' |
---|
[528] | 203 | ;'; |
---|
[587] | 204 | pwg_query($query); |
---|
[512] | 205 | } |
---|
| 206 | } |
---|
[5021] | 207 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[345] | 208 | } |
---|
[527] | 209 | |
---|
[1748] | 210 | //------------------------------------------------------ $conf reinitialization |
---|
| 211 | load_conf_from_db(); |
---|
[1565] | 212 | } |
---|
| 213 | |
---|
[512] | 214 | //----------------------------------------------------- template initialization |
---|
[2530] | 215 | $template->set_filename('config', 'configuration.tpl'); |
---|
[512] | 216 | |
---|
[2226] | 217 | // TabSheet |
---|
| 218 | $tabsheet = new tabsheet(); |
---|
[1881] | 219 | // TabSheet initialization |
---|
[5021] | 220 | $tabsheet->add('main', l10n('Main'), $conf_link.'main'); |
---|
[5293] | 221 | $tabsheet->add('display', l10n('Display'), $conf_link.'display'); |
---|
[5021] | 222 | $tabsheet->add('history', l10n('History'), $conf_link.'history'); |
---|
| 223 | $tabsheet->add('comments', l10n('Comments'), $conf_link.'comments'); |
---|
| 224 | $tabsheet->add('upload', l10n('Upload'), $conf_link.'upload'); |
---|
[5293] | 225 | $tabsheet->add('default', l10n('Guest Settings'), $conf_link.'default'); |
---|
[2226] | 226 | // TabSheet selection |
---|
| 227 | $tabsheet->select($page['section']); |
---|
[1881] | 228 | // Assign tabsheet to template |
---|
[2226] | 229 | $tabsheet->assign(); |
---|
[1881] | 230 | |
---|
[2249] | 231 | $action = get_root_url().'admin.php?page=configuration'; |
---|
[528] | 232 | $action.= '&section='.$page['section']; |
---|
[21] | 233 | |
---|
[2288] | 234 | $template->assign( |
---|
[528] | 235 | array( |
---|
[5920] | 236 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=configuration', |
---|
[1004] | 237 | 'F_ACTION'=>$action |
---|
[528] | 238 | )); |
---|
| 239 | |
---|
[527] | 240 | switch ($page['section']) |
---|
[528] | 241 | { |
---|
[1894] | 242 | case 'main' : |
---|
[2] | 243 | { |
---|
[2249] | 244 | $template->assign( |
---|
[1894] | 245 | 'main', |
---|
[528] | 246 | array( |
---|
[2021] | 247 | 'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']), |
---|
| 248 | 'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']), |
---|
[1044] | 249 | 'CONF_GALLERY_URL' => $conf['gallery_url'], |
---|
[528] | 250 | )); |
---|
[1617] | 251 | |
---|
[2325] | 252 | foreach ($main_checkboxes as $checkbox) |
---|
[1617] | 253 | { |
---|
[2249] | 254 | $template->append( |
---|
[1894] | 255 | 'main', |
---|
[1617] | 256 | array( |
---|
[2249] | 257 | $checkbox => $conf[$checkbox] |
---|
| 258 | ), |
---|
| 259 | true |
---|
[1617] | 260 | ); |
---|
| 261 | } |
---|
[528] | 262 | break; |
---|
| 263 | } |
---|
[1884] | 264 | case 'history' : |
---|
| 265 | { |
---|
| 266 | //Necessary for merge_block_vars |
---|
[2325] | 267 | foreach ($history_checkboxes as $checkbox) |
---|
[1884] | 268 | { |
---|
[2249] | 269 | $template->append( |
---|
[1884] | 270 | 'history', |
---|
| 271 | array( |
---|
[2249] | 272 | $checkbox => $conf[$checkbox] |
---|
| 273 | ), |
---|
| 274 | true |
---|
[1884] | 275 | ); |
---|
| 276 | } |
---|
| 277 | break; |
---|
| 278 | } |
---|
[528] | 279 | case 'comments' : |
---|
| 280 | { |
---|
[2249] | 281 | $template->assign( |
---|
[528] | 282 | 'comments', |
---|
| 283 | array( |
---|
| 284 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
| 285 | )); |
---|
[1617] | 286 | |
---|
[2325] | 287 | foreach ($comments_checkboxes as $checkbox) |
---|
[1617] | 288 | { |
---|
[2249] | 289 | $template->append( |
---|
[1617] | 290 | 'comments', |
---|
| 291 | array( |
---|
[2249] | 292 | $checkbox => $conf[$checkbox] |
---|
| 293 | ), |
---|
| 294 | true |
---|
[1617] | 295 | ); |
---|
| 296 | } |
---|
[528] | 297 | break; |
---|
| 298 | } |
---|
[2325] | 299 | case 'upload' : |
---|
| 300 | { |
---|
| 301 | $template->assign( |
---|
| 302 | 'upload', |
---|
| 303 | array( |
---|
| 304 | 'upload_user_access_options'=> get_user_access_level_html_options(ACCESS_GUEST), |
---|
| 305 | 'upload_user_access_options_selected' => array($conf['upload_user_access']) |
---|
| 306 | ) |
---|
| 307 | ); |
---|
| 308 | //Necessary for merge_block_vars |
---|
| 309 | foreach ($upload_checkboxes as $checkbox) |
---|
| 310 | { |
---|
| 311 | $template->append( |
---|
| 312 | 'upload', |
---|
| 313 | array( |
---|
| 314 | $checkbox => $conf[$checkbox] |
---|
| 315 | ), |
---|
| 316 | true |
---|
| 317 | ); |
---|
| 318 | } |
---|
| 319 | break; |
---|
| 320 | } |
---|
[528] | 321 | case 'default' : |
---|
| 322 | { |
---|
[5994] | 323 | $edit_user = build_user($conf['guest_id'], false); |
---|
[1926] | 324 | include_once(PHPWG_ROOT_PATH.'profile.php'); |
---|
[1071] | 325 | |
---|
[1926] | 326 | $errors = array(); |
---|
| 327 | if ( !is_adviser() ) |
---|
[858] | 328 | { |
---|
[1926] | 329 | if (save_profile_from_post($edit_user, $errors)) |
---|
[858] | 330 | { |
---|
[1926] | 331 | // Reload user |
---|
[5995] | 332 | $edit_user = build_user($conf['guest_id'], false); |
---|
[5021] | 333 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[858] | 334 | } |
---|
| 335 | } |
---|
[1926] | 336 | $page['errors'] = array_merge($page['errors'], $errors); |
---|
[541] | 337 | |
---|
[1926] | 338 | load_profile_in_template( |
---|
| 339 | $action, |
---|
| 340 | '', |
---|
| 341 | $edit_user |
---|
| 342 | ); |
---|
[2249] | 343 | $template->assign('default', array()); |
---|
[528] | 344 | break; |
---|
| 345 | } |
---|
[5293] | 346 | case 'display' : |
---|
| 347 | { |
---|
| 348 | foreach ($display_checkboxes as $checkbox) |
---|
| 349 | { |
---|
| 350 | $template->append( |
---|
| 351 | 'display', |
---|
| 352 | array( |
---|
| 353 | $checkbox => $conf[$checkbox] |
---|
| 354 | ), |
---|
| 355 | true |
---|
| 356 | ); |
---|
| 357 | } |
---|
[5304] | 358 | $template->append( |
---|
| 359 | 'display', |
---|
| 360 | array( |
---|
| 361 | 'picture_informations' => unserialize($conf['picture_informations']) |
---|
| 362 | ), |
---|
| 363 | true |
---|
| 364 | ); |
---|
[5293] | 365 | break; |
---|
| 366 | } |
---|
[528] | 367 | } |
---|
[1926] | 368 | |
---|
[2] | 369 | //----------------------------------------------------------- sending html code |
---|
[393] | 370 | $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
---|
[362] | 371 | ?> |
---|