[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: 2006-02-10 02:10:41 +0000 (Fri, 10 Feb 2006) $ |
---|
| 10 | // | last modifier : $Author: rvelices $ |
---|
| 11 | // | revision : $Revision: 1031 $ |
---|
| 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' |
---|
[1004] | 34 | and isset( $_COOKIE[session_name()] ) ) |
---|
[45] | 35 | { |
---|
| 36 | // cookie deletion if exists |
---|
[1004] | 37 | $_SESSION = array(); |
---|
| 38 | session_unset(); |
---|
| 39 | session_destroy(); |
---|
[1029] | 40 | setcookie(session_name(),'',0, cookie_path() ); |
---|
[45] | 41 | $url = 'category.php'; |
---|
[405] | 42 | redirect( $url ); |
---|
[45] | 43 | } |
---|
[2] | 44 | //-------------------------------------------------- access authorization check |
---|
[614] | 45 | if (isset($_GET['cat'])) |
---|
| 46 | { |
---|
| 47 | check_cat_id($_GET['cat']); |
---|
| 48 | } |
---|
[2] | 49 | check_login_authorization(); |
---|
[614] | 50 | if (isset($page['cat']) and is_numeric($page['cat'])) |
---|
[2] | 51 | { |
---|
[614] | 52 | check_restrictions($page['cat']); |
---|
[2] | 53 | } |
---|
[1022] | 54 | //----------------------------------------------- change of image dispaly order |
---|
| 55 | if ( isset($_GET['image_order']) ) |
---|
| 56 | { |
---|
| 57 | setcookie( 'pwg_image_order', |
---|
| 58 | $_GET['image_order']>0 ? $_GET['image_order'] : '', 0 ); |
---|
| 59 | redirect( PHPWG_ROOT_PATH.'category.php'. |
---|
| 60 | get_query_string_diff(array('image_order')) ); |
---|
| 61 | } |
---|
[2] | 62 | //-------------------------------------------------------------- initialization |
---|
[345] | 63 | // detection of the start picture to display |
---|
| 64 | if ( !isset( $_GET['start'] ) |
---|
| 65 | or !is_numeric( $_GET['start'] ) |
---|
| 66 | or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) |
---|
[514] | 67 | { |
---|
[345] | 68 | $page['start'] = 0; |
---|
[514] | 69 | } |
---|
[345] | 70 | else |
---|
[514] | 71 | { |
---|
[345] | 72 | $page['start'] = $_GET['start']; |
---|
[514] | 73 | } |
---|
[345] | 74 | |
---|
| 75 | initialize_category(); |
---|
| 76 | |
---|
[755] | 77 | // caddie filling :-) |
---|
| 78 | if (isset($_GET['caddie'])) |
---|
| 79 | { |
---|
[764] | 80 | // include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
[755] | 81 | |
---|
| 82 | $query = ' |
---|
| 83 | SELECT DISTINCT(id) |
---|
| 84 | FROM '.IMAGES_TABLE.' AS i |
---|
| 85 | INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id |
---|
| 86 | '.$page['where'].' |
---|
| 87 | ;'; |
---|
[764] | 88 | fill_caddie(array_from_query($query, 'id')); |
---|
[755] | 89 | } |
---|
| 90 | |
---|
[2] | 91 | //----------------------------------------------------- template initialization |
---|
[345] | 92 | // |
---|
| 93 | // Start output of page |
---|
| 94 | // |
---|
| 95 | $title = $page['title']; |
---|
[850] | 96 | $page['body_id'] = 'theCategoryPage'; |
---|
[369] | 97 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[345] | 98 | |
---|
[351] | 99 | $template->set_filenames( array('category'=>'category.tpl') ); |
---|
| 100 | //-------------------------------------------------------------- category title |
---|
[663] | 101 | if (isset($page['cat']) and is_numeric($page['cat'])) |
---|
[351] | 102 | { |
---|
[657] | 103 | $template_title = get_cat_display_name($page['cat_name'], |
---|
| 104 | 'category.php?cat=', |
---|
| 105 | false); |
---|
| 106 | } |
---|
[663] | 107 | else |
---|
| 108 | { |
---|
| 109 | $template_title = $page['title']; |
---|
| 110 | } |
---|
[657] | 111 | |
---|
[428] | 112 | if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 ) |
---|
| 113 | { |
---|
| 114 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
| 115 | } |
---|
[2] | 116 | |
---|
[452] | 117 | $icon_recent = get_icon(date('Y-m-d')); |
---|
[436] | 118 | |
---|
[850] | 119 | $template->assign_vars( |
---|
| 120 | array( |
---|
[351] | 121 | 'NB_PICTURE' => count_user_total_images(), |
---|
[428] | 122 | 'TITLE' => $template_title, |
---|
[351] | 123 | 'USERNAME' => $user['username'], |
---|
[507] | 124 | 'TOP_NUMBER'=>$conf['top_number'], |
---|
[614] | 125 | 'MENU_CATEGORIES_CONTENT'=>get_categories_menu(), |
---|
[2] | 126 | |
---|
[351] | 127 | 'L_CATEGORIES' => $lang['categories'], |
---|
| 128 | 'L_HINT_CATEGORY' => $lang['hint_category'], |
---|
| 129 | 'L_SUBCAT' => $lang['sub-cat'], |
---|
| 130 | 'L_IMG_AVAILABLE' => $lang['images_available'], |
---|
| 131 | 'L_TOTAL' => $lang['total'], |
---|
[428] | 132 | 'L_SPECIAL_CATEGORIES' => $lang['special_categories'], |
---|
[351] | 133 | 'L_SUMMARY' => $lang['title_menu'], |
---|
| 134 | 'L_UPLOAD' => $lang['upload_picture'], |
---|
| 135 | 'L_COMMENT' => $lang['comments'], |
---|
[671] | 136 | 'L_IDENTIFY' => $lang['identification'], |
---|
[375] | 137 | 'L_PASSWORD' => $lang['password'], |
---|
| 138 | 'L_HELLO' => $lang['hello'], |
---|
[654] | 139 | 'L_REGISTER' => $lang['ident_register'], |
---|
[375] | 140 | 'L_LOGOUT' => $lang['logout'], |
---|
| 141 | 'L_ADMIN' => $lang['admin'], |
---|
| 142 | 'L_ADMIN_HINT' => $lang['hint_admin'], |
---|
| 143 | 'L_PROFILE' => $lang['customize'], |
---|
| 144 | 'L_PROFILE_HINT' => $lang['hint_customize'], |
---|
[541] | 145 | 'L_REMEMBER_ME' => $lang['remember_me'], |
---|
[351] | 146 | |
---|
[1004] | 147 | 'F_IDENTIFY' => PHPWG_ROOT_PATH.'identification.php', |
---|
[452] | 148 | 'T_RECENT' => $icon_recent, |
---|
[2] | 149 | |
---|
[1004] | 150 | 'U_HOME' => PHPWG_ROOT_PATH.'category.php', |
---|
| 151 | 'U_REGISTER' => PHPWG_ROOT_PATH.'register.php', |
---|
| 152 | 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php', |
---|
[393] | 153 | 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout', |
---|
[1004] | 154 | 'U_ADMIN'=> PHPWG_ROOT_PATH.'admin.php', |
---|
| 155 | 'U_PROFILE'=> PHPWG_ROOT_PATH.'profile.php' |
---|
[351] | 156 | ) |
---|
| 157 | ); |
---|
[1015] | 158 | |
---|
| 159 | if (isset($page['cat']) and 'search' == $page['cat']) |
---|
| 160 | { |
---|
| 161 | $template->assign_block_vars( |
---|
| 162 | 'search_rules', |
---|
| 163 | array( |
---|
| 164 | 'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$_GET['search'], |
---|
| 165 | ) |
---|
| 166 | ); |
---|
| 167 | } |
---|
[797] | 168 | //-------------------------------------------------------------- external links |
---|
| 169 | if (count($conf['links']) > 0) |
---|
| 170 | { |
---|
| 171 | $template->assign_block_vars('links', array()); |
---|
| 172 | |
---|
| 173 | foreach ($conf['links'] as $url => $label) |
---|
| 174 | { |
---|
| 175 | $template->assign_block_vars( |
---|
| 176 | 'links.link', |
---|
| 177 | array( |
---|
| 178 | 'URL' => $url, |
---|
| 179 | 'LABEL' => $label |
---|
| 180 | )); |
---|
| 181 | } |
---|
| 182 | } |
---|
[510] | 183 | //---------------------------------------------------------- special categories |
---|
| 184 | // favorites categories |
---|
[2] | 185 | if ( !$user['is_the_guest'] ) |
---|
| 186 | { |
---|
[364] | 187 | $template->assign_block_vars('username', array()); |
---|
[510] | 188 | |
---|
| 189 | $template->assign_block_vars( |
---|
| 190 | 'special_cat', |
---|
| 191 | array( |
---|
[1004] | 192 | 'URL' => PHPWG_ROOT_PATH.'category.php?cat=fav', |
---|
[510] | 193 | 'TITLE' => $lang['favorite_cat_hint'], |
---|
| 194 | 'NAME' => $lang['favorite_cat'] |
---|
| 195 | )); |
---|
[2] | 196 | } |
---|
[510] | 197 | // most visited |
---|
| 198 | $template->assign_block_vars( |
---|
| 199 | 'special_cat', |
---|
| 200 | array( |
---|
[1004] | 201 | 'URL' => PHPWG_ROOT_PATH.'category.php?cat=most_visited', |
---|
[510] | 202 | 'TITLE' => $lang['most_visited_cat_hint'], |
---|
[733] | 203 | 'NAME' => $lang['most_visited_cat'] |
---|
[510] | 204 | )); |
---|
| 205 | // best rated |
---|
[869] | 206 | if ($conf['rate']) |
---|
| 207 | { |
---|
| 208 | $template->assign_block_vars( |
---|
| 209 | 'special_cat', |
---|
| 210 | array( |
---|
[1004] | 211 | 'URL' => PHPWG_ROOT_PATH.'category.php?cat=best_rated', |
---|
[869] | 212 | 'TITLE' => $lang['best_rated_cat_hint'], |
---|
| 213 | 'NAME' => $lang['best_rated_cat'] |
---|
| 214 | ) |
---|
| 215 | ); |
---|
| 216 | } |
---|
[510] | 217 | // random |
---|
| 218 | $template->assign_block_vars( |
---|
| 219 | 'special_cat', |
---|
| 220 | array( |
---|
[1004] | 221 | 'URL' => PHPWG_ROOT_PATH.'random.php', |
---|
[510] | 222 | 'TITLE' => $lang['random_cat_hint'], |
---|
| 223 | 'NAME' => $lang['random_cat'] |
---|
| 224 | )); |
---|
| 225 | // recent pics |
---|
| 226 | $template->assign_block_vars( |
---|
| 227 | 'special_cat', |
---|
| 228 | array( |
---|
[1004] | 229 | 'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_pics', |
---|
[510] | 230 | 'TITLE' => $lang['recent_pics_cat_hint'], |
---|
| 231 | 'NAME' => $lang['recent_pics_cat'] |
---|
| 232 | )); |
---|
| 233 | // recent cats |
---|
| 234 | $template->assign_block_vars( |
---|
| 235 | 'special_cat', |
---|
| 236 | array( |
---|
[1004] | 237 | 'URL' => PHPWG_ROOT_PATH.'category.php?cat=recent_cats', |
---|
[510] | 238 | 'TITLE' => $lang['recent_cats_cat_hint'], |
---|
| 239 | 'NAME' => $lang['recent_cats_cat'] |
---|
| 240 | )); |
---|
| 241 | // calendar |
---|
| 242 | $template->assign_block_vars( |
---|
| 243 | 'special_cat', |
---|
| 244 | array( |
---|
[1004] | 245 | 'URL' => PHPWG_ROOT_PATH.'category.php?cat=calendar', |
---|
[510] | 246 | 'TITLE' => $lang['calendar_hint'], |
---|
| 247 | 'NAME' => $lang['calendar'] |
---|
| 248 | )); |
---|
[2] | 249 | //--------------------------------------------------------------------- summary |
---|
[375] | 250 | |
---|
[804] | 251 | if ($user['is_the_guest']) |
---|
[2] | 252 | { |
---|
[804] | 253 | $template->assign_block_vars('register', array()); |
---|
| 254 | $template->assign_block_vars('login', array()); |
---|
| 255 | |
---|
| 256 | $template->assign_block_vars('quickconnect', array()); |
---|
| 257 | if ($conf['authorize_remembering']) |
---|
[375] | 258 | { |
---|
[804] | 259 | $template->assign_block_vars('quickconnect.remember_me', array()); |
---|
[375] | 260 | } |
---|
[2] | 261 | } |
---|
| 262 | else |
---|
| 263 | { |
---|
[804] | 264 | $template->assign_block_vars('hello', array()); |
---|
| 265 | $template->assign_block_vars('profile', array()); |
---|
| 266 | |
---|
| 267 | // the logout link has no meaning with Apache authentication : it is not |
---|
| 268 | // possible to logout with this kind of authentication. |
---|
| 269 | if (!$conf['apache_authentication']) |
---|
[555] | 270 | { |
---|
[804] | 271 | $template->assign_block_vars('logout', array()); |
---|
[555] | 272 | } |
---|
[804] | 273 | |
---|
| 274 | if ('admin' == $user['status']) |
---|
| 275 | { |
---|
| 276 | $template->assign_block_vars('admin', array()); |
---|
| 277 | } |
---|
[2] | 278 | } |
---|
[351] | 279 | |
---|
[2] | 280 | // search link |
---|
[351] | 281 | $template->assign_block_vars('summary', array( |
---|
| 282 | 'TITLE'=>$lang['hint_search'], |
---|
| 283 | 'NAME'=>$lang['search'], |
---|
[1004] | 284 | 'U_SUMMARY'=> 'search.php', |
---|
[1031] | 285 | 'REL'=> 'rel="search"' |
---|
[351] | 286 | )); |
---|
| 287 | |
---|
[166] | 288 | // comments link |
---|
[351] | 289 | $template->assign_block_vars('summary', array( |
---|
| 290 | 'TITLE'=>$lang['hint_comments'], |
---|
| 291 | 'NAME'=>$lang['comments'], |
---|
[1004] | 292 | 'U_SUMMARY'=> 'comments.php', |
---|
[351] | 293 | )); |
---|
| 294 | |
---|
[2] | 295 | // about link |
---|
[351] | 296 | $template->assign_block_vars('summary', array( |
---|
[889] | 297 | 'TITLE'=>$lang['about_page_title'], |
---|
| 298 | 'NAME'=>$lang['About'], |
---|
[1004] | 299 | 'U_SUMMARY'=> 'about.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) |
---|
[351] | 300 | )); |
---|
| 301 | |
---|
[833] | 302 | // notification |
---|
[801] | 303 | $template->assign_block_vars( |
---|
| 304 | 'summary', |
---|
| 305 | array( |
---|
[833] | 306 | 'TITLE'=>l10n('notification'), |
---|
| 307 | 'NAME'=>l10n('Notification'), |
---|
[1031] | 308 | 'U_SUMMARY'=> PHPWG_ROOT_PATH.'notification.php', |
---|
| 309 | 'REL'=> 'rel="nofollow"' |
---|
[801] | 310 | )); |
---|
| 311 | |
---|
[834] | 312 | if (isset($page['cat']) |
---|
| 313 | and is_numeric($page['cat']) |
---|
| 314 | and 'admin' == $user['status']) |
---|
| 315 | { |
---|
| 316 | $template->assign_block_vars( |
---|
| 317 | 'edit', |
---|
| 318 | array( |
---|
| 319 | 'URL' => |
---|
| 320 | PHPWG_ROOT_PATH.'admin.php?page=cat_modify' |
---|
| 321 | .'&cat_id='.$page['cat'] |
---|
| 322 | ) |
---|
| 323 | ); |
---|
| 324 | } |
---|
| 325 | |
---|
[441] | 326 | //------------------------------------------------------ main part : thumbnails |
---|
[453] | 327 | if (isset($page['cat']) |
---|
| 328 | and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0) |
---|
[510] | 329 | or in_array($page['cat'], |
---|
| 330 | array('search' |
---|
| 331 | ,'most_visited' |
---|
| 332 | ,'recent_pics' |
---|
| 333 | ,'best_rated' |
---|
[605] | 334 | ,'list' |
---|
[626] | 335 | ,'fav' |
---|
[510] | 336 | )))) |
---|
[2] | 337 | { |
---|
[441] | 338 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
[760] | 339 | |
---|
| 340 | if ('admin' == $user['status']) |
---|
| 341 | { |
---|
[834] | 342 | $template->assign_block_vars( |
---|
| 343 | 'caddie', |
---|
| 344 | array( |
---|
| 345 | 'URL' => |
---|
| 346 | PHPWG_ROOT_PATH.'category.php' |
---|
| 347 | .get_query_string_diff(array('caddie')).'&caddie=1') |
---|
| 348 | ); |
---|
[760] | 349 | } |
---|
[2] | 350 | } |
---|
[441] | 351 | elseif (isset($page['cat']) and $page['cat'] == 'calendar') |
---|
[428] | 352 | { |
---|
[441] | 353 | include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php'); |
---|
[428] | 354 | } |
---|
[441] | 355 | elseif (isset($page['cat']) and $page['cat'] == 'recent_cats') |
---|
[436] | 356 | { |
---|
[441] | 357 | include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php'); |
---|
[436] | 358 | } |
---|
[351] | 359 | else |
---|
[2] | 360 | { |
---|
[441] | 361 | include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php'); |
---|
[2] | 362 | } |
---|
| 363 | //------------------------------------------------------- category informations |
---|
| 364 | if ( isset ( $page['cat'] ) ) |
---|
| 365 | { |
---|
[394] | 366 | // upload a picture in the category |
---|
[602] | 367 | if (is_numeric($page['cat']) |
---|
| 368 | and $page['cat_site_id'] == 1 |
---|
| 369 | and $page['cat_dir'] != '' |
---|
| 370 | and $page['cat_uploadable']) |
---|
[2] | 371 | { |
---|
[394] | 372 | $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; |
---|
[428] | 373 | $template->assign_block_vars( |
---|
| 374 | 'upload', |
---|
[1004] | 375 | array('U_UPLOAD'=> $url ) |
---|
[428] | 376 | ); |
---|
[2] | 377 | } |
---|
[428] | 378 | |
---|
| 379 | if ( $page['navigation_bar'] != '' |
---|
| 380 | or ( isset( $page['comment'] ) and $page['comment'] != '' ) ) |
---|
| 381 | { |
---|
| 382 | $template->assign_block_vars('cat_infos',array()); |
---|
| 383 | } |
---|
[394] | 384 | |
---|
[351] | 385 | // navigation bar |
---|
| 386 | if ( $page['navigation_bar'] != '' ) |
---|
| 387 | { |
---|
[428] | 388 | $template->assign_block_vars( |
---|
| 389 | 'cat_infos.navigation', |
---|
| 390 | array('NAV_BAR' => $page['navigation_bar']) |
---|
| 391 | ); |
---|
[351] | 392 | } |
---|
| 393 | // category comment |
---|
| 394 | if ( isset( $page['comment'] ) and $page['comment'] != '' ) |
---|
| 395 | { |
---|
[428] | 396 | $template->assign_block_vars( |
---|
| 397 | 'cat_infos.comment', |
---|
| 398 | array('COMMENTS' => $page['comment']) |
---|
| 399 | ); |
---|
[351] | 400 | } |
---|
[1020] | 401 | if ($page['cat_nb_images']>0 and |
---|
| 402 | $page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') |
---|
| 403 | { |
---|
| 404 | // image order |
---|
| 405 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
| 406 | |
---|
[1022] | 407 | $order_idx = isset($_COOKIE['pwg_image_order']) ? |
---|
[1020] | 408 | $_COOKIE['pwg_image_order'] : 0; |
---|
[1022] | 409 | |
---|
[1020] | 410 | $orders = get_category_preferred_image_orders(); |
---|
| 411 | for ( $i = 0; $i < count($orders); $i++) |
---|
| 412 | { |
---|
| 413 | if ($orders[$i][2]) |
---|
| 414 | { |
---|
| 415 | $url = PHPWG_ROOT_PATH.'category.php' |
---|
| 416 | .get_query_string_diff(array('image_order')); |
---|
| 417 | $url .= '&image_order='.$i; |
---|
| 418 | $template->assign_block_vars( 'preferred_image_order.order', array( |
---|
| 419 | 'DISPLAY' => $orders[$i][0], |
---|
| 420 | 'URL' => $url, |
---|
| 421 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ), |
---|
| 422 | ) ); |
---|
| 423 | } |
---|
| 424 | } |
---|
| 425 | } |
---|
[2] | 426 | } |
---|
| 427 | //------------------------------------------------------------ log informations |
---|
| 428 | pwg_log( 'category', $page['title'] ); |
---|
[345] | 429 | |
---|
[688] | 430 | $template->parse('category'); |
---|
[369] | 431 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 432 | ?> |
---|