Moving large chunks of code around so that the functions.inc.php file is the main file to getting data loaded into the phpgw_info array. Basicly functions is the file to follow to see whats being loaded and where. We will need to add a bunch of debugging flags throught this file so that debugging can be turned on and the path can easily be followed.

This commit is contained in:
seek3r 2001-02-07 20:22:17 +00:00
parent 1054c949b4
commit 1ba6eb78d2
4 changed files with 704 additions and 612 deletions

View File

@ -684,40 +684,11 @@
return $count;
}
/* Wrapper to the session->appsession() */
function appsession($data = "##NOTHING##") {
global $phpgw_info, $phpgw;
if ($data == "##NOTHING##") { /* This allows the user to put "" as the value. */
$phpgw->db->query("select content from phpgw_app_sessions where sessionid = '"
.$phpgw_info["user"]["sessionid"]."' and loginid = '"
.$phpgw_info["user"]["userid"]."' and app = '"
.$phpgw_info["flags"]["currentapp"] . "'",__LINE__,__FILE__);
if($phpgw->db->num_rows()) {
$phpgw->db->next_record();
$data = $phpgw->db->f("content");
$data = $this->decrypt($data);
return $data;
}
} else {
$data = $this->encrypt($data);
$phpgw->db->query("select * from phpgw_app_sessions where sessionid = '"
. $phpgw_info["user"]["sessionid"] . "' and app = '"
. $phpgw_info["flags"]["currentapp"] . "'",__LINE__,__FILE__);
if ($phpgw->db->num_rows()==0) {
$phpgw->db->query("INSERT INTO phpgw_app_sessions (sessionid,loginid,app,content)"
." VALUES ('".$phpgw_info["user"]["sessionid"]."','"
.$phpgw_info["user"]["userid"]
."','".$phpgw_info["flags"]["currentapp"]."','".$data."');",__LINE__,__FILE__);
} else {
$phpgw->db->query("update phpgw_app_sessions set content = '$data' where sessionid = '"
.$phpgw_info["user"]["sessionid"]."' and loginid = '"
.$phpgw_info["user"]["userid"]."'",__LINE__,__FILE__);
}
$data = $this->decrypt($data);
return $data;
}
}
global $phpgw_info, $phpgw;
return $phpgw->session->appsession($data);
}
function show_date($t = "", $format = "")
{

View File

@ -1,235 +1,130 @@
<?php
/**************************************************************************\
* phpGroupWare API - Core class and functions for phpGroupWare *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* and Joseph Engo <jengo@phpgroupware.org> *
* This is the central class for the phpGroupWare API *
* Copyright (C) 2000, 2001 Dan Kuykendall *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/**************************************************************************\
* phpGroupWare API - Core class and functions for phpGroupWare *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* and Joseph Engo <jengo@phpgroupware.org> *
* This is the central class for the phpGroupWare API *
* Copyright (C) 2000, 2001 Dan Kuykendall *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
/****************************************************************************\
* Our API class starts here *
\****************************************************************************/
class phpgw
{
var $accounts;
var $applications;
var $acl;
var $auth;
var $db;
var $debug = 0; // This will turn on debugging information.
var $crypto;
var $categories;
var $common;
var $hooks;
var $network;
var $nextmatchs;
var $preferences;
var $session;
var $send;
var $template;
var $translation;
var $utilities;
var $vfs;
var $calendar;
var $msg;
var $addressbook;
var $todo;
/* $Id$ */
/****************************************************************************\
* Our API class starts here *
\****************************************************************************/
class phpgw
{
var $accounts;
var $applications;
var $acl;
var $auth;
var $db;
var $debug = 0; // This will turn on debugging information.
var $crypto;
var $categories;
var $common;
var $hooks;
var $network;
var $nextmatchs;
var $preferences;
var $session;
var $send;
var $template;
var $translation;
var $utilities;
var $vfs;
var $calendar;
var $msg;
var $addressbook;
var $todo;
// This is here so you can decied what the best way to handle bad sessions
// You could redirect them to login.php with code 2 or use the default
// I recommend using the default until all of the bugs are worked out.
// This is here so you can decied what the best way to handle bad sessions
// You could redirect them to login.php with code 2 or use the default
// I recommend using the default until all of the bugs are worked out.
function phpgw_()
{
global $phpgw_info, $sessionid, $login;
/************************************************************************\
* Required classes *
\************************************************************************/
$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"];
$this->db->User = $phpgw_info["server"]["db_user"];
$this->db->Password = $phpgw_info["server"]["db_pass"];
function phpgw()
{
global $phpgw_info, $sessionid, $login;
/************************************************************************\
* Required classes *
\************************************************************************/
$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"];
$this->db->User = $phpgw_info["server"]["db_user"];
$this->db->Password = $phpgw_info["server"]["db_pass"];
if ($this->debug) {
$this->db->Debug = 1;
}
if ($this->debug) {
$this->db->Debug = 1;
}
$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");
$this->applications = CreateObject("phpgwapi.applications");
$this->translation = CreateObject("phpgwapi.translation");
}
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"));
}
} 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]."'";
}
$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"));
}
}
/**************************************************************************\
* Core functions *
\**************************************************************************/
/************************************************************************\
* Continue adding the classes *
\************************************************************************/
$this->common = CreateObject("phpgwapi.common");
$this->hooks = CreateObject("phpgwapi.hooks");
/* Wrapper to the session->link() */
function link($url = "", $extravars = "")
{
global $phpgw, $phpgw_info, $usercookie, $kp3, $PHP_SELF;
return $this->session->link($url, $extravars);
}
$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");
$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;
}
$this->translation = CreateObject("phpgwapi.translation");
function redirect($url = "")
{
// This function handles redirects under iis and apache
// it assumes that $phpgw->link() has already been called
$sep = $phpgw_info["server"]["dir_separator"];
$template_root = $this->common->get_tpl_dir();
global $HTTP_ENV_VARS;
if (is_dir($template_root)) {
$this->template = CreateObject("phpgwapi.Template", $template_root);
}
}
$iis = strpos($HTTP_ENV_VARS["SERVER_SOFTWARE"], "IIS", 0);
if ( !$url ) {
$url = $PHP_SELF;
}
if ( $iis ) {
echo "\n<HTML>\n<HEAD>\n<TITLE>Redirecting to $url</TITLE>";
echo "\n<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL=$url\">";
echo "\n</HEAD><BODY>";
echo "<H3>Please continue to <a href=\"$url\">this page</a></H3>";
echo "\n</BODY></HTML>";
exit;
} else {
Header("Location: $url");
print("\n\n");
exit;
}
}
/**************************************************************************\
* Core functions *
\**************************************************************************/
/* A function to handle session support via url session id, or cookies */
function link($url = "", $extravars = "")
{
global $phpgw, $phpgw_info, $usercookie, $kp3, $PHP_SELF;
if ($url == $PHP_SELF){ $url = ""; } //fix problems when PHP_SELF if used as the param
if (! $kp3) { $kp3 = $phpgw_info["user"]["kp3"]; }
// Explicit hack to work around problems with php running as CGI on windows
// please let us know if this doesn't work for you!
if (! $url && (PHP_OS == "Windows" || PHP_OS == "OS/2" || PHP_OS == "WIN32" || PHP_OS == "WIN16")) {
$exe = strpos($PHP_SELF,"php.exe");
if ($exe != false) {
$exe += 7; // strlen("php.exe")
$url_root = split ("/", $phpgw_info["server"]["webserver_url"]);
$url = (strlen($url_root[0])? $url_root[0].'//':'') . $url_root[2];
$url .= substr($PHP_SELF,$exe,strlen($PHP_SELF)-$exe);
}
}
if (! $url) {
$url_root = split ("/", $phpgw_info["server"]["webserver_url"]);
/* Some hosting providers have their paths screwy.
If the value from $PHP_SELF is not what you expect, you can use this to patch it
It will need to be adjusted to your specific problem tho.
*/
//$patched_php_self = str_replace("/php4/php/phpgroupware", "/phpgroupware", $PHP_SELF);
$patched_php_self = $PHP_SELF;
$url = (strlen($url_root[0])? $url_root[0].'//':'') . $url_root[2] . $patched_php_self;
}
if (isset($phpgw_info["server"]["usecookies"]) &&
$phpgw_info["server"]["usecookies"]) {
if ($extravars) { $url .= "?$extravars"; }
} else {
$url .= "?sessionid=" . $phpgw_info["user"]["sessionid"];
$url .= "&kp3=" . $kp3;
$url .= "&domain=" . $phpgw_info["user"]["domain"];
// This doesn't belong in the API.
// Its up to the app to pass this value. (jengo)
// Putting it into the app requires a massive number of updates in email app.
// Until that happens this needs to stay here (seek3r)
if ($phpgw_info["flags"]["newsmode"]) { $url .= "&newsmode=on"; }
if ($extravars) { $url .= "&$extravars"; }
}
$url = str_replace("/?", "/index.php?", $url);
$webserver_url_count = strlen($phpgw_info["server"]["webserver_url"]);
$slash_check = strtolower(substr($url ,0,1));
if(substr($url ,0,$webserver_url_count) != $phpgw_info["server"]["webserver_url"]) {
$app = $phpgw_info["flags"]["currentapp"];
if($slash_check == "/") {
$url = $phpgw_info["server"]["webserver_url"].$url;
} elseif ($app == "home" || $app == "logout" || $app == "login"){
$url = $phpgw_info["server"]["webserver_url"]."/".$url;
}else{
$url = $phpgw_info["server"]["webserver_url"]."/".$app."/".$url;
}
}
return $url;
}
function strip_html($s)
{
return htmlspecialchars(stripslashes($s));
}
function redirect($url = "")
{
// This function handles redirects under iis and apache
// it assumes that $phpgw->link() has already been called
global $HTTP_ENV_VARS;
$iis = strpos($HTTP_ENV_VARS["SERVER_SOFTWARE"], "IIS", 0);
if ( !$url ) {
$url = $PHP_SELF;
}
if ( $iis ) {
echo "\n<HTML>\n<HEAD>\n<TITLE>Redirecting to $url</TITLE>";
echo "\n<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL=$url\">";
echo "\n</HEAD><BODY>";
echo "<H3>Please continue to <a href=\"$url\">this page</a></H3>";
echo "\n</BODY></HTML>";
exit;
} else {
Header("Location: $url");
print("\n\n");
exit;
}
}
function lang($key, $m1 = "", $m2 = "", $m3 = "", $m4 = "")
{
global $phpgw;
return $phpgw->translation->translate($key);
}
} //end phpgw class
function lang($key, $m1 = "", $m2 = "", $m3 = "", $m4 = "")
{
global $phpgw;
return $this->translation->translate($key);
}
} //end phpgw class
?>

View File

@ -36,6 +36,9 @@
var $db;
var $db2;
/*************************************************************************\
* Constructor just loads up some defaults from cookies *
\*************************************************************************/
function sessions()
{
global $phpgw, $phpgw_info, $sessionid, $kp3;
@ -46,6 +49,9 @@
$this->kp3 = $kp3;
}
/*************************************************************************\
* Functions for creating and verifying the session *
\*************************************************************************/
function getuser_ip()
{
global $REMOTE_ADDR, $HTTP_X_FORWARDED_FOR;
@ -150,37 +156,6 @@
. $this->sessionid . "'",__LINE__,__FILE__);
}
function read_repositories()
{
global $phpgw_info, $phpgw;
$phpgw->acl->acl($this->account_id);
$phpgw->accounts->accounts($this->account_id);
$phpgw->preferences->preferences($this->account_id);
$phpgw->applications->applications($this->account_id);
$phpgw_info["user"] = $phpgw->accounts->read_repository();
$phpgw_info["user"]["acl"] = $phpgw->acl->read_repository();
$phpgw_info["user"]["preferences"] = $phpgw->preferences->read_repository();
$phpgw_info["user"]["apps"] = $phpgw->applications->read_repository();
@reset($phpgw_info["user"]["apps"]);
$phpgw_info["user"]["domain"] = $this->account_domain;
$phpgw_info["user"]["sessionid"] = $this->sessionid;
$phpgw_info["user"]["kp3"] = $this->kp3;
$phpgw_info["user"]["session_ip"] = $this->getuser_ip();
$phpgw_info["user"]["session_lid"] = $this->account_lid."@".$this->account_domain;
$phpgw_info["user"]["account_id"] = $this->account_id;
$phpgw_info["user"]["account_lid"] = $this->account_lid;
$phpgw_info["user"]["userid"] = $this->account_lid;
$phpgw_info["user"]["passwd"] = $this->passwd;
$this->data["user"] = $phpgw_info["user"];
$this->data["apps"] = $phpgw_info["apps"];
$this->data["server"] = $phpgw_info["server"];
$this->data["hooks"] = $phpgw->hooks->read();
$this->data["user"]["preferences"] = $phpgw_info["user"]["preferences"];
$this->data["user"]["kp3"] = "";
}
function create($login,$passwd)
{
global $phpgw_info, $phpgw;
@ -292,5 +267,227 @@
return True;
}
/*************************************************************************\
* Functions for appsession data and session cache *
\*************************************************************************/
function read_repositories()
{
global $phpgw_info, $phpgw;
$phpgw->acl->acl($this->account_id);
$phpgw->accounts->accounts($this->account_id);
$phpgw->preferences->preferences($this->account_id);
$phpgw->applications->applications($this->account_id);
$phpgw_info["user"] = $phpgw->accounts->read_repository();
$phpgw_info["user"]["acl"] = $phpgw->acl->read_repository();
$phpgw_info["user"]["preferences"] = $phpgw->preferences->read_repository();
$phpgw_info["user"]["apps"] = $phpgw->applications->read_repository();
@reset($phpgw_info["user"]["apps"]);
$phpgw_info["user"]["domain"] = $this->account_domain;
$phpgw_info["user"]["sessionid"] = $this->sessionid;
$phpgw_info["user"]["kp3"] = $this->kp3;
$phpgw_info["user"]["session_ip"] = $this->getuser_ip();
$phpgw_info["user"]["session_lid"] = $this->account_lid."@".$this->account_domain;
$phpgw_info["user"]["account_id"] = $this->account_id;
$phpgw_info["user"]["account_lid"] = $this->account_lid;
$phpgw_info["user"]["userid"] = $this->account_lid;
$phpgw_info["user"]["passwd"] = $this->passwd;
$this->data["user"] = $phpgw_info["user"];
$this->data["apps"] = $phpgw_info["apps"];
$this->data["server"] = $phpgw_info["server"];
$this->data["hooks"] = $phpgw->hooks->read();
$this->data["user"]["preferences"] = $phpgw_info["user"]["preferences"];
$this->data["user"]["kp3"] = "";
}
function appsession($data = "##NOTHING##", $location = "default") {
global $phpgw_info, $phpgw;
if ($data == "##NOTHING##") { /* This allows the user to put "" as the value. */
$sql = 'select content from phpgw_app_sessions where'
.' sessionid = "'.$this->sessionid.'"'
.' and loginid = "'.$this->account_id.'"'
.' and app = "'.$phpgw_info["user"]["currentapp"].'"'
.' and location = "'.$location.'"',__LINE__,__FILE__
);
$phpgw->db->query($sql,__LINE__,__FILE__);
if($phpgw->db->num_rows()) {
$phpgw->db->next_record();
$data = $phpgw->db->f("content");
// $data = $phpgw->common->decrypt($data);
return $data;
}
} else {
// $data = $phpgw->common->encrypt($data);
$sql = 'select content from phpgw_app_sessions where'
.' sessionid = "'.$this->sessionid.'"'
.' and loginid = "'.$this->account_id.'"'
.' and app = "'.$phpgw_info["user"]["currentapp"].'"'
.' and location = "'.$location.'"',__LINE__,__FILE__
);
$phpgw->db->query($sql,__LINE__,__FILE__);
if ($phpgw->db->num_rows()==0) {
$sql = 'INSERT INTO phpgw_app_sessions (sessionid,loginid,app,location,content)'
.' VALUES ("'.$this->sessionid.'"'
.' ","'.$this->account_id.'"'
.' ","'.$phpgw_info["flags"]["currentapp"].'"'
.' ","'.$location.'"'
.' ","'.$data.'"')'
);
$phpgw->db->query($sql,__LINE__,__FILE__);
} else {
$sql = 'update phpgw_app_sessions set content = "'.$data.'"'
.' where sessionid = "'.$this->sessionid.'"'
.' and loginid = "'.$this->account_id.'"'
.' and app = "'.$phpgw_info["user"]["currentapp"].'"'
.' and location = "'.$location.'"',__LINE__,__FILE__
);
$phpgw->db->query($sql,__LINE__,__FILE__);
}
//$data = $phpgw->common->decrypt($data);
return $data;
}
}
function restore()
{
global $phpgw;
$serializedData = $phpgw->common->appsession();
$sessionData = unserialize($serializedData);
if (is_array($sessionData))
{
reset($sessionData);
while(list($key,$value) = each($sessionData))
{
global $$key;
$$key = $value;
$this->variableNames[$key]="registered";
#print "restored: ".$key.", $value<br>";
}
}
}
// save the current values of the variables
function save()
{
global $phpgw;
if (is_array($this->variableNames))
{
reset($this->variableNames);
while(list($key, $value) = each($this->variableNames))
{
if ($value == "registered")
{
global $$key;
$sessionData[$key] = $$key;
}
}
$serializedData = addslashes(serialize($sessionData));
$phpgw->common->appsession($serializedData);
}
}
// create a list a variable names, wich data need's to be restored
function register($_variableName)
{
$this->variableNames[$_variableName]="registered";
#print "registered $_variableName<br>";
}
// mark variable as unregistered
function unregister($_variableName)
{
$this->variableNames[$_variableName]="unregistered";
#print "unregistered $_variableName<br>";
}
// check if we have a variable registred already
function is_registered($_variableName)
{
if ($this->variableNames[$_variableName] == "registered")
{
return True;
}
else
{
return False;
}
}
}
/*************************************************************************\
* Function to handle session support via url or cookies *
\*************************************************************************/
function link($url = "", $extravars = "")
{
global $phpgw, $phpgw_info, $usercookie, $kp3, $PHP_SELF;
/* Fix problems when PHP_SELF if used as the param */
if ($url == $PHP_SELF){ $url = ""; }
if (! $kp3) { $kp3 = $phpgw_info["user"]["kp3"]; }
// Explicit hack to work around problems with php running as CGI on windows
// please let us know if this doesn't work for you!
if (! $url && (PHP_OS == "Windows" || PHP_OS == "OS/2" || PHP_OS == "WIN32" || PHP_OS == "WIN16")) {
$exe = strpos($PHP_SELF,"php.exe");
if ($exe != false) {
$exe += 7; // strlen("php.exe")
$url_root = split ("/", $phpgw_info["server"]["webserver_url"]);
$url = (strlen($url_root[0])? $url_root[0].'//':'') . $url_root[2];
$url .= substr($PHP_SELF,$exe,strlen($PHP_SELF)-$exe);
}
}
if (! $url) {
$url_root = split ("/", $phpgw_info["server"]["webserver_url"]);
/* Some hosting providers have their paths screwy.
If the value from $PHP_SELF is not what you expect, you can use this to patch it
It will need to be adjusted to your specific problem tho.
*/
//$patched_php_self = str_replace("/php4/php/phpgroupware", "/phpgroupware", $PHP_SELF);
$patched_php_self = $PHP_SELF;
$url = (strlen($url_root[0])? $url_root[0].'//':'') . $url_root[2] . $patched_php_self;
}
if (isset($phpgw_info["server"]["usecookies"]) &&
$phpgw_info["server"]["usecookies"]) {
if ($extravars) { $url .= "?$extravars"; }
} else {
$url .= "?sessionid=" . $phpgw_info["user"]["sessionid"];
$url .= "&kp3=" . $kp3;
$url .= "&domain=" . $phpgw_info["user"]["domain"];
// This doesn't belong in the API.
// Its up to the app to pass this value. (jengo)
// Putting it into the app requires a massive number of updates in email app.
// Until that happens this needs to stay here (seek3r)
if ($phpgw_info["flags"]["newsmode"]) { $url .= "&newsmode=on"; }
if ($extravars) { $url .= "&$extravars"; }
}
$url = str_replace("/?", "/index.php?", $url);
$webserver_url_count = strlen($phpgw_info["server"]["webserver_url"]);
$slash_check = strtolower(substr($url ,0,1));
if(substr($url ,0,$webserver_url_count) != $phpgw_info["server"]["webserver_url"]) {
$app = $phpgw_info["flags"]["currentapp"];
if($slash_check == "/") {
$url = $phpgw_info["server"]["webserver_url"].$url;
} elseif ($app == "home" || $app == "logout" || $app == "login"){
$url = $phpgw_info["server"]["webserver_url"]."/".$url;
}else{
$url = $phpgw_info["server"]["webserver_url"]."/".$app."/".$url;
}
}
return $url;
}
}
?>

View File

@ -1,357 +1,386 @@
<?php
/**************************************************************************\
* phpGroupWare API - phpgwapi loader *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* and Joseph Engo <jengo@phpgroupware.org> *
* Has a few functions, but primary role is to load the phpgwapi *
* Copyright (C) 2000, 2001 Dan Kuykendall *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/**************************************************************************\
* phpGroupWare API - phpgwapi loader *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* and Joseph Engo <jengo@phpgroupware.org> *
* Has a few functions, but primary role is to load the phpgwapi *
* Copyright (C) 2000, 2001 Dan Kuykendall *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/api *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
/****************************************************************************\
* 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;
}
/* $Id$ */
/****************************************************************************\
* 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 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;
}
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;
}
// Just a temp wrapper.
function check_code($code)
{
global $phpgw;
return $phpgw->common->check_code($code);
}
/* Just a temp wrapper. ###DELETE_ME#### (Seek3r) */
function check_code($code)
{
global $phpgw;
return $phpgw->common->check_code($code);
}
function filesystem_separator()
{
if (PHP_OS == "Windows" || PHP_OS == "OS/2") {
return "\\";
} else {
return "/";
}
}
function filesystem_separator()
{
if (PHP_OS == "Windows" || PHP_OS == "OS/2") {
return "\\";
} else {
return "/";
}
}
/****************************************************************************\
* 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;
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");
}
/****************************************************************************\
* 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;
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");
}
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");
}
}
// This function needs to be optimized, its reading duplicate information.
function phpgw_fillarray()
{
global $phpgw, $phpgw_info, $cd, $colspan;
// 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());
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"];
/* 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();
}
}
// 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;
}
/****************************************************************************\
* 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);
/****************************************************************************\
* 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>";
}
/* 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;
}
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
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"];
}
}
// 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 (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
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);
// 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);
// 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_();
//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
);
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();
/****************************************************************************\
* These lines load up the API, fill up the $phpgw_info array, etc *
\****************************************************************************/
/* Load main class */
$phpgw = CreateObject("phpgwapi.phpgw");
/* Fill phpgw_info["server"] array */
$phpgw->db->query("select * from config",__LINE__,__FILE__);
while ($phpgw->db->next_record()) {
$phpgw_info["server"][$phpgw->db->f("config_name")] = stripslashes($phpgw->db->f("config_value"));
}
// Handy little shortcut
$sep = $phpgw_info["server"]["dir_separator"];
if ($phpgw_info["flags"]["enable_utilities_class"]){
$phpgw->utilities->utilities_();
}
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()) {
Header("Location: " . $phpgw->redirect($phpgw->session->link($phpgw_info["server"]["webserver_url"]."/login.php","cd=10")));
exit;
}
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;
}
if ($preferences_update) {
$phpgw->preferences->save_repository();
}
unset($preferences_update);
}
/*************************************************************************\
* These lines load up the themes *
\*************************************************************************/
include(PHPGW_SERVER_ROOT . "/phpgwapi/themes/" .
$phpgw_info["user"]["preferences"]["common"]["theme"] . ".theme");
$template_root = $this->common->get_tpl_dir();
if (is_dir($template_root)) {
$this->template = CreateObject("phpgwapi.Template", $template_root);
}
if ($phpgw_info["theme"]["bg_color"] == "") {
/* Looks like there was a problem finding that theme. Try the default */
echo "Warning: error locating selected theme";
include (PHPGW_SERVER_ROOT . "/phpgwapi/themes/default.theme");
if ($phpgw_info["theme"]["bg_color"] == "") {
// Hope we don't get to this point. Better then the user seeing a
// complety back screen and not know whats going on
echo "<body bgcolor=FFFFFF>Fatal error: no themes found";
exit;
}
}
/*************************************************************************\
* If they are using frames, we need to set some variables *
\*************************************************************************/
if (($phpgw_info["user"]["preferences"]["common"]["useframes"] && $phpgw_info["server"]["useframes"] == "allowed")
|| ($phpgw_info["server"]["useframes"] == "always")) {
$phpgw_info["flags"]["navbar_target"] = "phpgw_body";
}
//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";
}
/*************************************************************************\
* Verify that the users session is still active otherwise kick them out *
\*************************************************************************/
if ($phpgw_info["flags"]["currentapp"] != "home" &&
$phpgw_info["flags"]["currentapp"] != "logout" &&
$phpgw_info["flags"]["currentapp"] != "preferences" &&
$phpgw_info["flags"]["currentapp"] != "about") {
/****************************************************************************\
* Everything from this point on will ONLY happen if *
* the currentapp is not login or logout *
\****************************************************************************/
if ($phpgw_info["flags"]["currentapp"] != "login" && $phpgw_info["flags"]["currentapp"] != "logout") {
if (! $phpgw->session->verify()) {
Header("Location: " . $phpgw->redirect($phpgw->session->link($phpgw_info["server"]["webserver_url"]."/login.php","cd=10")));
exit;
}
load_optional();
if (! $phpgw_info["user"]["apps"][$phpgw_info["flags"]["currentapp"]]) {
$phpgw->common->phpgw_header();
echo "<p><center><b>".lang("Access not permitted")."</b></center>";
exit;
}
}
phpgw_fillarray();
/*************************************************************************\
* Load the header unless the developer turns it off *
\*************************************************************************/
if (! $phpgw_info["flags"]["noheader"]) {
$phpgw->common->phpgw_header();
}
if ($phpgw_info["flags"]["enable_utilities_class"]){
$phpgw->utilities->utilities_();
}
/*************************************************************************\
* Load the app include files if the exists *
\*************************************************************************/
/* Then the include file */
if (! preg_match ("/phpgwapi/i", PHPGW_APP_INC) && file_exists(PHPGW_APP_INC."/functions.inc.php")){
include(PHPGW_APP_INC . "/functions.inc.php");
}
if (!$phpgw_info["flags"]["noheader"] && ! $phpgw_info["flags"]["noappheader"] &&
file_exists(PHPGW_APP_INC . "/header.inc.php")) {
include(PHPGW_APP_INC . "/header.inc.php");
}
}
error_reporting(7);
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->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 themes *
\*************************************************************************/
include(PHPGW_SERVER_ROOT . "/phpgwapi/themes/" .
$phpgw_info["user"]["preferences"]["common"]["theme"] . ".theme");
if ($phpgw_info["theme"]["bg_color"] == "") {
/* Looks like there was a problem finding that theme. Try the default */
echo "Warning: error locating selected theme";
include (PHPGW_SERVER_ROOT . "/phpgwapi/themes/default.theme");
if ($phpgw_info["theme"]["bg_color"] == "") {
// Hope we don't get to this point. Better then the user seeing a
// complety back screen and not know whats going on
echo "<body bgcolor=FFFFFF>Fatal error: no themes found";
exit;
}
}
/*************************************************************************\
* If they are using frames, we need to set some variables *
\*************************************************************************/
if (($phpgw_info["user"]["preferences"]["common"]["useframes"] && $phpgw_info["server"]["useframes"] == "allowed")
|| ($phpgw_info["server"]["useframes"] == "always")) {
$phpgw_info["flags"]["navbar_target"] = "phpgw_body";
}
/*************************************************************************\
* Verify that the users session is still active otherwise kick them out *
\*************************************************************************/
if ($phpgw_info["flags"]["currentapp"] != "home" &&
$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;
}
}
/*************************************************************************\
* Load the header unless the developer turns it off *
\*************************************************************************/
if (! $phpgw_info["flags"]["noheader"]) {
$phpgw->common->phpgw_header();
}
/*************************************************************************\
* Load the app include files if the exists *
\*************************************************************************/
/* Then the include file */
if (! preg_match ("/phpgwapi/i", PHPGW_APP_INC) && file_exists(PHPGW_APP_INC."/functions.inc.php")){
include(PHPGW_APP_INC . "/functions.inc.php");
}
if (!$phpgw_info["flags"]["noheader"] && ! $phpgw_info["flags"]["noappheader"] &&
file_exists(PHPGW_APP_INC . "/header.inc.php")) {
include(PHPGW_APP_INC . "/header.inc.php");
}
}
error_reporting(7);