[2] | 1 | <?php |
---|
[351] | 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 | |
---|
[351] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[351] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2005-08-08 20:52:19 +0000 (Mon, 08 Aug 2005) $ |
---|
| 10 | // | last modifier : $Author: plg $ |
---|
| 11 | // | revision : $Revision: 808 $ |
---|
| 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 | |
---|
[352] | 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. | |
---|
[351] | 26 | // +-----------------------------------------------------------------------+ |
---|
[2] | 27 | |
---|
[352] | 28 | //--------------------------------------------------------------------- include |
---|
[364] | 29 | define('PHPWG_ROOT_PATH','./'); |
---|
| 30 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
[45] | 31 | //---------------------------------------------------------------------- logout |
---|
[345] | 32 | if ( isset( $_GET['act'] ) |
---|
| 33 | and $_GET['act'] == 'logout' |
---|
| 34 | and isset( $_COOKIE['id'] ) ) |
---|
[45] | 35 | { |
---|
| 36 | // cookie deletion if exists |
---|
| 37 | setcookie( 'id', '', 0, cookie_path() ); |
---|
| 38 | $url = 'category.php'; |
---|
[405] | 39 | redirect( $url ); |
---|
[45] | 40 | } |
---|
[2] | 41 | //-------------------------------------------------- access authorization check |
---|
[614] | 42 | if (isset($_GET['cat'])) |
---|
| 43 | { |
---|
| 44 | check_cat_id($_GET['cat']); |
---|
| 45 | } |
---|
[2] | 46 | check_login_authorization(); |
---|
[614] | 47 | if (isset($page['cat']) and is_numeric($page['cat'])) |
---|
[2] | 48 | { |
---|
[614] | 49 | check_restrictions($page['cat']); |
---|
[2] | 50 | } |
---|
| 51 | //-------------------------------------------------------------- initialization |
---|
[345] | 52 | // detection of the start picture to display |
---|
| 53 | if ( !isset( $_GET['start'] ) |
---|
| 54 | or !is_numeric( $_GET['start'] ) |
---|
| 55 | or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) |
---|
[514] | 56 | { |
---|
[345] | 57 | $page['start'] = 0; |
---|
[514] | 58 | } |
---|
[345] | 59 | else |
---|
[514] | 60 | { |
---|
[345] | 61 | $page['start'] = $_GET['start']; |
---|
[514] | 62 | } |
---|
[345] | 63 | |
---|
[514] | 64 | // Sometimes, a "num" is provided in the URL. It is the number |
---|
| 65 | // of the picture to show. This picture must be in the thumbnails page. |
---|
| 66 | // We have to find the right $page['start'] that show the num picture |
---|
| 67 | // in this category |
---|
| 68 | if ( isset( $_GET['num'] ) |
---|
| 69 | and is_numeric( $_GET['num'] ) |
---|
| 70 | and $_GET['num'] >= 0 ) |
---|
| 71 | { |
---|
| 72 | $page['start'] = floor( $_GET['num'] / $user['nb_image_page'] ); |
---|
| 73 | $page['start']*= $user['nb_image_page']; |
---|
| 74 | } |
---|
| 75 | |
---|
[345] | 76 | initialize_category(); |
---|
| 77 | |
---|
[755] | 78 | // caddie filling :-) |
---|
| 79 | if (isset($_GET['caddie'])) |
---|
| 80 | { |
---|
[764] | 81 | // include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[755] | 82 | |
---|
| 83 | $query = ' |
---|
| 84 | SELECT DISTINCT(id) |
---|
| 85 | FROM '.IMAGES_TABLE.' AS i |
---|
| 86 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
---|
| 87 | '.$page['where'].' |
---|
| 88 | ;'; |
---|
[764] | 89 | fill_caddie(array_from_query($query, 'id')); |
---|
[755] | 90 | } |
---|
| 91 | |
---|
[2] | 92 | // creation of the array containing the cat ids to expand in the menu |
---|
| 93 | // $page['tab_expand'] contains an array with the category ids |
---|
| 94 | // $page['expand'] contains the string to display in URL with comma |
---|
| 95 | $page['tab_expand'] = array(); |
---|
[386] | 96 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
[2] | 97 | { |
---|
[345] | 98 | // the category displayed (in the URL cat=23) must be seen in the menu -> |
---|
| 99 | // parent categories must be expanded |
---|
| 100 | $uppercats = explode( ',', $page['uppercats'] ); |
---|
| 101 | foreach ( $uppercats as $uppercat ) { |
---|
| 102 | array_push( $page['tab_expand'], $uppercat ); |
---|
[193] | 103 | } |
---|
[2] | 104 | } |
---|
[386] | 105 | // in case of expanding all authorized cats $page['tab_expand'] is empty |
---|
| 106 | if ( $user['expand'] ) |
---|
[2] | 107 | { |
---|
| 108 | $page['tab_expand'] = array(); |
---|
| 109 | } |
---|
| 110 | //----------------------------------------------------- template initialization |
---|
[345] | 111 | // |
---|
| 112 | // Start output of page |
---|
| 113 | // |
---|
| 114 | $title = $page['title']; |
---|
[369] | 115 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[345] | 116 | |
---|
[351] | 117 | $template->set_filenames( array('category'=>'category.tpl') ); |
---|
| 118 | //-------------------------------------------------------------- category title |
---|
[663] | 119 | if (isset($page['cat']) and is_numeric($page['cat'])) |
---|
[351] | 120 | { |
---|
[657] | 121 | $template_title = get_cat_display_name($page['cat_name'], |
---|
| 122 | 'category.php?cat=', |
---|
| 123 | false); |
---|
| 124 | } |
---|
[663] | 125 | else |
---|
| 126 | { |
---|
| 127 | $template_title = $page['title']; |
---|
| 128 | } |
---|
[657] | 129 | |
---|
[428] | 130 | if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 ) |
---|
| 131 | { |
---|
| 132 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
| 133 | } |
---|
[2] | 134 | |
---|
[452] | 135 | $icon_recent = get_icon(date('Y-m-d')); |
---|
[436] | 136 | |
---|
[351] | 137 | $template->assign_vars(array( |
---|
| 138 | 'NB_PICTURE' => count_user_total_images(), |
---|
[428] | 139 | 'TITLE' => $template_title, |
---|
[351] | 140 | 'USERNAME' => $user['username'], |
---|
[507] | 141 | 'TOP_NUMBER'=>$conf['top_number'], |
---|
[614] | 142 | 'MENU_CATEGORIES_CONTENT'=>get_categories_menu(), |
---|
[2] | 143 | |
---|
[351] | 144 | 'L_CATEGORIES' => $lang['categories'], |
---|
| 145 | 'L_HINT_CATEGORY' => $lang['hint_category'], |
---|
| 146 | 'L_SUBCAT' => $lang['sub-cat'], |
---|
| 147 | 'L_IMG_AVAILABLE' => $lang['images_available'], |
---|
| 148 | 'L_TOTAL' => $lang['total'], |
---|
[428] | 149 | 'L_SPECIAL_CATEGORIES' => $lang['special_categories'], |
---|
[351] | 150 | 'L_SUMMARY' => $lang['title_menu'], |
---|
| 151 | 'L_UPLOAD' => $lang['upload_picture'], |
---|
| 152 | 'L_COMMENT' => $lang['comments'], |
---|
[671] | 153 | 'L_IDENTIFY' => $lang['identification'], |
---|
[375] | 154 | 'L_SUBMIT' => $lang['menu_login'], |
---|
| 155 | 'L_USERNAME' => $lang['login'], |
---|
| 156 | 'L_PASSWORD' => $lang['password'], |
---|
| 157 | 'L_HELLO' => $lang['hello'], |
---|
[654] | 158 | 'L_REGISTER' => $lang['ident_register'], |
---|
| 159 | 'L_LOGIN' => $lang['menu_login'], |
---|
[375] | 160 | 'L_LOGOUT' => $lang['logout'], |
---|
| 161 | 'L_ADMIN' => $lang['admin'], |
---|
| 162 | 'L_ADMIN_HINT' => $lang['hint_admin'], |
---|
| 163 | 'L_PROFILE' => $lang['customize'], |
---|
| 164 | 'L_PROFILE_HINT' => $lang['hint_customize'], |
---|
[541] | 165 | 'L_REMEMBER_ME' => $lang['remember_me'], |
---|
[351] | 166 | |
---|
[375] | 167 | 'F_IDENTIFY' => add_session_id( PHPWG_ROOT_PATH.'identification.php' ), |
---|
[452] | 168 | 'T_RECENT' => $icon_recent, |
---|
[2] | 169 | |
---|
[375] | 170 | 'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ), |
---|
[654] | 171 | 'U_REGISTER' => add_session_id( PHPWG_ROOT_PATH.'register.php' ), |
---|
[393] | 172 | 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout', |
---|
[375] | 173 | 'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ), |
---|
[808] | 174 | 'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php'), |
---|
[755] | 175 | 'U_CADDIE'=>add_session_id(PHPWG_ROOT_PATH.'category.php'.get_query_string_diff(array('caddie')).'&caddie=1') |
---|
[351] | 176 | ) |
---|
| 177 | ); |
---|
[797] | 178 | //-------------------------------------------------------------- external links |
---|
| 179 | if (count($conf['links']) > 0) |
---|
| 180 | { |
---|
| 181 | $template->assign_block_vars('links', array()); |
---|
| 182 | |
---|
| 183 | foreach ($conf['links'] as $url => $label) |
---|
| 184 | { |
---|
| 185 | $template->assign_block_vars( |
---|
| 186 | 'links.link', |
---|
| 187 | array( |
---|
| 188 | 'URL' => $url, |
---|
| 189 | 'LABEL' => $label |
---|
| 190 | )); |
---|
| 191 | } |
---|
| 192 | } |
---|
[510] | 193 | //---------------------------------------------------------- special categories |
---|
| 194 | // favorites categories |
---|
[2] | 195 | if ( !$user['is_the_guest'] ) |
---|
| 196 | { |
---|
[364] | 197 | $template->assign_block_vars('username', array()); |
---|
[510] | 198 | |
---|
| 199 | $template->assign_block_vars( |
---|
| 200 | 'special_cat', |
---|
| 201 | array( |
---|
| 202 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'), |
---|
| 203 | 'TITLE' => $lang['favorite_cat_hint'], |
---|
| 204 | 'NAME' => $lang['favorite_cat'] |
---|
| 205 | )); |
---|
[2] | 206 | } |
---|
[510] | 207 | // most visited |
---|
| 208 | $template->assign_block_vars( |
---|
| 209 | 'special_cat', |
---|
| 210 | array( |
---|
| 211 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'), |
---|
| 212 | 'TITLE' => $lang['most_visited_cat_hint'], |
---|
[733] | 213 | 'NAME' => $lang['most_visited_cat'] |
---|
[510] | 214 | )); |
---|
| 215 | // best rated |
---|
| 216 | $template->assign_block_vars( |
---|
| 217 | 'special_cat', |
---|
| 218 | array( |
---|
| 219 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'), |
---|
| 220 | 'TITLE' => $lang['best_rated_cat_hint'], |
---|
[733] | 221 | 'NAME' => $lang['best_rated_cat'] |
---|
[510] | 222 | )); |
---|
| 223 | // random |
---|
| 224 | $template->assign_block_vars( |
---|
| 225 | 'special_cat', |
---|
| 226 | array( |
---|
[605] | 227 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'random.php'), |
---|
[510] | 228 | 'TITLE' => $lang['random_cat_hint'], |
---|
| 229 | 'NAME' => $lang['random_cat'] |
---|
| 230 | )); |
---|
| 231 | // recent pics |
---|
| 232 | $template->assign_block_vars( |
---|
| 233 | 'special_cat', |
---|
| 234 | array( |
---|
| 235 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'), |
---|
| 236 | 'TITLE' => $lang['recent_pics_cat_hint'], |
---|
| 237 | 'NAME' => $lang['recent_pics_cat'] |
---|
| 238 | )); |
---|
| 239 | // recent cats |
---|
| 240 | $template->assign_block_vars( |
---|
| 241 | 'special_cat', |
---|
| 242 | array( |
---|
| 243 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'), |
---|
| 244 | 'TITLE' => $lang['recent_cats_cat_hint'], |
---|
| 245 | 'NAME' => $lang['recent_cats_cat'] |
---|
| 246 | )); |
---|
| 247 | // calendar |
---|
| 248 | $template->assign_block_vars( |
---|
| 249 | 'special_cat', |
---|
| 250 | array( |
---|
| 251 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'), |
---|
| 252 | 'TITLE' => $lang['calendar_hint'], |
---|
| 253 | 'NAME' => $lang['calendar'] |
---|
| 254 | )); |
---|
[2] | 255 | //--------------------------------------------------------------------- summary |
---|
[375] | 256 | |
---|
[804] | 257 | if ($user['is_the_guest']) |
---|
[2] | 258 | { |
---|
[804] | 259 | $template->assign_block_vars('register', array()); |
---|
| 260 | $template->assign_block_vars('login', array()); |
---|
| 261 | |
---|
| 262 | $template->assign_block_vars('quickconnect', array()); |
---|
| 263 | if ($conf['authorize_remembering']) |
---|
[375] | 264 | { |
---|
[804] | 265 | $template->assign_block_vars('quickconnect.remember_me', array()); |
---|
[375] | 266 | } |
---|
[2] | 267 | } |
---|
| 268 | else |
---|
| 269 | { |
---|
[804] | 270 | $template->assign_block_vars('hello', array()); |
---|
| 271 | $template->assign_block_vars('profile', array()); |
---|
| 272 | |
---|
| 273 | // the logout link has no meaning with Apache authentication : it is not |
---|
| 274 | // possible to logout with this kind of authentication. |
---|
| 275 | if (!$conf['apache_authentication']) |
---|
[555] | 276 | { |
---|
[804] | 277 | $template->assign_block_vars('logout', array()); |
---|
[555] | 278 | } |
---|
[804] | 279 | |
---|
| 280 | if ('admin' == $user['status']) |
---|
| 281 | { |
---|
| 282 | $template->assign_block_vars('admin', array()); |
---|
| 283 | } |
---|
[2] | 284 | } |
---|
[351] | 285 | |
---|
[2] | 286 | // search link |
---|
[351] | 287 | $template->assign_block_vars('summary', array( |
---|
| 288 | 'TITLE'=>$lang['hint_search'], |
---|
| 289 | 'NAME'=>$lang['search'], |
---|
| 290 | 'U_SUMMARY'=>add_session_id( 'search.php' ), |
---|
| 291 | )); |
---|
| 292 | |
---|
[166] | 293 | // comments link |
---|
[351] | 294 | $template->assign_block_vars('summary', array( |
---|
| 295 | 'TITLE'=>$lang['hint_comments'], |
---|
| 296 | 'NAME'=>$lang['comments'], |
---|
| 297 | 'U_SUMMARY'=>add_session_id( 'comments.php' ), |
---|
| 298 | )); |
---|
| 299 | |
---|
[2] | 300 | // about link |
---|
[351] | 301 | $template->assign_block_vars('summary', array( |
---|
| 302 | 'TITLE'=>$lang['hint_about'], |
---|
| 303 | 'NAME'=>$lang['about'], |
---|
| 304 | 'U_SUMMARY'=>add_session_id( 'about.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) ) |
---|
| 305 | )); |
---|
| 306 | |
---|
[801] | 307 | // notification feed |
---|
| 308 | $template->assign_block_vars( |
---|
| 309 | 'summary', |
---|
| 310 | array( |
---|
| 311 | 'TITLE'=>l10n('RSS notification feed'), |
---|
| 312 | 'NAME'=>l10n('Notification feed'), |
---|
| 313 | 'U_SUMMARY'=> |
---|
[808] | 314 | 'feed.php'.($user['is_the_guest'] ? '?feed='.$user['feed_id'] : '') |
---|
[801] | 315 | )); |
---|
| 316 | |
---|
[441] | 317 | //------------------------------------------------------ main part : thumbnails |
---|
[453] | 318 | if (isset($page['cat']) |
---|
| 319 | and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0) |
---|
[510] | 320 | or in_array($page['cat'], |
---|
| 321 | array('search' |
---|
| 322 | ,'most_visited' |
---|
| 323 | ,'recent_pics' |
---|
| 324 | ,'best_rated' |
---|
[605] | 325 | ,'list' |
---|
[626] | 326 | ,'fav' |
---|
[510] | 327 | )))) |
---|
[2] | 328 | { |
---|
[441] | 329 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
[760] | 330 | |
---|
| 331 | if ('admin' == $user['status']) |
---|
| 332 | { |
---|
| 333 | $template->assign_block_vars('caddie', array()); |
---|
| 334 | } |
---|
[2] | 335 | } |
---|
[441] | 336 | elseif (isset($page['cat']) and $page['cat'] == 'calendar') |
---|
[428] | 337 | { |
---|
[441] | 338 | include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php'); |
---|
[428] | 339 | } |
---|
[441] | 340 | elseif (isset($page['cat']) and $page['cat'] == 'recent_cats') |
---|
[436] | 341 | { |
---|
[441] | 342 | include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php'); |
---|
[436] | 343 | } |
---|
[351] | 344 | else |
---|
[2] | 345 | { |
---|
[441] | 346 | include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php'); |
---|
[2] | 347 | } |
---|
| 348 | //------------------------------------------------------- category informations |
---|
| 349 | if ( isset ( $page['cat'] ) ) |
---|
| 350 | { |
---|
[394] | 351 | // upload a picture in the category |
---|
[602] | 352 | if (is_numeric($page['cat']) |
---|
| 353 | and $page['cat_site_id'] == 1 |
---|
| 354 | and $page['cat_dir'] != '' |
---|
| 355 | and $page['cat_uploadable']) |
---|
[2] | 356 | { |
---|
[394] | 357 | $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; |
---|
[428] | 358 | $template->assign_block_vars( |
---|
| 359 | 'upload', |
---|
| 360 | array('U_UPLOAD'=>add_session_id( $url )) |
---|
| 361 | ); |
---|
[2] | 362 | } |
---|
[428] | 363 | |
---|
| 364 | if ( $page['navigation_bar'] != '' |
---|
| 365 | or ( isset( $page['comment'] ) and $page['comment'] != '' ) ) |
---|
| 366 | { |
---|
| 367 | $template->assign_block_vars('cat_infos',array()); |
---|
| 368 | } |
---|
[394] | 369 | |
---|
[351] | 370 | // navigation bar |
---|
| 371 | if ( $page['navigation_bar'] != '' ) |
---|
| 372 | { |
---|
[428] | 373 | $template->assign_block_vars( |
---|
| 374 | 'cat_infos.navigation', |
---|
| 375 | array('NAV_BAR' => $page['navigation_bar']) |
---|
| 376 | ); |
---|
[351] | 377 | } |
---|
| 378 | // category comment |
---|
| 379 | if ( isset( $page['comment'] ) and $page['comment'] != '' ) |
---|
| 380 | { |
---|
[428] | 381 | $template->assign_block_vars( |
---|
| 382 | 'cat_infos.comment', |
---|
| 383 | array('COMMENTS' => $page['comment']) |
---|
| 384 | ); |
---|
[351] | 385 | } |
---|
[2] | 386 | } |
---|
| 387 | //------------------------------------------------------------ log informations |
---|
| 388 | pwg_log( 'category', $page['title'] ); |
---|
| 389 | mysql_close(); |
---|
[345] | 390 | |
---|
[688] | 391 | $template->parse('category'); |
---|
[369] | 392 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 393 | ?> |
---|