[217] | 1 | <?php |
---|
[354] | 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
[675] | 5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[354] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[354] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2005-08-13 23:09:54 +0000 (Sat, 13 Aug 2005) $ |
---|
| 10 | // | last modifier : $Author: plg $ |
---|
| 11 | // | revision : $Revision: 809 $ |
---|
| 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 | // +-----------------------------------------------------------------------+ |
---|
[217] | 27 | |
---|
[345] | 28 | //----------------------------------------------------------- include |
---|
[364] | 29 | define('PHPWG_ROOT_PATH','./'); |
---|
[393] | 30 | define('IN_ADMIN', true); |
---|
[364] | 31 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
[393] | 32 | include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
---|
[808] | 33 | |
---|
| 34 | // +-----------------------------------------------------------------------+ |
---|
| 35 | // | synchronize user informations | |
---|
| 36 | // +-----------------------------------------------------------------------+ |
---|
| 37 | |
---|
| 38 | sync_users(); |
---|
| 39 | |
---|
[217] | 40 | //--------------------------------------- validating page and creation of title |
---|
| 41 | $page_valide = false; |
---|
| 42 | $title = ''; |
---|
[631] | 43 | $username=''; |
---|
[708] | 44 | if (isset($_POST['username'])) |
---|
| 45 | { |
---|
| 46 | $username = $_POST['username']; |
---|
| 47 | } |
---|
| 48 | else if (isset($_POST['userid'])) |
---|
| 49 | { |
---|
| 50 | $username = get_username($_POST['userid']); |
---|
| 51 | } |
---|
| 52 | else if (isset($_GET['user_id'])) |
---|
| 53 | { |
---|
| 54 | $username = get_username($_GET['user_id']); |
---|
| 55 | } |
---|
| 56 | |
---|
[345] | 57 | if (isset( $_GET['page'] )) |
---|
[217] | 58 | switch ( $_GET['page'] ) |
---|
| 59 | { |
---|
[768] | 60 | case 'user_list' : |
---|
| 61 | { |
---|
| 62 | $title = $lang['title_liste_users']; |
---|
| 63 | $page_valide = true; |
---|
| 64 | break; |
---|
| 65 | } |
---|
| 66 | case 'profile' : |
---|
| 67 | { |
---|
| 68 | $title = $lang['title_user_modify']; |
---|
| 69 | $page_valide = true; |
---|
| 70 | break; |
---|
| 71 | } |
---|
[655] | 72 | case 'user_perm': |
---|
[539] | 73 | $title = $lang['title_user_perm'].' '.$username; |
---|
[393] | 74 | $page_valide = true; break; |
---|
[217] | 75 | case 'group_list' : |
---|
| 76 | $title = $lang['title_groups']; $page_valide = true; break; |
---|
| 77 | case 'group_perm' : |
---|
[670] | 78 | /*if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1; |
---|
[393] | 79 | $query = 'SELECT name FROM '.GROUPS_TABLE; |
---|
[217] | 80 | $query.= ' WHERE id = '.$_GET['group_id']; |
---|
| 81 | $query.= ';'; |
---|
[587] | 82 | $result = pwg_query( $query ); |
---|
[217] | 83 | if ( mysql_num_rows( $result ) > 0 ) |
---|
| 84 | { |
---|
[670] | 85 | $row = mysql_fetch_array( $result );*/ |
---|
| 86 | $title = $lang['title_group_perm'];//.' "'.$row['name'].'"'; |
---|
[217] | 87 | $page_valide = true; |
---|
[670] | 88 | /*} |
---|
[217] | 89 | else |
---|
| 90 | { |
---|
| 91 | $page_valide = false; |
---|
[670] | 92 | }*/ |
---|
[217] | 93 | break; |
---|
| 94 | case 'stats': |
---|
| 95 | $title = $lang['title_history']; $page_valide = true; break; |
---|
| 96 | case 'update': |
---|
| 97 | $title = $lang['title_update']; $page_valide = true; break; |
---|
| 98 | case 'configuration': |
---|
| 99 | $title = $lang['title_configuration']; $page_valide = true; break; |
---|
[394] | 100 | case 'admin_phpinfo': |
---|
| 101 | $title = $lang['phpinfos']; $page_valide = true; break; |
---|
[217] | 102 | case 'help': |
---|
| 103 | $title = $lang['title_instructions']; $page_valide = true; break; |
---|
| 104 | case 'cat_perm': |
---|
| 105 | $title = $lang['title_cat_perm']; |
---|
[800] | 106 | if ( isset( $_GET['cat'] ) ) |
---|
[217] | 107 | { |
---|
[800] | 108 | check_cat_id( $_GET['cat'] ); |
---|
[217] | 109 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
| 110 | { |
---|
| 111 | $result = get_cat_info( $page['cat'] ); |
---|
[642] | 112 | $name = get_cat_display_name($result['name'], ''); |
---|
[217] | 113 | $title.= ' "'.$name.'"'; |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | $page_valide = true; |
---|
| 117 | break; |
---|
| 118 | case 'cat_list': |
---|
| 119 | $title = $lang['title_categories']; $page_valide = true; break; |
---|
| 120 | case 'cat_modify': |
---|
| 121 | $title = $lang['title_edit_cat']; $page_valide = true; break; |
---|
| 122 | case 'infos_images': |
---|
| 123 | $title = $lang['title_info_images']; $page_valide = true; break; |
---|
| 124 | case 'waiting': |
---|
| 125 | $title = $lang['title_waiting']; $page_valide = true; break; |
---|
| 126 | case 'thumbnail': |
---|
| 127 | $title = $lang['title_thumbnails']; |
---|
| 128 | if ( isset( $_GET['dir'] ) ) |
---|
| 129 | { |
---|
[393] | 130 | $title.= ' '.$lang['title_thumbnails_2'].' <span class="titreImg">'; |
---|
[217] | 131 | // $_GET['dir'] contains : |
---|
[228] | 132 | // ./galleries/vieux_lyon ou |
---|
| 133 | // ./galleries/vieux_lyon/visite ou |
---|
| 134 | // ./galleries/vieux_lyon/visite/truc ... |
---|
[217] | 135 | $dir = explode( "/", $_GET['dir'] ); |
---|
| 136 | $title.= $dir[2]; |
---|
[393] | 137 | for ( $i = 2; $i < sizeof( $dir ) - 1; $i++ ) |
---|
[217] | 138 | { |
---|
[393] | 139 | $title.= ' > '.$dir[$i+1]; |
---|
[217] | 140 | } |
---|
| 141 | $title.= "</span>"; |
---|
| 142 | } |
---|
| 143 | $page_valide = true; |
---|
| 144 | break; |
---|
| 145 | case 'comments' : |
---|
| 146 | $title = $lang['title_comments']; |
---|
| 147 | $page_valide = true; |
---|
| 148 | break; |
---|
| 149 | case 'picture_modify' : |
---|
| 150 | $title = $lang['title_picmod']; |
---|
| 151 | $page_valide = true; |
---|
| 152 | break; |
---|
[526] | 153 | case 'remote_site' : |
---|
| 154 | { |
---|
| 155 | $title = $lang['remote_sites']; |
---|
| 156 | $page_valide = true; |
---|
| 157 | break; |
---|
| 158 | } |
---|
[602] | 159 | case 'cat_options' : |
---|
| 160 | { |
---|
| 161 | $title = $lang['title_cat_options']; |
---|
| 162 | $page_valide = true; |
---|
| 163 | break; |
---|
| 164 | } |
---|
[764] | 165 | case 'element_set' : |
---|
[755] | 166 | { |
---|
| 167 | $title = 'batch management'; |
---|
| 168 | $page_valide = true; |
---|
| 169 | break; |
---|
| 170 | } |
---|
[809] | 171 | case 'maintenance' : |
---|
| 172 | { |
---|
| 173 | $title = l10n('Maintenance'); |
---|
| 174 | $page_valide = true; |
---|
| 175 | break; |
---|
| 176 | } |
---|
| 177 | case 'representative' : |
---|
| 178 | { |
---|
| 179 | $title = l10n('Representative'); |
---|
| 180 | $page_valide = true; |
---|
| 181 | break; |
---|
| 182 | } |
---|
[764] | 183 | // case 'element_set_unit' : |
---|
| 184 | // { |
---|
| 185 | // $title = 'batch management'; |
---|
| 186 | // $page_valide = true; |
---|
| 187 | // break; |
---|
| 188 | // } |
---|
[217] | 189 | default: |
---|
| 190 | $title = $lang['title_default']; break; |
---|
| 191 | } |
---|
| 192 | if ( $title == '' ) $title = $lang['title_default']; |
---|
[393] | 193 | |
---|
[217] | 194 | // waiting |
---|
[393] | 195 | $query = 'SELECT id FROM '.WAITING_TABLE; |
---|
[217] | 196 | $query.= " WHERE validated='false'"; |
---|
| 197 | $query.= ';'; |
---|
[587] | 198 | $result = pwg_query( $query ); |
---|
[217] | 199 | $nb_waiting = ''; |
---|
| 200 | if ( mysql_num_rows( $result ) > 0 ) |
---|
| 201 | { |
---|
| 202 | $nb_waiting = ' [ '.mysql_num_rows( $result ).' ]'; |
---|
| 203 | } |
---|
| 204 | // comments |
---|
[393] | 205 | $query = 'SELECT id FROM '.COMMENTS_TABLE; |
---|
[217] | 206 | $query.= " WHERE validated='false'"; |
---|
| 207 | $query.= ';'; |
---|
[587] | 208 | $result = pwg_query( $query ); |
---|
[393] | 209 | $nb_comments = ''; |
---|
[217] | 210 | if ( mysql_num_rows( $result ) > 0 ) |
---|
| 211 | { |
---|
[393] | 212 | $nb_comments = ' [ '.mysql_num_rows( $result ).' ]'; |
---|
[217] | 213 | } |
---|
[393] | 214 | |
---|
| 215 | $link_start = PHPWG_ROOT_PATH.'admin.php?page='; |
---|
[602] | 216 | $conf_link = $link_start.'configuration&section='; |
---|
[614] | 217 | $opt_link = $link_start.'cat_options&section='; |
---|
[393] | 218 | //----------------------------------------------------- template initialization |
---|
| 219 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
| 220 | $template->set_filenames( array('admin'=>'admin.tpl') ); |
---|
| 221 | |
---|
| 222 | $template->assign_vars(array( |
---|
[394] | 223 | 'L_TITLE'=>$lang['admin_panel'], |
---|
| 224 | 'L_LINKS'=>$lang['links'], |
---|
[607] | 225 | 'L_GALLERY_INDEX'=>$lang['home'], |
---|
[394] | 226 | 'L_GENERAL'=>$lang['general'], |
---|
| 227 | 'L_DEFAULT'=>$lang['gallery_default'], |
---|
| 228 | 'L_PHPINFO'=>$lang['phpinfos'], |
---|
| 229 | 'L_HISTORY'=>$lang['history'], |
---|
| 230 | 'L_FAQ'=>$lang['instructions'], |
---|
[527] | 231 | 'L_CONFIGURATION'=>$lang['config'], |
---|
| 232 | 'L_CONFIG_GENERAL'=>$lang['general'], |
---|
| 233 | 'L_CONFIG_COMMENTS'=>$lang['comments'], |
---|
| 234 | 'L_CONFIG_DISPLAY'=>$lang['conf_default'], |
---|
| 235 | 'L_CONFIG_UPLOAD'=>$lang['upload'], |
---|
| 236 | 'L_CONFIG_SESSION'=>$lang['conf_cookie'], |
---|
| 237 | 'L_CONFIG_METADATA'=>$lang['metadata'], |
---|
[528] | 238 | 'L_SITES'=>$lang['remote_sites'], |
---|
[394] | 239 | 'L_CATEGORIES'=>$lang['categories'], |
---|
| 240 | 'L_MANAGE'=>$lang['manage'], |
---|
| 241 | 'L_IMAGES'=>$lang['pictures'], |
---|
| 242 | 'L_WAITING'=>$lang['waiting'].$nb_waiting, |
---|
| 243 | 'L_COMMENTS'=>$lang['comments'].$nb_comments, |
---|
| 244 | 'L_THUMBNAILS'=>$lang['thumbnails'], |
---|
| 245 | 'L_IDENTIFY'=>$lang['identification'], |
---|
| 246 | 'L_USERS'=>$lang['users'], |
---|
| 247 | 'L_GROUPS'=>$lang['groups'], |
---|
| 248 | 'L_AUTH'=>$lang['permissions'], |
---|
| 249 | 'L_UPDATE'=>$lang['update'], |
---|
[622] | 250 | 'L_CAT_UPLOAD'=>$lang['upload'], |
---|
| 251 | 'L_CAT_COMMENTS'=>$lang['comments'], |
---|
| 252 | 'L_CAT_VISIBLE'=>$lang['lock'], |
---|
[646] | 253 | 'L_CAT_STATUS'=>$lang['cat_security'], |
---|
[614] | 254 | |
---|
[655] | 255 | 'U_HISTORY'=>add_session_id($link_start.'stats' ), |
---|
| 256 | 'U_FAQ'=>add_session_id($link_start.'help' ), |
---|
| 257 | 'U_SITES'=>add_session_id($link_start.'remote_site'), |
---|
| 258 | 'U_PHPINFO'=>add_session_id($link_start.'admin_phpinfo' ), |
---|
[809] | 259 | 'U_MAINTENANCE'=>add_session_id($link_start.'maintenance'), |
---|
[602] | 260 | 'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ), |
---|
| 261 | 'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ), |
---|
| 262 | 'U_CONFIG_DISPLAY'=>add_session_id($conf_link.'default' ), |
---|
| 263 | 'U_CONFIG_UPLOAD'=>add_session_id($conf_link.'upload' ), |
---|
| 264 | 'U_CONFIG_SESSION'=>add_session_id($conf_link.'session' ), |
---|
| 265 | 'U_CONFIG_METADATA'=>add_session_id($conf_link.'metadata' ), |
---|
[393] | 266 | 'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ), |
---|
[620] | 267 | 'U_CAT_UPLOAD'=>add_session_id($opt_link.'upload'), |
---|
| 268 | 'U_CAT_COMMENTS'=>add_session_id($opt_link.'comments'), |
---|
| 269 | 'U_CAT_VISIBLE'=>add_session_id($opt_link.'visible'), |
---|
| 270 | 'U_CAT_STATUS'=>add_session_id($opt_link.'status'), |
---|
[655] | 271 | 'U_CAT_OPTIONS'=>add_session_id($link_start.'cat_options'), |
---|
| 272 | 'U_CAT_UPDATE'=>add_session_id($link_start.'update'), |
---|
[393] | 273 | 'U_WAITING'=>add_session_id($link_start.'waiting' ), |
---|
| 274 | 'U_COMMENTS'=>add_session_id($link_start.'comments' ), |
---|
[764] | 275 | 'U_CADDIE'=>add_session_id($link_start.'element_set&cat=caddie'), |
---|
[393] | 276 | 'U_THUMBNAILS'=>add_session_id($link_start.'thumbnail' ), |
---|
[768] | 277 | 'U_USERS'=>add_session_id($link_start.'user_list' ), |
---|
[655] | 278 | 'U_GROUPS'=>add_session_id($link_start.'group_list' ), |
---|
| 279 | 'U_USERS_AUTH'=>add_session_id($link_start.'user_perm' ), |
---|
| 280 | 'U_GROUPS_AUTH'=>add_session_id($link_start.'group_perm'), |
---|
| 281 | 'U_CAT_AUTH'=>add_session_id($link_start.'cat_perm' ), |
---|
[393] | 282 | 'U_RETURN'=>add_session_id(PHPWG_ROOT_PATH.'category.php') |
---|
| 283 | )); |
---|
| 284 | |
---|
[809] | 285 | if ($conf['allow_random_representative']) |
---|
| 286 | { |
---|
| 287 | $template->assign_block_vars( |
---|
| 288 | 'representative', |
---|
| 289 | array( |
---|
| 290 | 'URL' => add_session_id($opt_link.'representative') |
---|
| 291 | ) |
---|
| 292 | ); |
---|
| 293 | } |
---|
| 294 | |
---|
[393] | 295 | //--------------------------------------------------------------------- summary |
---|
| 296 | $link_start = PHPWG_ROOT_PATH.'admin.php?page='; |
---|
[217] | 297 | //------------------------------------------------------------- content display |
---|
[792] | 298 | $page['errors'] = array(); |
---|
| 299 | $page['infos'] = array(); |
---|
| 300 | |
---|
[764] | 301 | if ($page_valide) |
---|
[217] | 302 | { |
---|
[764] | 303 | switch ($_GET['page']) |
---|
| 304 | { |
---|
| 305 | case 'comments' : |
---|
| 306 | { |
---|
| 307 | include(PHPWG_ROOT_PATH.'comments.php'); |
---|
| 308 | break; |
---|
| 309 | } |
---|
| 310 | case 'profile' : |
---|
| 311 | { |
---|
| 312 | include(PHPWG_ROOT_PATH.'profile.php'); |
---|
| 313 | break; |
---|
| 314 | } |
---|
| 315 | default : |
---|
| 316 | { |
---|
| 317 | include(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php'); |
---|
| 318 | } |
---|
| 319 | } |
---|
[217] | 320 | } |
---|
| 321 | else |
---|
| 322 | { |
---|
[764] | 323 | $template->assign_vars( |
---|
| 324 | array( |
---|
| 325 | 'ADMIN_CONTENT' |
---|
| 326 | =>'<div style="text-align:center">'.$lang['default_message'].'</div>' |
---|
| 327 | ) |
---|
| 328 | ); |
---|
[217] | 329 | } |
---|
[792] | 330 | // +-----------------------------------------------------------------------+ |
---|
| 331 | // | errors & infos | |
---|
| 332 | // +-----------------------------------------------------------------------+ |
---|
| 333 | if (count($page['errors']) != 0) |
---|
| 334 | { |
---|
| 335 | $template->assign_block_vars('errors',array()); |
---|
| 336 | foreach ($page['errors'] as $error) |
---|
| 337 | { |
---|
| 338 | $template->assign_block_vars('errors.error',array('ERROR'=>$error)); |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | if (count($page['infos']) != 0) |
---|
| 342 | { |
---|
| 343 | $template->assign_block_vars('infos',array()); |
---|
| 344 | foreach ($page['infos'] as $info) |
---|
| 345 | { |
---|
| 346 | $template->assign_block_vars('infos.info',array('INFO'=>$info)); |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | |
---|
[688] | 350 | $template->parse('admin'); |
---|
[393] | 351 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[657] | 352 | // +-----------------------------------------------------------------------+ |
---|
| 353 | // | order permission refreshment | |
---|
| 354 | // +-----------------------------------------------------------------------+ |
---|
| 355 | $query = ' |
---|
[808] | 356 | UPDATE '.USER_CACHE_TABLE.' |
---|
[657] | 357 | SET need_update = \'true\' |
---|
| 358 | ;'; |
---|
| 359 | pwg_query($query); |
---|
[362] | 360 | ?> |
---|