2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-12 00:20:38 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | PhpWebGallery - a PHP based picture gallery |
|
|
|
|
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
2006-12-21 22:38:20 +01:00
|
|
|
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
2004-02-12 00:20:38 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2004-11-06 22:12:59 +01:00
|
|
|
// | branch : BSF (Best So Far)
|
2004-02-12 00:20:38 +01:00
|
|
|
// | file : $RCSfile$
|
|
|
|
// | last update : $Date$
|
|
|
|
// | last modifier : $Author$
|
|
|
|
// | revision : $Revision$
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | This program is free software; you can redistribute it and/or modify |
|
|
|
|
// | it under the terms of the GNU General Public License as published by |
|
|
|
|
// | the Free Software Foundation |
|
|
|
|
// | |
|
|
|
|
// | This program is distributed in the hope that it will be useful, but |
|
|
|
|
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
|
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
|
|
|
// | General Public License for more details. |
|
|
|
|
// | |
|
|
|
|
// | You should have received a copy of the GNU General Public License |
|
|
|
|
// | along with this program; if not, write to the Free Software |
|
|
|
|
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
|
|
|
// | USA. |
|
|
|
|
// +-----------------------------------------------------------------------+
|
2004-02-02 01:55:18 +01:00
|
|
|
|
2006-10-20 04:17:53 +02:00
|
|
|
// by default we start with guest
|
|
|
|
$user['id'] = $conf['guest_id'];
|
|
|
|
|
2006-04-21 04:11:29 +02:00
|
|
|
if (isset($_COOKIE[session_name()]))
|
2003-07-27 10:24:10 +02:00
|
|
|
{
|
2006-07-28 11:34:27 +02:00
|
|
|
session_start();
|
|
|
|
if (isset($_GET['act']) and $_GET['act'] == 'logout')
|
2006-10-20 04:17:53 +02:00
|
|
|
{ // logout
|
2006-07-28 11:34:27 +02:00
|
|
|
$_SESSION = array();
|
|
|
|
session_unset();
|
|
|
|
session_destroy();
|
|
|
|
setcookie(session_name(),'',0,
|
2006-10-20 04:17:53 +02:00
|
|
|
ini_get('session.cookie_path'),
|
|
|
|
ini_get('session.cookie_domain')
|
|
|
|
);
|
2006-07-28 11:34:27 +02:00
|
|
|
setcookie($conf['remember_me_name'], '', 0, cookie_path());
|
|
|
|
redirect(make_index_url());
|
2006-10-20 04:17:53 +02:00
|
|
|
}
|
2006-12-01 02:46:32 +01:00
|
|
|
elseif (!empty($_SESSION['pwg_uid']))
|
2006-07-28 11:34:27 +02:00
|
|
|
{
|
|
|
|
$user['id'] = $_SESSION['pwg_uid'];
|
|
|
|
}
|
2006-04-21 04:11:29 +02:00
|
|
|
}
|
2006-10-20 04:17:53 +02:00
|
|
|
|
|
|
|
// Now check the auto-login
|
|
|
|
if ( $user['id']==$conf['guest_id'] )
|
2006-07-28 11:34:27 +02:00
|
|
|
{
|
|
|
|
auto_login();
|
|
|
|
}
|
|
|
|
|
2006-12-01 02:46:32 +01:00
|
|
|
if (session_id()=="")
|
|
|
|
{
|
|
|
|
session_start();
|
|
|
|
}
|
2003-05-09 14:42:42 +02:00
|
|
|
|
2005-07-17 17:06:39 +02:00
|
|
|
// using Apache authentication override the above user search
|
|
|
|
if ($conf['apache_authentication'] and isset($_SERVER['REMOTE_USER']))
|
|
|
|
{
|
2005-08-08 22:52:19 +02:00
|
|
|
if (!($user['id'] = get_userid($_SERVER['REMOTE_USER'])))
|
2005-07-17 17:06:39 +02:00
|
|
|
{
|
2005-08-08 22:52:19 +02:00
|
|
|
register_user($_SERVER['REMOTE_USER'], '', '');
|
|
|
|
$user['id'] = get_userid($_SERVER['REMOTE_USER']);
|
2005-07-17 17:06:39 +02:00
|
|
|
}
|
2004-12-21 00:54:59 +01:00
|
|
|
}
|
2006-12-13 01:05:16 +01:00
|
|
|
|
2006-10-20 04:17:53 +02:00
|
|
|
$user = build_user( $user['id'],
|
2006-12-21 22:38:20 +01:00
|
|
|
( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
|
2006-10-20 04:17:53 +02:00
|
|
|
);
|
2004-12-21 00:54:59 +01:00
|
|
|
|
2007-02-15 04:03:16 +01:00
|
|
|
trigger_action('user_init', $user);
|
2006-10-20 04:17:53 +02:00
|
|
|
?>
|