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-2006 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2006-03-28 02:16:34 +0000 (Tue, 28 Mar 2006) $ |
---|
10 | // | last modifier : $Author: rvelices $ |
---|
11 | // | revision : $Revision: 1109 $ |
---|
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 | include(PHPWG_ROOT_PATH.'include/section_init.inc.php'); |
---|
32 | |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | // | Check Access and exit when user status is not ok | |
---|
35 | // +-----------------------------------------------------------------------+ |
---|
36 | check_status(ACCESS_GUEST); |
---|
37 | |
---|
38 | //---------------------------------------------------------------------- logout |
---|
39 | if ( isset( $_GET['act'] ) |
---|
40 | and $_GET['act'] == 'logout' |
---|
41 | and isset( $_COOKIE[session_name()] ) ) |
---|
42 | { |
---|
43 | // cookie deletion if exists |
---|
44 | $_SESSION = array(); |
---|
45 | session_unset(); |
---|
46 | session_destroy(); |
---|
47 | setcookie(session_name(),'',0, cookie_path() ); |
---|
48 | redirect( make_index_url() ); |
---|
49 | } |
---|
50 | |
---|
51 | //---------------------------------------------- change of image display order |
---|
52 | if (isset($_GET['image_order'])) |
---|
53 | { |
---|
54 | setcookie( |
---|
55 | 'pwg_image_order', |
---|
56 | $_GET['image_order'] > 0 ? $_GET['image_order'] : '', |
---|
57 | 0 |
---|
58 | ); |
---|
59 | |
---|
60 | redirect( |
---|
61 | duplicate_index_URL( |
---|
62 | array(), // nothing to redefine |
---|
63 | array('start') // changing display order goes back to section first page |
---|
64 | ) |
---|
65 | ); |
---|
66 | } |
---|
67 | //-------------------------------------------------------------- initialization |
---|
68 | // detection of the start picture to display |
---|
69 | if (!isset($page['start'])) |
---|
70 | { |
---|
71 | $page['start'] = 0; |
---|
72 | } |
---|
73 | |
---|
74 | // access authorization check |
---|
75 | if (isset($page['category'])) |
---|
76 | { |
---|
77 | check_restrictions($page['category']); |
---|
78 | } |
---|
79 | |
---|
80 | if (isset($page['cat_nb_images']) |
---|
81 | and $page['cat_nb_images'] > $user['nb_image_page']) |
---|
82 | { |
---|
83 | $page['navigation_bar'] = create_navigation_bar( |
---|
84 | duplicate_index_URL(array(), array('start')), |
---|
85 | $page['cat_nb_images'], |
---|
86 | $page['start'], |
---|
87 | $user['nb_image_page'], |
---|
88 | true |
---|
89 | ); |
---|
90 | } |
---|
91 | else |
---|
92 | { |
---|
93 | $page['navigation_bar'] = ''; |
---|
94 | } |
---|
95 | |
---|
96 | // caddie filling :-) |
---|
97 | if (isset($_GET['caddie'])) |
---|
98 | { |
---|
99 | fill_caddie($page['items']); |
---|
100 | // redirect(); |
---|
101 | } |
---|
102 | |
---|
103 | //----------------------------------------------------- template initialization |
---|
104 | // |
---|
105 | // Start output of page |
---|
106 | // |
---|
107 | $title = $page['title']; |
---|
108 | $page['body_id'] = 'theCategoryPage'; |
---|
109 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
110 | |
---|
111 | $template->set_filenames( array('index'=>'index.tpl') ); |
---|
112 | //-------------------------------------------------------------- category title |
---|
113 | if (isset($page['category'])) |
---|
114 | { |
---|
115 | $template_title = get_cat_display_name( $page['cat_name'], '', false ); |
---|
116 | } |
---|
117 | else |
---|
118 | { |
---|
119 | $template_title = $page['title']; |
---|
120 | } |
---|
121 | |
---|
122 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0) |
---|
123 | { |
---|
124 | $template_title.= ' ['.$page['cat_nb_images'].']'; |
---|
125 | } |
---|
126 | |
---|
127 | $icon_recent = get_icon(date('Y-m-d')); |
---|
128 | |
---|
129 | if (!isset($page['chronology_field'])) |
---|
130 | { |
---|
131 | $chronology_params = |
---|
132 | array( |
---|
133 | 'chronology_field' => 'created', |
---|
134 | 'chronology_style' => 'monthly', |
---|
135 | 'chronology_view' => 'list', |
---|
136 | ); |
---|
137 | $template->assign_block_vars( |
---|
138 | 'mode_created', |
---|
139 | array( |
---|
140 | 'URL' => duplicate_index_URL( $chronology_params, array('start') ) |
---|
141 | ) |
---|
142 | ); |
---|
143 | |
---|
144 | $chronology_params['chronology_field'] = 'posted'; |
---|
145 | $template->assign_block_vars( |
---|
146 | 'mode_posted', |
---|
147 | array( |
---|
148 | 'URL' => duplicate_index_URL( $chronology_params, array('start') ) |
---|
149 | ) |
---|
150 | ); |
---|
151 | } |
---|
152 | else |
---|
153 | { |
---|
154 | $template->assign_block_vars( |
---|
155 | 'mode_normal', |
---|
156 | array( |
---|
157 | 'URL' => duplicate_index_URL( array(), array('chronology_field','start') ) |
---|
158 | ) |
---|
159 | ); |
---|
160 | |
---|
161 | if ($page['chronology_field'] == 'created') |
---|
162 | { |
---|
163 | $chronology_field = 'posted'; |
---|
164 | } |
---|
165 | else |
---|
166 | { |
---|
167 | $chronology_field = 'created'; |
---|
168 | } |
---|
169 | $url = duplicate_index_URL( |
---|
170 | array('chronology_field'=>$chronology_field ), |
---|
171 | array('chronology_date', 'start') |
---|
172 | ); |
---|
173 | $template->assign_block_vars( |
---|
174 | 'mode_'.$chronology_field, |
---|
175 | array('URL' => $url ) |
---|
176 | ); |
---|
177 | } |
---|
178 | |
---|
179 | $template->assign_vars( |
---|
180 | array( |
---|
181 | 'NB_PICTURE' => $user['nb_total_images'], |
---|
182 | 'TITLE' => $template_title, |
---|
183 | 'USERNAME' => $user['username'], |
---|
184 | 'TOP_NUMBER' => $conf['top_number'], |
---|
185 | 'MENU_CATEGORIES_CONTENT' => get_categories_menu(), |
---|
186 | |
---|
187 | 'F_IDENTIFY' => get_root_url().'identification.php', |
---|
188 | 'T_RECENT' => $icon_recent, |
---|
189 | |
---|
190 | 'U_HOME' => make_index_URL(), |
---|
191 | 'U_REGISTER' => get_root_url().'register.php', |
---|
192 | 'U_LOST_PASSWORD' => get_root_url().'password.php', |
---|
193 | 'U_LOGOUT' => add_url_params(make_index_URL(), array('act'=>'logout') ), |
---|
194 | 'U_ADMIN'=> get_root_url().'admin.php', |
---|
195 | 'U_PROFILE'=> get_root_url().'profile.php', |
---|
196 | ) |
---|
197 | ); |
---|
198 | |
---|
199 | if ('search' == $page['section']) |
---|
200 | { |
---|
201 | $template->assign_block_vars( |
---|
202 | 'search_rules', |
---|
203 | array( |
---|
204 | 'URL' => get_root_url().'search_rules.php?search_id='.$page['search'], |
---|
205 | ) |
---|
206 | ); |
---|
207 | } |
---|
208 | //-------------------------------------------------------------- external links |
---|
209 | if (count($conf['links']) > 0) |
---|
210 | { |
---|
211 | $template->assign_block_vars('links', array()); |
---|
212 | |
---|
213 | foreach ($conf['links'] as $url => $label) |
---|
214 | { |
---|
215 | $template->assign_block_vars( |
---|
216 | 'links.link', |
---|
217 | array( |
---|
218 | 'URL' => $url, |
---|
219 | 'LABEL' => $label |
---|
220 | ) |
---|
221 | ); |
---|
222 | } |
---|
223 | } |
---|
224 | //---------------------------------------------------------- special categories |
---|
225 | // favorites categories |
---|
226 | if ( !$user['is_the_guest'] ) |
---|
227 | { |
---|
228 | $template->assign_block_vars('username', array()); |
---|
229 | |
---|
230 | $template->assign_block_vars( |
---|
231 | 'special_cat', |
---|
232 | array( |
---|
233 | 'URL' => make_index_URL(array('section' => 'favorites')), |
---|
234 | 'TITLE' => $lang['favorite_cat_hint'], |
---|
235 | 'NAME' => $lang['favorite_cat'] |
---|
236 | )); |
---|
237 | } |
---|
238 | // most visited |
---|
239 | $template->assign_block_vars( |
---|
240 | 'special_cat', |
---|
241 | array( |
---|
242 | 'URL' => make_index_URL(array('section' => 'most_visited')), |
---|
243 | 'TITLE' => $lang['most_visited_cat_hint'], |
---|
244 | 'NAME' => $lang['most_visited_cat'] |
---|
245 | )); |
---|
246 | // best rated |
---|
247 | if ($conf['rate']) |
---|
248 | { |
---|
249 | $template->assign_block_vars( |
---|
250 | 'special_cat', |
---|
251 | array( |
---|
252 | 'URL' => make_index_URL(array('section' => 'best_rated')), |
---|
253 | 'TITLE' => $lang['best_rated_cat_hint'], |
---|
254 | 'NAME' => $lang['best_rated_cat'] |
---|
255 | ) |
---|
256 | ); |
---|
257 | } |
---|
258 | // random |
---|
259 | $template->assign_block_vars( |
---|
260 | 'special_cat', |
---|
261 | array( |
---|
262 | 'URL' => get_root_url().'random.php', |
---|
263 | 'TITLE' => $lang['random_cat_hint'], |
---|
264 | 'NAME' => $lang['random_cat'] |
---|
265 | )); |
---|
266 | // recent pics |
---|
267 | $template->assign_block_vars( |
---|
268 | 'special_cat', |
---|
269 | array( |
---|
270 | 'URL' => make_index_URL(array('section' => 'recent_pics')), |
---|
271 | 'TITLE' => $lang['recent_pics_cat_hint'], |
---|
272 | 'NAME' => $lang['recent_pics_cat'] |
---|
273 | )); |
---|
274 | // recent cats |
---|
275 | $template->assign_block_vars( |
---|
276 | 'special_cat', |
---|
277 | array( |
---|
278 | 'URL' => make_index_URL(array('section' => 'recent_cats')), |
---|
279 | 'TITLE' => $lang['recent_cats_cat_hint'], |
---|
280 | 'NAME' => $lang['recent_cats_cat'] |
---|
281 | )); |
---|
282 | |
---|
283 | // calendar |
---|
284 | $template->assign_block_vars( |
---|
285 | 'special_cat', |
---|
286 | array( |
---|
287 | 'URL' => |
---|
288 | make_index_URL( |
---|
289 | array( |
---|
290 | 'chronology_field' => ($conf['calendar_datefield']=='date_available' |
---|
291 | ? 'posted' : 'created'), |
---|
292 | 'chronology_style'=> 'monthly', |
---|
293 | 'chronology_view' => 'calendar' |
---|
294 | ) |
---|
295 | ), |
---|
296 | 'TITLE' => $lang['calendar_hint'], |
---|
297 | 'NAME' => $lang['calendar'] |
---|
298 | ) |
---|
299 | ); |
---|
300 | //--------------------------------------------------------------------- summary |
---|
301 | |
---|
302 | if ($user['is_the_guest']) |
---|
303 | { |
---|
304 | $template->assign_block_vars('register', array()); |
---|
305 | $template->assign_block_vars('login', array()); |
---|
306 | |
---|
307 | $template->assign_block_vars('quickconnect', array()); |
---|
308 | if ($conf['authorize_remembering']) |
---|
309 | { |
---|
310 | $template->assign_block_vars('quickconnect.remember_me', array()); |
---|
311 | } |
---|
312 | } |
---|
313 | else |
---|
314 | { |
---|
315 | $template->assign_block_vars('hello', array()); |
---|
316 | |
---|
317 | if (is_autorize_status(ACCESS_CLASSIC)) |
---|
318 | { |
---|
319 | $template->assign_block_vars('profile', array()); |
---|
320 | } |
---|
321 | |
---|
322 | // the logout link has no meaning with Apache authentication : it is not |
---|
323 | // possible to logout with this kind of authentication. |
---|
324 | if (!$conf['apache_authentication']) |
---|
325 | { |
---|
326 | $template->assign_block_vars('logout', array()); |
---|
327 | } |
---|
328 | |
---|
329 | if (is_admin()) |
---|
330 | { |
---|
331 | $template->assign_block_vars('admin', array()); |
---|
332 | } |
---|
333 | } |
---|
334 | |
---|
335 | // search link |
---|
336 | $template->assign_block_vars( |
---|
337 | 'summary', |
---|
338 | array( |
---|
339 | 'TITLE'=>$lang['hint_search'], |
---|
340 | 'NAME'=>$lang['search'], |
---|
341 | 'U_SUMMARY'=> get_root_url().'search.php', |
---|
342 | 'REL'=> 'rel="search"' |
---|
343 | ) |
---|
344 | ); |
---|
345 | |
---|
346 | // comments link |
---|
347 | $template->assign_block_vars( |
---|
348 | 'summary', |
---|
349 | array( |
---|
350 | 'TITLE'=>$lang['hint_comments'], |
---|
351 | 'NAME'=>$lang['comments'], |
---|
352 | 'U_SUMMARY'=> get_root_url().'comments.php', |
---|
353 | ) |
---|
354 | ); |
---|
355 | |
---|
356 | // about link |
---|
357 | $template->assign_block_vars( |
---|
358 | 'summary', |
---|
359 | array( |
---|
360 | 'TITLE' => $lang['about_page_title'], |
---|
361 | 'NAME' => $lang['About'], |
---|
362 | 'U_SUMMARY' => 'about.php?'.str_replace( |
---|
363 | '&', |
---|
364 | '&', |
---|
365 | $_SERVER['QUERY_STRING'] |
---|
366 | ) |
---|
367 | ) |
---|
368 | ); |
---|
369 | |
---|
370 | // notification |
---|
371 | $template->assign_block_vars( |
---|
372 | 'summary', |
---|
373 | array( |
---|
374 | 'TITLE'=>l10n('notification'), |
---|
375 | 'NAME'=>l10n('Notification'), |
---|
376 | 'U_SUMMARY'=> get_root_url().'notification.php', |
---|
377 | 'REL'=> 'rel="nofollow"' |
---|
378 | ) |
---|
379 | ); |
---|
380 | |
---|
381 | if (isset($page['category']) and is_admin()) |
---|
382 | { |
---|
383 | $template->assign_block_vars( |
---|
384 | 'edit', |
---|
385 | array( |
---|
386 | 'URL' => |
---|
387 | get_root_url().'admin.php?page=cat_modify' |
---|
388 | .'&cat_id='.$page['category'] |
---|
389 | ) |
---|
390 | ); |
---|
391 | } |
---|
392 | |
---|
393 | if (is_admin() and !empty($page['items']) ) |
---|
394 | { |
---|
395 | $template->assign_block_vars( |
---|
396 | 'caddie', |
---|
397 | array( |
---|
398 | 'URL' => |
---|
399 | add_url_params(duplicate_index_url(), array('caddie'=>1) ) |
---|
400 | ) |
---|
401 | ); |
---|
402 | } |
---|
403 | |
---|
404 | //------------------------------------------------------ main part : thumbnails |
---|
405 | if (isset($page['thumbnails_include'])) |
---|
406 | { |
---|
407 | include(PHPWG_ROOT_PATH.$page['thumbnails_include']); |
---|
408 | } |
---|
409 | //------------------------------------------------------- category informations |
---|
410 | if ( |
---|
411 | $page['navigation_bar'] != '' |
---|
412 | or (isset($page['comment']) and $page['comment'] != '') |
---|
413 | ) |
---|
414 | { |
---|
415 | $template->assign_block_vars('cat_infos',array()); |
---|
416 | } |
---|
417 | // navigation bar |
---|
418 | if ($page['navigation_bar'] != '') |
---|
419 | { |
---|
420 | $template->assign_block_vars( |
---|
421 | 'cat_infos.navigation', |
---|
422 | array( |
---|
423 | 'NAV_BAR' => $page['navigation_bar'], |
---|
424 | ) |
---|
425 | ); |
---|
426 | } |
---|
427 | |
---|
428 | if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0 |
---|
429 | and $page['section'] != 'most_visited' |
---|
430 | and $page['section'] != 'best_rated') |
---|
431 | { |
---|
432 | // image order |
---|
433 | $template->assign_block_vars( 'preferred_image_order', array() ); |
---|
434 | |
---|
435 | $order_idx = isset($_COOKIE['pwg_image_order']) |
---|
436 | ? $_COOKIE['pwg_image_order'] |
---|
437 | : 0 |
---|
438 | ; |
---|
439 | |
---|
440 | $orders = get_category_preferred_image_orders(); |
---|
441 | for ($i = 0; $i < count($orders); $i++) |
---|
442 | { |
---|
443 | if ($orders[$i][2]) |
---|
444 | { |
---|
445 | $template->assign_block_vars( |
---|
446 | 'preferred_image_order.order', |
---|
447 | array( |
---|
448 | 'DISPLAY' => $orders[$i][0], |
---|
449 | 'URL' => add_url_params( duplicate_index_URL(), array('image_order'=>$i) ), |
---|
450 | 'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''), |
---|
451 | ) |
---|
452 | ); |
---|
453 | } |
---|
454 | } |
---|
455 | } |
---|
456 | |
---|
457 | if (isset($page['category'])) |
---|
458 | { |
---|
459 | // upload a picture in the category |
---|
460 | if ($page['cat_uploadable']) |
---|
461 | { |
---|
462 | $url = get_root_url().'upload.php?cat='.$page['category']; |
---|
463 | $template->assign_block_vars( |
---|
464 | 'upload', |
---|
465 | array( |
---|
466 | 'U_UPLOAD'=> $url |
---|
467 | ) |
---|
468 | ); |
---|
469 | } |
---|
470 | |
---|
471 | // category comment |
---|
472 | if (isset($page['comment']) and $page['comment'] != '') |
---|
473 | { |
---|
474 | $template->assign_block_vars( |
---|
475 | 'cat_infos.comment', |
---|
476 | array( |
---|
477 | 'COMMENTS' => $page['comment'] |
---|
478 | ) |
---|
479 | ); |
---|
480 | } |
---|
481 | } |
---|
482 | //------------------------------------------------------------ log informations |
---|
483 | pwg_log('category', $page['title']); |
---|
484 | |
---|
485 | $template->parse('index'); |
---|
486 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
487 | ?> |
---|