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