2001-01-11 20:41:38 +01:00
|
|
|
<?php
|
2001-02-08 02:06:45 +01:00
|
|
|
//$debugme = "on";
|
2001-02-07 21:22:17 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* 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. *
|
|
|
|
\****************************************************************************/
|
2001-03-14 00:28:27 +01:00
|
|
|
/*!
|
|
|
|
@function CreateObject
|
|
|
|
@abstract Load a class and include the class file if not done so already.
|
2001-07-16 01:27:36 +02:00
|
|
|
@discussion Author: mdean, milosch (thanks to jengo and ralf)<br>
|
2001-03-14 00:28:27 +01:00
|
|
|
This function is used to create an instance of a class,
|
|
|
|
and if the class file has not been included it will do so. <br>
|
|
|
|
Syntax: CreateObject('app.class', 'constructor_params'); <br>
|
|
|
|
Example1: $phpgw->acl = CreateObject('phpgwapi.acl');
|
|
|
|
@param $classname name of class
|
2001-07-15 12:16:12 +02:00
|
|
|
@param $p1-$p16 class parameters (all optional)
|
2001-02-13 11:53:18 +01:00
|
|
|
*/
|
2001-07-16 01:27:36 +02:00
|
|
|
function CreateObject($classname,
|
|
|
|
$p1='_UNDEF_',$p2='_UNDEF_',$p3='_UNDEF_',$p4='_UNDEF_',
|
|
|
|
$p5='_UNDEF_',$p6='_UNDEF_',$p7='_UNDEF_',$p8='_UNDEF_',
|
|
|
|
$p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_',
|
|
|
|
$p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_')
|
2001-02-07 21:22:17 +01:00
|
|
|
{
|
|
|
|
global $phpgw, $phpgw_info, $phpgw_domain;
|
2001-08-02 16:33:35 +02:00
|
|
|
|
|
|
|
error_reporting(0);
|
|
|
|
|
2001-02-07 21:22:17 +01:00
|
|
|
$classpart = explode (".", $classname);
|
2001-08-02 16:33:35 +02:00
|
|
|
$appname = $classpart[0];
|
2001-02-07 21:22:17 +01:00
|
|
|
$classname = $classpart[1];
|
2001-08-02 16:33:35 +02:00
|
|
|
if (!isset($phpgw_info['flags']['included_classes'][$classname]) ||
|
|
|
|
!$phpgw_info['flags']['included_classes'][$classname])
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
|
|
|
$phpgw_info['flags']['included_classes'][$classname] = True;
|
|
|
|
include(PHPGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php');
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
2001-07-16 01:27:36 +02:00
|
|
|
if ($p1 == '_UNDEF_')
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
2001-08-02 16:56:23 +02:00
|
|
|
eval("\$obj = new \$classname;");
|
2001-06-13 08:27:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-16 01:27:36 +02:00
|
|
|
$input = array($p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9,$p10,$p11,$p12,$p13,$p14,$p15,$p16);
|
|
|
|
$i = 1;
|
|
|
|
$code = "\$obj = new \$classname(";
|
|
|
|
while (list($x,$test) = each($input))
|
|
|
|
{
|
|
|
|
if ($test == '_UNDEF_' || $i == 17)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$code .= "\$p" . $i . ',';
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
2001-08-02 16:56:23 +02:00
|
|
|
$code = substr($code,0,-1) . ");";
|
|
|
|
eval($code);
|
2001-08-02 16:33:35 +02:00
|
|
|
}
|
|
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
2001-08-02 16:56:23 +02:00
|
|
|
return $obj;
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
2001-08-03 23:10:02 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@function ExecObj
|
|
|
|
@abstract Execute a function, and load a class and include the class file if not done so already.
|
|
|
|
@discussion Author: seek3r<br>
|
|
|
|
This function is used to create an instance of a class,
|
|
|
|
and if the class file has not been included it will do so. <br>
|
|
|
|
Syntax: CreateObject('app.class', 'constructor_params'); <br>
|
|
|
|
Example1: ExecObj('phpgwapi.acl.read');
|
|
|
|
@param $object to execute
|
|
|
|
@param $functionparams function param should be an array
|
|
|
|
@param $loglevel developers choice of logging level
|
|
|
|
@param $classparams params to be sent to the contructor
|
|
|
|
*/
|
|
|
|
function ExecObj($object, $functionparams, $loglevel, $classparams)
|
|
|
|
{
|
|
|
|
global $GLOBAL;
|
|
|
|
$objparts = explode (".", $object);
|
|
|
|
$appname = $objparts[0];
|
|
|
|
$classname = $objparts[1];
|
|
|
|
$functionname = $objparts[2];
|
|
|
|
$code = 'global $'.$classname.';';
|
|
|
|
eval($code);
|
|
|
|
if (!is_object($$classname))
|
|
|
|
{
|
|
|
|
$classname = CreateObject($appname.'.'.$classname);
|
2001-08-03 23:12:28 +02:00
|
|
|
$code = '$'.$classname.' = CreateObject('.$appname.'.'.$classname.')';
|
2001-08-03 23:10:02 +02:00
|
|
|
/* $code = '$'.$classname.' = new '.$classname.';'; */
|
|
|
|
eval($code);
|
|
|
|
}
|
|
|
|
${$GLOBAL[$classname]}->${$functionname};
|
|
|
|
}
|
|
|
|
|
2001-07-15 12:16:12 +02:00
|
|
|
/*!
|
|
|
|
@function lang
|
2001-08-02 16:33:35 +02:00
|
|
|
@abstract function to handle multilanguage support
|
2001-07-15 12:16:12 +02:00
|
|
|
*/
|
2001-08-02 16:33:35 +02:00
|
|
|
function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='')
|
2001-02-07 21:22:17 +01:00
|
|
|
{
|
|
|
|
global $phpgw;
|
2001-08-02 16:33:35 +02:00
|
|
|
|
|
|
|
if(gettype($m1) == 'array')
|
|
|
|
{
|
|
|
|
$vars = $m1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$vars = array($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10);
|
|
|
|
}
|
|
|
|
$value = $phpgw->translation->translate("$key",$vars);
|
2001-02-07 21:22:17 +01:00
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Just a temp wrapper. ###DELETE_ME#### (Seek3r) */
|
|
|
|
function check_code($code)
|
|
|
|
{
|
|
|
|
global $phpgw;
|
|
|
|
return $phpgw->common->check_code($code);
|
|
|
|
}
|
2001-05-08 22:50:11 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
@function get_account_id()
|
|
|
|
@abstract Return a properly formatted account_id.
|
|
|
|
@discussion Author: skeeter <br>
|
|
|
|
This function will return a properly formatted account_id. <br>
|
|
|
|
This can take either a name or an account_id as paramters. <br>
|
|
|
|
If a name is provided it will return the associated id. <br>
|
|
|
|
Syntax: get_account_id($accountid); <br>
|
|
|
|
Example1: $account_id = get_account_id($accountid);
|
|
|
|
@param $account_id either a name or an id
|
|
|
|
@param $default_id either a name or an id
|
|
|
|
*/
|
|
|
|
function get_account_id($account_id = '',$default_id = '')
|
|
|
|
{
|
|
|
|
global $phpgw, $phpgw_info;
|
|
|
|
|
|
|
|
if (gettype($account_id) == 'integer')
|
|
|
|
{
|
|
|
|
return $account_id;
|
|
|
|
}
|
|
|
|
elseif ($account_id == '')
|
|
|
|
{
|
|
|
|
if ($default_id == '')
|
|
|
|
{
|
2001-06-17 18:55:04 +02:00
|
|
|
return (isset($phpgw_info['user']['account_id'])?$phpgw_info['user']['account_id']:0);
|
2001-05-08 22:50:11 +02:00
|
|
|
}
|
|
|
|
elseif (gettype($default_id) == 'string')
|
|
|
|
{
|
|
|
|
return $phpgw->accounts->name2id($default_id);
|
|
|
|
}
|
|
|
|
return intval($default_id);
|
|
|
|
}
|
|
|
|
elseif (gettype($account_id) == 'string')
|
|
|
|
{
|
|
|
|
if($phpgw->accounts->exists(intval($account_id)) == True)
|
|
|
|
{
|
|
|
|
return intval($account_id);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $phpgw->accounts->name2id($account_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
@function filesystem_separator()
|
|
|
|
@abstract sets the file system seperator depending on OS
|
|
|
|
@result file system separator
|
|
|
|
*/
|
2001-02-07 21:22:17 +01:00
|
|
|
function filesystem_separator()
|
|
|
|
{
|
2001-06-13 08:27:06 +02:00
|
|
|
if (PHP_OS == 'Windows' || PHP_OS == 'OS/2')
|
|
|
|
{
|
2001-02-08 01:49:34 +01:00
|
|
|
return '\\';
|
2001-06-13 08:27:06 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-08 01:49:34 +01:00
|
|
|
return '/';
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-01 19:57:59 +02:00
|
|
|
function _debug_array($array)
|
|
|
|
{
|
2001-07-23 02:02:33 +02:00
|
|
|
if(floor(phpversion()) == 4)
|
|
|
|
{
|
|
|
|
echo '<pre>'; print_r($array); echo '</pre>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
echo '<pre>'; var_dump($array); echo '</pre>';
|
|
|
|
}
|
2001-07-01 19:57:59 +02:00
|
|
|
}
|
|
|
|
|
2001-05-08 22:50:11 +02:00
|
|
|
function print_debug($text='')
|
2001-02-07 21:22:17 +01:00
|
|
|
{
|
2001-02-08 01:49:34 +01:00
|
|
|
global $debugme;
|
2001-06-13 08:27:06 +02:00
|
|
|
if (isset($debugme) && $debugme == 'on') { echo 'debug: '.$text.'<br>'; }
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
2001-07-06 08:46:10 +02:00
|
|
|
|
|
|
|
// print_debug('core functions are done');
|
2001-02-07 21:22:17 +01:00
|
|
|
/****************************************************************************\
|
2001-02-08 01:49:34 +01:00
|
|
|
* Quick verification of sane environment *
|
2001-02-07 21:22:17 +01:00
|
|
|
\****************************************************************************/
|
2001-05-08 22:50:11 +02:00
|
|
|
// error_reporting(7);
|
2001-02-08 01:49:34 +01:00
|
|
|
/* Make sure the header.inc.php is current. */
|
2001-06-13 08:27:06 +02:00
|
|
|
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>';
|
2001-02-07 21:22:17 +01:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure the developer is following the rules. */
|
2001-06-13 08:27:06 +02:00
|
|
|
if (!isset($phpgw_info['flags']['currentapp']))
|
|
|
|
{
|
2001-02-07 21:22:17 +01:00
|
|
|
echo "<b>!!! YOU DO NOT HAVE YOUR \$phpgw_info[\"flags\"][\"currentapp\"] SET !!!";
|
|
|
|
echo "<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>";
|
|
|
|
}
|
|
|
|
|
2001-02-08 01:49:34 +01:00
|
|
|
magic_quotes_runtime(false);
|
2001-02-08 05:42:44 +01:00
|
|
|
print_debug('sane environment');
|
2001-02-08 01:49:34 +01:00
|
|
|
|
|
|
|
/****************************************************************************\
|
|
|
|
* Multi-Domain support *
|
|
|
|
\****************************************************************************/
|
|
|
|
|
|
|
|
/* make them fix their header */
|
2001-06-13 08:27:06 +02:00
|
|
|
if (!isset($phpgw_domain))
|
|
|
|
{
|
|
|
|
echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>';
|
2001-02-07 21:22:17 +01:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
reset($phpgw_domain);
|
|
|
|
$default_domain = each($phpgw_domain);
|
2001-06-13 08:27:06 +02:00
|
|
|
$phpgw_info['server']['default_domain'] = $default_domain[0];
|
2001-02-07 21:22:17 +01:00
|
|
|
unset ($default_domain); // we kill this for security reasons
|
|
|
|
|
2001-02-08 01:49:34 +01:00
|
|
|
/* This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode. */
|
2001-06-13 08:27:06 +02:00
|
|
|
if (isset($domain))
|
|
|
|
{
|
|
|
|
$phpgw_info['user']['domain'] = $domain;
|
|
|
|
}
|
|
|
|
elseif (isset($login) && isset($logindomain))
|
|
|
|
{
|
|
|
|
if (!ereg ("\@", $login))
|
|
|
|
{
|
2001-02-07 21:22:17 +01:00
|
|
|
$login = $login."@".$logindomain;
|
|
|
|
}
|
2001-06-13 08:27:06 +02:00
|
|
|
$phpgw_info['user']['domain'] = $logindomain;
|
2001-02-07 21:22:17 +01:00
|
|
|
unset ($logindomain);
|
2001-06-13 08:27:06 +02:00
|
|
|
}
|
|
|
|
elseif (isset($login) && !isset($logindomain))
|
|
|
|
{
|
|
|
|
if (ereg ("\@", $login))
|
|
|
|
{
|
2001-02-07 21:22:17 +01:00
|
|
|
$login_array = explode("@", $login);
|
2001-06-13 08:27:06 +02:00
|
|
|
$phpgw_info['user']['domain'] = $login_array[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$phpgw_info['user']['domain'] = $phpgw_info['server']['default_domain'];
|
|
|
|
$login = $login . '@' . $phpgw_info['user']['domain'];
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-17 18:55:04 +02:00
|
|
|
if (@isset($phpgw_domain[$phpgw_info['user']['domain']]))
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
|
|
|
$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'];
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
|
|
|
|
2001-06-13 08:27:06 +02:00
|
|
|
if ($phpgw_info['flags']['currentapp'] != 'login' && ! $phpgw_info['server']['show_domain_selectbox'])
|
|
|
|
{
|
2001-02-07 21:22:17 +01:00
|
|
|
unset ($phpgw_domain); // we kill this for security reasons
|
|
|
|
}
|
|
|
|
unset ($domain); // we kill this to save memory
|
|
|
|
|
2001-06-17 18:55:04 +02:00
|
|
|
@print_debug('domain: '.$phpgw_info['user']['domain']);
|
2001-02-07 21:22:17 +01:00
|
|
|
|
|
|
|
/****************************************************************************\
|
|
|
|
* These lines load up the API, fill up the $phpgw_info array, etc *
|
|
|
|
\****************************************************************************/
|
|
|
|
/* Load main class */
|
2001-06-13 08:27:06 +02:00
|
|
|
$phpgw = CreateObject('phpgwapi.phpgw');
|
2001-02-13 11:53:18 +01:00
|
|
|
/************************************************************************\
|
|
|
|
* Load up the main instance of the db class. *
|
|
|
|
\************************************************************************/
|
2001-06-13 08:27:06 +02:00
|
|
|
$phpgw->db = CreateObject('phpgwapi.db');
|
|
|
|
$phpgw->db->Host = $phpgw_info['server']['db_host'];
|
|
|
|
$phpgw->db->Type = $phpgw_info['server']['db_type'];
|
|
|
|
$phpgw->db->Database = $phpgw_info['server']['db_name'];
|
|
|
|
$phpgw->db->User = $phpgw_info['server']['db_user'];
|
|
|
|
$phpgw->db->Password = $phpgw_info['server']['db_pass'];
|
|
|
|
if ($phpgw->debug)
|
|
|
|
{
|
2001-02-13 11:53:18 +01:00
|
|
|
$phpgw->db->Debug = 1;
|
|
|
|
}
|
|
|
|
|
2001-02-28 16:56:47 +01:00
|
|
|
$phpgw->db->Halt_On_Error = 'no';
|
2001-02-10 04:15:48 +01:00
|
|
|
@$phpgw->db->query("select count(*) from phpgw_config");
|
2001-02-28 16:56:47 +01:00
|
|
|
if (! @$phpgw->db->next_record())
|
|
|
|
{
|
|
|
|
$setup_dir = ereg_replace($PHP_SELF,'index.php','setup/');
|
|
|
|
echo '<center><b>Fatal Error:</b> It appears that you have not created the database tables for '
|
2001-06-13 08:27:06 +02:00
|
|
|
.'phpGroupWare. Click <a href="' . $setup_dir . '">here</a> to run setup.</center>';
|
2001-02-28 16:56:47 +01:00
|
|
|
exit;
|
2001-02-10 04:15:48 +01:00
|
|
|
}
|
2001-02-28 16:56:47 +01:00
|
|
|
$phpgw->db->Halt_On_Error = 'yes';
|
2001-02-08 01:49:34 +01:00
|
|
|
|
2001-02-07 21:22:17 +01:00
|
|
|
/* Fill phpgw_info["server"] array */
|
2001-06-22 02:49:32 +02:00
|
|
|
// An Attempt to speed things up using cache premise
|
|
|
|
$phpgw->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info'",__LINE__,__FILE__);
|
|
|
|
if ($phpgw->db->num_rows())
|
2001-05-21 19:30:55 +02:00
|
|
|
{
|
2001-06-23 13:01:59 +02:00
|
|
|
$phpgw->db->next_record();
|
2001-06-22 02:49:32 +02:00
|
|
|
$phpgw_info['server']['cache_phpgw_info'] = stripslashes($phpgw->db->f('config_value'));
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
2001-03-21 04:30:29 +01:00
|
|
|
|
2001-06-22 02:49:32 +02:00
|
|
|
$cache_query = "select content from phpgw_app_sessions where"
|
|
|
|
." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
|
|
|
|
|
|
|
|
$phpgw->db->query($cache_query,__LINE__,__FILE__);
|
|
|
|
$server_info_cache = $phpgw->db->num_rows();
|
|
|
|
|
|
|
|
if(@$phpgw_info['server']['cache_phpgw_info'] && $server_info_cache)
|
|
|
|
{
|
|
|
|
$phpgw->db->next_record();
|
|
|
|
$phpgw_info['server'] = unserialize(stripslashes($phpgw->db->f('content')));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$phpgw->db->query("select * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__);
|
|
|
|
while ($phpgw->db->next_record())
|
|
|
|
{
|
|
|
|
$phpgw_info['server'][$phpgw->db->f('config_name')] = stripslashes($phpgw->db->f('config_value'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if($phpgw_info['server']['cache_phpgw_info'])
|
|
|
|
{
|
|
|
|
if($server_info_cache)
|
|
|
|
{
|
|
|
|
$cache_query = "UPDATE phpgw_app_sessions set content='".addslashes(serialize($phpgw_info['server']))."'"
|
|
|
|
." WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
|
|
|
|
. "'0','0','phpgwapi','config','".addslashes(serialize($phpgw_info['server']))."')";
|
|
|
|
}
|
2001-07-28 04:18:17 +02:00
|
|
|
$phpgw->db->query($cache_query,__LINE__,__FILE__);
|
2001-06-22 02:49:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
unset($cache_query);
|
|
|
|
unset($server_info_cache);
|
2001-03-21 06:01:28 +01:00
|
|
|
/************************************************************************\
|
|
|
|
* Required classes *
|
|
|
|
\************************************************************************/
|
2001-05-21 19:30:55 +02:00
|
|
|
$phpgw->common = CreateObject('phpgwapi.common');
|
|
|
|
$phpgw->hooks = CreateObject('phpgwapi.hooks');
|
|
|
|
$phpgw->auth = CreateObject('phpgwapi.auth');
|
|
|
|
$phpgw->accounts = CreateObject('phpgwapi.accounts');
|
2001-05-31 12:11:18 +02:00
|
|
|
$phpgw->acl = CreateObject('phpgwapi.acl');
|
2001-05-21 19:30:55 +02:00
|
|
|
$phpgw->session = CreateObject('phpgwapi.sessions');
|
|
|
|
$phpgw->preferences = CreateObject('phpgwapi.preferences');
|
|
|
|
$phpgw->applications = CreateObject('phpgwapi.applications');
|
|
|
|
$phpgw->translation = CreateObject('phpgwapi.translation');
|
|
|
|
// $phpgw->datetime = CreateObject('phpgwapi.datetime');
|
2001-03-21 06:01:28 +01:00
|
|
|
print_debug('main class loaded');
|
|
|
|
|
2001-02-09 04:56:24 +01:00
|
|
|
/****************************************************************************\
|
|
|
|
* This is a global constant that should be used *
|
|
|
|
* instead of / or \ in file paths *
|
|
|
|
\****************************************************************************/
|
2001-06-26 23:40:45 +02:00
|
|
|
define('SEP',filesystem_separator());
|
2001-02-07 21:22:17 +01:00
|
|
|
|
|
|
|
/****************************************************************************\
|
2001-02-08 05:42:44 +01:00
|
|
|
* Stuff to use if logging in or logging out *
|
2001-02-07 21:22:17 +01:00
|
|
|
\****************************************************************************/
|
2001-06-13 08:27:06 +02:00
|
|
|
if ($phpgw_info['flags']['currentapp'] == 'login' || $phpgw_info['flags']['currentapp'] == 'logout')
|
|
|
|
{
|
|
|
|
if ($phpgw_info['flags']['currentapp'] == 'login')
|
|
|
|
{
|
2001-06-17 18:55:04 +02:00
|
|
|
if (@$login != '')
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
|
|
|
$login_array = explode("@",$login);
|
|
|
|
$login_id = $phpgw->accounts->name2id($login_array[0]);
|
|
|
|
$phpgw->accounts->accounts($login_id);
|
|
|
|
$phpgw->preferences->preferences($login_id);
|
2001-02-08 05:42:44 +01:00
|
|
|
}
|
2001-06-13 08:27:06 +02:00
|
|
|
}
|
|
|
|
/****************************************************************************\
|
|
|
|
* Everything from this point on will ONLY happen if *
|
|
|
|
* the currentapp is not login or logout *
|
|
|
|
\****************************************************************************/
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (! $phpgw->session->verify())
|
|
|
|
{
|
|
|
|
Header('Location: ' . $phpgw->redirect($phpgw->session->link('/login.php','cd=10')));
|
|
|
|
exit;
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
|
|
|
|
2001-02-08 02:06:45 +01:00
|
|
|
/* A few hacker resistant constants that will be used throught the program */
|
2001-03-18 05:55:36 +01:00
|
|
|
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());
|
2001-06-17 18:55:04 +02:00
|
|
|
define('PHPGW_APP_IMAGES_DIR', $phpgw->common->get_image_dir());
|
2001-06-26 23:40:45 +02:00
|
|
|
|
2001-03-18 05:55:36 +01:00
|
|
|
define('PHPGW_ACL_READ',1);
|
|
|
|
define('PHPGW_ACL_ADD',2);
|
|
|
|
define('PHPGW_ACL_EDIT',4);
|
|
|
|
define('PHPGW_ACL_DELETE',8);
|
|
|
|
define('PHPGW_ACL_PRIVATE',16);
|
2001-02-08 01:49:34 +01:00
|
|
|
|
|
|
|
/********* This sets the user variables *********/
|
2001-06-13 08:27:06 +02:00
|
|
|
$phpgw_info['user']['private_dir'] = $phpgw_info['server']['files_dir']
|
|
|
|
. '/users/'.$phpgw_info['user']['userid'];
|
2001-02-08 01:49:34 +01:00
|
|
|
|
|
|
|
/* This will make sure that a user has the basic default prefs. If not it will add them */
|
|
|
|
$phpgw->preferences->verify_basic_settings();
|
2001-05-31 12:11:18 +02:00
|
|
|
|
2001-02-08 01:49:34 +01:00
|
|
|
/********* Optional classes, which can be disabled for performance increases *********/
|
2001-05-15 02:35:29 +02:00
|
|
|
while ($phpgw_class_name = each($phpgw_info['flags']))
|
2001-05-02 07:31:23 +02:00
|
|
|
{
|
2001-05-15 02:35:29 +02:00
|
|
|
if (ereg('enable_',$phpgw_class_name[0]))
|
2001-05-02 07:31:23 +02:00
|
|
|
{
|
2001-06-23 04:00:12 +02:00
|
|
|
$enable_class = str_replace('enable_','',$phpgw_class_name[0]);
|
|
|
|
$enable_class = str_replace('_class','',$enable_class);
|
2001-05-02 07:31:23 +02:00
|
|
|
eval('$phpgw->' . $enable_class . ' = createobject(\'phpgwapi.' . $enable_class . '\');');
|
|
|
|
}
|
2001-04-07 16:29:41 +02:00
|
|
|
}
|
2001-05-02 07:31:23 +02:00
|
|
|
unset($enable_class);
|
|
|
|
reset($phpgw_info['flags']);
|
2001-04-07 16:29:41 +02:00
|
|
|
|
2001-02-08 01:49:34 +01:00
|
|
|
/*************************************************************************\
|
|
|
|
* These lines load up the templates class *
|
|
|
|
\*************************************************************************/
|
2001-07-22 01:29:07 +02:00
|
|
|
if(!@$phpgw_info['flags']['disable_Template_class'])
|
2001-07-16 08:24:17 +02:00
|
|
|
{
|
|
|
|
$phpgw->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
|
|
|
|
}
|
2001-02-08 01:49:34 +01:00
|
|
|
|
2001-02-07 21:22:17 +01:00
|
|
|
/*************************************************************************\
|
|
|
|
* These lines load up the themes *
|
|
|
|
\*************************************************************************/
|
2001-03-01 19:17:33 +01:00
|
|
|
if (! $phpgw_info['user']['preferences']['common']['theme'])
|
|
|
|
{
|
|
|
|
if ($phpgw_info['server']['template_set'] == 'user_choice')
|
|
|
|
{
|
|
|
|
$phpgw_info['user']['preferences']['common']['theme'] = 'default';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$phpgw_info['user']['preferences']['common']['theme'] = $phpgw_info['server']['template_set'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-27 12:02:33 +02:00
|
|
|
if ($phpgw_info['server']['force_theme'] == 'user_choice')
|
|
|
|
{
|
2001-06-25 04:45:36 +02:00
|
|
|
$theme_to_load = (isset($phpgw_info['user']['preferences']['common']['theme'])?$phpgw_info['user']['preferences']['common']['theme']:'default');
|
2001-06-24 04:18:47 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-06-25 04:45:36 +02:00
|
|
|
$theme_to_load = (isset($phpgw_info['server']['force_theme'])?$phpgw_info['server']['force_theme']:'default');
|
2001-06-24 04:18:47 +02:00
|
|
|
}
|
2001-02-07 21:22:17 +01:00
|
|
|
|
2001-06-24 04:18:47 +02:00
|
|
|
if(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $theme_to_load . '.theme'))
|
|
|
|
{
|
|
|
|
include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $theme_to_load . '.theme');
|
|
|
|
}
|
|
|
|
elseif(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme'))
|
|
|
|
{
|
|
|
|
include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme');
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
2001-04-27 12:02:33 +02:00
|
|
|
else
|
|
|
|
{
|
2001-06-24 04:18:47 +02:00
|
|
|
/* 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"><b>Fatal error: no themes found</b>';
|
|
|
|
exit;
|
2001-04-27 12:02:33 +02:00
|
|
|
}
|
2001-06-24 04:18:47 +02:00
|
|
|
unset($theme_to_load);
|
2001-02-08 01:49:34 +01:00
|
|
|
|
2001-02-07 21:22:17 +01:00
|
|
|
/*************************************************************************\
|
|
|
|
* If they are using frames, we need to set some variables *
|
|
|
|
\*************************************************************************/
|
2001-05-14 05:54:40 +02:00
|
|
|
if (((isset($phpgw_info['user']['preferences']['common']['useframes']) &&
|
2001-06-13 08:27:06 +02:00
|
|
|
$phpgw_info['user']['preferences']['common']['useframes']) &&
|
|
|
|
$phpgw_info['server']['useframes'] == 'allowed') ||
|
|
|
|
($phpgw_info['server']['useframes'] == 'always'))
|
|
|
|
{
|
|
|
|
$phpgw_info['flags']['navbar_target'] = 'phpgw_body';
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************\
|
|
|
|
* Verify that the users session is still active otherwise kick them out *
|
|
|
|
\*************************************************************************/
|
2001-06-13 08:27:06 +02:00
|
|
|
if ($phpgw_info['flags']['currentapp'] != 'home' &&
|
|
|
|
$phpgw_info['flags']['currentapp'] != 'preferences' &&
|
|
|
|
$phpgw_info['flags']['currentapp'] != 'about')
|
|
|
|
{
|
2001-06-23 07:28:03 +02:00
|
|
|
// This will need to use ACL in the future
|
2001-07-10 05:51:14 +02:00
|
|
|
if (! $phpgw_info['user']['apps'][$phpgw_info['flags']['currentapp']] || (@$phpgw_info['flags']['admin_only'] && ! $phpgw_info['user']['apps']['admin']))
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
2001-02-07 21:22:17 +01:00
|
|
|
$phpgw->common->phpgw_header();
|
2001-06-23 07:28:03 +02:00
|
|
|
if ($phpgw_info['flags']['noheader'])
|
|
|
|
{
|
|
|
|
echo parse_navbar();
|
|
|
|
}
|
|
|
|
|
2001-06-13 08:27:06 +02:00
|
|
|
echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
|
2001-02-08 07:10:36 +01:00
|
|
|
$phpgw->common->phpgw_exit(True);
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************\
|
|
|
|
* Load the header unless the developer turns it off *
|
|
|
|
\*************************************************************************/
|
2001-07-22 01:29:07 +02:00
|
|
|
if (!@$phpgw_info['flags']['noheader'])
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
2001-02-07 21:22:17 +01:00
|
|
|
$phpgw->common->phpgw_header();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************\
|
|
|
|
* Load the app include files if the exists *
|
|
|
|
\*************************************************************************/
|
|
|
|
/* Then the include file */
|
2001-07-22 01:29:07 +02:00
|
|
|
if (! preg_match ("/phpgwapi/i", PHPGW_APP_INC) && file_exists(PHPGW_APP_INC . '/functions.inc.php') && !isset($menuaction))
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
|
|
|
include(PHPGW_APP_INC . '/functions.inc.php');
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
2001-07-22 01:29:07 +02:00
|
|
|
if (!@$phpgw_info['flags']['noheader'] &&
|
|
|
|
!@$phpgw_info['flags']['noappheader'] &&
|
|
|
|
file_exists(PHPGW_APP_INC . '/header.inc.php') && !isset($menuaction))
|
2001-06-13 08:27:06 +02:00
|
|
|
{
|
|
|
|
include(PHPGW_APP_INC . '/header.inc.php');
|
2001-02-07 21:22:17 +01:00
|
|
|
}
|
|
|
|
}
|
2001-03-19 21:25:04 +01:00
|
|
|
|
2001-05-06 18:37:40 +02:00
|
|
|
error_reporting(E_ERROR | E_WARNING | E_PARSE);
|
2001-04-03 05:26:59 +02:00
|
|
|
|