6 |
kaklik |
1 |
<?php
|
|
|
2 |
// +-----------------------------------------------------------------------+
|
|
|
3 |
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
4 |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
|
|
5 |
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
|
|
6 |
// +-----------------------------------------------------------------------+
|
|
|
7 |
// | branch : BSF (Best So Far)
|
|
|
8 |
// | file : $RCSfile: category.php,v $
|
|
|
9 |
// | last update : $Date: 2005/04/30 15:23:28 $
|
|
|
10 |
// | last modifier : $Author: plg $
|
|
|
11 |
// | revision : $Revision: 1.67.2.1 $
|
|
|
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 |
// +-----------------------------------------------------------------------+
|
|
|
27 |
|
|
|
28 |
//--------------------------------------------------------------------- include
|
|
|
29 |
define('PHPWG_ROOT_PATH','./');
|
|
|
30 |
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
|
|
31 |
//---------------------------------------------------------------------- logout
|
|
|
32 |
if ( isset( $_GET['act'] )
|
|
|
33 |
and $_GET['act'] == 'logout'
|
|
|
34 |
and isset( $_COOKIE['id'] ) )
|
|
|
35 |
{
|
|
|
36 |
// cookie deletion if exists
|
|
|
37 |
setcookie( 'id', '', 0, cookie_path() );
|
|
|
38 |
$url = 'category.php';
|
|
|
39 |
redirect( $url );
|
|
|
40 |
}
|
|
|
41 |
//-------------------------------------------------- access authorization check
|
|
|
42 |
if (isset($_GET['cat']))
|
|
|
43 |
{
|
|
|
44 |
check_cat_id($_GET['cat']);
|
|
|
45 |
}
|
|
|
46 |
check_login_authorization();
|
|
|
47 |
if (isset($page['cat']) and is_numeric($page['cat']))
|
|
|
48 |
{
|
|
|
49 |
check_restrictions($page['cat']);
|
|
|
50 |
}
|
|
|
51 |
//-------------------------------------------------------------- initialization
|
|
|
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 ) )
|
|
|
56 |
{
|
|
|
57 |
$page['start'] = 0;
|
|
|
58 |
}
|
|
|
59 |
else
|
|
|
60 |
{
|
|
|
61 |
$page['start'] = $_GET['start'];
|
|
|
62 |
}
|
|
|
63 |
|
|
|
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 |
|
|
|
76 |
initialize_category();
|
|
|
77 |
|
|
|
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();
|
|
|
82 |
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
|
|
|
83 |
{
|
|
|
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 );
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
// in case of expanding all authorized cats $page['tab_expand'] is empty
|
|
|
92 |
if ( $user['expand'] )
|
|
|
93 |
{
|
|
|
94 |
$page['tab_expand'] = array();
|
|
|
95 |
}
|
|
|
96 |
//----------------------------------------------------- template initialization
|
|
|
97 |
//
|
|
|
98 |
// Start output of page
|
|
|
99 |
//
|
|
|
100 |
$title = $page['title'];
|
|
|
101 |
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
|
|
102 |
|
|
|
103 |
$template->set_filenames( array('category'=>'category.tpl') );
|
|
|
104 |
//-------------------------------------------------------------- category title
|
|
|
105 |
if (isset($page['cat']) and is_numeric($page['cat']))
|
|
|
106 |
{
|
|
|
107 |
$template_title = get_cat_display_name($page['cat_name'],
|
|
|
108 |
'category.php?cat=',
|
|
|
109 |
false);
|
|
|
110 |
}
|
|
|
111 |
else
|
|
|
112 |
{
|
|
|
113 |
$template_title = $page['title'];
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
if ( isset( $page['cat_nb_images'] ) and $page['cat_nb_images'] > 0 )
|
|
|
117 |
{
|
|
|
118 |
$template_title.= ' ['.$page['cat_nb_images'].']';
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
$icon_recent = get_icon(date('Y-m-d'));
|
|
|
122 |
|
|
|
123 |
$template->assign_vars(array(
|
|
|
124 |
'NB_PICTURE' => count_user_total_images(),
|
|
|
125 |
'TITLE' => $template_title,
|
|
|
126 |
'USERNAME' => $user['username'],
|
|
|
127 |
'TOP_NUMBER'=>$conf['top_number'],
|
|
|
128 |
'MENU_CATEGORIES_CONTENT'=>get_categories_menu(),
|
|
|
129 |
|
|
|
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'],
|
|
|
135 |
'L_SPECIAL_CATEGORIES' => $lang['special_categories'],
|
|
|
136 |
'L_SUMMARY' => $lang['title_menu'],
|
|
|
137 |
'L_UPLOAD' => $lang['upload_picture'],
|
|
|
138 |
'L_COMMENT' => $lang['comments'],
|
|
|
139 |
'L_IDENTIFY' => $lang['identification'],
|
|
|
140 |
'L_SUBMIT' => $lang['menu_login'],
|
|
|
141 |
'L_USERNAME' => $lang['login'],
|
|
|
142 |
'L_PASSWORD' => $lang['password'],
|
|
|
143 |
'L_HELLO' => $lang['hello'],
|
|
|
144 |
'L_REGISTER' => $lang['ident_register'],
|
|
|
145 |
'L_LOGIN' => $lang['menu_login'],
|
|
|
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'],
|
|
|
151 |
'L_REMEMBER_ME' => $lang['remember_me'],
|
|
|
152 |
|
|
|
153 |
'F_IDENTIFY' => add_session_id( PHPWG_ROOT_PATH.'identification.php' ),
|
|
|
154 |
'T_RECENT' => $icon_recent,
|
|
|
155 |
|
|
|
156 |
'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' ),
|
|
|
157 |
'U_REGISTER' => add_session_id( PHPWG_ROOT_PATH.'register.php' ),
|
|
|
158 |
'U_LOGOUT' => PHPWG_ROOT_PATH.'category.php?act=logout',
|
|
|
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'] ))
|
|
|
161 |
)
|
|
|
162 |
);
|
|
|
163 |
//---------------------------------------------------------- special categories
|
|
|
164 |
// favorites categories
|
|
|
165 |
if ( !$user['is_the_guest'] )
|
|
|
166 |
{
|
|
|
167 |
$template->assign_block_vars('username', array());
|
|
|
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 |
));
|
|
|
176 |
}
|
|
|
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'],
|
|
|
183 |
'NAME' => $lang['most_visited_cat']
|
|
|
184 |
));
|
|
|
185 |
// best rated
|
|
|
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 |
}
|
|
|
196 |
// random
|
|
|
197 |
$template->assign_block_vars(
|
|
|
198 |
'special_cat',
|
|
|
199 |
array(
|
|
|
200 |
'URL' => add_session_id(PHPWG_ROOT_PATH.'random.php'),
|
|
|
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 |
));
|
|
|
228 |
//--------------------------------------------------------------------- summary
|
|
|
229 |
|
|
|
230 |
if ( !$user['is_the_guest'] )
|
|
|
231 |
{
|
|
|
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 |
}
|
|
|
238 |
}
|
|
|
239 |
else
|
|
|
240 |
{
|
|
|
241 |
$template->assign_block_vars('login',array());
|
|
|
242 |
if ($conf['authorize_remembering'])
|
|
|
243 |
{
|
|
|
244 |
$template->assign_block_vars('login.remember_me',array());
|
|
|
245 |
}
|
|
|
246 |
}
|
|
|
247 |
|
|
|
248 |
// search link
|
|
|
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 |
|
|
|
255 |
// comments link
|
|
|
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 |
|
|
|
262 |
// about link
|
|
|
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 |
|
|
|
269 |
//------------------------------------------------------ main part : thumbnails
|
|
|
270 |
if (isset($page['cat'])
|
|
|
271 |
and ((is_numeric($page['cat']) and $page['cat_nb_images'] != 0)
|
|
|
272 |
or in_array($page['cat'],
|
|
|
273 |
array('search'
|
|
|
274 |
,'most_visited'
|
|
|
275 |
,'recent_pics'
|
|
|
276 |
,'best_rated'
|
|
|
277 |
,'list'
|
|
|
278 |
,'fav'
|
|
|
279 |
))))
|
|
|
280 |
{
|
|
|
281 |
include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
|
|
|
282 |
}
|
|
|
283 |
elseif (isset($page['cat']) and $page['cat'] == 'calendar')
|
|
|
284 |
{
|
|
|
285 |
include(PHPWG_ROOT_PATH.'include/category_calendar.inc.php');
|
|
|
286 |
}
|
|
|
287 |
elseif (isset($page['cat']) and $page['cat'] == 'recent_cats')
|
|
|
288 |
{
|
|
|
289 |
include(PHPWG_ROOT_PATH.'include/category_recent_cats.inc.php');
|
|
|
290 |
}
|
|
|
291 |
else
|
|
|
292 |
{
|
|
|
293 |
include(PHPWG_ROOT_PATH.'include/category_subcats.inc.php');
|
|
|
294 |
}
|
|
|
295 |
//------------------------------------------------------- category informations
|
|
|
296 |
if ( isset ( $page['cat'] ) )
|
|
|
297 |
{
|
|
|
298 |
// upload a picture in the category
|
|
|
299 |
if (is_numeric($page['cat'])
|
|
|
300 |
and $page['cat_site_id'] == 1
|
|
|
301 |
and $page['cat_dir'] != ''
|
|
|
302 |
and $page['cat_uploadable'])
|
|
|
303 |
{
|
|
|
304 |
$url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['cat'];
|
|
|
305 |
$template->assign_block_vars(
|
|
|
306 |
'upload',
|
|
|
307 |
array('U_UPLOAD'=>add_session_id( $url ))
|
|
|
308 |
);
|
|
|
309 |
}
|
|
|
310 |
|
|
|
311 |
if ( $page['navigation_bar'] != ''
|
|
|
312 |
or ( isset( $page['comment'] ) and $page['comment'] != '' ) )
|
|
|
313 |
{
|
|
|
314 |
$template->assign_block_vars('cat_infos',array());
|
|
|
315 |
}
|
|
|
316 |
|
|
|
317 |
// navigation bar
|
|
|
318 |
if ( $page['navigation_bar'] != '' )
|
|
|
319 |
{
|
|
|
320 |
$template->assign_block_vars(
|
|
|
321 |
'cat_infos.navigation',
|
|
|
322 |
array('NAV_BAR' => $page['navigation_bar'])
|
|
|
323 |
);
|
|
|
324 |
}
|
|
|
325 |
// category comment
|
|
|
326 |
if ( isset( $page['comment'] ) and $page['comment'] != '' )
|
|
|
327 |
{
|
|
|
328 |
$template->assign_block_vars(
|
|
|
329 |
'cat_infos.comment',
|
|
|
330 |
array('COMMENTS' => $page['comment'])
|
|
|
331 |
);
|
|
|
332 |
}
|
|
|
333 |
}
|
|
|
334 |
//------------------------------------------------------------ log informations
|
|
|
335 |
pwg_log( 'category', $page['title'] );
|
|
|
336 |
mysql_close();
|
|
|
337 |
|
|
|
338 |
$template->parse('category');
|
|
|
339 |
include(PHPWG_ROOT_PATH.'include/page_tail.php');
|
|
|
340 |
?>
|