2000-08-18 05:24:22 +02:00
|
|
|
<?php
|
2001-02-27 13:49:10 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Dan Kuykendall <seek3r@phpgroupware.org> *
|
|
|
|
* Joseph Engo <jengo@phpgroupware.org> *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* 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; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2001-12-05 17:00:39 +01:00
|
|
|
$phpgw_info = array();
|
2001-11-23 22:04:06 +01:00
|
|
|
$GLOBALS['phpgw_info']['flags'] = array(
|
2001-02-27 13:49:10 +01:00
|
|
|
'disable_template_class' => True,
|
|
|
|
'login' => True,
|
|
|
|
'currentapp' => 'login',
|
|
|
|
'noheader' => True
|
|
|
|
);
|
|
|
|
|
2002-02-17 09:07:38 +01:00
|
|
|
if(file_exists('./header.inc.php'))
|
|
|
|
{
|
|
|
|
include('./header.inc.php');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Header('Location: setup/index.php');
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-23 22:04:06 +01:00
|
|
|
$GLOBALS['phpgw_info']['server']['template_dir'] = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['login_template_set'];
|
|
|
|
$tmpl = CreateObject('phpgwapi.Template', $GLOBALS['phpgw_info']['server']['template_dir']);
|
2001-05-11 12:02:34 +02:00
|
|
|
|
|
|
|
// This is used for system downtime, to prevent new logins.
|
2001-11-23 22:04:06 +01:00
|
|
|
if ($GLOBALS['phpgw_info']['server']['deny_all_logins'])
|
2001-05-11 12:02:34 +02:00
|
|
|
{
|
|
|
|
$tmpl->set_file(array(
|
|
|
|
'login_form' => 'login_denylogin.tpl'
|
|
|
|
));
|
2001-09-06 10:27:22 +02:00
|
|
|
$tmpl->set_var('template_set','default');
|
2001-05-11 12:02:34 +02:00
|
|
|
$tmpl->pfp('loginout','login_form');
|
|
|
|
exit;
|
|
|
|
}
|
2001-02-27 13:49:10 +01:00
|
|
|
|
|
|
|
// !! NOTE !!
|
|
|
|
// Do NOT and I repeat, do NOT touch ANYTHING to do with lang in this file.
|
|
|
|
// If there is a problem, tell me and I will fix it. (jengo)
|
2000-12-08 06:13:50 +01:00
|
|
|
|
2000-09-06 17:55:58 +02:00
|
|
|
/*
|
2001-11-23 22:04:06 +01:00
|
|
|
if ($code != 10 && $GLOBALS['phpgw_info']['server']['usecookies'] == False)
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
|
|
|
Setcookie('sessionid');
|
|
|
|
Setcookie('kp3');
|
|
|
|
Setcookie('domain');
|
|
|
|
}
|
2000-09-06 17:55:58 +02:00
|
|
|
*/
|
2000-08-18 05:24:22 +02:00
|
|
|
|
2000-12-15 08:55:39 +01:00
|
|
|
/* This is not working yet because I need to figure out a way to clear the $cd =1
|
2001-02-27 13:49:10 +01:00
|
|
|
if (isset($PHP_AUTH_USER) && $cd == '1')
|
|
|
|
{
|
|
|
|
Header('HTTP/1.0 401 Unauthorized');
|
|
|
|
Header('WWW-Authenticate: Basic realm="phpGroupWare"');
|
|
|
|
echo 'You have to re-authentificate yourself';
|
|
|
|
exit;
|
|
|
|
}
|
2000-12-15 08:55:39 +01:00
|
|
|
*/
|
2000-12-19 19:14:22 +01:00
|
|
|
|
2001-11-23 22:04:06 +01:00
|
|
|
if (! $deny_login && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
|
|
|
$tmpl->set_file(array('login_form' => 'login.tpl'));
|
2001-03-27 20:31:07 +02:00
|
|
|
$tmpl->set_var('charset',lang('charset'));
|
2001-02-27 13:49:10 +01:00
|
|
|
}
|
2001-11-23 22:04:06 +01:00
|
|
|
elseif ($GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
|
|
|
$tmpl->set_file(array('login_form' => 'login_selectdomain.tpl'));
|
2001-03-27 20:31:07 +02:00
|
|
|
$tmpl->set_var('charset',lang('charset'));
|
2001-02-27 13:49:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function show_cookie()
|
|
|
|
{
|
2001-11-23 22:04:06 +01:00
|
|
|
global $code, $last_loginid, $login;
|
2001-02-27 13:49:10 +01:00
|
|
|
/* This needs to be this way, because if someone doesnt want to use cookies, we shouldnt sneak one in */
|
2001-11-23 22:04:06 +01:00
|
|
|
if ($code != 5 && (isset($GLOBALS['phpgw_info']['server']['usecookies']) && $GLOBALS['phpgw_info']['server']['usecookies']))
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
|
|
|
return $last_loginid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function check_logoutcode($code)
|
|
|
|
{
|
|
|
|
switch($code)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return lang('You have been successfully logged out');
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
return lang('Sorry, your login has expired');
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return '<font color="FF0000">' . lang('Bad login or password') . '</font>';
|
|
|
|
break;
|
|
|
|
case 10:
|
|
|
|
Setcookie('sessionid');
|
|
|
|
Setcookie('kp3');
|
|
|
|
Setcookie('domain');
|
|
|
|
return '<font color=FF0000>' . lang('Your session could not be verified.') . '</font>';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Program starts here */
|
2000-11-16 22:51:01 +01:00
|
|
|
|
2001-11-23 22:04:06 +01:00
|
|
|
if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'http' && isset($PHP_AUTH_USER))
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
|
|
|
$submit = True;
|
|
|
|
$login = $PHP_AUTH_USER;
|
|
|
|
$passwd = $PHP_AUTH_PW;
|
|
|
|
}
|
|
|
|
|
2001-04-26 00:01:52 +02:00
|
|
|
# Apache + mod_ssl style SSL certificate authentication
|
|
|
|
# Certificate (chain) verification occurs inside mod_ssl
|
2001-11-23 22:04:06 +01:00
|
|
|
if ($GLOBALS['phpgw_info']['server']['auth_type'] == 'sqlssl' && isset($HTTP_SERVER_VARS['SSL_CLIENT_S_DN']) && !isset($cd))
|
2001-04-26 00:01:52 +02:00
|
|
|
{
|
2001-04-26 00:25:35 +02:00
|
|
|
# an X.509 subject looks like:
|
|
|
|
# /CN=john.doe/OU=Department/O=Company/C=xx/Email=john@comapy.tld/L=City/
|
|
|
|
# the username is deliberately lowercase, to ease LDAP integration
|
2001-09-06 10:27:22 +02:00
|
|
|
$sslattribs = explode('/',$HTTP_SERVER_VARS['SSL_CLIENT_S_DN']);
|
|
|
|
# skip the part in front of the first '/' (nothing)
|
2001-05-01 11:15:40 +02:00
|
|
|
while ($sslattrib = next($sslattribs))
|
2001-04-26 00:01:52 +02:00
|
|
|
{
|
2001-09-06 10:27:22 +02:00
|
|
|
list($key,$val) = explode('=',$sslattrib);
|
2001-05-01 11:15:40 +02:00
|
|
|
$sslattributes[$key] = $val;
|
|
|
|
}
|
2001-04-26 00:25:35 +02:00
|
|
|
|
2001-09-06 10:27:22 +02:00
|
|
|
if (isset($sslattributes['Email']))
|
2001-04-26 00:01:52 +02:00
|
|
|
{
|
|
|
|
$submit = True;
|
|
|
|
|
|
|
|
# login will be set here if the user logged out and uses a different username with
|
|
|
|
# the same SSL-certificate.
|
2001-09-06 10:27:22 +02:00
|
|
|
if (!isset($login)&&isset($sslattributes['Email'])) {
|
|
|
|
$login = $sslattributes['Email'];
|
2001-05-01 11:15:40 +02:00
|
|
|
# not checked against the database, but delivered to authentication module
|
2001-09-06 10:27:22 +02:00
|
|
|
$passwd = $HTTP_SERVER_VARS['SSL_CLIENT_S_DN'];
|
2001-04-26 00:01:52 +02:00
|
|
|
}
|
|
|
|
}
|
2001-05-23 02:11:08 +02:00
|
|
|
unset($key);
|
|
|
|
unset($val);
|
|
|
|
unset($sslattributes);
|
2001-04-26 00:01:52 +02:00
|
|
|
}
|
|
|
|
|
2001-12-05 17:00:39 +01:00
|
|
|
if (isset($HTTP_POST_VARS['passwd_type']) || $submit_x || $submit_y)
|
|
|
|
// isset($HTTP_POST_VARS['passwd']) && $HTTP_POST_VARS['passwd']) // enable konqueror to login via Return
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
2001-09-06 10:27:22 +02:00
|
|
|
if (getenv(REQUEST_METHOD) != 'POST' && !isset($PHP_AUTH_USER) && !isset($HTTP_SERVER_VARS['SSL_CLIENT_S_DN']))
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
2001-09-06 10:27:22 +02:00
|
|
|
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/login.php','code=5'));
|
2001-02-27 13:49:10 +01:00
|
|
|
}
|
2001-10-02 07:38:35 +02:00
|
|
|
$GLOBALS['sessionid'] = $GLOBALS['phpgw']->session->create($GLOBALS['HTTP_POST_VARS']['login'],$GLOBALS['HTTP_POST_VARS']['passwd'],$GLOBALS['HTTP_POST_VARS']['passwd_type']);
|
2001-08-21 20:34:56 +02:00
|
|
|
|
|
|
|
if (! isset($GLOBALS['sessionid']) || ! $GLOBALS['sessionid'])
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
2001-11-23 22:04:06 +01:00
|
|
|
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php?cd=5');
|
2001-02-27 13:49:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-21 20:34:56 +02:00
|
|
|
if ($GLOBALS['phpgw_forward'])
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
|
|
|
while (list($name,$value) = each($HTTP_GET_VARS))
|
|
|
|
{
|
|
|
|
if (ereg('phpgw_',$name))
|
|
|
|
{
|
|
|
|
$extra_vars .= '&' . $name . '=' . urlencode($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-08-21 20:34:56 +02:00
|
|
|
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/home.php','cd=yes' . $extra_vars));
|
2001-02-27 13:49:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// !!! DONT CHANGE THESE LINES !!!
|
|
|
|
// If there is something wrong with this code TELL ME!
|
|
|
|
// Commenting out the code will not fix it. (jengo)
|
|
|
|
if (isset($last_loginid))
|
|
|
|
{
|
|
|
|
$accounts = CreateObject('phpgwapi.accounts');
|
|
|
|
$prefs = CreateObject('phpgwapi.preferences', $accounts->name2id($last_loginid));
|
|
|
|
|
|
|
|
if (! $prefs->account_id)
|
|
|
|
{
|
2001-09-06 10:27:22 +02:00
|
|
|
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = 'en';
|
2001-02-27 13:49:10 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-06 10:27:22 +02:00
|
|
|
$GLOBALS['phpgw_info']['user']['preferences'] = $prefs->read_repository();
|
2001-02-27 13:49:10 +01:00
|
|
|
}
|
2001-11-23 22:04:06 +01:00
|
|
|
#print 'LANG:' . $GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] . '<br>';
|
2001-09-06 10:27:22 +02:00
|
|
|
$GLOBALS['phpgw']->translation->add_app('login');
|
|
|
|
$GLOBALS['phpgw']->translation->add_app('loginscreen');
|
2001-02-27 13:49:10 +01:00
|
|
|
if (lang('loginscreen_message') != 'loginscreen_message*')
|
|
|
|
{
|
|
|
|
$tmpl->set_var('lang_message',stripslashes(lang('loginscreen_message')));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If the lastloginid cookies isn't set, we will default to english.
|
|
|
|
// Change this if you need.
|
2001-09-06 10:27:22 +02:00
|
|
|
$GLOBALS['phpgw_info']['user']['preferences']['common']['lang'] = 'en';
|
|
|
|
$GLOBALS['phpgw']->translation->add_app('login');
|
|
|
|
$GLOBALS['phpgw']->translation->add_app('loginscreen');
|
2001-02-27 13:49:10 +01:00
|
|
|
if (lang('loginscreen_message') != 'loginscreen_message*')
|
|
|
|
{
|
|
|
|
$tmpl->set_var('lang_message',stripslashes(lang('loginscreen_message')));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($cd) || !$cd)
|
|
|
|
{
|
|
|
|
$cd = '';
|
|
|
|
}
|
|
|
|
|
2001-09-06 10:27:22 +02:00
|
|
|
if ($GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
|
2001-02-27 13:49:10 +01:00
|
|
|
{
|
|
|
|
reset($phpgw_domain);
|
|
|
|
unset($domain_select); // For security ... just in case
|
|
|
|
while ($domain = each($phpgw_domain))
|
|
|
|
{
|
|
|
|
$domain_select .= '<option value="' . $domain[0] . '"';
|
|
|
|
if ($domain[0] == $last_domain)
|
|
|
|
{
|
|
|
|
$domain_select .= ' selected';
|
|
|
|
}
|
|
|
|
$domain_select .= '>' . $domain[0] . '</option>';
|
|
|
|
}
|
|
|
|
$tmpl->set_var('select_domain',$domain_select);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (list($name,$value) = each($HTTP_GET_VARS))
|
|
|
|
{
|
|
|
|
if (ereg('phpgw_',$name))
|
|
|
|
{
|
|
|
|
$extra_vars .= '&' . $name . '=' . urlencode($value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($extra_vars)
|
|
|
|
{
|
|
|
|
$extra_vars = '?' . substr($extra_vars,1,strlen($extra_vars));
|
|
|
|
}
|
|
|
|
|
2001-11-23 22:04:06 +01:00
|
|
|
$tmpl->set_var('login_url', $GLOBALS['phpgw_info']['server']['webserver_url'] . '/login.php' . $extra_vars);
|
|
|
|
$tmpl->set_var('registration_url',$GLOBALS['phpgw_info']['server']['webserver_url'] . '/registration/');
|
|
|
|
$tmpl->set_var('website_title', $GLOBALS['phpgw_info']['server']['site_title']);
|
2001-02-27 13:49:10 +01:00
|
|
|
$tmpl->set_var('cd',check_logoutcode($cd));
|
|
|
|
$tmpl->set_var('cookie',show_cookie());
|
|
|
|
$tmpl->set_var('lang_username',lang('username'));
|
|
|
|
$tmpl->set_var('lang_phpgw_login',lang('phpGroupWare login'));
|
2001-11-23 22:04:06 +01:00
|
|
|
$tmpl->set_var('version',$GLOBALS['phpgw_info']['server']['versions']['phpgwapi']);
|
2001-02-27 13:49:10 +01:00
|
|
|
$tmpl->set_var('lang_password',lang('password'));
|
|
|
|
$tmpl->set_var('lang_login',lang('login'));
|
2001-11-23 22:04:06 +01:00
|
|
|
$tmpl->set_var('template_set',$GLOBALS['phpgw_info']['login_template_set']);
|
2001-02-27 13:49:10 +01:00
|
|
|
|
|
|
|
$tmpl->pfp('loginout','login_form');
|
2001-02-04 11:26:15 +01:00
|
|
|
?>
|