[362] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[2226] | 5 | // | Copyright (C) 2003-2008 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[362] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[362] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2008-03-05 01:50:08 +0000 (Wed, 05 Mar 2008) $ |
---|
| 10 | // | last modifier : $Author: rvelices $ |
---|
| 11 | // | revision : $Revision: 2249 $ |
---|
| 12 | // +-----------------------------------------------------------------------+ |
---|
| 13 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 14 | // | it under the terms of the GNU General Public License as published by | |
---|
| 15 | // | the Free Software Foundation | |
---|
| 16 | // | | |
---|
| 17 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 20 | // | General Public License for more details. | |
---|
| 21 | // | | |
---|
| 22 | // | You should have received a copy of the GNU General Public License | |
---|
| 23 | // | along with this program; if not, write to the Free Software | |
---|
| 24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 25 | // | USA. | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
[2] | 27 | |
---|
[527] | 28 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
[393] | 29 | { |
---|
[1072] | 30 | die ("Hacking attempt!"); |
---|
[393] | 31 | } |
---|
[527] | 32 | |
---|
[1072] | 33 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[2226] | 34 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
[1072] | 35 | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
| 37 | // | Check Access and exit when user status is not ok | |
---|
| 38 | // +-----------------------------------------------------------------------+ |
---|
| 39 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 40 | |
---|
[512] | 41 | //-------------------------------------------------------- sections definitions |
---|
| 42 | if (!isset($_GET['section'])) |
---|
| 43 | { |
---|
[1894] | 44 | $page['section'] = 'main'; |
---|
[512] | 45 | } |
---|
| 46 | else |
---|
| 47 | { |
---|
| 48 | $page['section'] = $_GET['section']; |
---|
| 49 | } |
---|
[1617] | 50 | |
---|
[1894] | 51 | $main_checkboxes = array( |
---|
[2249] | 52 | 'gallery_locked', |
---|
[2032] | 53 | 'allow_user_registration', |
---|
| 54 | 'obligatory_user_mail_address', |
---|
[1920] | 55 | 'rate', |
---|
| 56 | 'rate_anonymous', |
---|
[1652] | 57 | 'email_admin_on_new_user', |
---|
[1901] | 58 | 'email_admin_on_picture_uploaded', |
---|
[1617] | 59 | ); |
---|
| 60 | |
---|
[1884] | 61 | $history_checkboxes = array( |
---|
| 62 | 'log', |
---|
| 63 | 'history_admin', |
---|
| 64 | 'history_guest' |
---|
| 65 | ); |
---|
| 66 | |
---|
[1617] | 67 | $comments_checkboxes = array( |
---|
| 68 | 'comments_forall', |
---|
| 69 | 'comments_validation', |
---|
| 70 | 'email_admin_on_comment', |
---|
| 71 | 'email_admin_on_comment_validation', |
---|
| 72 | ); |
---|
| 73 | |
---|
[2] | 74 | //------------------------------ verification and registration of modifications |
---|
[1571] | 75 | if (isset($_POST['submit']) and !is_adviser()) |
---|
[2] | 76 | { |
---|
[21] | 77 | $int_pattern = '/^\d+$/'; |
---|
[1926] | 78 | |
---|
[512] | 79 | switch ($page['section']) |
---|
[2] | 80 | { |
---|
[1894] | 81 | case 'main' : |
---|
[130] | 82 | { |
---|
[1044] | 83 | if ( !url_is_remote($_POST['gallery_url']) ) |
---|
| 84 | { |
---|
[2201] | 85 | array_push($page['errors'], l10n('conf_gallery_url_error')); |
---|
[1044] | 86 | } |
---|
[1894] | 87 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 88 | { |
---|
| 89 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 90 | } |
---|
[512] | 91 | break; |
---|
[130] | 92 | } |
---|
[1884] | 93 | case 'history' : |
---|
| 94 | { |
---|
| 95 | foreach( $history_checkboxes as $checkbox) |
---|
| 96 | { |
---|
| 97 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 98 | } |
---|
| 99 | break; |
---|
| 100 | } |
---|
[512] | 101 | case 'comments' : |
---|
| 102 | { |
---|
| 103 | // the number of comments per page must be an integer between 5 and 50 |
---|
| 104 | // included |
---|
| 105 | if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
---|
| 106 | or $_POST['nb_comment_page'] < 5 |
---|
| 107 | or $_POST['nb_comment_page'] > 50) |
---|
| 108 | { |
---|
[2201] | 109 | array_push($page['errors'], l10n('conf_nb_comment_page_error')); |
---|
[512] | 110 | } |
---|
[1617] | 111 | foreach( $comments_checkboxes as $checkbox) |
---|
| 112 | { |
---|
| 113 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 114 | } |
---|
[512] | 115 | break; |
---|
| 116 | } |
---|
| 117 | case 'default' : |
---|
| 118 | { |
---|
[1926] | 119 | // Never go here |
---|
[512] | 120 | break; |
---|
| 121 | } |
---|
[2] | 122 | } |
---|
[1071] | 123 | |
---|
[528] | 124 | // updating configuration if no error found |
---|
[792] | 125 | if (count($page['errors']) == 0) |
---|
[345] | 126 | { |
---|
[1565] | 127 | //echo '<pre>'; print_r($_POST); echo '</pre>'; |
---|
[1748] | 128 | $result = pwg_query('SELECT param FROM '.CONFIG_TABLE); |
---|
[512] | 129 | while ($row = mysql_fetch_array($result)) |
---|
| 130 | { |
---|
| 131 | if (isset($_POST[$row['param']])) |
---|
| 132 | { |
---|
[882] | 133 | $value = $_POST[$row['param']]; |
---|
[1071] | 134 | |
---|
| 135 | if ('gallery_title' == $row['param']) |
---|
[882] | 136 | { |
---|
| 137 | if (!$conf['allow_html_descriptions']) |
---|
| 138 | { |
---|
| 139 | $value = strip_tags($value); |
---|
| 140 | } |
---|
| 141 | } |
---|
[1071] | 142 | |
---|
[528] | 143 | $query = ' |
---|
| 144 | UPDATE '.CONFIG_TABLE.' |
---|
[1926] | 145 | SET value = \''. str_replace("\'", "''", $value).'\' |
---|
| 146 | WHERE param = \''.$row['param'].'\' |
---|
[528] | 147 | ;'; |
---|
[587] | 148 | pwg_query($query); |
---|
[512] | 149 | } |
---|
| 150 | } |
---|
[2201] | 151 | array_push($page['infos'], l10n('conf_confirmation')); |
---|
[345] | 152 | } |
---|
[527] | 153 | |
---|
[1748] | 154 | //------------------------------------------------------ $conf reinitialization |
---|
| 155 | load_conf_from_db(); |
---|
[1565] | 156 | } |
---|
| 157 | |
---|
[512] | 158 | //----------------------------------------------------- template initialization |
---|
[1881] | 159 | $template->set_filename('config', 'admin/configuration.tpl'); |
---|
[512] | 160 | |
---|
[2226] | 161 | // TabSheet |
---|
| 162 | $tabsheet = new tabsheet(); |
---|
[1881] | 163 | // TabSheet initialization |
---|
[2226] | 164 | $tabsheet->add('main', l10n('conf_main_title'), $conf_link.'main'); |
---|
| 165 | $tabsheet->add('history', l10n('conf_history_title'), $conf_link.'history'); |
---|
| 166 | $tabsheet->add('comments', l10n('conf_comments_title'), $conf_link.'comments'); |
---|
| 167 | $tabsheet->add('default', l10n('conf_display'), $conf_link.'default'); |
---|
| 168 | // TabSheet selection |
---|
| 169 | $tabsheet->select($page['section']); |
---|
[1881] | 170 | // Assign tabsheet to template |
---|
[2226] | 171 | $tabsheet->assign(); |
---|
[1881] | 172 | |
---|
[2249] | 173 | $action = get_root_url().'admin.php?page=configuration'; |
---|
[528] | 174 | $action.= '&section='.$page['section']; |
---|
[21] | 175 | |
---|
[528] | 176 | $template->assign_vars( |
---|
| 177 | array( |
---|
[2249] | 178 | 'U_HELP' => get_root_url().'popuphelp.php?page=configuration', |
---|
[858] | 179 | |
---|
[1004] | 180 | 'F_ACTION'=>$action |
---|
[528] | 181 | )); |
---|
| 182 | |
---|
[527] | 183 | switch ($page['section']) |
---|
[528] | 184 | { |
---|
[1894] | 185 | case 'main' : |
---|
[2] | 186 | { |
---|
[2249] | 187 | $template->assign( |
---|
[1894] | 188 | 'main', |
---|
[528] | 189 | array( |
---|
[2021] | 190 | 'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']), |
---|
| 191 | 'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']), |
---|
[1044] | 192 | 'CONF_GALLERY_URL' => $conf['gallery_url'], |
---|
[528] | 193 | )); |
---|
[1617] | 194 | |
---|
[1894] | 195 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 196 | { |
---|
[2249] | 197 | $template->append( |
---|
[1894] | 198 | 'main', |
---|
[1617] | 199 | array( |
---|
[2249] | 200 | $checkbox => $conf[$checkbox] |
---|
| 201 | ), |
---|
| 202 | true |
---|
[1617] | 203 | ); |
---|
| 204 | } |
---|
[528] | 205 | break; |
---|
| 206 | } |
---|
[1884] | 207 | case 'history' : |
---|
| 208 | { |
---|
| 209 | //Necessary for merge_block_vars |
---|
| 210 | foreach( $history_checkboxes as $checkbox) |
---|
| 211 | { |
---|
[2249] | 212 | $template->append( |
---|
[1884] | 213 | 'history', |
---|
| 214 | array( |
---|
[2249] | 215 | $checkbox => $conf[$checkbox] |
---|
| 216 | ), |
---|
| 217 | true |
---|
[1884] | 218 | ); |
---|
| 219 | } |
---|
| 220 | break; |
---|
| 221 | } |
---|
[528] | 222 | case 'comments' : |
---|
| 223 | { |
---|
[2249] | 224 | $template->assign( |
---|
[528] | 225 | 'comments', |
---|
| 226 | array( |
---|
| 227 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
| 228 | )); |
---|
[1617] | 229 | |
---|
| 230 | foreach( $comments_checkboxes as $checkbox) |
---|
| 231 | { |
---|
[2249] | 232 | $template->append( |
---|
[1617] | 233 | 'comments', |
---|
| 234 | array( |
---|
[2249] | 235 | $checkbox => $conf[$checkbox] |
---|
| 236 | ), |
---|
| 237 | true |
---|
[1617] | 238 | ); |
---|
| 239 | } |
---|
[528] | 240 | break; |
---|
| 241 | } |
---|
| 242 | case 'default' : |
---|
| 243 | { |
---|
[1926] | 244 | $edit_user = build_user($conf['default_user_id'], false); |
---|
| 245 | include_once(PHPWG_ROOT_PATH.'profile.php'); |
---|
[1071] | 246 | |
---|
[1926] | 247 | $errors = array(); |
---|
| 248 | if ( !is_adviser() ) |
---|
[858] | 249 | { |
---|
[1926] | 250 | if (save_profile_from_post($edit_user, $errors)) |
---|
[858] | 251 | { |
---|
[1926] | 252 | // Reload user |
---|
| 253 | $edit_user = build_user($conf['default_user_id'], false); |
---|
[2201] | 254 | array_push($page['infos'], l10n('conf_confirmation')); |
---|
[858] | 255 | } |
---|
| 256 | } |
---|
[1926] | 257 | $page['errors'] = array_merge($page['errors'], $errors); |
---|
[541] | 258 | |
---|
[1926] | 259 | load_profile_in_template( |
---|
| 260 | $action, |
---|
| 261 | '', |
---|
| 262 | $edit_user |
---|
| 263 | ); |
---|
[2249] | 264 | $template->assign('default', array()); |
---|
[528] | 265 | break; |
---|
| 266 | } |
---|
| 267 | } |
---|
[1926] | 268 | |
---|
[2] | 269 | //----------------------------------------------------------- sending html code |
---|
[393] | 270 | $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
---|
[362] | 271 | ?> |
---|