2001-01-11 20:41:38 +01:00
< ? php
2001-09-06 21:23:56 +02: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 *
2002-05-06 11:05:44 +02:00
* Copyright ( C ) 2000 , 2001 , 2002 Dan Kuykendall *
2001-09-06 21:23:56 +02:00
* -------------------------------------------------------------------------*
* 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 *
\ **************************************************************************/
2001-08-08 16:03:20 +02:00
2001-09-06 10:27:22 +02:00
/* $Id$ */
2001-08-08 16:03:20 +02:00
2001-09-06 10:27:22 +02:00
/**************************************************************************** \
* If running in PHP3 , then load up the support functions file for *
* transparent support . *
\ ****************************************************************************/
2001-08-16 08:32:22 +02:00
2001-09-06 10:27:22 +02:00
if ( floor ( phpversion ()) == 3 )
{
2001-08-16 08:32:22 +02:00
include ( PHPGW_API_INC . '/php3_support_functions.inc.php' );
2001-09-06 10:27:22 +02:00
}
2001-08-16 08:32:22 +02:00
2002-03-01 13:31:50 +01:00
include ( PHPGW_API_INC . '/common_functions.inc.php' );
2002-02-12 10:10:40 +01:00
2001-08-08 16:03:20 +02:00
/*!
@ function lang
@ abstract function to handle multilanguage support
2001-09-06 10:27:22 +02:00
*/
2001-08-08 16:03:20 +02:00
function lang ( $key , $m1 = '' , $m2 = '' , $m3 = '' , $m4 = '' , $m5 = '' , $m6 = '' , $m7 = '' , $m8 = '' , $m9 = '' , $m10 = '' )
{
2001-09-06 21:23:56 +02:00
if ( is_array ( $m1 ))
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$vars = $m1 ;
2001-08-08 02:13:00 +02:00
}
else
{
2001-08-08 16:03:20 +02:00
$vars = array ( $m1 , $m2 , $m3 , $m4 , $m5 , $m6 , $m7 , $m8 , $m9 , $m10 );
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
$value = $GLOBALS [ 'phpgw' ] -> translation -> translate ( " $key " , $vars );
return $value ;
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
2001-09-06 10:27:22 +02:00
/* Just a temp wrapper. ###DELETE_ME#### (Seek3r) */
2001-08-08 16:03:20 +02:00
function check_code ( $code )
{
return $GLOBALS [ 'phpgw' ] -> common -> check_code ( $code );
}
2001-12-23 11:15:40 +01:00
/*!
@ collection_end direct functions
*/
2001-08-08 16:03:20 +02:00
// print_debug('core functions are done');
/**************************************************************************** \
* Quick verification of sane environment *
\ ****************************************************************************/
// error_reporting(7);
2001-09-06 10:27:22 +02:00
/* Make sure the header.inc.php is current. */
2001-08-08 16:03:20 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'versions' ][ 'header' ] < $GLOBALS [ '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 ;
}
2001-09-06 10:27:22 +02:00
/* Make sure the developer is following the rules. */
2001-08-08 16:03:20 +02:00
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ]))
2001-08-08 02:13:00 +02:00
{
2001-08-21 20:34:56 +02:00
/* This object does not exist yet. */
/* $GLOBALS['phpgw']->log->write(array('text'=>'W-MissingFlags, currentapp flag not set'));*/
2001-08-08 16:03:20 +02:00
2001-12-29 19:02:51 +01:00
echo '<b>!!! YOU DO NOT HAVE YOUR $GLOBALS[\'phpgw_info\'][\'flags\'][\'currentapp\'] SET !!!' ;
2001-08-08 16:03:20 +02:00
echo '<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>' ;
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
magic_quotes_runtime ( false );
2002-02-14 08:29:26 +01:00
@ print_debug ( 'sane environment' , 'messageonly' , 'api' );
2001-08-08 16:03:20 +02:00
/**************************************************************************** \
* Multi - Domain support *
\ ****************************************************************************/
/* make them fix their header */
if ( ! isset ( $GLOBALS [ 'phpgw_domain' ]))
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>' ;
exit ;
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
reset ( $GLOBALS [ 'phpgw_domain' ]);
$default_domain = each ( $GLOBALS [ 'phpgw_domain' ]);
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ] = $default_domain [ 0 ];
unset ( $default_domain ); // we kill this for security reasons
2002-04-30 05:35:52 +02:00
$GLOBALS [ 'login' ] = get_var ( 'login' , Array ( 'POST' ));
$GLOBALS [ 'logindomain' ] = get_var ( 'logindomain' , Array ( 'POST' ));
2001-09-06 10:27:22 +02:00
2001-08-08 16:03:20 +02:00
/* This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode. */
2002-03-26 05:37:03 +01:00
if ( isset ( $domain ) && $domain )
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ] = $domain ;
}
2001-09-06 10:27:22 +02:00
elseif ( isset ( $GLOBALS [ 'login' ]) && isset ( $GLOBALS [ 'logindomain' ]))
2001-08-08 16:03:20 +02:00
{
2001-09-06 10:27:22 +02:00
if ( ! ereg ( " \ @ " , $GLOBALS [ 'login' ]))
2001-08-08 02:13:00 +02:00
{
2001-09-06 10:27:22 +02:00
$GLOBALS [ 'login' ] = $GLOBALS [ 'login' ] . '@' . $GLOBALS [ 'logindomain' ];
2001-08-08 02:13:00 +02:00
}
2001-09-06 10:27:22 +02:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ] = $GLOBALS [ 'logindomain' ];
unset ( $GLOBALS [ 'logindomain' ]);
2001-08-08 02:13:00 +02:00
}
2001-09-06 10:27:22 +02:00
elseif ( isset ( $GLOBALS [ 'login' ]) && ! isset ( $GLOBALS [ 'logindomain' ]))
2001-08-08 02:13:00 +02:00
{
2001-09-06 10:27:22 +02:00
if ( ereg ( " \ @ " , $GLOBALS [ 'login' ]))
2001-08-08 02:13:00 +02:00
{
2001-09-06 10:27:22 +02:00
$login_array = explode ( '@' , $GLOBALS [ 'login' ]);
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ] = $login_array [ 1 ];
2001-08-08 02:13:00 +02:00
}
else
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ];
2001-09-06 10:27:22 +02:00
$GLOBALS [ 'login' ] = $GLOBALS [ 'login' ] . '@' . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ];
2001-08-08 02:13:00 +02:00
}
}
2001-08-08 16:03:20 +02:00
if ( @ isset ( $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ]]))
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_host' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ]][ 'db_host' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_name' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ]][ 'db_name' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_user' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ]][ 'db_user' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_pass' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ]][ 'db_pass' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_type' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ]][ 'db_type' ];
2001-08-08 02:13:00 +02:00
}
else
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_host' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ]][ 'db_host' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_name' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ]][ 'db_name' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_user' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ]][ 'db_user' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_pass' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ]][ 'db_pass' ];
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_type' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ]][ 'db_type' ];
2001-08-08 02:13:00 +02:00
}
2001-08-07 18:02:55 +02:00
2001-08-08 16:03:20 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'login' && ! $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'show_domain_selectbox' ])
2001-08-08 02:13:00 +02:00
{
2001-09-06 10:27:22 +02:00
unset ( $GLOBALS [ 'phpgw_domain' ]); // we kill this for security reasons
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
unset ( $domain ); // we kill this to save memory
2002-02-14 08:29:26 +01:00
@ print_debug ( 'domain' , $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'domain' ], 'api' );
2001-08-08 16:03:20 +02:00
/**************************************************************************** \
* These lines load up the API , fill up the $phpgw_info array , etc *
\ ****************************************************************************/
/* Load main class */
$GLOBALS [ 'phpgw' ] = CreateObject ( 'phpgwapi.phpgw' );
/************************************************************************ \
* Load up the main instance of the db class . *
\ ************************************************************************/
$GLOBALS [ 'phpgw' ] -> db = CreateObject ( 'phpgwapi.db' );
$GLOBALS [ 'phpgw' ] -> db -> Host = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_host' ];
$GLOBALS [ 'phpgw' ] -> db -> Type = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_type' ];
$GLOBALS [ 'phpgw' ] -> db -> Database = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_name' ];
$GLOBALS [ 'phpgw' ] -> db -> User = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_user' ];
$GLOBALS [ 'phpgw' ] -> db -> Password = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_pass' ];
if ( $GLOBALS [ 'phpgw' ] -> debug )
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> db -> Debug = 1 ;
2001-08-08 02:13:00 +02:00
}
2001-08-07 18:02:55 +02:00
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> db -> Halt_On_Error = 'no' ;
2001-08-15 04:14:18 +02:00
@ $GLOBALS [ 'phpgw' ] -> db -> query ( " select count(config_name) from phpgw_config " );
2001-08-08 16:03:20 +02:00
if ( ! @ $GLOBALS [ 'phpgw' ] -> db -> next_record ())
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$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 '
. 'phpGroupWare. Click <a href="' . $setup_dir . '">here</a> to run setup.</center>' ;
exit ;
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> db -> Halt_On_Error = 'yes' ;
/* Fill phpgw_info["server"] array */
// An Attempt to speed things up using cache premise
$GLOBALS [ 'phpgw' ] -> db -> query ( " select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info' " , __LINE__ , __FILE__ );
if ( $GLOBALS [ 'phpgw' ] -> db -> num_rows ())
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> db -> next_record ();
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'cache_phpgw_info' ] = stripslashes ( $GLOBALS [ 'phpgw' ] -> db -> f ( 'config_value' ));
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
$cache_query = " select content from phpgw_app_sessions where "
. " sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config' " ;
$GLOBALS [ 'phpgw' ] -> db -> query ( $cache_query , __LINE__ , __FILE__ );
$server_info_cache = $GLOBALS [ 'phpgw' ] -> db -> num_rows ();
if ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'cache_phpgw_info' ] && $server_info_cache )
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> db -> next_record ();
$GLOBALS [ 'phpgw_info' ][ 'server' ] = unserialize ( stripslashes ( $GLOBALS [ 'phpgw' ] -> db -> f ( 'content' )));
2001-08-08 02:13:00 +02:00
}
else
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( " select * from phpgw_config WHERE config_app='phpgwapi' " , __LINE__ , __FILE__ );
while ( $GLOBALS [ 'phpgw' ] -> db -> next_record ())
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ $GLOBALS [ 'phpgw' ] -> db -> f ( 'config_name' )] = stripslashes ( $GLOBALS [ 'phpgw' ] -> db -> f ( 'config_value' ));
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
2001-09-06 21:23:56 +02:00
if ( @ isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'cache_phpgw_info' ]))
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
if ( $server_info_cache )
{
2002-01-13 05:06:40 +01:00
$cache_query = " DELETE FROM phpgw_app_sessions WHERE sessionid='0' and loginid='0' and app='phpgwapi' and location='config' " ;
$GLOBALS [ 'phpgw' ] -> db -> query ( $cache_query , __LINE__ , __FILE__ );
2001-08-08 16:03:20 +02:00
}
2002-01-13 05:06:40 +01:00
$cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
. " '0','0','phpgwapi','config',' " . addslashes ( serialize ( $GLOBALS [ 'phpgw_info' ][ 'server' ])) . " ') " ;
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> db -> query ( $cache_query , __LINE__ , __FILE__ );
2001-08-08 02:13:00 +02:00
}
}
2001-08-08 16:03:20 +02:00
unset ( $cache_query );
unset ( $server_info_cache );
2002-01-13 05:06:40 +01:00
if ( @ isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'enforce_ssl' ]) && ! $HTTPS )
{
Header ( 'Location: https://' . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'hostname' ] . $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] . $REQUEST_URI );
exit ;
}
2001-09-06 10:27:22 +02:00
/************************************************************************ \
* Required classes *
\ ************************************************************************/
2001-08-11 16:49:12 +02:00
$GLOBALS [ 'phpgw' ] -> log = CreateObject ( 'phpgwapi.errorlog' );
2001-09-06 21:23:56 +02:00
$GLOBALS [ 'phpgw' ] -> translation = CreateObject ( 'phpgwapi.translation' );
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> common = CreateObject ( 'phpgwapi.common' );
$GLOBALS [ 'phpgw' ] -> hooks = CreateObject ( 'phpgwapi.hooks' );
$GLOBALS [ 'phpgw' ] -> auth = CreateObject ( 'phpgwapi.auth' );
$GLOBALS [ 'phpgw' ] -> accounts = CreateObject ( 'phpgwapi.accounts' );
$GLOBALS [ 'phpgw' ] -> acl = CreateObject ( 'phpgwapi.acl' );
$GLOBALS [ 'phpgw' ] -> session = CreateObject ( 'phpgwapi.sessions' );
$GLOBALS [ 'phpgw' ] -> preferences = CreateObject ( 'phpgwapi.preferences' );
$GLOBALS [ 'phpgw' ] -> applications = CreateObject ( 'phpgwapi.applications' );
2002-02-14 08:29:26 +01:00
print_debug ( 'main class loaded' , 'messageonly' , 'api' );
2001-09-04 06:52:47 +02:00
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'included_classes' ][ 'error' ]) ||
! $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'included_classes' ][ 'error' ])
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
include ( PHPGW_INCLUDE_ROOT . '/phpgwapi/inc/class.error.inc.php' );
2001-09-04 06:52:47 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'included_classes' ][ 'error' ] = True ;
2001-08-08 16:03:20 +02:00
}
2001-09-06 10:27:22 +02:00
/**************************************************************************** \
* This is a global constant that should be used *
* instead of / or \ in file paths *
\ ****************************************************************************/
2001-08-08 16:03:20 +02:00
define ( 'SEP' , filesystem_separator ());
2001-08-23 06:32:15 +02:00
/***************************************************************************** \
* ACL defines - moved here to work for xml - rpc / soap , also *
\ *****************************************************************************/
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 );
2002-01-10 19:18:44 +01:00
define ( 'PHPGW_ACL_GROUP_MANAGERS' , 32 );
2001-08-23 06:32:15 +02:00
2001-09-06 10:27:22 +02:00
/**************************************************************************** \
* Stuff to use if logging in or logging out *
\ ****************************************************************************/
2001-08-08 16:03:20 +02:00
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'login' || $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'logout' )
{
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] == 'login' )
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
if ( @ $login != '' )
{
$login_array = explode ( " @ " , $login );
2002-02-16 04:58:03 +01:00
print_debug ( 'LID : ' . $login_array [ 0 ], 'messageonly' , 'api' );
2001-08-08 16:03:20 +02:00
$login_id = $GLOBALS [ 'phpgw' ] -> accounts -> name2id ( $login_array [ 0 ]);
2002-02-16 04:58:03 +01:00
print_debug ( 'User ID : ' . $login_id , 'messageonly' , 'api' );
2001-08-08 16:03:20 +02:00
$GLOBALS [ 'phpgw' ] -> accounts -> accounts ( $login_id );
$GLOBALS [ 'phpgw' ] -> preferences -> preferences ( $login_id );
}
2001-08-08 02:13:00 +02:00
}
2001-09-06 10:27:22 +02:00
/************************************************************************** \
* Everything from this point on will ONLY happen if *
* the currentapp is not login or logout *
\ **************************************************************************/
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
else
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
if ( ! $GLOBALS [ 'phpgw' ] -> session -> verify ())
{
Header ( 'Location: ' . $GLOBALS [ 'phpgw' ] -> redirect ( $GLOBALS [ 'phpgw' ] -> session -> link ( '/login.php' , 'cd=10' )));
exit ;
}
2001-08-07 18:02:55 +02:00
2002-04-30 05:35:52 +02:00
$GLOBALS [ 'phpgw' ] -> datetime = CreateObject ( 'phpgwapi.datetime' );
2001-08-08 16:03:20 +02:00
/* A few hacker resistant constants that will be used throught the program */
define ( 'PHPGW_TEMPLATE_DIR' , ExecMethod ( 'phpgwapi.phpgw.common.get_tpl_dir' , 'phpgwapi' ));
define ( 'PHPGW_IMAGES_DIR' , ExecMethod ( 'phpgwapi.phpgw.common.get_image_path' , 'phpgwapi' ));
define ( 'PHPGW_IMAGES_FILEDIR' , ExecMethod ( 'phpgwapi.phpgw.common.get_image_dir' , 'phpgwapi' ));
define ( 'PHPGW_APP_ROOT' , ExecMethod ( 'phpgwapi.phpgw.common.get_app_dir' ));
define ( 'PHPGW_APP_INC' , ExecMethod ( 'phpgwapi.phpgw.common.get_inc_dir' ));
define ( 'PHPGW_APP_TPL' , ExecMethod ( 'phpgwapi.phpgw.common.get_tpl_dir' ));
define ( 'PHPGW_IMAGES' , ExecMethod ( 'phpgwapi.phpgw.common.get_image_path' ));
define ( 'PHPGW_APP_IMAGES_DIR' , ExecMethod ( 'phpgwapi.phpgw.common.get_image_dir' ));
2001-08-23 06:32:15 +02:00
/* define('PHPGW_APP_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_dir()); */
2001-08-08 16:03:20 +02:00
2001-08-23 06:32:15 +02:00
/* Moved outside of this logic
2001-08-08 16:03:20 +02: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-08-23 06:32:15 +02:00
*/
2001-08-08 16:03:20 +02:00
2002-04-30 05:35:52 +02:00
/******* Define the GLOBALS['MENUACTION'] *******/
define ( 'MENUACTION' , get_var ( 'menuaction' , Array ( 'GET' )));
2001-08-08 16:03:20 +02:00
/********* This sets the user variables *********/
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'private_dir' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'files_dir' ]
. '/users/' . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'userid' ];
/* This will make sure that a user has the basic default prefs. If not it will add them */
$GLOBALS [ 'phpgw' ] -> preferences -> verify_basic_settings ();
/********* Optional classes, which can be disabled for performance increases *********/
while ( $phpgw_class_name = each ( $GLOBALS [ 'phpgw_info' ][ 'flags' ]))
2001-08-08 02:13:00 +02:00
{
2001-08-08 16:03:20 +02:00
if ( ereg ( 'enable_' , $phpgw_class_name [ 0 ]))
{
$enable_class = str_replace ( 'enable_' , '' , $phpgw_class_name [ 0 ]);
$enable_class = str_replace ( '_class' , '' , $enable_class );
eval ( '$GLOBALS["phpgw"]->' . $enable_class . ' = createobject(\'phpgwapi.' . $enable_class . '\');' );
}
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
unset ( $enable_class );
reset ( $GLOBALS [ 'phpgw_info' ][ 'flags' ]);
2001-08-07 18:02:55 +02:00
2001-08-08 16:03:20 +02:00
/************************************************************************* \
2002-05-23 23:28:59 +02:00
* These lines load up the themes and CSS data *
2001-08-08 16:03:20 +02:00
\ *************************************************************************/
if ( ! $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ])
{
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ] == 'user_choice' )
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = 'default' ;
}
else
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'template_set' ];
}
}
if ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_theme' ] == 'user_choice' )
2001-08-08 02:13:00 +02:00
{
2001-12-29 09:53:28 +01:00
if ( ! isset ( $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ]))
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = 'default' ;
}
2001-08-08 02:13:00 +02:00
}
else
{
2001-12-29 09:53:28 +01:00
if ( isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_theme' ]))
{
$GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] = $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'force_theme' ];
}
2001-08-08 02:13:00 +02:00
}
2001-12-29 09:53:28 +01:00
if ( @ file_exists ( PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] . '.theme' ))
2001-08-08 16:03:20 +02:00
{
2001-12-29 09:53:28 +01:00
include ( PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'preferences' ][ 'common' ][ 'theme' ] . '.theme' );
2001-08-08 16:03:20 +02:00
}
elseif ( @ file_exists ( PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme' ))
{
include ( PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme' );
}
else
{
/* 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">' ;
2001-09-06 10:27:22 +02:00
$GLOBALS [ 'phpgw' ] -> log -> write ( array ( 'text' => 'F-Abort, No themes found' ));
2001-08-07 18:02:55 +02:00
2001-08-08 16:03:20 +02:00
exit ;
}
2002-05-23 23:28:59 +02:00
if ( isset ( $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'hovlink' ])
&& ( $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'hovlink' ] != '' ))
{
2002-05-24 12:38:03 +02:00
$phpgw_info [ 'theme' ][ 'css' ][ 'A:hover' ] = 'text-decoration:none; color: ' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'hovlink' ] . ';' ;
2002-05-23 23:28:59 +02:00
}
2002-05-24 12:38:03 +02:00
$phpgw_info [ 'theme' ][ 'css' ][ 'A' ] = 'text-decoration:none;' ;
$phpgw_info [ 'theme' ][ 'css' ][ 'A:link' ] = 'text-decoration:none; color: ' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'link' ] . ';' ;
$phpgw_info [ 'theme' ][ 'css' ][ 'A:visited' ] = 'text-decoration:none; color: ' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'vlink' ] . ';' ;
$phpgw_info [ 'theme' ][ 'css' ][ 'A:active' ] = 'text-decoration:none; color: ' . $GLOBALS [ 'phpgw_info' ][ 'theme' ][ 'alink' ] . ';' ;
2002-05-23 23:28:59 +02:00
2002-05-24 12:38:03 +02:00
if ( @ file_exists ( PHPGW_TEMPLATE_DIR . '/css.inc.php' ))
2002-05-23 23:28:59 +02:00
{
2002-05-24 12:38:03 +02:00
include ( PHPGW_TEMPLATE_DIR . '/css.inc.php' );
}
if ( @ file_exists ( PHPGW_APP_TPL . '/css.inc.php' ))
{
include ( PHPGW_APP_TPL . '/css.inc.php' );
2002-05-23 23:28:59 +02:00
}
2001-08-08 16:03:20 +02:00
unset ( $theme_to_load );
2002-05-23 23:28:59 +02:00
/************************************************************************* \
* These lines load up the templates class *
\ *************************************************************************/
if ( !@ $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'disable_Template_class' ])
{
$GLOBALS [ 'phpgw' ] -> template = CreateObject ( 'phpgwapi.Template' , PHPGW_APP_TPL );
}
2001-08-08 16:03:20 +02:00
/************************************************************************* \
* Verify that the users session is still active otherwise kick them out *
\ *************************************************************************/
if ( $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'home' &&
2001-08-08 02:13:00 +02:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'preferences' &&
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ] != 'about' )
{
2001-08-08 16:03:20 +02:00
// This will need to use ACL in the future
if ( ! $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ]] ||
( @ $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'admin_only' ] &&
! $GLOBALS [ 'phpgw_info' ][ 'user' ][ 'apps' ][ 'admin' ]))
2001-08-08 02:13:00 +02:00
{
2002-05-24 12:38:03 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ( False , False );
2001-08-08 02:13:00 +02:00
2001-09-06 10:27:22 +02:00
$GLOBALS [ 'phpgw' ] -> log -> write ( array ( 'text' => 'W-Permissions, Attempted to access %1' , 'p1' => $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'currentapp' ]));
2001-08-08 02:13:00 +02:00
2001-08-08 16:03:20 +02:00
echo '<p><center><b>' . lang ( 'Access not permitted' ) . '</b></center>' ;
$GLOBALS [ 'phpgw' ] -> common -> phpgw_exit ( True );
}
2001-08-08 02:13:00 +02:00
}
2001-08-07 18:02:55 +02:00
2001-08-08 16:03:20 +02:00
/************************************************************************* \
* Load the header unless the developer turns it off *
\ *************************************************************************/
2002-05-24 12:38:03 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_header ( False , False );
2001-08-07 18:02:55 +02:00
2001-08-08 16:03:20 +02:00
/************************************************************************* \
* Load the app include files if the exists *
\ *************************************************************************/
/* Then the include file */
2002-04-30 05:35:52 +02:00
if ( ! preg_match ( " /phpgwapi/i " , PHPGW_APP_INC ) && file_exists ( PHPGW_APP_INC . '/functions.inc.php' ) && ! MENUACTION )
2001-08-08 16:03:20 +02:00
{
include ( PHPGW_APP_INC . '/functions.inc.php' );
}
2002-05-24 12:38:03 +02:00
if ( !@ $GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noappheader' ])
2001-08-08 16:03:20 +02:00
{
2002-05-24 12:38:03 +02:00
$GLOBALS [ 'phpgw' ] -> common -> phpgw_appheader ();
2001-08-08 16:03:20 +02:00
}
2001-08-08 02:13:00 +02:00
}
2001-08-08 16:03:20 +02:00
error_reporting ( E_ERROR | E_WARNING | E_PARSE );