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,13 +24,20 @@
/* $Id$ */
class accounts_
class accounts
{
var $db;
var $account_id;
var $data;
var $memberships;
var $members;
function accounts()
{
global $phpgw;
$this->db = $phpgw->db;
}
function read_repository()
{

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,30 +379,38 @@
return $list;
}
function get_tpl_dir($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if ($appname == "home" || $appname == "logout" || $appname == "login"){$appname = "phpgwapi";}
function get_tpl_dir($appname = "")
{
global $phpgw_info;
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"; }
// 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" && 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"])){
$phpgw_info["server"]["template_set"] = "default";
}
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"])) {
$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)){
return $tpldir;
}elseif (is_dir ($tpldir_default)){
return $tpldir_default;
}else{
return False;
}
if (is_dir ($tpldir)) {
return $tpldir;
} elseif (is_dir ($tpldir_default)) {
return $tpldir_default;
} else {
return False;
}
}
function get_image_dir($appname = ""){
@ -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

@ -63,7 +63,7 @@
/************************************************************************\
* Required classes *
\************************************************************************/
$this->db = CreateObject("phpgwapi.db");
$this->db = CreateObject("phpgwapi.db");
$this->db->Host = $phpgw_info["server"]["db_host"];
$this->db->Type = $phpgw_info["server"]["db_type"];
$this->db->Database = $phpgw_info["server"]["db_name"];
@ -76,47 +76,61 @@
if ($phpgw_info["flags"]["currentapp"] == "login") {
$this->db->query("select * from config",__LINE__,__FILE__);
while($this->db->next_record()) {
$phpgw_info["server"][$this->db->f("config_name")] = stripslashes($this->db->f("config_value"));
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= "";
for ($i=0;$i<count($config_var);$i++) {
if($i) $c .= " OR ";
$c .= "config_name='".$config_var[$i]."'";
}
$config_var = array("encryptkey","auth_type","account_repository");
$c = "";
for ($i=0;$i<count($config_var);$i++) {
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()) {
$phpgw_info["server"][$this->db->f("config_name")] = stripslashes($this->db->f("config_value"));
while ($this->db->next_record()) {
$phpgw_info["server"][$this->db->f("config_name")] = stripslashes($this->db->f("config_value"));
}
}
/************************************************************************\
* Continue adding the classes *
\************************************************************************/
$this->common = CreateObject("phpgwapi.common");
$this->hooks = CreateObject("phpgwapi.hooks");
$this->common = CreateObject("phpgwapi.common");
$this->hooks = CreateObject("phpgwapi.hooks");
$this->auth = CreateObject("phpgwapi.auth");
$this->acl = CreateObject("phpgwapi.acl");
$this->accounts = CreateObject("phpgwapi.accounts");
$this->session = CreateObject("phpgwapi.sessions");
$this->preferences = CreateObject("phpgwapi.preferences");
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");
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");
if ($phpgw_info["flags"]["currentapp"] == "login") {
if ($login != ""){
$login_array = explode("@",$login);
$login_id = $this->accounts->name2id($login_array[0]);
$this->accounts->accounts($login_id);
$this->preferences->preferences($login_id);
}
}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")));
exit;
if ($login != ""){
$login_array = explode("@",$login);
$login_id = $this->accounts->name2id($login_array[0]);
$this->accounts->accounts($login_id);
$this->preferences->preferences($login_id);
}
} 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")));
exit;
}
$this->translation = CreateObject("phpgwapi.translation");
@ -124,7 +138,7 @@
$template_root = $this->common->get_tpl_dir();
if (is_dir($template_root)) {
$this->template = CreateObject("phpgwapi.Template", $template_root);
$this->template = CreateObject("phpgwapi.Template", $template_root);
}
}
@ -229,12 +243,5 @@
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,23 +171,25 @@
$login_array = explode("@", $login);
$this->account_lid = $login_array[0];
if ($login_array[1]!=""){
$this->account_domain = $login_array[1];
}else{
$this->account_domain = $phpgw_info["server"]["default_domain"];
if ($login_array[1]!="") {
$this->account_domain = $login_array[1];
} 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;
exit;
return False;
exit;
}
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{
$this->account_id = $phpgw->accounts->name2id($this->account_lid);
$this->account_id = $accts->auto_add($this->account_lid, $passwd);
} 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,35 +28,58 @@
* 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 = ""){
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.".inc.php");
}
if ($constructor_param == ""){ $obj = new $classname; }else{$obj = new $classname($constructor_param); }
return $obj;
function CreateObject($classname, $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.".inc.php");
}
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;
// # TODO: check if $m1 is of type array.
// If so, use it instead of $m2-$mN (Stephan)
$vars = array( $m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8, $m9, $m10 );
$value = $phpgw->translation->translate("$key", $vars );
return $value;
global $phpgw;
// # TODO: check if $m1 is of type array.
// If so, use it instead of $m2-$mN (Stephan)
$vars = array( $m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8, $m9, $m10 );
$value = $phpgw->translation->translate("$key", $vars );
return $value;
}
// Just a temp wrapper.
function check_code($code)
{
global $phpgw;
return $phpgw->common->check_code($code);
global $phpgw;
return $phpgw->common->check_code($code);
}
function filesystem_separator()
@ -68,129 +91,39 @@
}
}
/****************************************************************************\
* Optional classes, which can be disabled for performance increases *
* - they are loaded after pulling in the config from the DB *
\****************************************************************************/
function load_optional()
{
global $phpgw,$phpgw_info;
global $phpgw,$phpgw_info;
if ($phpgw_info["flags"]["enable_categories_class"]) {
$phpgw->categories = CreateObject("phpgwapi.categories");
}
if ($phpgw_info["flags"]["enable_network_class"]) {
$phpgw->network = CreateObject("phpgwapi.network");
}
if ($phpgw_info["flags"]["enable_send_class"]) {
$phpgw->send = CreateObject("phpgwapi.send");
}
if ($phpgw_info["flags"]["enable_categories_class"]) {
$phpgw->categories = CreateObject("phpgwapi.categories");
}
if ($phpgw_info["flags"]["enable_nextmatchs_class"]) {
$phpgw->nextmatchs = CreateObject("phpgwapi.nextmatchs");
}
if ($phpgw_info["flags"]["enable_utilities_class"]) {
$phpgw->utilities = CreateObject("phpgwapi.utilities");
}
if ($phpgw_info["flags"]["enable_network_class"]) {
$phpgw->network = CreateObject("phpgwapi.network");
}
if ($phpgw_info["flags"]["enable_send_class"]) {
$phpgw->send = CreateObject("phpgwapi.send");
}
if ($phpgw_info["flags"]["enable_nextmatchs_class"]) {
$phpgw->nextmatchs = CreateObject("phpgwapi.nextmatchs");
}
if ($phpgw_info["flags"]["enable_utilities_class"]) {
$phpgw->utilities = CreateObject("phpgwapi.utilities");
}
if ($phpgw_info["flags"]["enable_vfs_class"]) {
$phpgw->vfs = CreateObject("phpgwapi.vfs");
}
if ($phpgw_info["flags"]["enable_vfs_class"]) {
$phpgw->vfs = CreateObject("phpgwapi.vfs");
}
}
/****************************************************************************\
* 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()
{
@ -205,36 +138,140 @@
define("PHPGW_IMAGES_DIR", $phpgw->common->get_image_dir());
/* LEGACY SUPPORT!!! WILL BE DELETED AFTER 0.9.11 IS RELEASED !!! */
$phpgw_info["server"]["template_dir"] = PHPGW_TEMPLATE_DIR;
$phpgw_info["server"]["images_dir"] = PHPGW_IMAGES_DIR;
$phpgw_info["server"]["template_dir"] = PHPGW_TEMPLATE_DIR;
$phpgw_info["server"]["images_dir"] = PHPGW_IMAGES_DIR;
$phpgw_info["server"]["images_filedir"] = PHPGW_IMAGES_FILEDIR;
$phpgw_info["server"]["app_root"] = PHPGW_APP_ROOT;
$phpgw_info["server"]["app_inc"] = PHPGW_APP_INC;
$phpgw_info["server"]["app_tpl"] = PHPGW_APP_TPL;
$phpgw_info["server"]["app_images"] = PHPGW_IMAGES;
$phpgw_info["server"]["app_images_dir"] = PHPGW_IMAGES_DIR;
$phpgw_info["server"]["app_root"] = PHPGW_APP_ROOT;
$phpgw_info["server"]["app_inc"] = PHPGW_APP_INC;
$phpgw_info["server"]["app_tpl"] = PHPGW_APP_TPL;
$phpgw_info["server"]["app_images"] = PHPGW_IMAGES;
$phpgw_info["server"]["app_images_dir"] = PHPGW_IMAGES_DIR;
/* ********This sets the user variables******** */
$phpgw_info["user"]["private_dir"] = $phpgw_info["server"]["files_dir"] . "/users/"
. $phpgw_info["user"]["userid"];
. $phpgw_info["user"]["userid"];
// This shouldn't happen, but if it does get ride of the warnings it will spit out
if (gettype($phpgw_info["user"]["preferences"]) != "array") {
$phpgw_info["user"]["preferences"] = array();
}
}
/****************************************************************************\
* 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->session->verify()) {
// Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/login.php", "cd=10"));
// exit;
//}
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;
//}
load_optional();
phpgw_fillarray();
@ -243,36 +280,35 @@
$phpgw->utilities->utilities_();
}
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"]) {
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);
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["theme"]) ||
!$phpgw_info["user"]["preferences"]["common"]["theme"]) {
$phpgw->preferences->add("common","theme","default");
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["dateformat"]) ||
!$phpgw_info["user"]["preferences"]["common"]["dateformat"]) {
$phpgw->preferences->add("common","dateformat","m/d/Y");
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["timeformat"]) ||
!$phpgw_info["user"]["preferences"]["common"]["timeformat"]) {
$phpgw->preferences->add("common","timeformat",12);
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["lang"]) ||
!$phpgw_info["user"]["preferences"]["common"]["lang"]) {
$phpgw->preferences->add("common","lang",$phpgw->common->getPreferredLanguage());
$preferences_update = True;
$phpgw->preferences->add("common","maxmatchs",15);
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["theme"]) ||
!$phpgw_info["user"]["preferences"]["common"]["theme"]) {
$phpgw->preferences->add("common","theme","default");
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["dateformat"]) ||
!$phpgw_info["user"]["preferences"]["common"]["dateformat"]) {
$phpgw->preferences->add("common","dateformat","m/d/Y");
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["timeformat"]) ||
!$phpgw_info["user"]["preferences"]["common"]["timeformat"]) {
$phpgw->preferences->add("common","timeformat",12);
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["lang"]) ||
!$phpgw_info["user"]["preferences"]["common"]["lang"]) {
$phpgw->preferences->add("common","lang",$phpgw->common->getPreferredLanguage());
$preferences_update = True;
}
if ($preferences_update) {
$phpgw->preferences->save_repository();
$phpgw->preferences->save_repository();
}
unset($preferences_update);
}
@ -309,11 +345,11 @@
$phpgw_info["flags"]["currentapp"] != "preferences" &&
$phpgw_info["flags"]["currentapp"] != "about") {
if (! $phpgw_info["user"]["apps"][$phpgw_info["flags"]["currentapp"]]) {
$phpgw->common->phpgw_header();
echo "<p><center><b>".lang("Access not permitted")."</b></center>";
exit;
}
if (! $phpgw_info["user"]["apps"][$phpgw_info["flags"]["currentapp"]]) {
$phpgw->common->phpgw_header();
echo "<p><center><b>".lang("Access not permitted")."</b></center>";
exit;
}
}
/*************************************************************************\

View File

@ -11,15 +11,18 @@
/* $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"]."\"";
} else {
$bodyheader = "BGCOLOR=\"".$phpgw_info["theme"]["bg_color"]."\"";
}
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"] . '"';
} else {
$bodyheader = 'BGCOLOR="' . $phpgw_info["theme"]["bg_color"] . '"';
}
$tpl = CreateObject('phpgwapi.Template',$phpgw_info["server"]["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"));
$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",