source: trunk/category.php @ 1070

Last change on this file since 1070 was 1070, checked in by rub, 18 years ago

Step 1 improvement issue 0000301:

o Change status of table #_user_infos
o Don't send password to webmaster, guest, generic

Next Step:

o Functions Check of status
o Restricted Access for user generic

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