[362] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[2297] | 3 | // | Piwigo - a PHP based picture gallery | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[3049] | 5 | // | Copyright(C) 2008-2009 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 | |
---|
[2] | 78 | //------------------------------ verification and registration of modifications |
---|
[1571] | 79 | if (isset($_POST['submit']) and !is_adviser()) |
---|
[2] | 80 | { |
---|
[21] | 81 | $int_pattern = '/^\d+$/'; |
---|
[1926] | 82 | |
---|
[512] | 83 | switch ($page['section']) |
---|
[2] | 84 | { |
---|
[1894] | 85 | case 'main' : |
---|
[130] | 86 | { |
---|
[1044] | 87 | if ( !url_is_remote($_POST['gallery_url']) ) |
---|
| 88 | { |
---|
[2201] | 89 | array_push($page['errors'], l10n('conf_gallery_url_error')); |
---|
[1044] | 90 | } |
---|
[1894] | 91 | foreach( $main_checkboxes as $checkbox) |
---|
[1617] | 92 | { |
---|
| 93 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 94 | } |
---|
[512] | 95 | break; |
---|
[130] | 96 | } |
---|
[1884] | 97 | case 'history' : |
---|
| 98 | { |
---|
| 99 | foreach( $history_checkboxes as $checkbox) |
---|
| 100 | { |
---|
| 101 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 102 | } |
---|
| 103 | break; |
---|
| 104 | } |
---|
[512] | 105 | case 'comments' : |
---|
| 106 | { |
---|
| 107 | // the number of comments per page must be an integer between 5 and 50 |
---|
| 108 | // included |
---|
| 109 | if (!preg_match($int_pattern, $_POST['nb_comment_page']) |
---|
| 110 | or $_POST['nb_comment_page'] < 5 |
---|
| 111 | or $_POST['nb_comment_page'] > 50) |
---|
| 112 | { |
---|
[2201] | 113 | array_push($page['errors'], l10n('conf_nb_comment_page_error')); |
---|
[512] | 114 | } |
---|
[1617] | 115 | foreach( $comments_checkboxes as $checkbox) |
---|
| 116 | { |
---|
| 117 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 118 | } |
---|
[512] | 119 | break; |
---|
| 120 | } |
---|
[2325] | 121 | case 'upload' : |
---|
| 122 | { |
---|
| 123 | foreach( $upload_checkboxes as $checkbox) |
---|
| 124 | { |
---|
| 125 | $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true'; |
---|
| 126 | } |
---|
| 127 | break; |
---|
| 128 | } |
---|
[512] | 129 | case 'default' : |
---|
| 130 | { |
---|
[1926] | 131 | // Never go here |
---|
[512] | 132 | break; |
---|
| 133 | } |
---|
[2] | 134 | } |
---|
[1071] | 135 | |
---|
[528] | 136 | // updating configuration if no error found |
---|
[792] | 137 | if (count($page['errors']) == 0) |
---|
[345] | 138 | { |
---|
[1565] | 139 | //echo '<pre>'; print_r($_POST); echo '</pre>'; |
---|
[1748] | 140 | $result = pwg_query('SELECT param FROM '.CONFIG_TABLE); |
---|
[512] | 141 | while ($row = mysql_fetch_array($result)) |
---|
| 142 | { |
---|
| 143 | if (isset($_POST[$row['param']])) |
---|
| 144 | { |
---|
[882] | 145 | $value = $_POST[$row['param']]; |
---|
[1071] | 146 | |
---|
| 147 | if ('gallery_title' == $row['param']) |
---|
[882] | 148 | { |
---|
| 149 | if (!$conf['allow_html_descriptions']) |
---|
| 150 | { |
---|
| 151 | $value = strip_tags($value); |
---|
| 152 | } |
---|
| 153 | } |
---|
[1071] | 154 | |
---|
[528] | 155 | $query = ' |
---|
| 156 | UPDATE '.CONFIG_TABLE.' |
---|
[1926] | 157 | SET value = \''. str_replace("\'", "''", $value).'\' |
---|
| 158 | WHERE param = \''.$row['param'].'\' |
---|
[528] | 159 | ;'; |
---|
[587] | 160 | pwg_query($query); |
---|
[512] | 161 | } |
---|
| 162 | } |
---|
[2201] | 163 | array_push($page['infos'], l10n('conf_confirmation')); |
---|
[345] | 164 | } |
---|
[527] | 165 | |
---|
[1748] | 166 | //------------------------------------------------------ $conf reinitialization |
---|
| 167 | load_conf_from_db(); |
---|
[1565] | 168 | } |
---|
| 169 | |
---|
[512] | 170 | //----------------------------------------------------- template initialization |
---|
[2530] | 171 | $template->set_filename('config', 'configuration.tpl'); |
---|
[512] | 172 | |
---|
[2226] | 173 | // TabSheet |
---|
| 174 | $tabsheet = new tabsheet(); |
---|
[1881] | 175 | // TabSheet initialization |
---|
[2226] | 176 | $tabsheet->add('main', l10n('conf_main_title'), $conf_link.'main'); |
---|
| 177 | $tabsheet->add('history', l10n('conf_history_title'), $conf_link.'history'); |
---|
| 178 | $tabsheet->add('comments', l10n('conf_comments_title'), $conf_link.'comments'); |
---|
[2325] | 179 | $tabsheet->add('upload', l10n('conf_upload_title'), $conf_link.'upload'); |
---|
[2226] | 180 | $tabsheet->add('default', l10n('conf_display'), $conf_link.'default'); |
---|
| 181 | // TabSheet selection |
---|
| 182 | $tabsheet->select($page['section']); |
---|
[1881] | 183 | // Assign tabsheet to template |
---|
[2226] | 184 | $tabsheet->assign(); |
---|
[1881] | 185 | |
---|
[2249] | 186 | $action = get_root_url().'admin.php?page=configuration'; |
---|
[528] | 187 | $action.= '&section='.$page['section']; |
---|
[21] | 188 | |
---|
[2288] | 189 | $template->assign( |
---|
[528] | 190 | array( |
---|
[2249] | 191 | 'U_HELP' => get_root_url().'popuphelp.php?page=configuration', |
---|
[1004] | 192 | 'F_ACTION'=>$action |
---|
[528] | 193 | )); |
---|
| 194 | |
---|
[527] | 195 | switch ($page['section']) |
---|
[528] | 196 | { |
---|
[1894] | 197 | case 'main' : |
---|
[2] | 198 | { |
---|
[2249] | 199 | $template->assign( |
---|
[1894] | 200 | 'main', |
---|
[528] | 201 | array( |
---|
[2021] | 202 | 'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']), |
---|
| 203 | 'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']), |
---|
[1044] | 204 | 'CONF_GALLERY_URL' => $conf['gallery_url'], |
---|
[528] | 205 | )); |
---|
[1617] | 206 | |
---|
[2325] | 207 | foreach ($main_checkboxes as $checkbox) |
---|
[1617] | 208 | { |
---|
[2249] | 209 | $template->append( |
---|
[1894] | 210 | 'main', |
---|
[1617] | 211 | array( |
---|
[2249] | 212 | $checkbox => $conf[$checkbox] |
---|
| 213 | ), |
---|
| 214 | true |
---|
[1617] | 215 | ); |
---|
| 216 | } |
---|
[528] | 217 | break; |
---|
| 218 | } |
---|
[1884] | 219 | case 'history' : |
---|
| 220 | { |
---|
| 221 | //Necessary for merge_block_vars |
---|
[2325] | 222 | foreach ($history_checkboxes as $checkbox) |
---|
[1884] | 223 | { |
---|
[2249] | 224 | $template->append( |
---|
[1884] | 225 | 'history', |
---|
| 226 | array( |
---|
[2249] | 227 | $checkbox => $conf[$checkbox] |
---|
| 228 | ), |
---|
| 229 | true |
---|
[1884] | 230 | ); |
---|
| 231 | } |
---|
| 232 | break; |
---|
| 233 | } |
---|
[528] | 234 | case 'comments' : |
---|
| 235 | { |
---|
[2249] | 236 | $template->assign( |
---|
[528] | 237 | 'comments', |
---|
| 238 | array( |
---|
| 239 | 'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'], |
---|
| 240 | )); |
---|
[1617] | 241 | |
---|
[2325] | 242 | foreach ($comments_checkboxes as $checkbox) |
---|
[1617] | 243 | { |
---|
[2249] | 244 | $template->append( |
---|
[1617] | 245 | 'comments', |
---|
| 246 | array( |
---|
[2249] | 247 | $checkbox => $conf[$checkbox] |
---|
| 248 | ), |
---|
| 249 | true |
---|
[1617] | 250 | ); |
---|
| 251 | } |
---|
[528] | 252 | break; |
---|
| 253 | } |
---|
[2325] | 254 | case 'upload' : |
---|
| 255 | { |
---|
| 256 | $template->assign( |
---|
| 257 | 'upload', |
---|
| 258 | array( |
---|
| 259 | 'upload_user_access_options'=> get_user_access_level_html_options(ACCESS_GUEST), |
---|
| 260 | 'upload_user_access_options_selected' => array($conf['upload_user_access']) |
---|
| 261 | ) |
---|
| 262 | ); |
---|
| 263 | //Necessary for merge_block_vars |
---|
| 264 | foreach ($upload_checkboxes as $checkbox) |
---|
| 265 | { |
---|
| 266 | $template->append( |
---|
| 267 | 'upload', |
---|
| 268 | array( |
---|
| 269 | $checkbox => $conf[$checkbox] |
---|
| 270 | ), |
---|
| 271 | true |
---|
| 272 | ); |
---|
| 273 | } |
---|
| 274 | break; |
---|
| 275 | } |
---|
[528] | 276 | case 'default' : |
---|
| 277 | { |
---|
[1926] | 278 | $edit_user = build_user($conf['default_user_id'], false); |
---|
| 279 | include_once(PHPWG_ROOT_PATH.'profile.php'); |
---|
[1071] | 280 | |
---|
[1926] | 281 | $errors = array(); |
---|
| 282 | if ( !is_adviser() ) |
---|
[858] | 283 | { |
---|
[1926] | 284 | if (save_profile_from_post($edit_user, $errors)) |
---|
[858] | 285 | { |
---|
[1926] | 286 | // Reload user |
---|
| 287 | $edit_user = build_user($conf['default_user_id'], false); |
---|
[2201] | 288 | array_push($page['infos'], l10n('conf_confirmation')); |
---|
[858] | 289 | } |
---|
| 290 | } |
---|
[1926] | 291 | $page['errors'] = array_merge($page['errors'], $errors); |
---|
[541] | 292 | |
---|
[1926] | 293 | load_profile_in_template( |
---|
| 294 | $action, |
---|
| 295 | '', |
---|
| 296 | $edit_user |
---|
| 297 | ); |
---|
[2249] | 298 | $template->assign('default', array()); |
---|
[528] | 299 | break; |
---|
| 300 | } |
---|
| 301 | } |
---|
[1926] | 302 | |
---|
[2] | 303 | //----------------------------------------------------------- sending html code |
---|
[393] | 304 | $template->assign_var_from_handle('ADMIN_CONTENT', 'config'); |
---|
[362] | 305 | ?> |
---|