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