fixed my formatting nightmare

This commit is contained in:
seek3r 2001-08-08 00:13:00 +00:00
parent b51bb7b055
commit eee5228676

View File

@ -41,47 +41,47 @@
@param $p1-$p16 class parameters (all optional) @param $p1-$p16 class parameters (all optional)
*/ */
function CreateObject($class, function CreateObject($class,
$p1='_UNDEF_',$p2='_UNDEF_',$p3='_UNDEF_',$p4='_UNDEF_', $p1='_UNDEF_',$p2='_UNDEF_',$p3='_UNDEF_',$p4='_UNDEF_',
$p5='_UNDEF_',$p6='_UNDEF_',$p7='_UNDEF_',$p8='_UNDEF_', $p5='_UNDEF_',$p6='_UNDEF_',$p7='_UNDEF_',$p8='_UNDEF_',
$p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_', $p9='_UNDEF_',$p10='_UNDEF_',$p11='_UNDEF_',$p12='_UNDEF_',
$p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_') $p13='_UNDEF_',$p14='_UNDEF_',$p15='_UNDEF_',$p16='_UNDEF_')
{ {
global $phpgw_info; global $phpgw_info;
/* error_reporting(0); */ /* error_reporting(0); */
list($appname,$classname) = explode(".", $class); list($appname,$classname) = explode(".", $class);
if (!isset($GLOBALS['phpgw_info']['flags']['included_classes'][$classname]) || if (!isset($GLOBALS['phpgw_info']['flags']['included_classes'][$classname]) ||
!$GLOBALS['phpgw_info']['flags']['included_classes'][$classname]) !$GLOBALS['phpgw_info']['flags']['included_classes'][$classname])
{ {
$GLOBALS['phpgw_info']['flags']['included_classes'][$classname] = True; $GLOBALS['phpgw_info']['flags']['included_classes'][$classname] = True;
include(PHPGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php'); include(PHPGW_INCLUDE_ROOT.'/'.$appname.'/inc/class.'.$classname.'.inc.php');
} }
if ($p1 == '_UNDEF_') if ($p1 == '_UNDEF_')
{ {
eval('$obj = new '.$classname.';'); eval('$obj = new '.$classname.';');
} }
else else
{ {
$input = array($p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9,$p10,$p11,$p12,$p13,$p14,$p15,$p16); $input = array($p1,$p2,$p3,$p4,$p5,$p6,$p7,$p8,$p9,$p10,$p11,$p12,$p13,$p14,$p15,$p16);
$i = 1; $i = 1;
$code = '$obj = new '.$classname.'('; $code = '$obj = new '.$classname.'(';
while (list($x,$test) = each($input)) while (list($x,$test) = each($input))
{ {
if ($test == '_UNDEF_' || $i == 17) if ($test == '_UNDEF_' || $i == 17)
{ {
break; break;
} }
else else
{ {
$code .= '$p' . $i . ','; $code .= '$p' . $i . ',';
} }
$i++; $i++;
} }
$code = substr($code,0,-1) . ');'; $code = substr($code,0,-1) . ');';
eval($code); eval($code);
} }
/* error_reporting(E_ERROR | E_WARNING | E_PARSE); */ /* error_reporting(E_ERROR | E_WARNING | E_PARSE); */
return $obj; return $obj;
} }
/*! /*!
@ -100,94 +100,94 @@ function CreateObject($class,
function ExecMethod($method, $functionparams = '_UNDEF_', $loglevel = 3, $classparams = '_UNDEF_') function ExecMethod($method, $functionparams = '_UNDEF_', $loglevel = 3, $classparams = '_UNDEF_')
{ {
/* Need to make sure this is working against a single dimensional object */ /* Need to make sure this is working against a single dimensional object */
$partscount = substr_count($method, '.'); $partscount = substr_count($method, '.');
if ($partscount == 2) if ($partscount == 2)
{ {
list($appname,$classname,$functionname) = explode(".", $method); list($appname,$classname,$functionname) = explode(".", $method);
if (!is_object($GLOBALS[$classname])) if (!is_object($GLOBALS[$classname]))
{ {
if ($classparams != '_UNDEF_' && $classparams != True) if ($classparams != '_UNDEF_' && $classparams != True)
{ {
$GLOBALS[$classname] = CreateObject($appname.'.'.$classname, $classparams); $GLOBALS[$classname] = CreateObject($appname.'.'.$classname, $classparams);
} }
else else
{ {
$GLOBALS[$classname] = CreateObject($appname.'.'.$classname); $GLOBALS[$classname] = CreateObject($appname.'.'.$classname);
} }
} }
if ($functionparams != '_UNDEF_' && $functionparams != True) if ($functionparams != '_UNDEF_' && $functionparams != True)
{ {
return $GLOBALS[$classname]->$functionname($functionparams); return $GLOBALS[$classname]->$functionname($functionparams);
} }
else else
{ {
return $GLOBALS[$classname]->$functionname(); return $GLOBALS[$classname]->$functionname();
} }
} }
/* if the $method includes a parent class (multi-dimensional) then we have to work from it */ /* if the $method includes a parent class (multi-dimensional) then we have to work from it */
elseif ($partscount >= 3) elseif ($partscount >= 3)
{ {
$GLOBALS['methodparts'] = explode(".", $method); $GLOBALS['methodparts'] = explode(".", $method);
$classpartnum = $partscount - 1; $classpartnum = $partscount - 1;
$appname = $GLOBALS['methodparts'][0]; $appname = $GLOBALS['methodparts'][0];
$classname = $GLOBALS['methodparts'][$classpartnum]; $classname = $GLOBALS['methodparts'][$classpartnum];
$functionname = $GLOBALS['methodparts'][$partscount]; $functionname = $GLOBALS['methodparts'][$partscount];
/* Now I clear these out of the array so that I can do a proper */ /* Now I clear these out of the array so that I can do a proper */
/* loop and build the $parentobject */ /* loop and build the $parentobject */
unset ($GLOBALS['methodparts'][0]); unset ($GLOBALS['methodparts'][0]);
unset ($GLOBALS['methodparts'][$classpartnum]); unset ($GLOBALS['methodparts'][$classpartnum]);
unset ($GLOBALS['methodparts'][$partscount]); unset ($GLOBALS['methodparts'][$partscount]);
reset ($GLOBALS['methodparts']); reset ($GLOBALS['methodparts']);
$firstparent = 'True'; $firstparent = 'True';
while (list ($key, $val) = each ($GLOBALS['methodparts'])) while (list ($key, $val) = each ($GLOBALS['methodparts']))
{ {
if ($firstparent == 'True') if ($firstparent == 'True')
{ {
$parentobject = '$GLOBALS["'.$val.'"]'; $parentobject = '$GLOBALS["'.$val.'"]';
$firstparent = False; $firstparent = False;
} }
else else
{ {
$parentobject .= '->'.$val; $parentobject .= '->'.$val;
} }
} }
unset($GLOBALS['methodparts']); unset($GLOBALS['methodparts']);
eval ('$isobject = is_object('.$parentobject.'->'.$classname.');'); eval ('$isobject = is_object('.$parentobject.'->'.$classname.');');
if (!$isobject) if (!$isobject)
{ {
if ($classparams != '_UNDEF_') if ($classparams != '_UNDEF_')
{ {
if (is_string($classparams)) if (is_string($classparams))
{ {
eval($parentobject.'->'.$classname.' = CreateObject("'.$appname.'.'.$classname.'", "'.$classparams.'");'); eval($parentobject.'->'.$classname.' = CreateObject("'.$appname.'.'.$classname.'", "'.$classparams.'");');
} }
else else
{ {
eval($parentobject.'->'.$classname.' = CreateObject("'.$appname.'.'.$classname.'", '.$classparams.');'); eval($parentobject.'->'.$classname.' = CreateObject("'.$appname.'.'.$classname.'", '.$classparams.');');
} }
} }
else else
{ {
eval($parentobject.'->'.$classname.' = CreateObject("'.$appname.'.'.$classname.'");'); eval($parentobject.'->'.$classname.' = CreateObject("'.$appname.'.'.$classname.'");');
} }
} }
if ($functionparams != '_UNDEF_') if ($functionparams != '_UNDEF_')
{ {
eval('$returnval = '.$parentobject.'->'.$classname.'->'.$functionname.'('.$functionparams.');'); eval('$returnval = '.$parentobject.'->'.$classname.'->'.$functionname.'('.$functionparams.');');
return $returnval; return $returnval;
} }
else else
{ {
eval('$returnval = '.$parentobject.'->'.$classname.'->'.$functionname.'();'); eval('$returnval = '.$parentobject.'->'.$classname.'->'.$functionname.'();');
return $returnval; return $returnval;
} }
} }
else else
{ {
return 'error in parts'; return 'error in parts';
} }
} }
/*! /*!
@function lang @function lang
@ -195,22 +195,22 @@ function ExecMethod($method, $functionparams = '_UNDEF_', $loglevel = 3, $classp
*/ */
function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='') function lang($key,$m1='',$m2='',$m3='',$m4='',$m5='',$m6='',$m7='',$m8='',$m9='',$m10='')
{ {
if(gettype($m1) == 'array') if(gettype($m1) == 'array')
{ {
$vars = $m1; $vars = $m1;
} }
else else
{ {
$vars = array($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10); $vars = array($m1,$m2,$m3,$m4,$m5,$m6,$m7,$m8,$m9,$m10);
} }
$value = $GLOBALS['phpgw']->translation->translate("$key",$vars); $value = $GLOBALS['phpgw']->translation->translate("$key",$vars);
return $value; return $value;
} }
/* Just a temp wrapper. ###DELETE_ME#### (Seek3r) */ /* Just a temp wrapper. ###DELETE_ME#### (Seek3r) */
function check_code($code) function check_code($code)
{ {
return $GLOBALS['phpgw']->common->check_code($code); return $GLOBALS['phpgw']->common->check_code($code);
} }
/*! /*!
@ -227,33 +227,33 @@ function check_code($code)
*/ */
function get_account_id($account_id = '',$default_id = '') function get_account_id($account_id = '',$default_id = '')
{ {
if (gettype($account_id) == 'integer') if (gettype($account_id) == 'integer')
{ {
return $account_id; return $account_id;
} }
elseif ($account_id == '') elseif ($account_id == '')
{ {
if ($default_id == '') if ($default_id == '')
{ {
return (isset($GLOBALS['phpgw_info']['user']['account_id'])?$GLOBALS['phpgw_info']['user']['account_id']:0); return (isset($GLOBALS['phpgw_info']['user']['account_id'])?$GLOBALS['phpgw_info']['user']['account_id']:0);
} }
elseif (gettype($default_id) == 'string') elseif (gettype($default_id) == 'string')
{ {
return $GLOBALS['phpgw']->accounts->name2id($default_id); return $GLOBALS['phpgw']->accounts->name2id($default_id);
} }
return intval($default_id); return intval($default_id);
} }
elseif (gettype($account_id) == 'string') elseif (gettype($account_id) == 'string')
{ {
if($GLOBALS['phpgw']->accounts->exists(intval($account_id)) == True) if($GLOBALS['phpgw']->accounts->exists(intval($account_id)) == True)
{ {
return intval($account_id); return intval($account_id);
} }
else else
{ {
return $GLOBALS['phpgw']->accounts->name2id($account_id); return $GLOBALS['phpgw']->accounts->name2id($account_id);
} }
} }
} }
/*! /*!
@ -263,35 +263,35 @@ function get_account_id($account_id = '',$default_id = '')
*/ */
function filesystem_separator() function filesystem_separator()
{ {
if (PHP_OS == 'Windows' || PHP_OS == 'OS/2') if (PHP_OS == 'Windows' || PHP_OS == 'OS/2')
{ {
return '\\'; return '\\';
} }
else else
{ {
return '/'; return '/';
} }
} }
function _debug_array($array) function _debug_array($array)
{ {
if(floor(phpversion()) == 4) if(floor(phpversion()) == 4)
{ {
echo '<pre>'; print_r($array); echo '</pre>'; echo '<pre>'; print_r($array); echo '</pre>';
} }
else else
{ {
echo '<pre>'; var_dump($array); echo '</pre>'; echo '<pre>'; var_dump($array); echo '</pre>';
} }
} }
function print_debug($text='') function print_debug($text='')
{ {
if (isset($GLOBALS['debugme']) && if (isset($GLOBALS['debugme']) &&
$GLOBALS['debugme'] == 'on') $GLOBALS['debugme'] == 'on')
{ {
echo 'debug: '.$text.'<br>'; echo 'debug: '.$text.'<br>';
} }
} }
// print_debug('core functions are done'); // print_debug('core functions are done');
@ -302,17 +302,17 @@ function print_debug($text='')
/* Make sure the header.inc.php is current. */ /* Make sure the header.inc.php is current. */
if ($GLOBALS['phpgw_info']['server']['versions']['header'] < $GLOBALS['phpgw_info']['server']['versions']['current_header']) 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>'; echo '<center><b>You need to port your settings to the new header.inc.php version.</b></center>';
exit; exit;
} }
/* Make sure the developer is following the rules. */ /* Make sure the developer is following the rules. */
if (!isset($GLOBALS['phpgw_info']['flags']['currentapp'])) if (!isset($GLOBALS['phpgw_info']['flags']['currentapp']))
{ {
$phpgw->log->write(array('text'=>'W-MissingFlags, currentapp flag not set')); $phpgw->log->write(array('text'=>'W-MissingFlags, currentapp flag not set'));
echo '<b>!!! YOU DO NOT HAVE YOUR $phpgw_info["flags"]["currentapp"] SET !!!'; echo '<b>!!! YOU DO NOT HAVE YOUR $phpgw_info["flags"]["currentapp"] SET !!!';
echo '<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>'; echo '<br>!!! PLEASE CORRECT THIS SITUATION !!!</b>';
} }
magic_quotes_runtime(false); magic_quotes_runtime(false);
@ -325,8 +325,8 @@ print_debug('sane environment');
/* make them fix their header */ /* make them fix their header */
if (!isset($GLOBALS['phpgw_domain'])) if (!isset($GLOBALS['phpgw_domain']))
{ {
echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>'; echo '<center><b>The administrator must upgrade the header.inc.php file before you can continue.</b></center>';
exit; exit;
} }
reset($GLOBALS['phpgw_domain']); reset($GLOBALS['phpgw_domain']);
$default_domain = each($GLOBALS['phpgw_domain']); $default_domain = each($GLOBALS['phpgw_domain']);
@ -336,51 +336,51 @@ unset ($default_domain); // we kill this for security reasons
/* This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode. */ /* This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode. */
if (isset($domain)) if (isset($domain))
{ {
$GLOBALS['phpgw_info']['user']['domain'] = $domain; $GLOBALS['phpgw_info']['user']['domain'] = $domain;
} }
elseif (isset($login) && isset($logindomain)) elseif (isset($login) && isset($logindomain))
{ {
if (!ereg ("\@", $login)) if (!ereg ("\@", $login))
{ {
$login = $login."@".$logindomain; $login = $login."@".$logindomain;
} }
$GLOBALS['phpgw_info']['user']['domain'] = $logindomain; $GLOBALS['phpgw_info']['user']['domain'] = $logindomain;
unset ($logindomain); unset ($logindomain);
} }
elseif (isset($login) && !isset($logindomain)) elseif (isset($login) && !isset($logindomain))
{ {
if (ereg ("\@", $login)) if (ereg ("\@", $login))
{ {
$login_array = explode("@", $login); $login_array = explode("@", $login);
$GLOBALS['phpgw_info']['user']['domain'] = $login_array[1]; $GLOBALS['phpgw_info']['user']['domain'] = $login_array[1];
} }
else else
{ {
$GLOBALS['phpgw_info']['user']['domain'] = $GLOBALS['phpgw_info']['server']['default_domain']; $GLOBALS['phpgw_info']['user']['domain'] = $GLOBALS['phpgw_info']['server']['default_domain'];
$login = $login . '@' . $GLOBALS['phpgw_info']['user']['domain']; $login = $login . '@' . $GLOBALS['phpgw_info']['user']['domain'];
} }
} }
if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']])) if (@isset($GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]))
{ {
$GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_host']; $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_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_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_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']; $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['user']['domain']]['db_type'];
} }
else else
{ {
$GLOBALS['phpgw_info']['server']['db_host'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_host']; $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_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_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_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']; $GLOBALS['phpgw_info']['server']['db_type'] = $GLOBALS['phpgw_domain'][$GLOBALS['phpgw_info']['server']['default_domain']]['db_type'];
} }
if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'login' && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox']) if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'login' && ! $GLOBALS['phpgw_info']['server']['show_domain_selectbox'])
{ {
unset ($GLOBALS['phpgw_domain']); // we kill this for security reasons unset ($GLOBALS['phpgw_domain']); // we kill this for security reasons
} }
unset ($domain); // we kill this to save memory unset ($domain); // we kill this to save memory
@ -402,17 +402,17 @@ $GLOBALS['phpgw']->db->User = $GLOBALS['phpgw_info']['server']['db_user'];
$GLOBALS['phpgw']->db->Password = $GLOBALS['phpgw_info']['server']['db_pass']; $GLOBALS['phpgw']->db->Password = $GLOBALS['phpgw_info']['server']['db_pass'];
if ($GLOBALS['phpgw']->debug) if ($GLOBALS['phpgw']->debug)
{ {
$GLOBALS['phpgw']->db->Debug = 1; $GLOBALS['phpgw']->db->Debug = 1;
} }
$GLOBALS['phpgw']->db->Halt_On_Error = 'no'; $GLOBALS['phpgw']->db->Halt_On_Error = 'no';
@$GLOBALS['phpgw']->db->query("select count(*) from phpgw_config"); @$GLOBALS['phpgw']->db->query("select count(*) from phpgw_config");
if (! @$GLOBALS['phpgw']->db->next_record()) if (! @$GLOBALS['phpgw']->db->next_record())
{ {
$setup_dir = ereg_replace($PHP_SELF,'index.php','setup/'); $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 ' 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>'; .'phpGroupWare. Click <a href="' . $setup_dir . '">here</a> to run setup.</center>';
exit; exit;
} }
$GLOBALS['phpgw']->db->Halt_On_Error = 'yes'; $GLOBALS['phpgw']->db->Halt_On_Error = 'yes';
@ -421,43 +421,43 @@ $GLOBALS['phpgw']->db->Halt_On_Error = 'yes';
$GLOBALS['phpgw']->db->query("select config_value from phpgw_config WHERE config_app='phpgwapi' and config_name='cache_phpgw_info'",__LINE__,__FILE__); $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()) if ($GLOBALS['phpgw']->db->num_rows())
{ {
$GLOBALS['phpgw']->db->next_record(); $GLOBALS['phpgw']->db->next_record();
$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] = stripslashes($GLOBALS['phpgw']->db->f('config_value')); $GLOBALS['phpgw_info']['server']['cache_phpgw_info'] = stripslashes($GLOBALS['phpgw']->db->f('config_value'));
} }
$cache_query = "select content from phpgw_app_sessions where" $cache_query = "select content from phpgw_app_sessions where"
." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'"; ." sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__); $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
$server_info_cache = $GLOBALS['phpgw']->db->num_rows(); $server_info_cache = $GLOBALS['phpgw']->db->num_rows();
if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $server_info_cache) if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info'] && $server_info_cache)
{ {
$GLOBALS['phpgw']->db->next_record(); $GLOBALS['phpgw']->db->next_record();
$GLOBALS['phpgw_info']['server'] = unserialize(stripslashes($GLOBALS['phpgw']->db->f('content'))); $GLOBALS['phpgw_info']['server'] = unserialize(stripslashes($GLOBALS['phpgw']->db->f('content')));
} }
else else
{ {
$GLOBALS['phpgw']->db->query("select * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__); $GLOBALS['phpgw']->db->query("select * from phpgw_config WHERE config_app='phpgwapi'",__LINE__,__FILE__);
while ($GLOBALS['phpgw']->db->next_record()) while ($GLOBALS['phpgw']->db->next_record())
{ {
$GLOBALS['phpgw_info']['server'][$GLOBALS['phpgw']->db->f('config_name')] = stripslashes($GLOBALS['phpgw']->db->f('config_value')); $GLOBALS['phpgw_info']['server'][$GLOBALS['phpgw']->db->f('config_name')] = stripslashes($GLOBALS['phpgw']->db->f('config_value'));
} }
if($GLOBALS['phpgw_info']['server']['cache_phpgw_info']) if($GLOBALS['phpgw_info']['server']['cache_phpgw_info'])
{ {
if($server_info_cache) if($server_info_cache)
{ {
$cache_query = "UPDATE phpgw_app_sessions set content='".addslashes(serialize($GLOBALS['phpgw_info']['server']))."'" $cache_query = "UPDATE phpgw_app_sessions set content='".addslashes(serialize($GLOBALS['phpgw_info']['server']))."'"
." WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'"; ." WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'";
} }
else else
{ {
$cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES(' $cache_query = 'INSERT INTO phpgw_app_sessions(sessionid,loginid,app,location,content) VALUES('
. "'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')"; . "'0','0','phpgwapi','config','".addslashes(serialize($GLOBALS['phpgw_info']['server']))."')";
} }
$GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__); $GLOBALS['phpgw']->db->query($cache_query,__LINE__,__FILE__);
} }
} }
unset($cache_query); unset($cache_query);
unset($server_info_cache); unset($server_info_cache);
@ -477,10 +477,10 @@ $GLOBALS['phpgw']->log = CreateObject('phpgwapi.errorlog');
// $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.datetime'); // $GLOBALS['phpgw']->datetime = CreateObject('phpgwapi.datetime');
print_debug('main class loaded'); print_debug('main class loaded');
if (! isset($phpgw_info['flags']['included_classes']['error']) || if (! isset($phpgw_info['flags']['included_classes']['error']) ||
! $phpgw_info['flags']['included_classes']['error']) ! $phpgw_info['flags']['included_classes']['error'])
{ {
$phpgw_info['flags']['included_classes']['error'] = True; $phpgw_info['flags']['included_classes']['error'] = True;
include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php'); include(PHPGW_INCLUDE_ROOT.'/phpgwapi/inc/class.error.inc.php');
} }
@ -495,16 +495,16 @@ define('SEP',filesystem_separator());
\****************************************************************************/ \****************************************************************************/
if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'logout') if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'logout')
{ {
if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login') if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login')
{ {
if (@$login != '') if (@$login != '')
{ {
$login_array = explode("@",$login); $login_array = explode("@",$login);
$login_id = $GLOBALS['phpgw']->accounts->name2id($login_array[0]); $login_id = $GLOBALS['phpgw']->accounts->name2id($login_array[0]);
$GLOBALS['phpgw']->accounts->accounts($login_id); $GLOBALS['phpgw']->accounts->accounts($login_id);
$GLOBALS['phpgw']->preferences->preferences($login_id); $GLOBALS['phpgw']->preferences->preferences($login_id);
} }
} }
/****************************************************************************\ /****************************************************************************\
* Everything from this point on will ONLY happen if * * Everything from this point on will ONLY happen if *
* the currentapp is not login or logout * * the currentapp is not login or logout *
@ -512,157 +512,157 @@ if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'login' || $GLOBALS['phpgw_
} }
else else
{ {
if (! $GLOBALS['phpgw']->session->verify()) if (! $GLOBALS['phpgw']->session->verify())
{ {
Header('Location: ' . $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->session->link('/login.php','cd=10'))); Header('Location: ' . $GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->session->link('/login.php','cd=10')));
exit; exit;
} }
/* A few hacker resistant constants that will be used throught the program */ /* A few hacker resistant constants that will be used throught the program */
define('PHPGW_TEMPLATE_DIR',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi')); define('PHPGW_TEMPLATE_DIR',$GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi'));
define('PHPGW_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_path('phpgwapi')); define('PHPGW_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_path('phpgwapi'));
define('PHPGW_IMAGES_FILEDIR', $GLOBALS['phpgw']->common->get_image_dir('phpgwapi')); define('PHPGW_IMAGES_FILEDIR', $GLOBALS['phpgw']->common->get_image_dir('phpgwapi'));
define('PHPGW_APP_ROOT', $GLOBALS['phpgw']->common->get_app_dir()); define('PHPGW_APP_ROOT', $GLOBALS['phpgw']->common->get_app_dir());
define('PHPGW_APP_INC', $GLOBALS['phpgw']->common->get_inc_dir()); define('PHPGW_APP_INC', $GLOBALS['phpgw']->common->get_inc_dir());
define('PHPGW_APP_TPL', $GLOBALS['phpgw']->common->get_tpl_dir()); define('PHPGW_APP_TPL', $GLOBALS['phpgw']->common->get_tpl_dir());
define('PHPGW_IMAGES', $GLOBALS['phpgw']->common->get_image_path()); define('PHPGW_IMAGES', $GLOBALS['phpgw']->common->get_image_path());
define('PHPGW_APP_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_dir()); define('PHPGW_APP_IMAGES_DIR', $GLOBALS['phpgw']->common->get_image_dir());
define('PHPGW_ACL_READ',1); define('PHPGW_ACL_READ',1);
define('PHPGW_ACL_ADD',2); define('PHPGW_ACL_ADD',2);
define('PHPGW_ACL_EDIT',4); define('PHPGW_ACL_EDIT',4);
define('PHPGW_ACL_DELETE',8); define('PHPGW_ACL_DELETE',8);
define('PHPGW_ACL_PRIVATE',16); define('PHPGW_ACL_PRIVATE',16);
/********* This sets the user variables *********/ /********* This sets the user variables *********/
$GLOBALS['phpgw_info']['user']['private_dir'] = $GLOBALS['phpgw_info']['server']['files_dir'] $GLOBALS['phpgw_info']['user']['private_dir'] = $GLOBALS['phpgw_info']['server']['files_dir']
. '/users/'.$GLOBALS['phpgw_info']['user']['userid']; . '/users/'.$GLOBALS['phpgw_info']['user']['userid'];
/* This will make sure that a user has the basic default prefs. If not it will add them */ /* This will make sure that a user has the basic default prefs. If not it will add them */
$GLOBALS['phpgw']->preferences->verify_basic_settings(); $GLOBALS['phpgw']->preferences->verify_basic_settings();
/********* Optional classes, which can be disabled for performance increases *********/ /********* Optional classes, which can be disabled for performance increases *********/
while ($phpgw_class_name = each($GLOBALS['phpgw_info']['flags'])) while ($phpgw_class_name = each($GLOBALS['phpgw_info']['flags']))
{ {
if (ereg('enable_',$phpgw_class_name[0])) if (ereg('enable_',$phpgw_class_name[0]))
{ {
$enable_class = str_replace('enable_','',$phpgw_class_name[0]); $enable_class = str_replace('enable_','',$phpgw_class_name[0]);
$enable_class = str_replace('_class','',$enable_class); $enable_class = str_replace('_class','',$enable_class);
eval('$GLOBALS["phpgw"]->' . $enable_class . ' = createobject(\'phpgwapi.' . $enable_class . '\');'); eval('$GLOBALS["phpgw"]->' . $enable_class . ' = createobject(\'phpgwapi.' . $enable_class . '\');');
} }
} }
unset($enable_class); unset($enable_class);
reset($GLOBALS['phpgw_info']['flags']); reset($GLOBALS['phpgw_info']['flags']);
/*************************************************************************\ /*************************************************************************\
* These lines load up the templates class * * These lines load up the templates class *
\*************************************************************************/ \*************************************************************************/
if(!@$GLOBALS['phpgw_info']['flags']['disable_Template_class']) if(!@$GLOBALS['phpgw_info']['flags']['disable_Template_class'])
{ {
$GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL); $GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
} }
/*************************************************************************\ /*************************************************************************\
* These lines load up the themes * * These lines load up the themes *
\*************************************************************************/ \*************************************************************************/
if (! $GLOBALS['phpgw_info']['user']['preferences']['common']['theme']) if (! $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])
{ {
if ($GLOBALS['phpgw_info']['server']['template_set'] == 'user_choice') if ($GLOBALS['phpgw_info']['server']['template_set'] == 'user_choice')
{ {
$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = 'default'; $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = 'default';
} }
else else
{ {
$GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $GLOBALS['phpgw_info']['server']['template_set']; $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'] = $GLOBALS['phpgw_info']['server']['template_set'];
} }
} }
if ($GLOBALS['phpgw_info']['server']['force_theme'] == 'user_choice') if ($GLOBALS['phpgw_info']['server']['force_theme'] == 'user_choice')
{ {
$theme_to_load = (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])?$GLOBALS['phpgw_info']['user']['preferences']['common']['theme']:'default'); $theme_to_load = (isset($GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])?$GLOBALS['phpgw_info']['user']['preferences']['common']['theme']:'default');
} }
else else
{ {
$theme_to_load = (isset($GLOBALS['phpgw_info']['server']['force_theme'])?$GLOBALS['phpgw_info']['server']['force_theme']:'default'); $theme_to_load = (isset($GLOBALS['phpgw_info']['server']['force_theme'])?$GLOBALS['phpgw_info']['server']['force_theme']:'default');
} }
if(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $theme_to_load . '.theme')) if(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/' . $theme_to_load . '.theme'))
{ {
include(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')) elseif(@file_exists(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme'))
{ {
include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme'); include(PHPGW_SERVER_ROOT . '/phpgwapi/themes/default.theme');
} }
else else
{ {
/* Hope we don't get to this point. Better then the user seeing a */ /* Hope we don't get to this point. Better then the user seeing a */
/* complety back screen and not know whats going on */ /* complety back screen and not know whats going on */
echo '<body bgcolor="FFFFFF">'; echo '<body bgcolor="FFFFFF">';
$phpgw->log->write(array('text'=>'F-Abort, No themes found')); $phpgw->log->write(array('text'=>'F-Abort, No themes found'));
exit; exit;
} }
unset($theme_to_load); unset($theme_to_load);
/*************************************************************************\ /*************************************************************************\
* If they are using frames, we need to set some variables * * If they are using frames, we need to set some variables *
\*************************************************************************/ \*************************************************************************/
if (((isset($GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) && if (((isset($GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) &&
$GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) && $GLOBALS['phpgw_info']['user']['preferences']['common']['useframes']) &&
$GLOBALS['phpgw_info']['server']['useframes'] == 'allowed') || $GLOBALS['phpgw_info']['server']['useframes'] == 'allowed') ||
($GLOBALS['phpgw_info']['server']['useframes'] == 'always')) ($GLOBALS['phpgw_info']['server']['useframes'] == 'always'))
{ {
$GLOBALS['phpgw_info']['flags']['navbar_target'] = 'phpgw_body'; $GLOBALS['phpgw_info']['flags']['navbar_target'] = 'phpgw_body';
} }
/*************************************************************************\ /*************************************************************************\
* Verify that the users session is still active otherwise kick them out * * Verify that the users session is still active otherwise kick them out *
\*************************************************************************/ \*************************************************************************/
if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' && if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' &&
$GLOBALS['phpgw_info']['flags']['currentapp'] != 'preferences' && $GLOBALS['phpgw_info']['flags']['currentapp'] != 'preferences' &&
$GLOBALS['phpgw_info']['flags']['currentapp'] != 'about') $GLOBALS['phpgw_info']['flags']['currentapp'] != 'about')
{ {
// This will need to use ACL in the future // This will need to use ACL in the future
if (! $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']] || if (! $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']] ||
(@$GLOBALS['phpgw_info']['flags']['admin_only'] && (@$GLOBALS['phpgw_info']['flags']['admin_only'] &&
! $GLOBALS['phpgw_info']['user']['apps']['admin'])) ! $GLOBALS['phpgw_info']['user']['apps']['admin']))
{ {
$GLOBALS['phpgw']->common->phpgw_header(); $GLOBALS['phpgw']->common->phpgw_header();
if ($GLOBALS['phpgw_info']['flags']['noheader']) if ($GLOBALS['phpgw_info']['flags']['noheader'])
{ {
echo parse_navbar(); echo parse_navbar();
} }
$phpgw->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp'])); $phpgw->log->write(array('text'=>'W-Permissions, Attempted to access %1','p1'=>$GLOBALS['phpgw_info']['flags']['currentapp']));
echo '<p><center><b>'.lang('Access not permitted').'</b></center>'; echo '<p><center><b>'.lang('Access not permitted').'</b></center>';
$GLOBALS['phpgw']->common->phpgw_exit(True); $GLOBALS['phpgw']->common->phpgw_exit(True);
} }
} }
/*************************************************************************\ /*************************************************************************\
* Load the header unless the developer turns it off * * Load the header unless the developer turns it off *
\*************************************************************************/ \*************************************************************************/
if (!@$GLOBALS['phpgw_info']['flags']['noheader']) if (!@$GLOBALS['phpgw_info']['flags']['noheader'])
{ {
$GLOBALS['phpgw']->common->phpgw_header(); $GLOBALS['phpgw']->common->phpgw_header();
} }
/*************************************************************************\ /*************************************************************************\
* Load the app include files if the exists * * Load the app include files if the exists *
\*************************************************************************/ \*************************************************************************/
/* Then the include file */ /* Then the include file */
if (! preg_match ("/phpgwapi/i", PHPGW_APP_INC) && file_exists(PHPGW_APP_INC . '/functions.inc.php') && !isset($menuaction)) if (! preg_match ("/phpgwapi/i", PHPGW_APP_INC) && file_exists(PHPGW_APP_INC . '/functions.inc.php') && !isset($menuaction))
{ {
include(PHPGW_APP_INC . '/functions.inc.php'); include(PHPGW_APP_INC . '/functions.inc.php');
} }
if (!@$GLOBALS['phpgw_info']['flags']['noheader'] && if (!@$GLOBALS['phpgw_info']['flags']['noheader'] &&
!@$GLOBALS['phpgw_info']['flags']['noappheader'] && !@$GLOBALS['phpgw_info']['flags']['noappheader'] &&
file_exists(PHPGW_APP_INC . '/header.inc.php') && !isset($menuaction)) file_exists(PHPGW_APP_INC . '/header.inc.php') && !isset($menuaction))
{ {
include(PHPGW_APP_INC . '/header.inc.php'); include(PHPGW_APP_INC . '/header.inc.php');
} }
} }
error_reporting(E_ERROR | E_WARNING | E_PARSE); error_reporting(E_ERROR | E_WARNING | E_PARSE);