2000-08-18 05:24:22 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Dan Kuykendall <seek3r@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$ */
|
|
|
|
|
2000-11-16 08:40:37 +01:00
|
|
|
$phpgw_info["flags"] = array("disable_template_class" => True, "login" => True, "currentapp" => "login", "noheader" => True);
|
2000-11-29 19:32:56 +01:00
|
|
|
include("./header.inc.php");
|
2000-12-08 06:13:50 +01:00
|
|
|
|
|
|
|
$deny_login = False;
|
|
|
|
|
2000-09-06 17:55:58 +02:00
|
|
|
/*
|
2000-09-04 15:31:05 +02:00
|
|
|
if ($code != 10 && $phpgw_info["server"]["usecookies"] == False) {
|
|
|
|
Setcookie("sessionid");
|
|
|
|
Setcookie("kp3");
|
2000-11-23 08:45:16 +01:00
|
|
|
Setcookie("domain");
|
2000-09-04 15:31:05 +02:00
|
|
|
}
|
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
|
|
|
|
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 \n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
*/
|
2000-12-19 19:14:22 +01:00
|
|
|
|
2001-02-06 12:00:26 +01:00
|
|
|
$phpgw_info["server"]["template_dir"] = PHPGW_SERVER_ROOT."/phpgwapi/templates/default";
|
|
|
|
$tmpl = CreateObject("phpgwapi.Template", $phpgw_info["server"]["template_dir"]);
|
2000-12-08 06:13:50 +01:00
|
|
|
|
|
|
|
if (! $deny_login && ! $phpgw_info["server"]["show_domain_selectbox"]) {
|
|
|
|
$tmpl->set_file(array("login_form" => "login.tpl"));
|
|
|
|
} else if ($phpgw_info["server"]["show_domain_selectbox"]) {
|
|
|
|
$tmpl->set_file(array("login_form" => "login_selectdomain.tpl"));
|
|
|
|
} else {
|
|
|
|
$tmpl->set_file(array("login_form" => "login_denylogin.tpl"));
|
|
|
|
}
|
2000-08-18 05:24:22 +02:00
|
|
|
|
|
|
|
// When I am updating my server, I don't want people logging in a messing
|
|
|
|
// things up.
|
|
|
|
function deny_login()
|
|
|
|
{
|
|
|
|
global $tmpl;
|
2000-12-08 06:13:50 +01:00
|
|
|
$tmpl->parse("loginout", "login_form");
|
2000-08-18 05:24:22 +02:00
|
|
|
$tmpl->p("loginout");
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2000-09-03 11:15:37 +02:00
|
|
|
function show_cookie()
|
2000-08-18 05:24:22 +02:00
|
|
|
{
|
2000-11-23 21:25:58 +01:00
|
|
|
global $phpgw_info, $code, $last_loginid, $login;
|
2000-09-04 15:31:05 +02:00
|
|
|
/* This needs to be this way, because if someone doesnt want to use cookies, we shouldnt sneak one in */
|
2000-11-09 14:21:36 +01:00
|
|
|
if ($code != 5 && (isset($phpgw_info["server"]["usecookies"]) && $phpgw_info["server"]["usecookies"])){
|
2000-11-23 21:25:58 +01:00
|
|
|
return $last_loginid;
|
2000-09-03 11:15:37 +02:00
|
|
|
}
|
2000-08-18 05:24:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function check_logoutcode($code)
|
|
|
|
{
|
2000-09-03 09:56:11 +02:00
|
|
|
global $phpgw_info;
|
|
|
|
switch($code){
|
|
|
|
case "1":
|
2000-11-20 18:47:02 +01:00
|
|
|
return "You have been successfully logged out";
|
2000-09-03 09:56:11 +02:00
|
|
|
break;
|
|
|
|
case "2":
|
2000-11-20 18:47:02 +01:00
|
|
|
return "Sorry, your login has expired";
|
2000-09-03 09:56:11 +02:00
|
|
|
break;
|
|
|
|
case "5":
|
2000-11-20 18:47:02 +01:00
|
|
|
return "<font color=FF0000>" . "Bad login or password" . "</font>";
|
2000-09-03 09:56:11 +02:00
|
|
|
break;
|
|
|
|
case "10":
|
2000-10-05 09:11:49 +02:00
|
|
|
Setcookie("sessionid");
|
|
|
|
Setcookie("kp3");
|
2000-11-23 08:45:16 +01:00
|
|
|
Setcookie("domain");
|
2000-11-20 18:47:02 +01:00
|
|
|
return "<font color=FF0000>" . "Your session could not be verified." . "</font>";
|
2000-09-03 09:56:11 +02:00
|
|
|
break;
|
|
|
|
default:
|
2000-08-18 05:24:22 +02:00
|
|
|
return " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Program starts here */
|
|
|
|
|
|
|
|
if ($deny_login) {
|
2000-09-04 01:22:14 +02:00
|
|
|
deny_login();
|
2000-08-18 05:24:22 +02:00
|
|
|
}
|
2000-11-16 22:51:01 +01:00
|
|
|
|
2001-02-10 04:59:50 +01:00
|
|
|
if ($phpgw_info["server"]["auth_type"] == "http" && isset($PHP_AUTH_USER)) {
|
2000-12-15 05:12:35 +01:00
|
|
|
$submit = True;
|
|
|
|
$login = $PHP_AUTH_USER;
|
|
|
|
$passwd = $PHP_AUTH_PW;
|
|
|
|
}
|
|
|
|
|
2000-11-09 14:21:36 +01:00
|
|
|
if (isset($submit) && $submit) {
|
2000-12-15 05:12:35 +01:00
|
|
|
if (getenv(REQUEST_METHOD) != "POST" && !isset($PHP_AUTH_USER)) {
|
2000-11-29 19:32:56 +01:00
|
|
|
$phpgw->redirect($phpgw->link("","code=5"));
|
2000-08-18 05:24:22 +02:00
|
|
|
}
|
2000-09-03 09:56:11 +02:00
|
|
|
$sessionid = $phpgw->session->create($login,$passwd);
|
2000-11-09 14:21:36 +01:00
|
|
|
if (!isset($sessionid) || !$sessionid) {
|
2000-11-29 19:32:56 +01:00
|
|
|
$phpgw->redirect($phpgw_info["server"]["webserver_url"]."/login.php?cd=5");
|
2000-08-18 05:24:22 +02:00
|
|
|
} else {
|
2001-02-04 10:19:07 +01:00
|
|
|
if ($phpgw_forward) {
|
|
|
|
while (list($name,$value) = each($HTTP_GET_VARS)) {
|
|
|
|
if (ereg("phpgw_",$name)) {
|
2001-02-04 11:18:47 +01:00
|
|
|
$extra_vars .= "&" . $name . "=" . urlencode($value);
|
2001-02-04 10:19:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$phpgw->redirect($phpgw->link($phpgw_info["server"]["webserver_url"] . "/index.php", "cd=yes$extra_vars"));
|
2000-09-03 09:56:11 +02:00
|
|
|
}
|
2000-08-18 05:24:22 +02:00
|
|
|
} else {
|
2000-11-28 20:54:10 +01:00
|
|
|
// !!! DONT CHANGE THESE LINES !!!
|
|
|
|
// If there is something wrong with this code TELL ME!
|
|
|
|
// Commenting out the code will not fix it. (jengo)
|
2000-11-20 18:47:02 +01:00
|
|
|
if (isset($last_loginid)) {
|
2001-02-06 12:00:26 +01:00
|
|
|
$prefs = CreateObject("phpgwapi.preferences", $last_loginid);
|
|
|
|
if ($prefs->account_id == ""){
|
|
|
|
$phpgw_info["user"]["preferences"]["common"]["lang"] = "en";
|
|
|
|
}else{
|
|
|
|
$phpgw_info["user"]["preferences"] = $prefs->read_repository();
|
|
|
|
}
|
|
|
|
#print "LANG:".$phpgw_info["user"]["preferences"]["common"]["lang"]."<br>";
|
|
|
|
$phpgw->translation->add_app("login");
|
|
|
|
$phpgw->translation->add_app("loginscreen");
|
|
|
|
if (lang("loginscreen_message") != "loginscreen_message*") {
|
|
|
|
$tmpl->set_var("lang_message",stripslashes(lang("loginscreen_message")));
|
|
|
|
}
|
2000-11-28 20:54:10 +01:00
|
|
|
} else {
|
2000-12-11 08:17:03 +01:00
|
|
|
// If the lastloginid cookies isn't set, we will default to english.
|
|
|
|
// Change this if you need.
|
|
|
|
$phpgw_info["user"]["preferences"]["common"]["lang"] = "en";
|
|
|
|
$phpgw->translation->add_app("login");
|
|
|
|
$phpgw->translation->add_app("loginscreen");
|
|
|
|
if (lang("loginscreen_message") != "loginscreen_message*") {
|
|
|
|
$tmpl->set_var("lang_message",stripslashes(lang("loginscreen_message")));
|
|
|
|
}
|
2000-09-29 22:41:34 +02:00
|
|
|
}
|
2000-08-18 05:24:22 +02:00
|
|
|
}
|
2000-11-09 20:37:45 +01:00
|
|
|
|
|
|
|
if(!isset($cd) || !$cd) $cd="";
|
2000-12-08 06:13:50 +01:00
|
|
|
|
|
|
|
if ($phpgw_info["server"]["show_domain_selectbox"]) {
|
|
|
|
reset($phpgw_domain);
|
|
|
|
unset($domain_select); // For security ... just in case
|
|
|
|
while ($domain = each($phpgw_domain)) {
|
|
|
|
$domain_select .= '<option value="' . $domain[0] . '"';
|
2000-12-08 06:29:55 +01:00
|
|
|
if ($domain[0] == $last_domain) {
|
2000-12-08 06:13:50 +01:00
|
|
|
$domain_select .= " selected";
|
|
|
|
}
|
|
|
|
$domain_select .= '>' . $domain[0] . '</option>';
|
|
|
|
}
|
|
|
|
$tmpl->set_var("select_domain",$domain_select);
|
|
|
|
}
|
2001-02-04 10:19:07 +01:00
|
|
|
|
|
|
|
while (list($name,$value) = each($HTTP_GET_VARS)) {
|
|
|
|
if (ereg("phpgw_",$name)) {
|
2001-02-04 11:18:47 +01:00
|
|
|
$extra_vars .= "&" . $name . "=" . urlencode($value);
|
2001-02-04 10:19:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($extra_vars) {
|
|
|
|
$extra_vars = "?" . substr($extra_vars,1,strlen($extra_vars));
|
|
|
|
}
|
|
|
|
|
|
|
|
$tmpl->set_var("login_url", $phpgw_info["server"]["webserver_url"] . "/login.php" . $extra_vars);
|
2000-09-04 01:22:14 +02:00
|
|
|
$tmpl->set_var("website_title", $phpgw_info["server"]["site_title"]);
|
2000-08-18 05:24:22 +02:00
|
|
|
$tmpl->set_var("cd",check_logoutcode($cd));
|
2000-09-03 11:15:37 +02:00
|
|
|
$tmpl->set_var("cookie",show_cookie());
|
2000-11-20 18:47:02 +01:00
|
|
|
$tmpl->set_var("lang_username","username");
|
|
|
|
$tmpl->set_var("lang_phpgw_login","phpGroupWare login");
|
2000-12-21 21:43:26 +01:00
|
|
|
$tmpl->set_var("version",$phpgw_info["server"]["versions"]["phpgwapi"]);
|
2000-11-20 18:47:02 +01:00
|
|
|
$tmpl->set_var("lang_password","password");
|
|
|
|
$tmpl->set_var("lang_login","login");
|
2001-01-09 10:36:16 +01:00
|
|
|
$tmpl->set_var("template_set","default");
|
2000-10-31 15:02:21 +01:00
|
|
|
$tmpl->parse("loginout", "login_form");
|
2000-08-18 05:24:22 +02:00
|
|
|
$tmpl->p("loginout");
|
2001-02-04 11:26:15 +01:00
|
|
|
?>
|