source: trunk/include/user.inc.php @ 1403

Last change on this file since 1403 was 1231, checked in by rvelices, 18 years ago

merge r1230 from branch-1_6 into trunk

bugs 344 and 308: broken user id in $_SESSION due to php.ini register_globals

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.3 KB
RevLine 
[2]1<?php
[362]2// +-----------------------------------------------------------------------+
[593]3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
[675]5// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
[362]6// +-----------------------------------------------------------------------+
[593]7// | branch        : BSF (Best So Far)
[362]8// | file          : $RCSfile$
9// | last update   : $Date: 2006-04-21 02:11:29 +0000 (Fri, 21 Apr 2006) $
10// | last modifier : $Author: rvelices $
11// | revision      : $Revision: 1231 $
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// +-----------------------------------------------------------------------+
[2]27
[648]28// retrieving connected user informations
[1231]29if (isset($_COOKIE[session_name()]))
[2]30{
[1004]31 session_start();
[1231]32 if (isset($_SESSION['pwg_uid']))
[1004]33 {
[1231]34   $user['id'] = $_SESSION['pwg_uid'];
[1023]35   $user['is_the_guest'] = false;
[1004]36 }
[1231]37 else
[1004]38 {
39   // session timeout
40   $user['id'] = $conf['guest_id'];
41   $user['is_the_guest'] = true;
42 }
[1231]43}
44else
[45]45{
[1004]46 $user['id'] = $conf['guest_id'];
47 $user['is_the_guest'] = true;
[541]48}
[45]49
[804]50// using Apache authentication override the above user search
51if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER']))
52{
[808]53  if (!($user['id'] = get_userid($_SERVER['REMOTE_USER'])))
[804]54  {
[808]55    register_user($_SERVER['REMOTE_USER'], '', '');
56    $user['id'] = get_userid($_SERVER['REMOTE_USER']);
[804]57  }
[1231]58
[804]59  $user['is_the_guest'] = false;
60}
[1036]61$user = array_merge(
62  $user,
63  getuserdata(
64    $user['id'],
[1052]65    ( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
[1036]66    )
67  );
[648]68
[653]69// properties of user guest are found in the configuration
70if ($user['is_the_guest'])
71{
72  $user['template'] = $conf['default_template'];
73  $user['nb_image_line'] = $conf['nb_image_line'];
74  $user['nb_line_page'] = $conf['nb_line_page'];
75  $user['language'] = $conf['default_language'];
76  $user['maxwidth'] = $conf['default_maxwidth'];
77  $user['maxheight'] = $conf['default_maxheight'];
78  $user['recent_period'] = $conf['recent_period'];
79  $user['expand'] = $conf['auto_expand'];
80  $user['show_nb_comments'] = $conf['show_nb_comments'];
[1106]81  $user['enabled_high'] = $conf['newuser_default_enabled_high'];
[653]82}
83
[351]84// calculation of the number of picture to display per page
85$user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
[362]86?>
Note: See TracBrowser for help on using the repository browser.