2000-08-18 05:24:22 +02:00
< ? php
2001-02-27 13:49:10 +01:00
/************************************************************************** \
2004-08-21 17:22:56 +02:00
* eGroupWare login *
* http :// www . egroupware . org *
* Originaly written by Dan Kuykendall < seek3r @ phpgroupware . org > *
* Joseph Engo < jengo @ phpgroupware . org > *
2001-02-27 13:49:10 +01:00
* -------------------------------------------- *
* 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 . *
\ **************************************************************************/
2003-08-28 16:16:30 +02:00
2001-02-27 13:49:10 +01:00
/* $Id$ */
2003-12-11 14:14:47 +01:00
$submit = False ; // set to some initial value
2005-06-20 10:48:39 +02:00
$GLOBALS [ 'egw_info' ] = array ( 'flags' => array (
'disable_Template_class' => True ,
'login' => True ,
'currentapp' => 'login' ,
'noheader' => True
));
2003-12-11 14:14:47 +01:00
2002-02-17 09:07:38 +01:00
if ( file_exists ( './header.inc.php' ))
{
2003-11-26 14:51:58 +01:00
include ( './header.inc.php' );
2005-07-17 23:33:51 +02:00
if ( ! function_exists ( 'CreateObject' ))
2003-11-26 00:03:59 +01:00
{
Header ( 'Location: setup/index.php' );
exit ;
}
2002-02-17 09:07:38 +01:00
}
else
{
Header ( 'Location: setup/index.php' );
exit ;
}
2003-08-28 16:16:30 +02:00
2005-06-20 10:48:39 +02:00
$GLOBALS [ 'egw_info' ][ 'server' ][ 'template_dir' ] = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS [ 'egw_info' ][ 'login_template_set' ];
2005-06-15 13:16:27 +02:00
$tmpl = CreateObject ( 'phpgwapi.Template' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'template_dir' ]);
2002-10-18 23:45:46 +02:00
2004-03-23 11:28:15 +01:00
// read the images from the login-template-set, not the (maybe not even set) users template-set
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'template_set' ] = $GLOBALS [ 'egw_info' ][ 'login_template_set' ];
2004-03-23 11:28:15 +01:00
2003-08-28 16:16:30 +02:00
// This is used for system downtime, to prevent new logins.
2005-03-03 11:45:52 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'deny_all_logins' ])
2002-10-19 22:44:40 +02:00
{
2004-01-17 15:59:40 +01:00
$deny_msg = lang ( ' Oops ! You caught us in the middle of system maintainance .< br />
2003-12-13 04:55:30 +01:00
Please , check back with us shortly . ' );
2004-01-17 15:59:40 +01:00
2004-04-14 13:52:16 +02:00
$tmpl -> set_file ( array
(
'login_form' => 'login_denylogin.tpl'
));
$tmpl -> set_var ( 'template_set' , 'default' );
$tmpl -> set_var ( 'deny_msg' , $deny_msg );
$tmpl -> pfp ( 'loginout' , 'login_form' );
exit ;
2002-10-19 22:44:40 +02:00
}
2003-12-11 14:14:47 +01:00
$tmpl -> set_file ( array ( 'login_form' => 'login.tpl' ));
2005-06-15 13:16:27 +02:00
2003-08-28 16:16:30 +02: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)
2002-10-18 23:45:46 +02:00
2003-12-13 04:55:30 +01:00
// whoooo scaring
2004-05-03 15:52:09 +02:00
/*
2005-03-03 11:45:52 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'usecookies' ] == True )
2004-01-28 07:05:25 +01:00
{
2005-06-20 10:48:39 +02:00
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( 'eGroupWareLoginTime' , time ());
2004-01-28 07:05:25 +01:00
}
2004-05-03 15:52:09 +02:00
*/
2003-08-28 16:16:30 +02:00
/*
2005-03-03 11:45:52 +01:00
if ( $_GET [ 'cd' ] != 10 && $GLOBALS [ 'egw_info' ][ 'server' ][ 'usecookies' ] == False )
2003-08-28 16:16:30 +02:00
{
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> session -> setcookie ( 'sessionid' );
$GLOBALS [ 'egw' ] -> session -> setcookie ( 'kp3' );
$GLOBALS [ 'egw' ] -> session -> setcookie ( 'domain' );
2003-08-28 16:16:30 +02:00
}
*/
2001-05-11 12:02:34 +02:00
2003-08-28 16:16:30 +02:00
/* This is not working yet because I need to figure out a way to clear the $cd = 1
2003-12-11 14:14:47 +01:00
if ( isset ( $_SERVER [ 'PHP_AUTH_USER' ]) && $_GET [ 'cd' ] == '1' )
2001-05-11 12:02:34 +02:00
{
2003-08-28 16:16:30 +02:00
Header ( 'HTTP/1.0 401 Unauthorized' );
2005-07-08 07:00:14 +02:00
Header ( 'WWW-Authenticate: Basic realm="phpGroupWare"' );
echo 'You have to re-authentificate yourself' ;
2001-02-27 13:49:10 +01:00
exit ;
}
2003-08-28 16:16:30 +02:00
*/
2001-02-27 13:49:10 +01:00
2003-08-28 16:16:30 +02:00
function check_logoutcode ( $code )
2001-02-27 13:49:10 +01:00
{
2003-08-28 16:16:30 +02:00
switch ( $code )
2001-02-27 13:49:10 +01:00
{
case 1 :
2003-08-28 16:16:30 +02:00
return lang ( 'You have been successfully logged out' );
2001-02-27 13:49:10 +01:00
break ;
case 2 :
2003-08-28 16:16:30 +02:00
return lang ( 'Sorry, your login has expired' );
2001-02-27 13:49:10 +01:00
break ;
2004-01-28 07:05:25 +01:00
case 4 :
return lang ( 'Cookies are required to login to this site.' );
break ;
2001-02-27 13:49:10 +01:00
case 5 :
2003-08-28 16:16:30 +02:00
return '<font color="FF0000">' . lang ( 'Bad login or password' ) . '</font>' ;
2001-02-27 13:49:10 +01:00
break ;
2003-10-16 16:55:12 +02:00
case 98 :
return '<font color="FF0000">' . lang ( 'Account is expired' ) . '</font>' ;
break ;
2003-05-18 21:18:58 +02:00
case 99 :
2003-08-28 16:16:30 +02:00
return '<font color="FF0000">' . lang ( 'Blocked, too many attempts' ) . '</font>' ;
2003-05-18 21:18:58 +02:00
break ;
2001-02-27 13:49:10 +01:00
case 10 :
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( 'sessionid' );
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( 'kp3' );
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( 'domain' );
2003-05-18 21:18:58 +02:00
//fix for bug php4 expired sessions bug
2005-10-13 14:11:48 +02:00
if ( substr ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'sessions_type' ], 0 , 4 ) == 'php4' )
2002-08-12 02:57:51 +02:00
{
2005-06-20 10:48:39 +02:00
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( EGW_PHPSESSID );
2002-08-12 02:57:51 +02:00
}
2003-08-28 16:16:30 +02:00
2003-10-05 07:55:36 +02:00
return '<font color="#FF0000">' . lang ( 'Your session could not be verified.' ) . '</font>' ;
2001-02-27 13:49:10 +01:00
break ;
2003-08-28 16:16:30 +02:00
default :
return ' ' ;
2001-02-27 13:49:10 +01:00
}
}
2005-07-08 07:00:14 +02:00
2001-02-27 13:49:10 +01:00
/* Program starts here */
2003-10-04 15:36:11 +02:00
2005-03-03 11:45:52 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'auth_type' ] == 'http' && isset ( $_SERVER [ 'PHP_AUTH_USER' ]))
2001-02-27 13:49:10 +01:00
{
$submit = True ;
2003-05-18 21:18:58 +02:00
$login = $_SERVER [ 'PHP_AUTH_USER' ];
$passwd = $_SERVER [ 'PHP_AUTH_PW' ];
2003-12-11 14:14:47 +01:00
$passwd_type = 'text' ;
}
else
{
$passwd = $_POST [ 'passwd' ];
$passwd_type = $_POST [ 'passwd_type' ];
2005-06-16 00:12:35 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'allow_cookie_auth' ])
{
$eGW_remember = unserialize ( stripslashes ( $_COOKIE [ 'eGW_remember' ]));
2005-07-08 07:00:14 +02:00
2005-06-16 00:12:35 +02:00
if ( $eGW_remember [ 'login' ] && $eGW_remember [ 'passwd' ] && $eGW_remember [ 'passwd_type' ])
{
$_SERVER [ 'PHP_AUTH_USER' ] = $login = $eGW_remember [ 'login' ];
$_SERVER [ 'PHP_AUTH_PW' ] = $passwd = $eGW_remember [ 'passwd' ];
$passwd_type = $eGW_remember [ 'passwd_type' ];
$submit = True ;
}
}
2006-06-07 20:12:39 +02:00
if ( ! $passwd && ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'auto_anon_login' ]) && ! $_GET [ 'cd' ])
{
$_SERVER [ 'PHP_AUTH_USER' ] = $login = 'anonymous' ;
$_SERVER [ 'PHP_AUTH_PW' ] = $passwd = 'anonymous' ;
$passwd_type = 'text' ;
$submit = True ;
}
2001-02-27 13:49:10 +01:00
}
2001-04-26 00:01:52 +02:00
# Apache + mod_ssl style SSL certificate authentication
# Certificate (chain) verification occurs inside mod_ssl
2005-03-03 11:45:52 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'auth_type' ] == 'sqlssl' && isset ( $_SERVER [ 'SSL_CLIENT_S_DN' ]) && ! isset ( $_GET [ '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
2003-05-18 21:18:58 +02:00
$sslattribs = explode ( '/' , $_SERVER [ 'SSL_CLIENT_S_DN' ]);
2001-09-06 10:27:22 +02:00
# skip the part in front of the first '/' (nothing)
2005-06-20 10:48:39 +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
2003-12-11 14:14:47 +01: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.
2003-12-11 14:14:47 +01:00
if ( ! isset ( $_POST [ 'login' ]) && isset ( $sslattributes [ 'Email' ]))
{
2001-09-06 10:27:22 +02:00
$login = $sslattributes [ 'Email' ];
2001-05-01 11:15:40 +02:00
# not checked against the database, but delivered to authentication module
2003-05-18 21:18:58 +02:00
$passwd = $_SERVER [ '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
}
2003-05-18 21:18:58 +02:00
2004-01-28 07:05:25 +01:00
if ( isset ( $passwd_type ) || $_POST [ 'submitit_x' ] || $_POST [ 'submitit_y' ] || $submit )
2003-12-11 14:14:47 +01:00
// isset($_POST['passwd']) && $_POST['passwd']) // enable konqueror to login via Return
2001-02-27 13:49:10 +01:00
{
2004-01-28 07:05:25 +01:00
if ( getenv ( 'REQUEST_METHOD' ) != 'POST' && $_SERVER [ 'REQUEST_METHOD' ] != 'POST' &&
2003-12-11 14:14:47 +01:00
! isset ( $_SERVER [ 'PHP_AUTH_USER' ]) && ! isset ( $_SERVER [ 'SSL_CLIENT_S_DN' ]))
2001-02-27 13:49:10 +01:00
{
2005-07-08 07:00:14 +02:00
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( 'eGW_remember' );
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw' ] -> link ( '/login.php' , 'cd=5' ));
2004-01-28 07:05:25 +01:00
}
2004-01-28 10:27:00 +01:00
#if(!isset($_COOKIE['eGroupWareLoginTime']))
#{
2005-03-03 11:45:52 +01:00
# $GLOBALS['egw']->redirect($GLOBALS['egw']->link('/login.php','cd=4'));
2004-01-28 10:27:00 +01:00
#}
2005-07-08 07:00:14 +02:00
2003-11-18 23:03:34 +01:00
// don't get login data again when $submit is true
if ( $submit == false )
{
$login = $_POST [ 'login' ];
}
2005-07-08 07:00:14 +02:00
2005-06-20 10:48:39 +02:00
//conference - for strings like vinicius@thyamad.com@default , allows
//that user have a login that is his e-mail. (viniciuscb)
$login_parts = explode ( '@' , $login );
$got_login = false ;
if ( count ( $login_parts ) > 1 )
2003-05-18 21:18:58 +02:00
{
2005-06-20 10:48:39 +02:00
//Last part of login string, when separated by @, is a domain name
if ( array_key_exists ( array_pop ( $login_parts ), $GLOBALS [ 'egw_domain' ]))
{
$got_login = true ;
}
2003-05-18 21:18:58 +02:00
}
2005-06-20 10:48:39 +02:00
if ( ! $got_login )
2003-11-14 00:15:55 +01:00
{
2005-06-20 10:48:39 +02:00
if ( isset ( $_POST [ 'logindomain' ]))
{
$login .= '@' . $_POST [ 'logindomain' ];
}
elseif ( ! isset ( $GLOBALS [ 'egw_domain' ][ $GLOBALS [ 'egw_info' ][ 'user' ][ 'domain' ]]))
{
$login .= '@' . $GLOBALS [ 'egw_info' ][ 'server' ][ 'default_domain' ];
}
2003-11-14 00:15:55 +01:00
}
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'sessionid' ] = $GLOBALS [ 'egw' ] -> session -> create ( $login , $passwd , $passwd_type , 'u' );
2001-08-21 20:34:56 +02:00
2003-12-11 14:14:47 +01:00
if ( ! isset ( $GLOBALS [ 'sessionid' ]) || ! $GLOBALS [ 'sessionid' ])
2001-02-27 13:49:10 +01:00
{
2005-07-08 07:00:14 +02:00
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( 'eGW_remember' );
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> redirect ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . '/login.php?cd=' . $GLOBALS [ 'egw' ] -> session -> cd_reason );
2001-02-27 13:49:10 +01:00
}
else
{
2005-06-16 00:12:35 +02:00
/* set auth_cookie */
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'allow_cookie_auth' ] && $_POST [ 'remember_me' ] && $_POST [ 'passwd' ])
{
switch ( $_POST [ 'remember_me' ])
{
case '1hour' :
$remember_time = time () + 60 * 60 ;
break ;
case '1day' :
$remember_time = time () + 60 * 60 * 24 ;
break ;
case '1week' :
$remember_time = time () + 60 * 60 * 24 * 7 ;
break ;
case '1month' :
$remember_time = time () + 60 * 60 * 24 * 30 ;
break ;
case 'forever' :
default :
$remember_time = 2147483647 ;
break ;
}
$GLOBALS [ 'egw' ] -> session -> phpgw_setcookie ( 'eGW_remember' , serialize ( array (
'login' => $login ,
'passwd' => $passwd ,
'passwd_type' => $passwd_type )),
2005-07-08 07:00:14 +02:00
$remember_time );
}
2004-03-21 22:20:05 +01:00
if ( $_POST [ 'lang' ] && preg_match ( '/^[a-z]{2}(-[a-z]{2}){0,1}$/' , $_POST [ 'lang' ]) &&
2005-07-08 07:00:14 +02:00
$_POST [ 'lang' ] != $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ])
2004-03-21 22:20:05 +01:00
{
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> preferences -> add ( 'common' , 'lang' , $_POST [ 'lang' ], 'session' );
2004-03-21 22:20:05 +01:00
}
2004-04-14 13:52:16 +02:00
2005-03-03 11:45:52 +01:00
if ( ! $GLOBALS [ 'egw_info' ][ 'server' ][ 'disable_autoload_langfiles' ])
2003-08-10 12:11:43 +02:00
{
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> translation -> autoload_changed_langfiles ();
2003-08-10 12:11:43 +02:00
}
2005-06-20 10:48:39 +02:00
$forward = isset ( $_GET [ 'phpgw_forward' ]) ? urldecode ( $_GET [ 'phpgw_forward' ]) : @ $_POST [ 'phpgw_forward' ];
2004-04-14 13:52:16 +02:00
if ( ! $forward )
{
$extra_vars [ 'cd' ] = 'yes' ;
2005-07-08 07:00:14 +02:00
if ( $GLOBALS [ 'egw' ] -> hooks -> single ( 'hasUpdates' , 'home' ))
2005-06-15 13:16:27 +02:00
{
$extra_vars [ 'hasupdates' ] = 'yes' ;
}
$forward = '/index.php' ;
2004-04-14 13:52:16 +02:00
}
2004-05-03 15:52:09 +02:00
else
{
list ( $forward , $extra_vars ) = explode ( '?' , $forward , 2 );
}
2006-03-13 22:56:28 +01:00
// Check for save passwd
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'check_save_passwd' ] && $GLOBALS [ 'egw' ] -> acl -> check ( 'changepassword' , 1 , 'preferences' ) && $unsave_msg = $GLOBALS [ 'egw' ] -> auth -> crackcheck ( $passwd ))
{
$GLOBALS [ 'egw' ] -> log -> write ( array ( 'text' => 'D-message, User ' . $login . ' authenticated with an unsave password' , 'file' => __FILE__ , 'line' => __LINE__ ));
$message = '<font color="red">' . lang ( 'eGroupWare checked your password for saftyness. You have to change your password for the following reason:' ) . '<br>' ;
$GLOBALS [ 'egw' ] -> redirect_link ( '/index.php' , array ( 'menuaction' => 'preferences.uipassword.change' , 'message' => $message . $unsave_msg . '</font>' ));
}
else
{
$GLOBALS [ 'egw' ] -> redirect_link ( $forward , $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)
2003-12-11 14:14:47 +01:00
if ( isset ( $_COOKIE [ 'last_loginid' ]))
2001-02-27 13:49:10 +01:00
{
2005-06-20 10:48:39 +02:00
$accounts =& CreateObject ( 'phpgwapi.accounts' );
$prefs =& CreateObject ( 'phpgwapi.preferences' , $accounts -> name2id ( $_COOKIE [ 'last_loginid' ]));
2001-02-27 13:49:10 +01:00
2003-12-11 14:14:47 +01:00
if ( $prefs -> account_id )
2001-02-27 13:49:10 +01:00
{
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ] = $prefs -> read_repository ();
2001-02-27 13:49:10 +01:00
}
}
2004-07-11 11:42:54 +02:00
if ( $_GET [ 'lang' ])
{
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ] = $_GET [ 'lang' ];
2004-07-11 11:42:54 +02:00
}
elseif ( ! isset ( $_COOKIE [ 'last_loginid' ]) || ! $prefs -> account_id )
2001-02-27 13:49:10 +01:00
{
2003-09-18 07:04:06 +02:00
// If the lastloginid cookies isn't set, we will default to the first language,
// the users browser accepts.
2003-09-23 23:26:58 +02:00
list ( $lang ) = explode ( ',' , $_SERVER [ 'HTTP_ACCEPT_LANGUAGE' ]);
2003-12-11 14:14:47 +01:00
if ( strlen ( $lang ) > 2 )
2003-09-23 23:26:58 +02:00
{
$lang = substr ( $lang , 0 , 2 );
}
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ] = $lang ;
2003-05-18 21:18:58 +02:00
}
2005-03-03 11:45:52 +01:00
#print 'LANG:' . $GLOBALS['egw_info']['user']['preferences']['common']['lang'] . '<br>';
2003-09-23 23:26:58 +02:00
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> translation -> init (); // this will set the language according to the (new) set prefs
$GLOBALS [ 'egw' ] -> translation -> add_app ( 'login' );
$GLOBALS [ 'egw' ] -> translation -> add_app ( 'loginscreen' );
2003-12-11 14:14:47 +01:00
if ( lang ( 'loginscreen_message' ) == 'loginscreen_message*' )
2003-09-15 10:41:57 +02:00
{
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw' ] -> translation -> add_app ( 'loginscreen' , 'en' ); // trying the en one
2003-09-15 10:41:57 +02:00
}
2003-12-11 14:14:47 +01:00
if ( lang ( 'loginscreen_message' ) != 'loginscreen_message*' )
2003-05-18 21:18:58 +02:00
{
2003-08-28 16:16:30 +02:00
$tmpl -> set_var ( 'lang_message' , stripslashes ( lang ( 'loginscreen_message' )));
2001-02-27 13:49:10 +01:00
}
}
2005-06-20 10:48:39 +02:00
$tmpl -> set_block ( 'login_form' , 'domain_selection' );
2003-10-15 14:55:48 +02:00
$domain_select = ' ' ;
2005-06-20 10:48:39 +02:00
$lang_domain_select = ' ' ;
2003-05-18 21:18:58 +02:00
$last_loginid = $_COOKIE [ 'last_loginid' ];
2005-03-03 11:45:52 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'show_domain_selectbox' ])
2001-02-27 13:49:10 +01:00
{
2003-10-15 14:55:48 +02:00
$domain_select = " <select name= \" logindomain \" > \n " ;
2005-03-03 11:45:52 +01:00
foreach ( $GLOBALS [ 'egw_domain' ] as $domain_name => $domain_vars )
2003-12-11 14:14:47 +01:00
{
2003-08-28 16:16:30 +02:00
$domain_select .= '<option value="' . $domain_name . '"' ;
2003-12-11 14:14:47 +01:00
if ( $domain_name == $_COOKIE [ 'last_domain' ])
2001-02-27 13:49:10 +01:00
{
2003-08-28 16:16:30 +02:00
$domain_select .= ' selected' ;
2002-10-19 16:33:32 +02:00
}
2003-10-15 14:55:48 +02:00
$domain_select .= '>' . $domain_name . " </option> \n " ;
2001-02-27 13:49:10 +01:00
}
2003-10-15 14:55:48 +02:00
$domain_select .= " </select> \n " ;
2005-06-20 10:48:39 +02:00
$lang_domain_select = lang ( 'Domain' );
2005-06-16 00:12:35 +02:00
}
2003-12-11 14:14:47 +01:00
elseif ( $last_loginid !== '' )
2003-05-18 21:18:58 +02:00
{
2005-03-03 11:45:52 +01:00
reset ( $GLOBALS [ 'egw_domain' ]);
list ( $default_domain ) = each ( $GLOBALS [ 'egw_domain' ]);
2003-08-10 12:11:43 +02:00
2003-12-11 14:14:47 +01:00
if ( $_COOKIE [ 'last_domain' ] != $default_domain && ! empty ( $_COOKIE [ 'last_domain' ]))
2003-05-18 21:18:58 +02:00
{
$last_loginid .= '@' . $_COOKIE [ 'last_domain' ];
}
}
2005-06-20 10:48:39 +02:00
$tmpl -> set_var ( 'lang_select_domain' , $lang_domain_select );
$tmpl -> set_var ( 'select_domain' , $domain_select );
2005-06-16 00:12:35 +02:00
if ( ! $GLOBALS [ 'egw_info' ][ 'server' ][ 'show_domain_selectbox' ])
{
2005-07-08 07:00:14 +02:00
/* trick to make domain section disapear */
2005-10-10 09:55:38 +02:00
$tmpl -> set_var ( 'domain_selection' , $GLOBALS [ 'egw_info' ][ 'user' ][ 'domain' ] ?
'<input type="hidden" name="logindomain" value="' . htmlspecialchars ( $GLOBALS [ 'egw_info' ][ 'user' ][ 'domain' ]) . '" />' : '' );
2005-06-16 00:12:35 +02:00
}
2001-02-27 13:49:10 +01:00
2003-08-10 12:11:43 +02:00
foreach ( $_GET as $name => $value )
2001-02-27 13:49:10 +01:00
{
2005-06-20 10:48:39 +02:00
if ( ereg ( 'phpgw_' , $name ))
2001-02-27 13:49:10 +01:00
{
$extra_vars .= '&' . $name . '=' . urlencode ( $value );
}
}
2003-12-11 14:14:47 +01:00
if ( $extra_vars )
2001-02-27 13:49:10 +01:00
{
2004-04-14 13:52:16 +02:00
$extra_vars = '?' . substr ( $extra_vars , 1 );
2001-02-27 13:49:10 +01:00
}
2003-12-13 04:55:30 +01:00
/******************************************************** \
* Check is the registration app is installed , activated *
* And if the register link must be placed *
\ ********************************************************/
2005-07-08 07:00:14 +02:00
2005-06-20 10:48:39 +02:00
$cnf_reg =& CreateObject ( 'phpgwapi.config' , 'registration' );
2003-12-13 04:55:30 +01:00
$cnf_reg -> read_repository ();
$config_reg = $cnf_reg -> config_data ;
2005-06-20 10:48:39 +02:00
if ( $config_reg [ enable_registration ] == 'True' )
2005-06-16 00:12:35 +02:00
{
2005-07-08 07:00:14 +02:00
if ( $config_reg [ register_link ] == 'True' )
{
2005-11-26 15:31:16 +01:00
$reg_link = ' <a href="' . $GLOBALS [ 'egw' ] -> link ( '/registration/index.php' ) . '">' . lang ( 'Not a user yet? Register now' ) . '</a><br/>' ;
2005-07-08 07:00:14 +02:00
}
if ( $config_reg [ lostpassword_link ] == 'True' )
{
2005-11-26 15:31:16 +01:00
$lostpw_link = ' <a href="' . $GLOBALS [ 'egw' ] -> link ( '/registration/index.php' , 'menuaction=registration.boreg.lostpw1' ) . '">' . lang ( 'Lost password' ) . '</a><br/>' ;
2005-07-08 07:00:14 +02:00
}
if ( $config_reg [ lostid_link ] == 'True' )
{
2005-11-26 15:31:16 +01:00
$lostid_link = ' <a href="' . $GLOBALS [ 'egw' ] -> link ( '/registration/index.php' , 'menuaction=registration.boreg.lostid1' ) . '">' . lang ( 'Lost Login Id' ) . '</a><br/>' ;
2005-07-08 07:00:14 +02:00
}
/* if at least one option of "registration" is activated display the registration section */
if ( $config_reg [ register_link ] == 'True' || $config_reg [ lostpassword_link ] == 'True' || $config_reg [ lostid_link ] == 'True' )
{
$tmpl -> set_var ( 'register_link' , $reg_link );
$tmpl -> set_var ( 'lostpassword_link' , $lostpw_link );
$tmpl -> set_var ( 'lostid_link' , $lostid_link ) ;
//$tmpl->set_var('registration_url',$GLOBALS['egw_info']['server']['webserver_url'] . '/registration/');
}
else
{
/* trick to make registration section disapear */
$tmpl -> set_block ( 'login_form' , 'registration' );
$tmpl -> set_var ( 'registration' , '' );
}
2005-06-16 00:12:35 +02:00
}
2003-12-13 04:55:30 +01:00
2005-06-20 10:48:39 +02:00
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
header ( 'Content-type: text/html; charset=' . $GLOBALS [ 'egw' ] -> translation -> charset ());
2005-07-08 07:00:14 +02:00
2005-03-03 11:45:52 +01:00
$GLOBALS [ 'egw_info' ][ 'server' ][ 'template_set' ] = $GLOBALS [ 'egw_info' ][ 'login_template_set' ];
2003-10-26 18:01:51 +01:00
2005-03-03 11:45:52 +01:00
$tmpl -> set_var ( 'charset' , $GLOBALS [ 'egw' ] -> translation -> charset ());
$tmpl -> set_var ( 'login_url' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'webserver_url' ] . '/login.php' . $extra_vars );
2005-06-20 10:48:39 +02:00
$tmpl -> set_var ( 'version' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'versions' ][ 'phpgwapi' ]);
2003-08-28 16:16:30 +02:00
$tmpl -> set_var ( 'cd' , check_logoutcode ( $_GET [ 'cd' ]));
$tmpl -> set_var ( 'cookie' , $last_loginid );
2002-10-20 02:34:12 +02:00
2003-08-28 16:16:30 +02:00
$tmpl -> set_var ( 'lang_username' , lang ( 'username' ));
$tmpl -> set_var ( 'lang_password' , lang ( 'password' ));
$tmpl -> set_var ( 'lang_login' , lang ( 'login' ));
2002-10-18 02:21:54 +02:00
2005-03-03 11:45:52 +01:00
$tmpl -> set_var ( 'website_title' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'site_title' ]);
$tmpl -> set_var ( 'template_set' , $GLOBALS [ 'egw_info' ][ 'login_template_set' ]);
$tmpl -> set_var ( 'bg_color' ,( $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_bg_color' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_bg_color' ] : 'FFFFFF' ));
$tmpl -> set_var ( 'bg_color_title' ,( $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_bg_color_title' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_bg_color_title' ] : '486591' ));
2004-01-16 15:23:35 +01:00
2005-03-03 11:45:52 +01:00
if ( substr ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ], 0 , 4 ) == 'http' )
2004-01-16 15:23:35 +01:00
{
2005-03-03 11:45:52 +01:00
$var [ 'logo_file' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ];
2004-01-16 15:23:35 +01:00
}
2004-03-21 15:58:04 +01:00
else
2004-01-16 15:23:35 +01:00
{
2005-06-20 10:48:39 +02:00
$var [ 'logo_file' ] = $GLOBALS [ 'egw' ] -> common -> image ( 'phpgwapi' , $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_file' ] : 'logo' );
2004-01-16 15:23:35 +01:00
}
2005-03-03 11:45:52 +01:00
$var [ 'logo_url' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_url' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_url' ] : 'http://www.eGroupWare.org' ;
2004-03-21 15:58:04 +01:00
if ( substr ( $var [ 'logo_url' ], 0 , 4 ) != 'http' )
2004-01-16 15:23:35 +01:00
{
2004-03-21 15:58:04 +01:00
$var [ 'logo_url' ] = 'http://' . $var [ 'logo_url' ];
2004-01-16 15:23:35 +01:00
}
2005-03-03 11:45:52 +01:00
$var [ 'logo_title' ] = $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_title' ] ? $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_logo_title' ] : 'www.eGroupWare.org' ;
2004-03-21 15:58:04 +01:00
$tmpl -> set_var ( $var );
2004-01-17 15:59:40 +01:00
2005-06-20 10:48:39 +02:00
/* language section if activated in site config */
2005-03-03 11:45:52 +01:00
if ( @ $GLOBALS [ 'egw_info' ][ 'server' ][ 'login_show_language_selection' ])
2004-03-21 22:20:05 +01:00
{
2005-06-20 10:48:39 +02:00
$select_lang = '<select name="lang" onchange="' . " if (this.form.login.value && this.form.passwd.value) this.form.submit(); else location.href=location.href+(location.search?'&':'?')+'lang='+this.value " . '">' ;
2005-11-15 00:44:31 +01:00
foreach ( $GLOBALS [ 'egw' ] -> translation -> get_installed_langs () as $key => $name ) // if we have a translation use it
2004-03-21 22:20:05 +01:00
{
2005-11-15 00:44:31 +01:00
$select_lang .= " \n \t " . '<option value="' . $key . '"' . ( $key == $GLOBALS [ 'egw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'lang' ] ? ' selected="selected"' : '' ) . '>' . $name . '</option>' ;
2004-03-21 22:20:05 +01:00
}
$select_lang .= " \n </select> \n " ;
$tmpl -> set_var ( array (
'lang_language' => lang ( 'Language' ),
'select_language' => $select_lang ,
));
}
else
{
$tmpl -> set_block ( 'login_form' , 'language_select' );
$tmpl -> set_var ( 'language_select' , '' );
}
2005-06-16 00:12:35 +02:00
/******************************************************** \
* Check if authentification via cookies is allowed *
* and place a time selectbox , how long cookie is valid *
\ ********************************************************/
2005-07-08 07:00:14 +02:00
2005-06-16 00:12:35 +02:00
if ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'allow_cookie_auth' ])
{
2005-06-20 10:48:39 +02:00
$html =& CreateObject ( 'phpgwapi.html' ); /* Why the hell was nobody useing this here before??? */
2005-06-16 00:12:35 +02:00
$tmpl -> set_block ( 'login_form' , 'remember_me_selection' );
$tmpl -> set_var ( 'lang_remember_me' , lang ( 'Remember me' ));
$tmpl -> set_var ( 'select_remember_me' , $html -> select ( 'remember_me' , 'forever' , array (
false => lang ( 'not' ),
'1hour' => lang ( '1 Hour' ),
'1day' => lang ( '1 Day' ),
'1week' => lang ( '1 Week' ),
'1month' => lang ( '1 Month' ),
'forever' => lang ( 'Forever' )), true
));
}
else
{
2005-07-08 07:00:14 +02:00
/* trick to make remember_me section disapear */
$tmpl -> set_block ( 'login_form' , 'remember_me_selection' );
$tmpl -> set_var ( 'remember_me_selection' , '' );
2005-06-16 00:12:35 +02:00
}
2005-07-08 07:00:14 +02:00
2005-03-03 11:45:52 +01:00
$tmpl -> set_var ( 'autocomplete' , ( $GLOBALS [ 'egw_info' ][ 'server' ][ 'autocomplete_login' ] ? 'autocomplete="off"' : '' ));
2002-10-20 02:34:12 +02:00
2003-08-28 16:16:30 +02:00
$tmpl -> pfp ( 'loginout' , 'login_form' );
2001-02-04 11:26:15 +01:00
?>