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

Last change on this file since 1594 was 1553, checked in by nikrou, 18 years ago

Fix bug 451: Auto login does not work properly
svn merge r1492:1493 from trunk
svn merge r1510:1511 from trunk
svn merge r1521:1522 from trunk
svn merge r1523:1524 from trunk
svn merge r1525:1526 from trunk
auto_login key add to users table:

  • add update script
  • update upgrade_1.5.0.php script
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.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-10-04 20:48:18 +0000 (Wed, 04 Oct 2006) $
10// | last modifier : $Author: nikrou $
11// | revision      : $Revision: 1553 $
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' );
31include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
32
33// +-----------------------------------------------------------------------+
34// | Check Access and exit when user status is not ok                      |
35// +-----------------------------------------------------------------------+
36check_status(ACCESS_GUEST);
37
38//---------------------------------------------- change of image display order
39if (isset($_GET['image_order']))
40{
41  setcookie(
42    'pwg_image_order',
43    $_GET['image_order'] > 0 ? $_GET['image_order'] : '',
44    0, cookie_path()
45    );
46
47  redirect(
48    duplicate_index_url(
49      array(),        // nothing to redefine
50      array('start')  // changing display order goes back to section first page
51      )
52    );
53}
54//-------------------------------------------------------------- initialization
55// detection of the start picture to display
56if (!isset($page['start']))
57{
58  $page['start'] = 0;
59}
60
61// access authorization check
62if (isset($page['category']))
63{
64  check_restrictions($page['category']);
65}
66
67if (isset($page['cat_nb_images'])
68    and $page['cat_nb_images'] > $user['nb_image_page'])
69{
70  $page['navigation_bar'] = create_navigation_bar(
71    duplicate_index_url(array(), array('start')),
72    $page['cat_nb_images'],
73    $page['start'],
74    $user['nb_image_page'],
75    true
76    );
77}
78else
79{
80  $page['navigation_bar'] = '';
81}
82
83// caddie filling :-)
84if (isset($_GET['caddie']))
85{
86  fill_caddie($page['items']);
87  // redirect();
88}
89
90//----------------------------------------------------- template initialization
91//
92// Start output of page
93//
94$title = $page['title'];
95$page['body_id'] = 'theCategoryPage';
96include(PHPWG_ROOT_PATH.'include/page_header.php');
97
98$template->set_filenames( array('index'=>'index.tpl') );
99//-------------------------------------------------------------- category title
100$template_title = $page['title'];
101if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
102{
103  $template_title.= ' ['.$page['cat_nb_images'].']';
104}
105
106$icon_recent = get_icon(date('Y-m-d'));
107
108if (!isset($page['chronology_field']))
109{
110  $chronology_params =
111      array(
112          'chronology_field' => 'created',
113          'chronology_style' => 'monthly',
114          'chronology_view' => 'list',
115      );
116  $template->assign_block_vars(
117    'mode_created',
118    array(
119      'URL' => duplicate_index_url( $chronology_params, array('start') )
120      )
121    );
122
123  $chronology_params['chronology_field'] = 'posted';
124  $template->assign_block_vars(
125    'mode_posted',
126    array(
127      'URL' => duplicate_index_url( $chronology_params, array('start') )
128      )
129    );
130}
131else
132{
133  $template->assign_block_vars(
134    'mode_normal',
135    array(
136      'URL' => duplicate_index_url( array(), array('chronology_field','start') )
137      )
138    );
139
140  if ($page['chronology_field'] == 'created')
141  {
142    $chronology_field = 'posted';
143  }
144  else
145  {
146    $chronology_field = 'created';
147  }
148  $url = duplicate_index_url(
149            array('chronology_field'=>$chronology_field ),
150            array('chronology_date', 'start')
151          );
152  $template->assign_block_vars(
153    'mode_'.$chronology_field,
154    array('URL' => $url )
155    );
156}
157// include menubar
158include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
159
160$template->assign_vars(
161  array(
162    'TITLE' => $template_title,
163    'TOP_NUMBER' => $conf['top_number'],        // still used ?
164    'T_RECENT' => $icon_recent,                 // still used ?
165    )
166  );
167
168if ('search' == $page['section'])
169{
170  $template->assign_block_vars(
171    'search_rules',
172    array(
173      'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
174      )
175    );
176}
177
178if (isset($page['category']) and is_admin())
179{
180  $template->assign_block_vars(
181    'edit',
182    array(
183      'URL' =>
184        get_root_url().'admin.php?page=cat_modify'
185        .'&amp;cat_id='.$page['category']
186      )
187    );
188}
189
190if (is_admin() and !empty($page['items']) )
191{
192    $template->assign_block_vars(
193      'caddie',
194      array(
195        'URL' =>
196          add_url_params(duplicate_index_url(), array('caddie'=>1) )
197        )
198      );
199  }
200
201//------------------------------------------------------ main part : thumbnails
202if (isset($page['thumbnails_include']))
203{
204  include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
205}
206//------------------------------------------------------- category informations
207if (
208  $page['navigation_bar'] != ''
209  or (isset($page['comment']) and $page['comment'] != '')
210  )
211{
212  $template->assign_block_vars('cat_infos',array());
213}
214// navigation bar
215if ($page['navigation_bar'] != '')
216{
217  $template->assign_block_vars(
218    'cat_infos.navigation',
219    array(
220      'NAV_BAR' => $page['navigation_bar'],
221      )
222    );
223}
224
225if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
226    and $page['section'] != 'most_visited'
227    and $page['section'] != 'best_rated')
228{
229  // image order
230  $template->assign_block_vars( 'preferred_image_order', array() );
231
232  $order_idx = isset($_COOKIE['pwg_image_order'])
233    ? $_COOKIE['pwg_image_order']
234    : 0
235    ;
236
237  $orders = get_category_preferred_image_orders();
238  for ($i = 0; $i < count($orders); $i++)
239  {
240    if ($orders[$i][2])
241    {
242      $template->assign_block_vars(
243        'preferred_image_order.order',
244        array(
245          'DISPLAY' => $orders[$i][0],
246          'URL' => add_url_params( duplicate_index_url(), array('image_order'=>$i) ),
247          'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : ''),
248          )
249        );
250    }
251  }
252}
253
254if (isset($page['category']))
255{
256  // category comment
257  if (isset($page['comment']) and $page['comment'] != '')
258  {
259    $template->assign_block_vars(
260      'cat_infos.comment',
261      array(
262        'COMMENTS' => $page['comment']
263        )
264      );
265  }
266}
267//------------------------------------------------------------ log informations
268pwg_log('category', $page['title']);
269
270$template->parse('index');
271include(PHPWG_ROOT_PATH.'include/page_tail.php');
272?>
Note: See TracBrowser for help on using the repository browser.