[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-04-30 15:23:28 +0000 (Sat, 30 Apr 2005) $ |
---|
| 10 | // | last modifier : $Author: plg $ |
---|
| 11 | // | revision : $Revision: 778 $ |
---|
| 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 |
---|
[663] | 105 | if (isset($page['cat']) and is_numeric($page['cat'])) |
---|
[351] | 106 | { |
---|
[657] | 107 | $template_title = get_cat_display_name($page['cat_name'], |
---|
| 108 | 'category.php?cat=', |
---|
| 109 | false); |
---|
| 110 | } |
---|
[663] | 111 | else |
---|
| 112 | { |
---|
| 113 | $template_title = $page['title']; |
---|
| 114 | } |
---|
[657] | 115 | |
---|
[428] | 116 | if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 ) |
---|
| 117 | { |
---|
| 118 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
| 119 | } |
---|
[2] | 120 | |
---|
[452] | 121 | $icon_recent = get_icon(date('Y-m-d')); |
---|
[436] | 122 | |
---|
[351] | 123 | $template->assign_vars(array( |
---|
| 124 | 'NB_PICTURE' => count_user_total_images(), |
---|
[428] | 125 | 'TITLE' => $template_title, |
---|
[351] | 126 | 'USERNAME' => $user['username'], |
---|
[507] | 127 | 'TOP_NUMBER'=>$conf['top_number'], |
---|
[614] | 128 | 'MENU_CATEGORIES_CONTENT'=>get_categories_menu(), |
---|
[2] | 129 | |
---|
[351] | 130 | 'L_CATEGORIES' => $lang['categories'], |
---|
| 131 | 'L_HINT_CATEGORY' => $lang['hint_category'], |
---|
| 132 | 'L_SUBCAT' => $lang['sub-cat'], |
---|
| 133 | 'L_IMG_AVAILABLE' => $lang['images_available'], |
---|
| 134 | 'L_TOTAL' => $lang['total'], |
---|
[428] | 135 | 'L_SPECIAL_CATEGORIES' => $lang['special_categories'], |
---|
[351] | 136 | 'L_SUMMARY' => $lang['title_menu'], |
---|
| 137 | 'L_UPLOAD' => $lang['upload_picture'], |
---|
| 138 | 'L_COMMENT' => $lang['comments'], |
---|
[671] | 139 | 'L_IDENTIFY' => $lang['identification'], |
---|
[375] | 140 | 'L_SUBMIT' => $lang['menu_login'], |
---|
| 141 | 'L_USERNAME' => $lang['login'], |
---|
| 142 | 'L_PASSWORD' => $lang['password'], |
---|
| 143 | 'L_HELLO' => $lang['hello'], |
---|
[654] | 144 | 'L_REGISTER' => $lang['ident_register'], |
---|
| 145 | 'L_LOGIN' => $lang['menu_login'], |
---|
[375] | 146 | 'L_LOGOUT' => $lang['logout'], |
---|
| 147 | 'L_ADMIN' => $lang['admin'], |
---|
| 148 | 'L_ADMIN_HINT' => $lang['hint_admin'], |
---|
| 149 | 'L_PROFILE' => $lang['customize'], |
---|
| 150 | 'L_PROFILE_HINT' => $lang['hint_customize'], |
---|
[541] | 151 | 'L_REMEMBER_ME' => $lang['remember_me'], |
---|
[351] | 152 | |
---|
[375] | 153 | 'F_IDENTIFY' => add_session_id( PHPWG_ROOT_PATH.'identification.php' ), |
---|
[452] | 154 | 'T_RECENT' => $icon_recent, |
---|
[2] | 155 | |
---|
[375] | 156 | 'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ), |
---|
[654] | 157 | 'U_REGISTER' => add_session_id( PHPWG_ROOT_PATH.'register.php' ), |
---|
[393] | 158 | 'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout', |
---|
[375] | 159 | 'U_ADMIN'=>add_session_id( PHPWG_ROOT_PATH.'admin.php' ), |
---|
| 160 | 'U_PROFILE'=>add_session_id(PHPWG_ROOT_PATH.'profile.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] )) |
---|
[351] | 161 | ) |
---|
| 162 | ); |
---|
[510] | 163 | //---------------------------------------------------------- special categories |
---|
| 164 | // favorites categories |
---|
[2] | 165 | if ( !$user['is_the_guest'] ) |
---|
| 166 | { |
---|
[364] | 167 | $template->assign_block_vars('username', array()); |
---|
[510] | 168 | |
---|
| 169 | $template->assign_block_vars( |
---|
| 170 | 'special_cat', |
---|
| 171 | array( |
---|
| 172 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=fav'), |
---|
| 173 | 'TITLE' => $lang['favorite_cat_hint'], |
---|
| 174 | 'NAME' => $lang['favorite_cat'] |
---|
| 175 | )); |
---|
[2] | 176 | } |
---|
[510] | 177 | // most visited |
---|
| 178 | $template->assign_block_vars( |
---|
| 179 | 'special_cat', |
---|
| 180 | array( |
---|
| 181 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=most_visited'), |
---|
| 182 | 'TITLE' => $lang['most_visited_cat_hint'], |
---|
[733] | 183 | 'NAME' => $lang['most_visited_cat'] |
---|
[510] | 184 | )); |
---|
| 185 | // best rated |
---|
[778] | 186 | if ($conf['rate']) |
---|
| 187 | { |
---|
| 188 | $template->assign_block_vars( |
---|
| 189 | 'special_cat', |
---|
| 190 | array( |
---|
| 191 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=best_rated'), |
---|
| 192 | 'TITLE' => $lang['best_rated_cat_hint'], |
---|
| 193 | 'NAME' => $lang['best_rated_cat'] |
---|
| 194 | )); |
---|
| 195 | } |
---|
[510] | 196 | // random |
---|
| 197 | $template->assign_block_vars( |
---|
| 198 | 'special_cat', |
---|
| 199 | array( |
---|
[605] | 200 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'random.php'), |
---|
[510] | 201 | 'TITLE' => $lang['random_cat_hint'], |
---|
| 202 | 'NAME' => $lang['random_cat'] |
---|
| 203 | )); |
---|
| 204 | // recent pics |
---|
| 205 | $template->assign_block_vars( |
---|
| 206 | 'special_cat', |
---|
| 207 | array( |
---|
| 208 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_pics'), |
---|
| 209 | 'TITLE' => $lang['recent_pics_cat_hint'], |
---|
| 210 | 'NAME' => $lang['recent_pics_cat'] |
---|
| 211 | )); |
---|
| 212 | // recent cats |
---|
| 213 | $template->assign_block_vars( |
---|
| 214 | 'special_cat', |
---|
| 215 | array( |
---|
| 216 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=recent_cats'), |
---|
| 217 | 'TITLE' => $lang['recent_cats_cat_hint'], |
---|
| 218 | 'NAME' => $lang['recent_cats_cat'] |
---|
| 219 | )); |
---|
| 220 | // calendar |
---|
| 221 | $template->assign_block_vars( |
---|
| 222 | 'special_cat', |
---|
| 223 | array( |
---|
| 224 | 'URL' => add_session_id(PHPWG_ROOT_PATH.'category.php?cat=calendar'), |
---|
| 225 | 'TITLE' => $lang['calendar_hint'], |
---|
| 226 | 'NAME' => $lang['calendar'] |
---|
| 227 | )); |
---|
[2] | 228 | //--------------------------------------------------------------------- summary |
---|
[375] | 229 | |
---|
[2] | 230 | if ( !$user['is_the_guest'] ) |
---|
| 231 | { |
---|
[375] | 232 | $template->assign_block_vars('logout',array()); |
---|
| 233 | // administration link |
---|
| 234 | if ( $user['status'] == 'admin' ) |
---|
| 235 | { |
---|
| 236 | $template->assign_block_vars('logout.admin', array()); |
---|
| 237 | } |
---|
[2] | 238 | } |
---|
| 239 | else |
---|
| 240 | { |
---|
[375] | 241 | $template->assign_block_vars('login',array()); |
---|
[555] | 242 | if ($conf['authorize_remembering']) |
---|
| 243 | { |
---|
| 244 | $template->assign_block_vars('login.remember_me',array()); |
---|
| 245 | } |
---|
[2] | 246 | } |
---|
[351] | 247 | |
---|
[2] | 248 | // search link |
---|
[351] | 249 | $template->assign_block_vars('summary', array( |
---|
| 250 | 'TITLE'=>$lang['hint_search'], |
---|
| 251 | 'NAME'=>$lang['search'], |
---|
| 252 | 'U_SUMMARY'=>add_session_id( 'search.php' ), |
---|
| 253 | )); |
---|
| 254 | |
---|
[166] | 255 | // comments link |
---|
[351] | 256 | $template->assign_block_vars('summary', array( |
---|
| 257 | 'TITLE'=>$lang['hint_comments'], |
---|
| 258 | 'NAME'=>$lang['comments'], |
---|
| 259 | 'U_SUMMARY'=>add_session_id( 'comments.php' ), |
---|
| 260 | )); |
---|
| 261 | |
---|
[2] | 262 | // about link |
---|
[351] | 263 | $template->assign_block_vars('summary', array( |
---|
| 264 | 'TITLE'=>$lang['hint_about'], |
---|
| 265 | 'NAME'=>$lang['about'], |
---|
| 266 | 'U_SUMMARY'=>add_session_id( 'about.php?'.str_replace( '&', '&', $_SERVER['QUERY_STRING'] ) ) |
---|
| 267 | )); |
---|
| 268 | |
---|
[441] | 269 | //------------------------------------------------------ main part : thumbnails |
---|
[453] | 270 | if (isset($page['cat']) |
---|
| 271 | and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0) |
---|
[510] | 272 | or in_array($page['cat'], |
---|
| 273 | array('search' |
---|
| 274 | ,'most_visited' |
---|
| 275 | ,'recent_pics' |
---|
| 276 | ,'best_rated' |
---|
[605] | 277 | ,'list' |
---|
[626] | 278 | ,'fav' |
---|
[510] | 279 | )))) |
---|
[2] | 280 | { |
---|
[441] | 281 | include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); |
---|
[2] | 282 | } |
---|
[441] | 283 | elseif (isset($page['cat']) and $page['cat'] == 'calendar') |
---|
[428] | 284 | { |
---|
[441] | 285 | include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php'); |
---|
[428] | 286 | } |
---|
[441] | 287 | elseif (isset($page['cat']) and $page['cat'] == 'recent_cats') |
---|
[436] | 288 | { |
---|
[441] | 289 | include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php'); |
---|
[436] | 290 | } |
---|
[351] | 291 | else |
---|
[2] | 292 | { |
---|
[441] | 293 | include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php'); |
---|
[2] | 294 | } |
---|
| 295 | //------------------------------------------------------- category informations |
---|
| 296 | if ( isset ( $page['cat'] ) ) |
---|
| 297 | { |
---|
[394] | 298 | // upload a picture in the category |
---|
[602] | 299 | if (is_numeric($page['cat']) |
---|
| 300 | and $page['cat_site_id'] == 1 |
---|
| 301 | and $page['cat_dir'] != '' |
---|
| 302 | and $page['cat_uploadable']) |
---|
[2] | 303 | { |
---|
[394] | 304 | $url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat']; |
---|
[428] | 305 | $template->assign_block_vars( |
---|
| 306 | 'upload', |
---|
| 307 | array('U_UPLOAD'=>add_session_id( $url )) |
---|
| 308 | ); |
---|
[2] | 309 | } |
---|
[428] | 310 | |
---|
| 311 | if ( $page['navigation_bar'] != '' |
---|
| 312 | or ( isset( $page['comment'] ) and $page['comment'] != '' ) ) |
---|
| 313 | { |
---|
| 314 | $template->assign_block_vars('cat_infos',array()); |
---|
| 315 | } |
---|
[394] | 316 | |
---|
[351] | 317 | // navigation bar |
---|
| 318 | if ( $page['navigation_bar'] != '' ) |
---|
| 319 | { |
---|
[428] | 320 | $template->assign_block_vars( |
---|
| 321 | 'cat_infos.navigation', |
---|
| 322 | array('NAV_BAR' => $page['navigation_bar']) |
---|
| 323 | ); |
---|
[351] | 324 | } |
---|
| 325 | // category comment |
---|
| 326 | if ( isset( $page['comment'] ) and $page['comment'] != '' ) |
---|
| 327 | { |
---|
[428] | 328 | $template->assign_block_vars( |
---|
| 329 | 'cat_infos.comment', |
---|
| 330 | array('COMMENTS' => $page['comment']) |
---|
| 331 | ); |
---|
[351] | 332 | } |
---|
[2] | 333 | } |
---|
| 334 | //------------------------------------------------------------ log informations |
---|
| 335 | pwg_log( 'category', $page['title'] ); |
---|
| 336 | mysql_close(); |
---|
[345] | 337 | |
---|
[688] | 338 | $template->parse('category'); |
---|
[369] | 339 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
[362] | 340 | ?> |
---|