cleaned up functions.inc.php

There are still problems to resolve, but might need help resolving them. I can basicly login now
This commit is contained in:
seek3r 2001-02-08 00:49:34 +00:00
parent 948e27a129
commit ff2eb0bb36
2 changed files with 275 additions and 269 deletions

View File

@ -126,7 +126,7 @@
return $this->data; return $this->data;
} }
// legacy support /* legacy support */
function change($app_name,$var,$value = "") function change($app_name,$var,$value = "")
{ {
return $this->add($app_name,$var,$value); return $this->add($app_name,$var,$value);
@ -136,5 +136,46 @@
return $this->save_repository($update_session_info); return $this->save_repository($update_session_info);
} }
/**************************************************************************\
* These are the non-standard $this->account_id specific functions *
\**************************************************************************/
function verify_basic_settings()
{
global $phpgw, $phpgw_info;
if (gettype($phpgw_info["user"]["preferences"]) != "array") {
$phpgw_info["user"]["preferences"] = array();
}
/* This takes care of new users who dont have proper default prefs setup */
if (! $phpgw_info["flags"]["nocommon_preferences"]) {
if (! $phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) {
$this->add("common","maxmatchs",15);
$preferences_update = True;
}
if (! $phpgw_info["user"]["preferences"]["common"]["theme"]) {
$this->add("common","theme","default");
$preferences_update = True;
}
if (! $phpgw_info["user"]["preferences"]["common"]["template_set"]) {
$this->add("common","template_set","default");
$preferences_update = True;
}
if (! $phpgw_info["user"]["preferences"]["common"]["dateformat"]) {
$this->add("common","dateformat","m/d/Y");
$preferences_update = True;
}
if (! $phpgw_info["user"]["preferences"]["common"]["timeformat"]) {
$this->add("common","timeformat",12);
$preferences_update = True;
}
if (! $phpgw_info["user"]["preferences"]["common"]["lang"]) {
$this->add("common","lang",$phpgw->common->getPreferredLanguage());
$preferences_update = True;
}
if ($preferences_update) {
$this->save_repository();
}
unset($preferences_update);
}
}
} //end of preferences class } //end of preferences class
?> ?>

View File

@ -1,4 +1,5 @@
<?php <?php
$debugme = "on";
/**************************************************************************\ /**************************************************************************\
* phpGroupWare API - phpgwapi loader * * phpGroupWare API - phpgwapi loader *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> * * This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
@ -65,112 +66,53 @@
function filesystem_separator() function filesystem_separator()
{ {
if (PHP_OS == "Windows" || PHP_OS == "OS/2") { if (PHP_OS == 'Windows' || PHP_OS == 'OS/2') {
return "\\"; return '\\';
} else { } else {
return "/"; return '/';
} }
} }
/****************************************************************************\ function print_debug($text)
* 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 $debugme;
if ($debugme == "on") { echo 'debug: '.$text.'<br>'; }
if ($phpgw_info["flags"]["enable_categories_class"]) {
$phpgw->categories = CreateObject("phpgwapi.categories");
} }
print_debug('core functions are done');
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");
}
}
// This function needs to be optimized, its reading duplicate information.
function phpgw_fillarray()
{
global $phpgw, $phpgw_info, $cd, $colspan;
define("PHPGW_TEMPLATE_DIR",$phpgw->common->get_tpl_dir("phpgwapi"));
define("PHPGW_IMAGES_DIR", $phpgw->common->get_image_path("phpgwapi"));
define("PHPGW_IMAGES_FILEDIR", $phpgw->common->get_image_dir("phpgwapi"));
define("PHPGW_APP_ROOT", $phpgw->common->get_app_dir());
define("PHPGW_APP_INC", $phpgw->common->get_inc_dir());
define("PHPGW_APP_TPL", $phpgw->common->get_tpl_dir());
define("PHPGW_IMAGES", $phpgw->common->get_image_path());
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"]["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;
/* ********This sets the user variables******** */
$phpgw_info["user"]["private_dir"] = $phpgw_info["server"]["files_dir"] . "/users/"
. $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 * * Quick verification of sane environment *
\****************************************************************************/ \****************************************************************************/
error_reporting(7); error_reporting(7);
/* Make sure the header.inc.php is current. */
if ($phpgw_info["server"]["versions"]["header"] != $phpgw_info["server"]["versions"]["current_header"]){ 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>"; echo "<center><b>You need to port your settings to the new header.inc.php version.</b></center>";
exit; exit;
} }
/****************************************************************************\
* Load up all the base values *
\****************************************************************************/
magic_quotes_runtime(false);
/* Make sure the developer is following the rules. */ /* Make sure the developer is following the rules. */
if (!isset($phpgw_info["flags"]["currentapp"])) { if (!isset($phpgw_info["flags"]["currentapp"])) {
echo "<b>!!! YOU DO NOT HAVE YOUR \$phpgw_info[\"flags\"][\"currentapp\"] SET !!!"; echo "<b>!!! YOU DO NOT HAVE YOUR \$phpgw_info[\"flags\"][\"currentapp\"] SET !!!";
echo "<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>"; echo "<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>";
} }
if (!isset($phpgw_domain)) { // make them fix their header magic_quotes_runtime(false);
print_debug('sane environment');
/****************************************************************************\
* Multi-Domain support *
\****************************************************************************/
/* make them fix their header */
if (!isset($phpgw_domain)) {
echo "<center><b>The administration is required to upgrade the header.inc.php file before you can continue.</b></center>"; echo "<center><b>The administration is required to upgrade the header.inc.php file before you can continue.</b></center>";
exit; exit;
} }
reset($phpgw_domain); reset($phpgw_domain);
$default_domain = each($phpgw_domain); $default_domain = each($phpgw_domain);
$phpgw_info["server"]["default_domain"] = $default_domain[0]; $phpgw_info["server"]["default_domain"] = $default_domain[0];
unset ($default_domain); // we kill this for security reasons 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. /* This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode. */
if (isset($domain)){ if (isset($domain)){
$phpgw_info["user"]["domain"] = $domain; $phpgw_info["user"]["domain"] = $domain;
} elseif (isset($login) && isset($logindomain)) { } elseif (isset($login) && isset($logindomain)) {
@ -208,13 +150,10 @@
} }
unset ($domain); // we kill this to save memory unset ($domain); // we kill this to save memory
// some constants which can be used in setting user acl rights. print_debug('sane environment');
define("PHPGW_ACL_READ",1);
define("PHPGW_ACL_ADD",2);
define("PHPGW_ACL_EDIT",4);
define("PHPGW_ACL_DELETE",8);
// Since LDAP will return system accounts, there are a few we don't want to login. //dont know where to put this (seek3r)
/* 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, $phpgw_info["server"]["global_denied_users"] = array('root' => True,
'bin' => True, 'bin' => True,
'daemon' => True, 'daemon' => True,
@ -239,14 +178,14 @@
'named' => True 'named' => True
); );
/****************************************************************************\ /****************************************************************************\
* These lines load up the API, fill up the $phpgw_info array, etc * * These lines load up the API, fill up the $phpgw_info array, etc *
\****************************************************************************/ \****************************************************************************/
/* Load main class */ /* Load main class */
$phpgw = CreateObject("phpgwapi.phpgw"); $phpgw = CreateObject("phpgwapi.phpgw");
print_debug('main class loaded');
/* Fill phpgw_info["server"] array */ /* Fill phpgw_info["server"] array */
$phpgw->db->query("select * from config",__LINE__,__FILE__); $phpgw->db->query("select * from config",__LINE__,__FILE__);
while ($phpgw->db->next_record()) { while ($phpgw->db->next_record()) {
@ -255,76 +194,101 @@
// Handy little shortcut // Handy little shortcut
$sep = $phpgw_info["server"]["dir_separator"]; $sep = $phpgw_info["server"]["dir_separator"];
if ($phpgw_info["flags"]["currentapp"] == "login" || $phpgw_info["flags"]["currentapp"] == "logout") {
/****************************************************************************\
* Stuff to use if logging in or logging out *
\****************************************************************************/
/* incase we are dealing with a fresh login */
// not sure these lines are needed anymore (seek3r)
// if (! isset($phpgw_info["user"]["preferences"]["common"]["template_set"])) {
// $phpgw_info["user"]["preferences"]["common"]["template_set"] = "default";
// }
if ($phpgw_info["flags"]["currentapp"] == "login") { if ($phpgw_info["flags"]["currentapp"] == "login") {
if ($login != ""){ if ($login != ""){
$login_array = explode("@",$login); $login_array = explode("@",$login);
$login_id = $this->accounts->name2id($login_array[0]); $login_id = $phpgw->accounts->name2id($login_array[0]);
$this->accounts->accounts($login_id); $phpgw->accounts->accounts($login_id);
$this->preferences->preferences($login_id); $phpgw->preferences->preferences($login_id);
} }
} elseif (! $this->session->verify()) {
Header("Location: " . $phpgw->redirect($phpgw->session->link($phpgw_info["server"]["webserver_url"]."/login.php","cd=10")));
exit;
}
$template_root = $this->common->get_tpl_dir();
if (is_dir($template_root)) {
$this->template = CreateObject("phpgwapi.Template", $template_root);
}
//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";
} }
/****************************************************************************\ /****************************************************************************\
* Everything from this point on will ONLY happen if * * Everything from this point on will ONLY happen if *
* the currentapp is not login or logout * * the currentapp is not login or logout *
\****************************************************************************/ \****************************************************************************/
if ($phpgw_info["flags"]["currentapp"] != "login" && $phpgw_info["flags"]["currentapp"] != "logout") { } else {
if (! $phpgw->session->verify()) { if (! $phpgw->session->verify()) {
Header("Location: " . $phpgw->redirect($phpgw->session->link($phpgw_info["server"]["webserver_url"]."/login.php","cd=10"))); Header("Location: " . $phpgw->redirect($phpgw->session->link($phpgw_info["server"]["webserver_url"]."/login.php","cd=10")));
exit; exit;
} }
load_optional();
phpgw_fillarray(); /* A few hacker proof constants that will be used throught the program */
if ($phpgw_info["flags"]["enable_utilities_class"]){ define("PHPGW_TEMPLATE_DIR",$phpgw->common->get_tpl_dir("phpgwapi"));
define("PHPGW_IMAGES_DIR", $phpgw->common->get_image_path("phpgwapi"));
define("PHPGW_IMAGES_FILEDIR", $phpgw->common->get_image_dir("phpgwapi"));
define("PHPGW_APP_ROOT", $phpgw->common->get_app_dir());
define("PHPGW_APP_INC", $phpgw->common->get_inc_dir());
define("PHPGW_APP_TPL", $phpgw->common->get_tpl_dir());
define("PHPGW_IMAGES", $phpgw->common->get_image_path());
define("PHPGW_IMAGES_DIR", $phpgw->common->get_image_dir());
define("PHPGW_ACL_READ",1);
define("PHPGW_ACL_ADD",2);
define("PHPGW_ACL_EDIT",4);
define("PHPGW_ACL_DELETE",8);
/********* Load up additional phpgw_info["server"] values *********/
/* 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"]["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;
/* END LEGACY SUPPORT!!!*/
/********* This sets the user variables *********/
$phpgw_info["user"]["private_dir"] = $phpgw_info["server"]["files_dir"]
. "/users/".$phpgw_info["user"]["userid"];
/* This will make sure that a user has the basic default prefs. If not it will add them */
$phpgw->preferences->verify_basic_settings();
/********* Optional classes, which can be disabled for performance increases *********/
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_nextmatchs_class"]) {
$phpgw->nextmatchs = CreateObject("phpgwapi.nextmatchs");
}
if ($phpgw_info["flags"]["enable_utilities_class"]) {
$phpgw->utilities = CreateObject("phpgwapi.utilities");
$phpgw->utilities->utilities_(); $phpgw->utilities->utilities_();
} }
if (! isset($phpgw_info["flags"]["nocommon_preferences"]) || ! $phpgw_info["flags"]["nocommon_preferences"]) { if ($phpgw_info["flags"]["enable_vfs_class"]) {
if (! isset($phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) || $phpgw->vfs = CreateObject("phpgwapi.vfs");
!$phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) {
$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();
}
unset($preferences_update);
} }
/*************************************************************************\
* These lines load up the templates class *
\*************************************************************************/
$phpgw->template = CreateObject("phpgwapi.Template", PHPGW_TEMPLATE_DIR);
/*************************************************************************\ /*************************************************************************\
* These lines load up the themes * * These lines load up the themes *
\*************************************************************************/ \*************************************************************************/
@ -336,12 +300,13 @@
echo "Warning: error locating selected theme"; echo "Warning: error locating selected theme";
include (PHPGW_SERVER_ROOT . "/phpgwapi/themes/default.theme"); include (PHPGW_SERVER_ROOT . "/phpgwapi/themes/default.theme");
if ($phpgw_info["theme"]["bg_color"] == "") { if ($phpgw_info["theme"]["bg_color"] == "") {
// Hope we don't get to this point. Better then the user seeing a /* Hope we don't get to this point. Better then the user seeing a */
// complety back screen and not know whats going on /* complety back screen and not know whats going on */
echo "<body bgcolor=FFFFFF>Fatal error: no themes found"; echo "<body bgcolor=FFFFFF>Fatal error: no themes found";
exit; exit;
} }
} }
/*************************************************************************\ /*************************************************************************\
* If they are using frames, we need to set some variables * * If they are using frames, we need to set some variables *
\*************************************************************************/ \*************************************************************************/