source: tags/release-1_5_0/include/user.inc.php @ 27601

Last change on this file since 27601 was 817, checked in by plg, 19 years ago
  • modification : major simplification of admin.php. Titles are managed by included page, localized items are managed directly in the template.
  • new : sub template admin/double_select is included in templates admin/cat_options, admin/user_perm and admin/group_perm. I haven't been able to use it in admin/picture_modify because it seems impossible to have two instance of the same sub-template without interfering.
  • modification : bug 99, in profile manager, no auto submit when changing language (useless and generate accessibility problem).
  • improvement : HTML semantically correct for administration menu, simpler syntax, less tags, correct tags (dl/dt/dd instead of div/div).
  • modification : number of waiting elements and unvalidated comments are displayed in admin/intro instead of administration menu (with a link to the dedicated pages).
  • deletion : no link to profile from admin/user_list anymore (no need).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 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-2005 PhpWebGallery Team - http://phpwebgallery.net |
6// +-----------------------------------------------------------------------+
7// | branch        : BSF (Best So Far)
8// | file          : $RCSfile$
9// | last update   : $Date: 2005-08-17 14:25:38 +0000 (Wed, 17 Aug 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 817 $
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// retrieving connected user informations
29if (isset($_COOKIE['id']))
30{
31  $session_id = $_COOKIE['id'];
32  $user['has_cookie'] = true;
33}
34else if (isset($_GET['id']))
35{
36  $session_id = $_GET['id'];
37  $user['has_cookie'] = false;
38}
39else
40{
41  $user['has_cookie'] = false;
42}
43
44if (isset($session_id)
45    and ereg("^[0-9a-zA-Z]{".$conf['session_id_size']."}$", $session_id))
46{
47  $page['session_id'] = $session_id;
48  $query = '
49SELECT user_id,expiration,NOW() AS now
50  FROM '.SESSIONS_TABLE.'
51  WHERE id = \''.$page['session_id'].'\'
52;';
53  $result = pwg_query($query);
54  if (mysql_num_rows($result) > 0)
55  {
56    $row = mysql_fetch_array($result);
57    if (strnatcmp($row['expiration'], $row['now']) < 0)
58    {
59      // deletion of the session from the database, because it is
60      // out-of-date
61      $delete_query = '
62DELETE FROM '.SESSIONS_TABLE.'
63  WHERE id = \''.$page['session_id'].'\'
64;';
65      pwg_query($delete_query);
66    }
67    else
68    {
69      $user['id'] = $row['user_id'];
70      $user['is_the_guest'] = false;
71    }
72  }
73}
74if (!isset($user['id']))
75{
76  $user['id'] = $conf['guest_id'];
77  $user['is_the_guest'] = true;
78}
79
80// using Apache authentication override the above user search
81if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER']))
82{
83  if (!($user['id'] = get_userid($_SERVER['REMOTE_USER'])))
84  {
85    register_user($_SERVER['REMOTE_USER'], '', '');
86    $user['id'] = get_userid($_SERVER['REMOTE_USER']);
87  }
88 
89  $user['is_the_guest'] = false;
90}
91
92$use_cache = (defined('IN_ADMIN') and IN_ADMIN) ? false : true;
93$user = array_merge($user, getuserdata($user['id'], $use_cache));
94
95// properties of user guest are found in the configuration
96if ($user['is_the_guest'])
97{
98  $user['template'] = $conf['default_template'];
99  $user['nb_image_line'] = $conf['nb_image_line'];
100  $user['nb_line_page'] = $conf['nb_line_page'];
101  $user['language'] = $conf['default_language'];
102  $user['maxwidth'] = $conf['default_maxwidth'];
103  $user['maxheight'] = $conf['default_maxheight'];
104  $user['recent_period'] = $conf['recent_period'];
105  $user['expand'] = $conf['auto_expand'];
106  $user['show_nb_comments'] = $conf['show_nb_comments'];
107}
108
109// calculation of the number of picture to display per page
110$user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
111?>
Note: See TracBrowser for help on using the repository browser.