2003-05-09 14:42:42 +02:00
|
|
|
<?php
|
2004-02-12 00:20:38 +01:00
|
|
|
// +-----------------------------------------------------------------------+
|
2011-01-18 01:02:52 +01:00
|
|
|
// | Piwigo - a PHP based photo gallery |
|
2008-04-05 00:57:23 +02:00
|
|
|
// +-----------------------------------------------------------------------+
|
2014-01-05 01:19:25 +01:00
|
|
|
// | Copyright(C) 2008-2014 Piwigo Team http://piwigo.org |
|
2008-04-05 00:57:23 +02:00
|
|
|
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
|
|
|
|
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
|
|
|
|
// +-----------------------------------------------------------------------+
|
|
|
|
// | 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 |
|
2004-02-12 00:20:38 +01:00
|
|
|
// | |
|
|
|
|
// | 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
|
|
|
if (isset($_GET['act']) and $_GET['act'] == 'logout')
|
2006-10-20 04:17:53 +02:00
|
|
|
{ // logout
|
2008-10-16 02:38:26 +02:00
|
|
|
logout_user();
|
2011-06-14 14:14:29 +02:00
|
|
|
redirect(get_gallery_home_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();
|
|
|
|
}
|
|
|
|
|
2005-07-17 17:06:39 +02:00
|
|
|
// using Apache authentication override the above user search
|
2010-05-05 00:21:11 +02:00
|
|
|
if ($conf['apache_authentication'])
|
2005-07-17 17:06:39 +02:00
|
|
|
{
|
2010-05-05 00:21:11 +02:00
|
|
|
$remote_user = null;
|
|
|
|
foreach (array('REMOTE_USER', 'REDIRECT_REMOTE_USER') as $server_key)
|
2005-07-17 17:06:39 +02:00
|
|
|
{
|
2010-05-05 00:21:11 +02:00
|
|
|
if (isset($_SERVER[$server_key]))
|
|
|
|
{
|
|
|
|
$remote_user = $_SERVER[$server_key];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($remote_user))
|
|
|
|
{
|
|
|
|
if (!($user['id'] = get_userid($remote_user)))
|
|
|
|
{
|
2013-10-24 15:01:25 +02:00
|
|
|
$user['id'] = register_user($remote_user, '', '', false);
|
2010-05-05 00:21:11 +02:00
|
|
|
}
|
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
|
|
|
);
|
2008-07-06 00:36:39 +02:00
|
|
|
if ($conf['browser_language'] and (is_a_guest() or is_generic()) )
|
2008-05-31 13:43:13 +02:00
|
|
|
{
|
2008-07-06 00:36:39 +02:00
|
|
|
get_browser_language($user['language']);
|
2008-05-31 13:43:13 +02:00
|
|
|
}
|
2007-02-15 04:03:16 +01:00
|
|
|
trigger_action('user_init', $user);
|
2007-03-13 23:44:45 +01:00
|
|
|
?>
|