source: branches/branch-1_6/index.php @ 1178

Last change on this file since 1178 was 1144, checked in by rvelices, 19 years ago

fix: iptc keywords are split the same way for local and remote sites
(create_listing_file)

fix: recent_cats and category_subcats build the url the same way
(both subcatify and normal)

fix: recent_cats subcatify also strip tags on subcategory comment

fix: cookie deletion on logout uses cookie_domain from ini file

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.5 KB
RevLine 
[2]1<?php
[351]2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[1058]5// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
[351]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[351]8// | file          : $RCSfile$
9// | last update   : $Date: 2006-04-11 03:54:42 +0000 (Tue, 11 Apr 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1144 $
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]29define('PHPWG_ROOT_PATH','./');
30include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
[1084]31include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
[1072]32
33// +-----------------------------------------------------------------------+
34// | Check Access and exit when user status is not ok                      |
35// +-----------------------------------------------------------------------+
36check_status(ACCESS_GUEST);
37
[45]38//---------------------------------------------------------------------- logout
[345]39if ( isset( $_GET['act'] )
40     and $_GET['act'] == 'logout'
[1004]41     and isset( $_COOKIE[session_name()] ) )
[45]42{
43  // cookie deletion if exists
[1004]44  $_SESSION = array();
45  session_unset();
46  session_destroy();
[1144]47  setcookie(session_name(),'',0,
48      ini_get('session.cookie_path'), ini_get('session.cookie_domain') );
[1092]49  redirect( make_index_url() );
[45]50}
[1084]51
[1059]52//---------------------------------------------- change of image display order
[1036]53if (isset($_GET['image_order']))
[614]54{
[1036]55  setcookie(
[1059]56    'pwg_image_order',
[1036]57    $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
[1113]58    0, cookie_path()
[1036]59    );
[1059]60
[1036]61  redirect(
[1084]62    duplicate_index_URL(
63      array(),        // nothing to redefine
64      array('start')  // changing display order goes back to section first page
[1082]65      )
[1036]66    );
[614]67}
[2]68//-------------------------------------------------------------- initialization
[345]69// detection of the start picture to display
[1082]70if (!isset($page['start']))
[514]71{
[345]72  $page['start'] = 0;
[514]73}
[345]74
[1036]75// access authorization check
[1082]76if (isset($page['category']))
[1036]77{
[1082]78  check_restrictions($page['category']);
[1036]79}
80
[1082]81if (isset($page['cat_nb_images'])
[1036]82    and $page['cat_nb_images'] > $user['nb_image_page'])
83{
84  $page['navigation_bar'] = create_navigation_bar(
[1082]85    duplicate_index_URL(array(), array('start')),
[1036]86    $page['cat_nb_images'],
87    $page['start'],
88    $user['nb_image_page'],
[1084]89    true
[1036]90    );
91}
92else
93{
94  $page['navigation_bar'] = '';
95}
96
[755]97// caddie filling :-)
98if (isset($_GET['caddie']))
99{
[1036]100  fill_caddie($page['items']);
[1082]101  // redirect();
[755]102}
103
[2]104//----------------------------------------------------- template initialization
[345]105//
106// Start output of page
107//
108$title = $page['title'];
[850]109$page['body_id'] = 'theCategoryPage';
[369]110include(PHPWG_ROOT_PATH.'include/page_header.php');
[345]111
[1109]112$template->set_filenames( array('index'=>'index.tpl') );
[351]113//-------------------------------------------------------------- category title
[1120]114$template_title = $page['title'];
[1082]115if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
[428]116{
117  $template_title.= ' ['.$page['cat_nb_images'].']';
118}
[2]119
[452]120$icon_recent = get_icon(date('Y-m-d'));
[436]121
[1090]122if (!isset($page['chronology_field']))
[1047]123{
[1090]124  $chronology_params =
125      array(
126          'chronology_field' => 'created',
127          'chronology_style' => 'monthly',
128          'chronology_view' => 'list',
129      );
[1050]130  $template->assign_block_vars(
[1059]131    'mode_created',
[1082]132    array(
[1090]133      'URL' => duplicate_index_URL( $chronology_params, array('start') )
[1082]134      )
[1050]135    );
[1083]136
[1090]137  $chronology_params['chronology_field'] = 'posted';
[1059]138  $template->assign_block_vars(
139    'mode_posted',
[1082]140    array(
[1090]141      'URL' => duplicate_index_URL( $chronology_params, array('start') )
[1082]142      )
[1059]143    );
[1047]144}
[1050]145else
146{
147  $template->assign_block_vars(
[1059]148    'mode_normal',
[1082]149    array(
[1090]150      'URL' => duplicate_index_URL( array(), array('chronology_field','start') )
[1082]151      )
[1050]152    );
[1059]153
[1090]154  if ($page['chronology_field'] == 'created')
[1059]155  {
[1090]156    $chronology_field = 'posted';
[1059]157  }
158  else
159  {
[1090]160    $chronology_field = 'created';
[1059]161  }
[1086]162  $url = duplicate_index_URL(
[1090]163            array('chronology_field'=>$chronology_field ),
[1086]164            array('chronology_date', 'start')
165          );
166  $template->assign_block_vars(
[1090]167    'mode_'.$chronology_field,
[1086]168    array('URL' => $url )
169    );
[1050]170}
[1047]171
[850]172$template->assign_vars(
173  array(
[1082]174    'NB_PICTURE' => $user['nb_total_images'],
175    'TITLE' => $template_title,
176    'USERNAME' => $user['username'],
177    'TOP_NUMBER' => $conf['top_number'],
178    'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
[2]179
[1090]180    'F_IDENTIFY' => get_root_url().'identification.php',
[1082]181    'T_RECENT' => $icon_recent,
[1083]182
[1082]183    'U_HOME' => make_index_URL(),
[1090]184    'U_REGISTER' => get_root_url().'register.php',
185    'U_LOST_PASSWORD' => get_root_url().'password.php',
[1094]186    'U_LOGOUT' => add_url_params(make_index_URL(), array('act'=>'logout') ),
[1090]187    'U_ADMIN'=> get_root_url().'admin.php',
188    'U_PROFILE'=> get_root_url().'profile.php',
[1082]189    )
190  );
[1059]191
[1082]192if ('search' == $page['section'])
[1015]193{
194  $template->assign_block_vars(
195    'search_rules',
196    array(
[1092]197      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
[1015]198      )
199    );
200}
[797]201//-------------------------------------------------------------- external links
202if (count($conf['links']) > 0)
203{
204  $template->assign_block_vars('links', array());
205
206  foreach ($conf['links'] as $url => $label)
207  {
208    $template->assign_block_vars(
209      'links.link',
210      array(
211        'URL' => $url,
212        'LABEL' => $label
[1082]213        )
214      );
[797]215  }
216}
[1119]217//------------------------------------------------------------------------ tags
218if ('tags' == $page['section'])
219{
220  $template->assign_block_vars('tags', array());
[1120]221
[1119]222  // display tags associated to currently tagged items, less current tags
[1120]223  $tags = array();
224
225  if ( !empty($page['items']) )
226  {
227    $query = '
[1119]228SELECT tag_id, name, url_name, count(*) counter
229  FROM '.IMAGE_TAG_TABLE.'
230    INNER JOIN '.TAGS_TABLE.' ON tag_id = id
231  WHERE image_id IN ('.implode(',', $items).')
232    AND tag_id NOT IN ('.implode(',', $page['tag_ids']).')
233  GROUP BY tag_id
234  ORDER BY name ASC
235;';
[1120]236    $result = pwg_query($query);
237    while($row = mysql_fetch_array($result))
238    {
239      array_push($tags, $row);
240    }
[1119]241  }
242
243  $tags = add_level_to_tags($tags);
244
245  foreach ($tags as $tag)
246  {
247    $template->assign_block_vars(
248      'tags.tag',
249      array(
250        'URL_ADD' => make_index_URL(
251          array(
252            'tags' => array_merge(
253              $page['tags'],
254              array(
255                array(
256                  'id' => $tag['tag_id'],
257                  'url_name' => $tag['url_name'],
258                  ),
259                )
260              )
261            )
262          ),
263
264        'URL' => make_index_URL(
265          array(
266            'tags' => array(
267              array(
268                'id' => $tag['tag_id'],
269                'url_name' => $tag['url_name'],
270                ),
271              )
272            )
273          ),
[1120]274
[1119]275        'NAME' => $tag['name'],
[1120]276
[1119]277        'TITLE' => l10n('See pictures linked to this tag only'),
278
279        'TITLE_ADD' => sprintf(
280          l10n('%d pictures are also linked to current tags'),
281          $tag['counter']
282          ),
[1120]283
[1119]284        'CLASS' => 'tagLevel'.$tag['level']
285        )
286      );
287  }
288}
[510]289//---------------------------------------------------------- special categories
290// favorites categories
[2]291if ( !$user['is_the_guest'] )
292{
[364]293  $template->assign_block_vars('username', array());
[510]294
295  $template->assign_block_vars(
296    'special_cat',
297    array(
[1082]298      'URL' => make_index_URL(array('section' => 'favorites')),
[510]299      'TITLE' => $lang['favorite_cat_hint'],
300      'NAME' => $lang['favorite_cat']
301      ));
[2]302}
[510]303// most visited
304$template->assign_block_vars(
305  'special_cat',
306  array(
[1082]307    'URL' => make_index_URL(array('section' => 'most_visited')),
[510]308    'TITLE' => $lang['most_visited_cat_hint'],
[733]309    'NAME' => $lang['most_visited_cat']
[510]310    ));
311// best rated
[869]312if ($conf['rate'])
313{
314  $template->assign_block_vars(
315    'special_cat',
316    array(
[1082]317      'URL' => make_index_URL(array('section' => 'best_rated')),
[869]318      'TITLE' => $lang['best_rated_cat_hint'],
319      'NAME' => $lang['best_rated_cat']
320      )
321    );
322}
[510]323// random
324$template->assign_block_vars(
325  'special_cat',
326  array(
[1092]327    'URL' => get_root_url().'random.php',
[510]328    'TITLE' => $lang['random_cat_hint'],
329    'NAME' => $lang['random_cat']
330    ));
331// recent pics
332$template->assign_block_vars(
333  'special_cat',
334  array(
[1082]335    'URL' => make_index_URL(array('section' => 'recent_pics')),
[510]336    'TITLE' => $lang['recent_pics_cat_hint'],
337    'NAME' => $lang['recent_pics_cat']
338    ));
339// recent cats
340$template->assign_block_vars(
341  'special_cat',
342  array(
[1082]343    'URL' => make_index_URL(array('section' => 'recent_cats')),
[510]344    'TITLE' => $lang['recent_cats_cat_hint'],
345    'NAME' => $lang['recent_cats_cat']
346    ));
[1082]347
[510]348// calendar
349$template->assign_block_vars(
350  'special_cat',
351  array(
[1082]352    'URL' =>
[1086]353      make_index_URL(
354        array(
[1090]355          'chronology_field' => ($conf['calendar_datefield']=='date_available'
356                                  ? 'posted' : 'created'),
357           'chronology_style'=> 'monthly',
358           'chronology_view' => 'calendar'
[1086]359        )
360      ),
[510]361    'TITLE' => $lang['calendar_hint'],
362    'NAME' => $lang['calendar']
[1082]363    )
364  );
[2]365//--------------------------------------------------------------------- summary
[375]366
[804]367if ($user['is_the_guest'])
[2]368{
[804]369  $template->assign_block_vars('register', array());
370  $template->assign_block_vars('login', array());
[1059]371
[804]372  $template->assign_block_vars('quickconnect', array());
373  if ($conf['authorize_remembering'])
[375]374  {
[804]375    $template->assign_block_vars('quickconnect.remember_me', array());
[375]376  }
[2]377}
378else
379{
[804]380  $template->assign_block_vars('hello', array());
381
[1072]382  if (is_autorize_status(ACCESS_CLASSIC))
383  {
384    $template->assign_block_vars('profile', array());
385  }
386
[804]387  // the logout link has no meaning with Apache authentication : it is not
388  // possible to logout with this kind of authentication.
389  if (!$conf['apache_authentication'])
[555]390  {
[804]391    $template->assign_block_vars('logout', array());
[555]392  }
[804]393
[1070]394  if (is_admin())
[804]395  {
396    $template->assign_block_vars('admin', array());
397  }
[2]398}
[351]399
[1119]400// tags link
401$template->assign_block_vars(
402  'summary',
403  array(
404    'TITLE' => l10n('See available tags'),
405    'NAME' => l10n('Tags'),
406    'U_SUMMARY'=> get_root_url().'tags.php',
407    )
408  );
409
[2]410// search link
[1082]411$template->assign_block_vars(
412  'summary',
413  array(
414    'TITLE'=>$lang['hint_search'],
415    'NAME'=>$lang['search'],
[1090]416    'U_SUMMARY'=> get_root_url().'search.php',
[1082]417    'REL'=> 'rel="search"'
418    )
419  );
[351]420
[166]421// comments link
[1082]422$template->assign_block_vars(
423  'summary',
424  array(
425    'TITLE'=>$lang['hint_comments'],
426    'NAME'=>$lang['comments'],
[1090]427    'U_SUMMARY'=> get_root_url().'comments.php',
[1082]428    )
429  );
[351]430
[2]431// about link
[1082]432$template->assign_block_vars(
433  'summary',
434  array(
435    'TITLE'     => $lang['about_page_title'],
436    'NAME'      => $lang['About'],
[1123]437    'U_SUMMARY' => get_root_url().'about.php',
[1082]438    )
439  );
[351]440
[833]441// notification
[801]442$template->assign_block_vars(
443  'summary',
444  array(
[833]445    'TITLE'=>l10n('notification'),
446    'NAME'=>l10n('Notification'),
[1090]447    'U_SUMMARY'=> get_root_url().'notification.php',
[1031]448    'REL'=> 'rel="nofollow"'
[1082]449    )
450  );
[801]451
[1082]452if (isset($page['category']) and is_admin())
[834]453{
454  $template->assign_block_vars(
455    'edit',
456    array(
457      'URL' =>
[1090]458        get_root_url().'admin.php?page=cat_modify'
[1082]459        .'&amp;cat_id='.$page['category']
[834]460      )
461    );
462}
463
[1092]464if (is_admin() and !empty($page['items']) )
465{
466    $template->assign_block_vars(
467      'caddie',
468      array(
469        'URL' =>
[1094]470          add_url_params(duplicate_index_url(), array('caddie'=>1) )
[1092]471        )
472      );
473  }
474
[441]475//------------------------------------------------------ main part : thumbnails
[1082]476if (isset($page['thumbnails_include']))
[1047]477{
478  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
479}
[2]480//------------------------------------------------------- category informations
[1082]481if (
482  $page['navigation_bar'] != ''
483  or (isset($page['comment']) and $page['comment'] != '')
484  )
[1047]485{
486  $template->assign_block_vars('cat_infos',array());
487}
488// navigation bar
[1082]489if ($page['navigation_bar'] != '')
[1059]490{
[1047]491  $template->assign_block_vars(
492    'cat_infos.navigation',
[1082]493    array(
494      'NAV_BAR' => $page['navigation_bar'],
495      )
[1047]496    );
497}
[1051]498
[1082]499if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
500    and $page['section'] != 'most_visited'
501    and $page['section'] != 'best_rated')
[1051]502{
503  // image order
504  $template->assign_block_vars( 'preferred_image_order', array() );
505
[1082]506  $order_idx = isset($_COOKIE['pwg_image_order'])
507    ? $_COOKIE['pwg_image_order']
508    : 0
509    ;
[1051]510
511  $orders = get_category_preferred_image_orders();
[1082]512  for ($i = 0; $i < count($orders); $i++)
[1051]513  {
514    if ($orders[$i][2])
515    {
[1082]516      $template->assign_block_vars(
517        'preferred_image_order.order',
518        array(
519          'DISPLAY' => $orders[$i][0],
[1094]520          'URL' => add_url_params( duplicate_index_URL(), array('image_order'=>$i) ),
[1082]521          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
522          )
523        );
[1051]524    }
525  }
526}
527
[1082]528if (isset($page['category']))
[2]529{
[394]530  // upload a picture in the category
[1082]531  if ($page['cat_uploadable'])
[2]532  {
[1092]533    $url = get_root_url().'upload.php?cat='.$page['category'];
[428]534    $template->assign_block_vars(
535      'upload',
[1082]536      array(
537        'U_UPLOAD'=> $url
538        )
[428]539      );
[2]540  }
[1083]541
[351]542  // category comment
[1082]543  if (isset($page['comment']) and $page['comment'] != '')
[351]544  {
[428]545    $template->assign_block_vars(
546      'cat_infos.comment',
[1082]547      array(
548        'COMMENTS' => $page['comment']
549        )
[428]550      );
[351]551  }
[2]552}
553//------------------------------------------------------------ log informations
[1082]554pwg_log('category', $page['title']);
[345]555
[1109]556$template->parse('index');
[369]557include(PHPWG_ROOT_PATH.'include/page_tail.php');
[362]558?>
Note: See TracBrowser for help on using the repository browser.