[2] | 1 | <?php |
---|
[351] | 2 | // +-----------------------------------------------------------------------+ |
---|
[593] | 3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
| 4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
| 5 | // | Copyright (C) 2003-2004 PhpWebGallery Team - http://phpwebgallery.net | |
---|
[351] | 6 | // +-----------------------------------------------------------------------+ |
---|
[593] | 7 | // | branch : BSF (Best So Far) |
---|
[351] | 8 | // | file : $RCSfile$ |
---|
| 9 | // | last update : $Date: 2004-11-23 22:31:24 +0000 (Tue, 23 Nov 2004) $ |
---|
| 10 | // | last modifier : $Author: plg $ |
---|
| 11 | // | revision : $Revision: 614 $ |
---|
| 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 | |
---|
[2] | 78 | // creation of the array containing the cat ids to expand in the menu |
---|
| 79 | // $page['tab_expand'] contains an array with the category ids |
---|
| 80 | // $page['expand'] contains the string to display in URL with comma |
---|
| 81 | $page['tab_expand'] = array(); |
---|
[386] | 82 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
[2] | 83 | { |
---|
[345] | 84 | // the category displayed (in the URL cat=23) must be seen in the menu -> |
---|
| 85 | // parent categories must be expanded |
---|
| 86 | $uppercats = explode( ',', $page['uppercats'] ); |
---|
| 87 | foreach ( $uppercats as $uppercat ) { |
---|
| 88 | array_push( $page['tab_expand'], $uppercat ); |
---|
[193] | 89 | } |
---|
[2] | 90 | } |
---|
[386] | 91 | // in case of expanding all authorized cats $page['tab_expand'] is empty |
---|
| 92 | if ( $user['expand'] ) |
---|
[2] | 93 | { |
---|
| 94 | $page['tab_expand'] = array(); |
---|
| 95 | } |
---|
| 96 | //----------------------------------------------------- template initialization |
---|
[345] | 97 | // |
---|
| 98 | // Start output of page |
---|
| 99 | // |
---|
| 100 | $title = $page['title']; |
---|
[369] | 101 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
[345] | 102 | |
---|
[351] | 103 | $template->set_filenames( array('category'=>'category.tpl') ); |
---|
| 104 | //-------------------------------------------------------------- category title |
---|
[428] | 105 | if ( !isset( $page['title'] ) ) |
---|
[351] | 106 | { |
---|
[428] | 107 | $page['title'] = $lang['no_category']; |
---|
[351] | 108 | } |
---|
[428] | 109 | $template_title = $page['title']; |
---|
| 110 | if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 ) |
---|
| 111 | { |
---|
| 112 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
| 113 | } |
---|
[2] | 114 | |
---|
[452] | 115 | $icon_recent = get_icon(date('Y-m-d')); |
---|
[436] | 116 | |
---|
[351] | 117 | $template->assign_vars(array( |
---|
| 118 | 'NB_PICTURE' => count_user_total_images(), |
---|
[428] | 119 | 'TITLE' => $template_title, |
---|
[351] | 120 | 'USERNAME' => $user['username'], |
---|
[507] | 121 | 'TOP_NUMBER'=>$conf['top_number'], |
---|
[614] | 122 | 'MENU_CATEGORIES_CONTENT'=>get_categories_menu(), |
---|
[2] | 123 | |
---|
[351] | 124 | 'L_CATEGORIES' => $lang['categories'], |
---|
| 125 | 'L_HINT_CATEGORY' => $lang['hint_category'], |
---|
| 126 | 'L_SUBCAT' => $lang['sub-cat'], |
---|
| 127 | 'L_IMG_AVAILABLE' => $lang['images_available'], |
---|
| 128 | 'L_TOTAL' => $lang['total'], |
---|
[428] | 129 | 'L_SPECIAL_CATEGORIES' => $lang['special_categories'], |
---|
[351] | 130 | 'L_SUMMARY' => $lang['title_menu'], |
---|
| 131 | 'L_UPLOAD' => $lang['upload_picture'], |
---|
| 132 | 'L_COMMENT' => $lang['comments'], |
---|
[375] | 133 | 'L_IDENTIFY' => $lang['ident_title'], |
---|
| 134 | 'L_SUBMIT' => $lang['menu_login'], |
---|
| 135 | 'L_USERNAME' => $lang['login'], |
---|
| 136 | 'L_PASSWORD' => $lang['password'], |
---|
| 137 | 'L_HELLO' => $lang['hello'], |
---|
| 138 | 'L_LOGOUT' => $lang['logout'], |
---|
| 139 | 'L_ADMIN' => $lang['admin'], |
---|
| 140 | 'L_ADMIN_HINT' => $lang['hint_admin'], |
---|
| 141 | 'L_PROFILE' => $lang['customize'], |
---|
| 142 | 'L_PROFILE_HINT' => $lang['hint_customize'], |
---|
[541] | 143 | 'L_REMEMBER_ME' => $lang['remember_me'], |
---|
[351] | 144 | |
---|
[375] | 145 | 'F_IDENTIFY' => add_session_id( PHPWG_ROOT_PATH.'identification.php' ), |
---|
[452] | 146 | 'T_RECENT' => $icon_recent, |
---|
[2] | 147 | |
---|
[375] | 148 | 'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ), |
---|
[393] | 149 | 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout', |
---|
[375] | 150 | 'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ), |
---|
| 151 | 'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] )) |
---|
[351] | 152 | ) |
---|
| 153 | ); |
---|
[510] | 154 | //---------------------------------------------------------- special categories |
---|
| 155 | // favorites categories |
---|
[2] | 156 | if ( !$user['is_the_guest'] ) |
---|
| 157 | { |
---|
[364] | 158 | $template->assign_block_vars('username', array()); |
---|
[510] | 159 | |
---|
| 160 | $template->assign_block_vars( |
---|
| 161 | 'special_cat', |
---|
| 162 | array( |
---|
| 163 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'), |
---|
| 164 | 'TITLE' => $lang['favorite_cat_hint'], |
---|
| 165 | 'NAME' => $lang['favorite_cat'] |
---|
| 166 | )); |
---|
[2] | 167 | } |
---|
[510] | 168 | // most visited |
---|
| 169 | $template->assign_block_vars( |
---|
| 170 | 'special_cat', |
---|
| 171 | array( |
---|
| 172 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'), |
---|
| 173 | 'TITLE' => $lang['most_visited_cat_hint'], |
---|
| 174 | 'NAME' => $conf['top_number'].' '.$lang['most_visited_cat'] |
---|
| 175 | )); |
---|
| 176 | // best rated |
---|
| 177 | $template->assign_block_vars( |
---|
| 178 | 'special_cat', |
---|
| 179 | array( |
---|
| 180 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'), |
---|
| 181 | 'TITLE' => $lang['best_rated_cat_hint'], |
---|
| 182 | 'NAME' => $conf['top_number'].' '.$lang['best_rated_cat'] |
---|
| 183 | )); |
---|
| 184 | // random |
---|
| 185 | $template->assign_block_vars( |
---|
| 186 | 'special_cat', |
---|
| 187 | array( |
---|
[605] | 188 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'random.php'), |
---|
[510] | 189 | 'TITLE' => $lang['random_cat_hint'], |
---|
| 190 | 'NAME' => $lang['random_cat'] |
---|
| 191 | )); |
---|
| 192 | // recent pics |
---|
| 193 | $template->assign_block_vars( |
---|
| 194 | 'special_cat', |
---|
| 195 | array( |
---|
| 196 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'), |
---|
| 197 | 'TITLE' => $lang['recent_pics_cat_hint'], |
---|
| 198 | 'NAME' => $lang['recent_pics_cat'] |
---|
| 199 | )); |
---|
| 200 | // recent cats |
---|
| 201 | $template->assign_block_vars( |
---|
| 202 | 'special_cat', |
---|
| 203 | array( |
---|
| 204 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'), |
---|
| 205 | 'TITLE' => $lang['recent_cats_cat_hint'], |
---|
| 206 | 'NAME' => $lang['recent_cats_cat'] |
---|
| 207 | )); |
---|
| 208 | // calendar |
---|
| 209 | $template->assign_block_vars( |
---|
| 210 | 'special_cat', |
---|
| 211 | array( |
---|
| 212 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'), |
---|
| 213 | 'TITLE' => $lang['calendar_hint'], |
---|
| 214 | 'NAME' => $lang['calendar'] |
---|
| 215 | )); |
---|
[2] | 216 | //--------------------------------------------------------------------- summary |
---|
[375] | 217 | |
---|
[2] | 218 | if ( !$user['is_the_guest'] ) |
---|
| 219 | { |
---|
[375] | 220 | $template->assign_block_vars('logout',array()); |
---|
| 221 | // administration link |
---|
| 222 | if ( $user['status'] == 'admin' ) |
---|
| 223 | { |
---|
| 224 | $template->assign_block_vars('logout.admin', array()); |
---|
| 225 | } |
---|
[2] | 226 | } |
---|
| 227 | else |
---|
| 228 | { |
---|
[375] | 229 | $template->assign_block_vars('login',array()); |
---|
[555] | 230 | if ($conf['authorize_remembering']) |
---|
| 231 | { |
---|
| 232 | $template->assign_block_vars('login.remember_me',array()); |
---|
| 233 | } |
---|
[2] | 234 | } |
---|
[351] | 235 | |
---|
[2] | 236 | // search link |
---|
[351] | 237 | $template->assign_block_vars('summary', array( |
---|
| 238 | 'TITLE'=>$lang['hint_search'], |
---|
| 239 | 'NAME'=>$lang['search'], |
---|
| 240 | 'U_SUMMARY'=>add_session_id( 'search.php' ), |
---|
| 241 | )); |
---|
| 242 | |
---|
[166] | 243 | // comments link |
---|
[351] | 244 | $template->assign_block_vars('summary', array( |
---|
| 245 | 'TITLE'=>$lang['hint_comments'], |
---|
| 246 | 'NAME'=>$lang['comments'], |
---|
| 247 | 'U_SUMMARY'=>add_session_id( 'comments.php' ), |
---|
| 248 | )); |
---|
| 249 | |
---|
[2] | 250 | // about link |
---|
[351] | 251 | $template->assign_block_vars('summary', array( |
---|
| 252 | 'TITLE'=>$lang['hint_about'], |
---|
| 253 | 'NAME'=>$lang['about'], |
---|
| 254 | 'U_SUMMARY'=>add_session_id( 'about.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) ) |
---|
| 255 | )); |
---|
| 256 | |
---|
[441] | 257 | //------------------------------------------------------ main part : thumbnails |
---|
[453] | 258 | if (isset($page['cat']) |
---|
| 259 | and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0) |
---|
[510] | 260 | or in_array($page['cat'], |
---|
| 261 | array('search' |
---|
| 262 | ,'most_visited' |
---|
| 263 | ,'recent_pics' |
---|
| 264 | ,'best_rated' |
---|
[605] | 265 | ,'list' |
---|
[510] | 266 | )))) |
---|
[2] | 267 | { |
---|
[441] | 268 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
[2] | 269 | } |
---|
[441] | 270 | elseif (isset($page['cat']) and $page['cat'] == 'calendar') |
---|
[428] | 271 | { |
---|
[441] | 272 | include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php'); |
---|
[428] | 273 | } |
---|
[441] | 274 | elseif (isset($page['cat']) and $page['cat'] == 'recent_cats') |
---|
[436] | 275 | { |
---|
[441] | 276 | include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php'); |
---|
[436] | 277 | } |
---|
[351] | 278 | else |
---|
[2] | 279 | { |
---|
[441] | 280 | include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php'); |
---|
[2] | 281 | } |
---|
| 282 | //------------------------------------------------------- category informations |
---|
| 283 | if ( isset ( $page['cat'] ) ) |
---|
| 284 | { |
---|
[394] | 285 | // upload a picture in the category |
---|
[602] | 286 | if (is_numeric($page['cat']) |
---|
| 287 | and $page['cat_site_id'] == 1 |
---|
| 288 | and $page['cat_dir'] != '' |
---|
| 289 | and $page['cat_uploadable']) |
---|
[2] | 290 | { |
---|
[394] | 291 | $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; |
---|
[428] | 292 | $template->assign_block_vars( |
---|
| 293 | 'upload', |
---|
| 294 | array('U_UPLOAD'=>add_session_id( $url )) |
---|
| 295 | ); |
---|
[2] | 296 | } |
---|
[428] | 297 | |
---|
| 298 | if ( $page['navigation_bar'] != '' |
---|
| 299 | or ( isset( $page['comment'] ) and $page['comment'] != '' ) ) |
---|
| 300 | { |
---|
| 301 | $template->assign_block_vars('cat_infos',array()); |
---|
| 302 | } |
---|
[394] | 303 | |
---|
[351] | 304 | // navigation bar |
---|
| 305 | if ( $page['navigation_bar'] != '' ) |
---|
| 306 | { |
---|
[428] | 307 | $template->assign_block_vars( |
---|
| 308 | 'cat_infos.navigation', |
---|
| 309 | array('NAV_BAR' => $page['navigation_bar']) |
---|
| 310 | ); |
---|
[351] | 311 | } |
---|
| 312 | // category comment |
---|
| 313 | if ( isset( $page['comment'] ) and $page['comment'] != '' ) |
---|
| 314 | { |
---|
[428] | 315 | $template->assign_block_vars( |
---|
| 316 | 'cat_infos.comment', |
---|
| 317 | array('COMMENTS' => $page['comment']) |
---|
| 318 | ); |
---|
[351] | 319 | } |
---|
[2] | 320 | } |
---|
| 321 | //------------------------------------------------------------ log informations |
---|
| 322 | pwg_log( 'category', $page['title'] ); |
---|
| 323 | mysql_close(); |
---|
[345] | 324 | |
---|
[351] | 325 | $template->pparse('category'); |
---|
[369] | 326 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 327 | ?> |
---|