Fixed not being able to login and clean up a ton of code. It was a mess in there, things flow a little but better now. I still have some cleaning up to do

This commit is contained in:
jengo 2001-02-06 13:18:51 +00:00
parent 6c9387eb13
commit e0b8a07f9c
9 changed files with 333 additions and 285 deletions

View File

@ -1,11 +0,0 @@
<?php
if (empty($phpgw_info["server"]["account_repository"])){
if (!empty($phpgw_info["server"]["auth_type"])){
$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];
}else{
$phpgw_info["server"]["account_repository"] = "sql";
}
}
include(PHPGW_API_INC."/class.accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
include(PHPGW_API_INC."/class.accounts_shared.inc.php");
?>

View File

@ -24,7 +24,7 @@
/* $Id$ */
class accounts_
class accounts
{
var $db;
var $account_id;
@ -32,6 +32,13 @@
var $memberships;
var $members;
function accounts()
{
global $phpgw;
$this->db = $phpgw->db;
}
function read_repository()
{
global $phpgw, $phpgw_info;

View File

@ -1,4 +0,0 @@
<?php
if (empty($phpgw_info["server"]["auth_type"])){$phpgw_info["server"]["auth_type"] = "sql";}
include(PHPGW_API_INC."/class.auth_".$phpgw_info["server"]["auth_type"].".inc.php");
?>

View File

@ -379,28 +379,36 @@
return $list;
}
function get_tpl_dir($appname = ""){
function get_tpl_dir($appname = "")
{
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if ($appname == "home" || $appname == "logout" || $appname == "login"){$appname = "phpgwapi";}
if (! $appname) {
$appname = $phpgw_info["flags"]["currentapp"];
}
if ($appname == "home" || $appname == "logout" || $appname == "login") {
$appname = "phpgwapi";
}
// Setting this for display of template choices in user preferences
if ($phpgw_info["server"]["template_set"] == "user_choice" ){$phpgw_info["server"]["usrtplchoice"] = "user_choice"; }
if ($phpgw_info["server"]["template_set"] == "user_choice") {
$phpgw_info["server"]["usrtplchoice"] = "user_choice";
}
if ($phpgw_info["server"]["template_set"] == "user_choice" && isset($phpgw_info["user"]["preferences"]["common"]["template_set"])){
if ($phpgw_info["server"]["template_set"] == "user_choice" && isset($phpgw_info["user"]["preferences"]["common"]["template_set"])) {
$phpgw_info["server"]["template_set"] = $phpgw_info["user"]["preferences"]["common"]["template_set"];
}elseif ($phpgw_info["server"]["template_set"] == "user_choice" || !isset($phpgw_info["server"]["template_set"])){
} elseif ($phpgw_info["server"]["template_set"] == "user_choice" || !isset($phpgw_info["server"]["template_set"])) {
$phpgw_info["server"]["template_set"] = "default";
}
$tpldir = $phpgw_info["server"]["server_root"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"];
$tpldir_default = $phpgw_info["server"]["server_root"]."/".$appname."/templates/default";
$tpldir = PHPGW_SERVER_ROOT . "/" . $appname . "/templates/"
. $phpgw_info["server"]["template_set"];
$tpldir_default = PHPGW_SERVER_ROOT . "/".$appname . "/templates/default";
if (is_dir ($tpldir)){
if (is_dir ($tpldir)) {
return $tpldir;
}elseif (is_dir ($tpldir_default)){
} elseif (is_dir ($tpldir_default)) {
return $tpldir_default;
}else{
} else {
return False;
}
}
@ -506,11 +514,11 @@
function phpgw_header() {
global $phpgw, $phpgw_info;
include($phpgw_info["server"]["include_root"] . "/phpgwapi/templates/"
. $phpgw_info["server"]["template_set"] . "/head.inc.php");
include(PHPGW_INCLUDE_ROOT . "/phpgwapi/templates/" . $phpgw_info["server"]["template_set"]
. "/head.inc.php");
$this->navbar(False);
include($phpgw_info["server"]["include_root"] . "/phpgwapi/templates/"
. $phpgw_info["server"]["template_set"] . "/navbar.inc.php");
include(PHPGW_INCLUDE_ROOT . "/phpgwapi/templates/" . $phpgw_info["server"]["template_set"]
. "/navbar.inc.php");
if ((! isset($phpgw_info["flags"]["nonavbar"]) || ! $phpgw_info["flags"]["nonavbar"]) && ! $phpgw_info["flags"]["navbar_target"]) {
echo parse_navbar();
}

View File

@ -76,18 +76,20 @@
if ($phpgw_info["flags"]["currentapp"] == "login") {
$this->db->query("select * from config",__LINE__,__FILE__);
while($this->db->next_record()) {
while ($this->db->next_record()) {
$phpgw_info["server"][$this->db->f("config_name")] = stripslashes($this->db->f("config_value"));
}
} else {
$config_var = array("encryptkey","auth_type","account_repository");
$c= "";
$c = "";
for ($i=0;$i<count($config_var);$i++) {
if($i) $c .= " OR ";
if ($i) {
$c .= " OR ";
}
$c .= "config_name='".$config_var[$i]."'";
}
$this->db->query("select * from config where $c",__LINE__,__FILE__);
while($this->db->next_record()) {
while ($this->db->next_record()) {
$phpgw_info["server"][$this->db->f("config_name")] = stripslashes($this->db->f("config_value"));
}
}
@ -98,9 +100,21 @@
$this->common = CreateObject("phpgwapi.common");
$this->hooks = CreateObject("phpgwapi.hooks");
$this->auth = CreateObject("phpgwapi.auth");
if (! $phpgw_info["server"]["auth_type"]) {
$phpgw_info["server"]["auth_type"] = "sql";
}
$this->auth = create_specialobject("phpgwapi.auth",$phpgw_info["server"]["auth_type"]);
$this->acl = CreateObject("phpgwapi.acl");
$this->accounts = CreateObject("phpgwapi.accounts");
if (! $phpgw_info["server"]["account_repository"]) {
if ($phpgw_info["server"]["auth_type"]) {
$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];
} else {
$phpgw_info["server"]["account_repository"] = "sql";
}
}
$this->accounts = create_specialobject("phpgwapi.accounts",$phpgw_info["server"]["auth_type"]);
$this->session = CreateObject("phpgwapi.sessions");
$this->preferences = CreateObject("phpgwapi.preferences");
$this->applications = CreateObject("phpgwapi.applications");
@ -112,7 +126,7 @@
$this->accounts->accounts($login_id);
$this->preferences->preferences($login_id);
}
}elseif (! $this->session->verify()) {
} elseif (! $this->session->verify()) {
$this->db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__);
$this->db->next_record();
Header("Location: " . $this->redirect($this->link($this->db->f("config_value")."/login.php","cd=10")));
@ -230,11 +244,4 @@
return $phpgw->translation->translate($key);
}
// Some people might prefear to use this one
function _L($key, $m1 = "", $m2 = "", $m3 = "", $m4 = "")
{
global $phpgw;
return $phpgw->translation->translate($key);
}
}//end phpgw class
} //end phpgw class

View File

@ -61,8 +61,8 @@
global $phpgw, $phpgw_info, $sessionid, $kp3;
$db = $phpgw->db;
$db2 = $phpgw->db;
$this->sessionid .= $sessionid;
$this->kp3 .= $kp3;
$this->sessionid = $sessionid;
$this->kp3 = $kp3;
// PHP 3 complains that these are not defined when the already are defined.
$phpgw->common->key = $phpgw_info["server"]["encryptkey"];
@ -74,7 +74,7 @@
$cryptovars[1] = $phpgw->common->iv;
$phpgw->crypto = CreateObject("phpgwapi.crypto", $cryptovars);
$db->query("select * from phpgw_sessions where session_id='$this->sessionid'",__LINE__,__FILE__);
$db->query("select * from phpgw_sessions where session_id='" . $this->sessionid . "'",__LINE__,__FILE__);
$db->next_record();
if ($db->f("session_info") == "" || $db->f("session_info") == "NULL") {
@ -171,13 +171,15 @@
$login_array = explode("@", $login);
$this->account_lid = $login_array[0];
if ($login_array[1]!=""){
if ($login_array[1]!="") {
$this->account_domain = $login_array[1];
}else{
} else {
$this->account_domain = $phpgw_info["server"]["default_domain"];
}
if ($phpgw_info["server"]["global_denied_users"][$this->account_lid]) { return False; }
if ($phpgw_info["server"]["global_denied_users"][$this->account_lid]) {
return False;
}
if (! $phpgw->auth->authenticate($this->account_lid, $passwd)) {
return False;
@ -186,7 +188,7 @@
if (!$phpgw->accounts->exists($this->account_lid) && $phpgw_info["server"]["auto_create_acct"] == True) {
$this->account_id = $accts->auto_add($this->account_lid, $passwd);
}else{
} else {
$this->account_id = $phpgw->accounts->name2id($this->account_lid);
}
$phpgw->accounts->account_id = $this->account_id;
@ -233,7 +235,7 @@
. "$login','" . $this->getuser_ip() . "','" . time()
. "','') ",__LINE__,__FILE__);
//$phpgw->auth->update_lastlogin($login,$this->getuser_ip());
$phpgw->auth->update_lastlogin($login,$this->getuser_ip());
return $this->sessionid;
}

View File

@ -28,7 +28,8 @@
* Direct functions, which are not part of the API class *
* because they are require to be availble at the lowest level. *
\****************************************************************************/
function CreateObject($classname, $constructor_param = ""){
function CreateObject($classname, $constructor_param = "")
{
global $phpgw, $phpgw_info, $phpgw_domain;
$classpart = explode (".", $classname);
$appname = $classpart[0];
@ -37,10 +38,33 @@
$phpgw_info["flags"]["included_classes"][$classname] = True;
include(PHPGW_INCLUDE_ROOT."/".$appname."/inc/class.".$classname.".inc.php");
}
if ($constructor_param == ""){ $obj = new $classname; }else{$obj = new $classname($constructor_param); }
if ($constructor_param == ""){
$obj = new $classname;
} else {
$obj = new $classname($constructor_param);
}
return $obj;
}
function create_specialobject($classname, $ext, $constructor_param = "")
{
global $phpgw, $phpgw_info, $phpgw_domain;
$classpart = explode (".", $classname);
$appname = $classpart[0];
$classname = $classpart[1];
if (!$phpgw_info["flags"]["included_classes"][$classname]){
$phpgw_info["flags"]["included_classes"][$classname] = True;
include(PHPGW_INCLUDE_ROOT . "/" . $appname . "/inc/class." . $classname . "_" . $ext . ".inc.php");
}
if ($constructor_param == ""){
$obj = new $classname;
} else {
$obj = new $classname($constructor_param);
}
return $obj;
}
function lang($key, $m1="", $m2="", $m3="", $m4="", $m5="", $m6="", $m7="", $m8="", $m9="", $m10="" )
{
global $phpgw;
@ -51,7 +75,6 @@
return $value;
}
// Just a temp wrapper.
function check_code($code)
{
@ -68,7 +91,6 @@
}
}
/****************************************************************************\
* Optional classes, which can be disabled for performance increases *
* - they are loaded after pulling in the config from the DB *
@ -102,95 +124,6 @@
}
}
/****************************************************************************\
* Quick verification of updated header.inc.php *
\****************************************************************************/
error_reporting(7);
if ($phpgw_info["server"]["versions"]["header"] != $phpgw_info["server"]["versions"]["current_header"]){
echo "You need to port your settings to the new header.inc.php version.";
}
/****************************************************************************\
* Load up all the base values *
\****************************************************************************/
magic_quotes_runtime(false);
/* Make sure the developer is following the rules. */
if (!isset($phpgw_info["flags"]["currentapp"])) {
echo "!!! YOU DO NOT HAVE YOUR \$phpgw_info[\"flags\"][\"currentapp\"] SET !!!";
echo "!!! PLEASE CORRECT THIS SITUATION !!!";
}
if (!isset($phpgw_domain)) { // make them fix their header
echo "The administration is required to upgrade the header.inc.php file before you can continue.";
exit;
}
reset($phpgw_domain);
$default_domain = each($phpgw_domain);
$phpgw_info["server"]["default_domain"] = $default_domain[0];
unset ($default_domain); // we kill this for security reasons
// This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode.
if (isset($domain)){
$phpgw_info["user"]["domain"] = $domain;
}elseif (isset($login) && isset($logindomain)){
if (!ereg ("\@", $login)){
$login = $login."@".$logindomain;
}
$phpgw_info["user"]["domain"] = $logindomain;
unset ($logindomain);
}elseif (isset($login) && !isset($logindomain)){
if (ereg ("\@", $login)){
$login_array = explode("@", $login);
$phpgw_info["user"]["domain"] = $login_array[1];
}else{
$phpgw_info["user"]["domain"] = $phpgw_info["server"]["default_domain"];
$login = $login."@".$phpgw_info["user"]["domain"];
}
}
if (isset($phpgw_domain[$phpgw_info["user"]["domain"]])){
$phpgw_info["server"]["db_host"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_host"];
$phpgw_info["server"]["db_name"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_name"];
$phpgw_info["server"]["db_user"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_user"];
$phpgw_info["server"]["db_pass"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_pass"];
$phpgw_info["server"]["db_type"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_type"];
}else{
$phpgw_info["server"]["db_host"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_host"];
$phpgw_info["server"]["db_name"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_name"];
$phpgw_info["server"]["db_user"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_user"];
$phpgw_info["server"]["db_pass"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_pass"];
$phpgw_info["server"]["db_type"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_type"];
}
if ($phpgw_info["flags"]["currentapp"] != "login" && ! $phpgw_info["server"]["show_domain_selectbox"]) {
unset ($phpgw_domain); // we kill this for security reasons
}
unset ($domain); // we kill this to save memory
$phpgw_info["server"]["dir_separator"] = filesystem_separator();
$phpgw_info["server"]["sep"] = $phpgw_info["server"]["dir_separator"];
// some constants which can be used in setting user acl rights.
define("PHPGW_ACL_READ",1);
define("PHPGW_ACL_ADD",2);
define("PHPGW_ACL_EDIT",4);
define("PHPGW_ACL_DELETE",8);
//incase we are dealing with a fresh login
if (!isset($phpgw_info["user"]["preferences"]["common"]["template_set"])){
$phpgw_info["user"]["preferences"]["common"]["template_set"] = "default";
}
// Since LDAP will return system accounts, there are a few we don't want to login.
$phpgw_info["server"]["global_denied_users"] = array(
'root'=>True,'bin'=>True,'daemon'=>True,'adm'=>True,'lp'=>True,'sync'=>True,
'shutdown' => True,'halt'=>True,'mail'=>True,'news'=>True,'uucp'=>True,
'operator' => True,'games'=>True,'gopher'=>True,'nobody'=>True,'xfs'=>True,
'pgsql'=>True,'mysql'=>True,'postgres'=>True,'ftp'=>True,'gdm'=>True,'named'=>True
);
// This function needs to be optimized, its reading duplicate information.
function phpgw_fillarray()
{
@ -224,13 +157,117 @@
}
}
/****************************************************************************\
* Quick verification of updated header.inc.php *
\****************************************************************************/
error_reporting(7);
if ($phpgw_info["server"]["versions"]["header"] != $phpgw_info["server"]["versions"]["current_header"]){
echo "<center><b>You need to port your settings to the new header.inc.php version.</b></center>";
exit;
}
/****************************************************************************\
* Load up all the base values *
\****************************************************************************/
magic_quotes_runtime(false);
/* Make sure the developer is following the rules. */
if (!isset($phpgw_info["flags"]["currentapp"])) {
echo "<b>!!! YOU DO NOT HAVE YOUR \$phpgw_info[\"flags\"][\"currentapp\"] SET !!!";
echo "<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>";
}
if (!isset($phpgw_domain)) { // make them fix their header
echo "<center><b>The administration is required to upgrade the header.inc.php file before you can continue.</b></center>";
exit;
}
reset($phpgw_domain);
$default_domain = each($phpgw_domain);
$phpgw_info["server"]["default_domain"] = $default_domain[0];
unset ($default_domain); // we kill this for security reasons
// This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode.
if (isset($domain)){
$phpgw_info["user"]["domain"] = $domain;
} elseif (isset($login) && isset($logindomain)) {
if (!ereg ("\@", $login)){
$login = $login."@".$logindomain;
}
$phpgw_info["user"]["domain"] = $logindomain;
unset ($logindomain);
} elseif (isset($login) && !isset($logindomain)) {
if (ereg ("\@", $login)) {
$login_array = explode("@", $login);
$phpgw_info["user"]["domain"] = $login_array[1];
} else {
$phpgw_info["user"]["domain"] = $phpgw_info["server"]["default_domain"];
$login = $login."@".$phpgw_info["user"]["domain"];
}
}
if (isset($phpgw_domain[$phpgw_info["user"]["domain"]])){
$phpgw_info["server"]["db_host"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_host"];
$phpgw_info["server"]["db_name"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_name"];
$phpgw_info["server"]["db_user"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_user"];
$phpgw_info["server"]["db_pass"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_pass"];
$phpgw_info["server"]["db_type"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_type"];
} else {
$phpgw_info["server"]["db_host"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_host"];
$phpgw_info["server"]["db_name"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_name"];
$phpgw_info["server"]["db_user"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_user"];
$phpgw_info["server"]["db_pass"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_pass"];
$phpgw_info["server"]["db_type"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_type"];
}
if ($phpgw_info["flags"]["currentapp"] != "login" && ! $phpgw_info["server"]["show_domain_selectbox"]) {
unset ($phpgw_domain); // we kill this for security reasons
}
unset ($domain); // we kill this to save memory
// some constants which can be used in setting user acl rights.
define("PHPGW_ACL_READ",1);
define("PHPGW_ACL_ADD",2);
define("PHPGW_ACL_EDIT",4);
define("PHPGW_ACL_DELETE",8);
//incase we are dealing with a fresh login
if (! isset($phpgw_info["user"]["preferences"]["common"]["template_set"])) {
$phpgw_info["user"]["preferences"]["common"]["template_set"] = "default";
}
// Since LDAP will return system accounts, there are a few we don't want to login.
$phpgw_info["server"]["global_denied_users"] = array('root' => True,
'bin' => True,
'daemon' => True,
'adm' => True,
'lp' => True,
'sync' => True,
'shutdown' => True,
'halt' => True,
'mail' => True,
'news' => True,
'uucp' => True,
'operator' => True,
'games' => True,
'gopher' => True,
'nobody' => True,
'xfs' => True,
'pgsql' => True,
'mysql' => True,
'postgres' => True,
'ftp' => True,
'gdm' => True,
'named' => True
);
/****************************************************************************\
* These lines load up the API, fill up the $phpgw_info array, etc *
\****************************************************************************/
$phpgw = CreateObject("phpgwapi.phpgw");
$phpgw->phpgw_();
if ($phpgw_info["flags"]["currentapp"] != "login" &&
$phpgw_info["flags"]["currentapp"] != "logout") {
if ($phpgw_info["flags"]["currentapp"] != "login" && $phpgw_info["flags"]["currentapp"] != "logout") {
//if (! $phpgw->session->verify()) {
// Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/login.php", "cd=10"));
// exit;
@ -243,9 +280,8 @@
$phpgw->utilities->utilities_();
}
if (!isset($phpgw_info["flags"]["nocommon_preferences"]) ||
!$phpgw_info["flags"]["nocommon_preferences"]) {
if (!isset($phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) ||
if (! isset($phpgw_info["flags"]["nocommon_preferences"]) || ! $phpgw_info["flags"]["nocommon_preferences"]) {
if (! isset($phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) ||
!$phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) {
// $phpgw->preferences->change("common","maxmatchs",15);
$phpgw->preferences->add("common","maxmatchs",15);

View File

@ -12,14 +12,17 @@
/* $Id$ */
if ($phpgw_info["server"]["htmlcompliant"]) {
$bodyheader = "BGCOLOR=\"".$phpgw_info["theme"]["bg_color"]."\" ALINK=\"".$phpgw_info["theme"]["alink"]."\" LINK=\"".$phpgw_info["theme"]["link"]."\" VLINK=\"".$phpgw_info["theme"]["vlink"]."\"";
$bodyheader = 'BGCOLOR="' . $phpgw_info["theme"]["bg_color"] . '" ALINK="'
. $phpgw_info["theme"]["alink"] . '" LINK="' . $phpgw_info["theme"]["link"]
. '" VLINK="' . $phpgw_info["theme"]["vlink"] . '"';
} else {
$bodyheader = "BGCOLOR=\"".$phpgw_info["theme"]["bg_color"]."\"";
$bodyheader = 'BGCOLOR="' . $phpgw_info["theme"]["bg_color"] . '"';
}
$tpl = CreateObject('phpgwapi.Template',$phpgw_info["server"]["template_dir"]);
$tpl = $phpgw->template; //CreateObject('phpgwapi.Template',PHPGW_TEMPLATE_DIR);
$tpl->set_unknowns("remove");
$tpl->set_file(array("head" => "head.tpl"));
$tpl->set_var("website_title", $phpgw_info["server"]["site_title"]);
$tpl->set_var("body_tags",$bodyheader);
echo $tpl->finish($tpl->parse("out","head"));
?>

View File

@ -15,7 +15,7 @@
{
global $phpgw_info, $phpgw;
$tpl = new Template($phpgw_info["server"]["template_dir"]);
$tpl = createobject("phpgwapi.Template",PHPGW_TEMPLATE_DIR);
$tpl->set_unknowns("remove");
$tpl->set_file(array("navbar" => "navbar.tpl",