[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 | { |
---|
[1894] | 112 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 113 | { |
---|
| 114 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 115 | } |
---|
[512] | 116 | break; |
---|
[130] | 117 | } |
---|
[1884] | 118 | case 'history' : |
---|
| 119 | { |
---|
| 120 | foreach( $history_checkboxes as $checkbox) |
---|
| 121 | { |
---|
| 122 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 123 | } |
---|
| 124 | break; |
---|
| 125 | } |
---|
[512] | 126 | case 'comments' : |
---|
| 127 | { |
---|
| 128 | // the number of comments per page must be an integer between 5 and 50 |
---|
| 129 | // included |
---|
| 130 | if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
---|
| 131 | or $_POST['nb_comment_page'] < 5 |
---|
| 132 | or $_POST['nb_comment_page'] > 50) |
---|
| 133 | { |
---|
[5021] | 134 | array_push($page['errors'], l10n('The number of comments a page must be between 5 and 50 included.')); |
---|
[512] | 135 | } |
---|
[1617] | 136 | foreach( $comments_checkboxes as $checkbox) |
---|
| 137 | { |
---|
| 138 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 139 | } |
---|
[512] | 140 | break; |
---|
| 141 | } |
---|
| 142 | case 'default' : |
---|
| 143 | { |
---|
[1926] | 144 | // Never go here |
---|
[512] | 145 | break; |
---|
| 146 | } |
---|
[5293] | 147 | case 'display' : |
---|
| 148 | { |
---|
| 149 | foreach( $display_checkboxes as $checkbox) |
---|
| 150 | { |
---|
| 151 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 152 | } |
---|
[5304] | 153 | foreach( $display_info_checkboxes as $checkbox) |
---|
| 154 | { |
---|
| 155 | $_POST['picture_informations'][$checkbox] = |
---|
| 156 | empty($_POST['picture_informations'][$checkbox])? false : true; |
---|
| 157 | } |
---|
| 158 | $_POST['picture_informations'] = addslashes(serialize($_POST['picture_informations'])); |
---|
[5293] | 159 | break; |
---|
| 160 | } |
---|
[2] | 161 | } |
---|
[1071] | 162 | |
---|
[528] | 163 | // updating configuration if no error found |
---|
[792] | 164 | if (count($page['errors']) == 0) |
---|
[345] | 165 | { |
---|
[1565] | 166 | //echo '<pre>'; print_r($_POST); echo '</pre>'; |
---|
[1748] | 167 | $result = pwg_query('SELECT param FROM '.CONFIG_TABLE); |
---|
[4325] | 168 | while ($row = pwg_db_fetch_assoc($result)) |
---|
[512] | 169 | { |
---|
| 170 | if (isset($_POST[$row['param']])) |
---|
| 171 | { |
---|
[882] | 172 | $value = $_POST[$row['param']]; |
---|
[1071] | 173 | |
---|
| 174 | if ('gallery_title' == $row['param']) |
---|
[882] | 175 | { |
---|
| 176 | if (!$conf['allow_html_descriptions']) |
---|
| 177 | { |
---|
| 178 | $value = strip_tags($value); |
---|
| 179 | } |
---|
| 180 | } |
---|
[1071] | 181 | |
---|
[528] | 182 | $query = ' |
---|
| 183 | UPDATE '.CONFIG_TABLE.' |
---|
[1926] | 184 | SET value = \''. str_replace("\'", "''", $value).'\' |
---|
| 185 | WHERE param = \''.$row['param'].'\' |
---|
[528] | 186 | ;'; |
---|
[587] | 187 | pwg_query($query); |
---|
[512] | 188 | } |
---|
| 189 | } |
---|
[5021] | 190 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[345] | 191 | } |
---|
[527] | 192 | |
---|
[1748] | 193 | //------------------------------------------------------ $conf reinitialization |
---|
| 194 | load_conf_from_db(); |
---|
[1565] | 195 | } |
---|
| 196 | |
---|
[512] | 197 | //----------------------------------------------------- template initialization |
---|
[2530] | 198 | $template->set_filename('config', 'configuration.tpl'); |
---|
[512] | 199 | |
---|
[2226] | 200 | // TabSheet |
---|
| 201 | $tabsheet = new tabsheet(); |
---|
[1881] | 202 | // TabSheet initialization |
---|
[5021] | 203 | $tabsheet->add('main', l10n('Main'), $conf_link.'main'); |
---|
[5293] | 204 | $tabsheet->add('display', l10n('Display'), $conf_link.'display'); |
---|
[5021] | 205 | $tabsheet->add('history', l10n('History'), $conf_link.'history'); |
---|
| 206 | $tabsheet->add('comments', l10n('Comments'), $conf_link.'comments'); |
---|
[5293] | 207 | $tabsheet->add('default', l10n('Guest Settings'), $conf_link.'default'); |
---|
[2226] | 208 | // TabSheet selection |
---|
| 209 | $tabsheet->select($page['section']); |
---|
[1881] | 210 | // Assign tabsheet to template |
---|
[2226] | 211 | $tabsheet->assign(); |
---|
[1881] | 212 | |
---|
[2249] | 213 | $action = get_root_url().'admin.php?page=configuration'; |
---|
[528] | 214 | $action.= '&section='.$page['section']; |
---|
[21] | 215 | |
---|
[2288] | 216 | $template->assign( |
---|
[528] | 217 | array( |
---|
[5920] | 218 | 'U_HELP' => get_root_url().'admin/popuphelp.php?page=configuration', |
---|
[1004] | 219 | 'F_ACTION'=>$action |
---|
[528] | 220 | )); |
---|
| 221 | |
---|
[527] | 222 | switch ($page['section']) |
---|
[528] | 223 | { |
---|
[1894] | 224 | case 'main' : |
---|
[2] | 225 | { |
---|
[2249] | 226 | $template->assign( |
---|
[1894] | 227 | 'main', |
---|
[528] | 228 | array( |
---|
[2021] | 229 | 'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']), |
---|
| 230 | 'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']), |
---|
[1044] | 231 | 'CONF_GALLERY_URL' => $conf['gallery_url'], |
---|
[8626] | 232 | 'week_starts_on_options' => array( |
---|
| 233 | 'sunday' => $lang['day'][0], |
---|
| 234 | 'monday' => $lang['day'][1], |
---|
| 235 | ), |
---|
| 236 | 'week_starts_on_options_selected' => $conf['week_starts_on'], |
---|
[528] | 237 | )); |
---|
[1617] | 238 | |
---|
[2325] | 239 | foreach ($main_checkboxes as $checkbox) |
---|
[1617] | 240 | { |
---|
[2249] | 241 | $template->append( |
---|
[1894] | 242 | 'main', |
---|
[1617] | 243 | array( |
---|
[2249] | 244 | $checkbox => $conf[$checkbox] |
---|
| 245 | ), |
---|
| 246 | true |
---|
[1617] | 247 | ); |
---|
| 248 | } |
---|
[528] | 249 | break; |
---|
| 250 | } |
---|
[1884] | 251 | case 'history' : |
---|
| 252 | { |
---|
| 253 | //Necessary for merge_block_vars |
---|
[2325] | 254 | foreach ($history_checkboxes as $checkbox) |
---|
[1884] | 255 | { |
---|
[2249] | 256 | $template->append( |
---|
[1884] | 257 | 'history', |
---|
| 258 | array( |
---|
[2249] | 259 | $checkbox => $conf[$checkbox] |
---|
| 260 | ), |
---|
| 261 | true |
---|
[1884] | 262 | ); |
---|
| 263 | } |
---|
| 264 | break; |
---|
| 265 | } |
---|
[528] | 266 | case 'comments' : |
---|
| 267 | { |
---|
[2249] | 268 | $template->assign( |
---|
[528] | 269 | 'comments', |
---|
| 270 | array( |
---|
| 271 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
| 272 | )); |
---|
[1617] | 273 | |
---|
[2325] | 274 | foreach ($comments_checkboxes as $checkbox) |
---|
[1617] | 275 | { |
---|
[2249] | 276 | $template->append( |
---|
[1617] | 277 | 'comments', |
---|
| 278 | array( |
---|
[2249] | 279 | $checkbox => $conf[$checkbox] |
---|
| 280 | ), |
---|
| 281 | true |
---|
[1617] | 282 | ); |
---|
| 283 | } |
---|
[528] | 284 | break; |
---|
| 285 | } |
---|
| 286 | case 'default' : |
---|
| 287 | { |
---|
[5994] | 288 | $edit_user = build_user($conf['guest_id'], false); |
---|
[1926] | 289 | include_once(PHPWG_ROOT_PATH.'profile.php'); |
---|
[1071] | 290 | |
---|
[1926] | 291 | $errors = array(); |
---|
[8126] | 292 | if (save_profile_from_post($edit_user, $errors)) |
---|
[858] | 293 | { |
---|
[8126] | 294 | // Reload user |
---|
| 295 | $edit_user = build_user($conf['guest_id'], false); |
---|
| 296 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[858] | 297 | } |
---|
[1926] | 298 | $page['errors'] = array_merge($page['errors'], $errors); |
---|
[541] | 299 | |
---|
[1926] | 300 | load_profile_in_template( |
---|
| 301 | $action, |
---|
| 302 | '', |
---|
| 303 | $edit_user |
---|
| 304 | ); |
---|
[2249] | 305 | $template->assign('default', array()); |
---|
[528] | 306 | break; |
---|
| 307 | } |
---|
[5293] | 308 | case 'display' : |
---|
| 309 | { |
---|
| 310 | foreach ($display_checkboxes as $checkbox) |
---|
| 311 | { |
---|
| 312 | $template->append( |
---|
| 313 | 'display', |
---|
| 314 | array( |
---|
| 315 | $checkbox => $conf[$checkbox] |
---|
| 316 | ), |
---|
| 317 | true |
---|
| 318 | ); |
---|
| 319 | } |
---|
[5304] | 320 | $template->append( |
---|
| 321 | 'display', |
---|
| 322 | array( |
---|
| 323 | 'picture_informations' => unserialize($conf['picture_informations']) |
---|
| 324 | ), |
---|
| 325 | true |
---|
| 326 | ); |
---|
[5293] | 327 | break; |
---|
| 328 | } |
---|
[528] | 329 | } |
---|
[1926] | 330 | |
---|
[2] | 331 | //----------------------------------------------------------- sending html code |
---|
[393] | 332 | $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
---|
[362] | 333 | ?> |
---|