True,
'nonavbar' => True,
'currentapp' => 'home',
'noapi' => True
);
include('./inc/functions.inc.php');
/*
Authorize the user to use setup app and load the database
Does not return unless user is authorized
*/
if(!$GLOBALS['phpgw_setup']->auth('Config'))
{
Header('Location: index.php');
exit;
}
$tpl_root = $GLOBALS['phpgw_setup']->html->setup_tpl_dir('setup');
$setup_tpl = CreateObject('setup.Template',$tpl_root);
// test if $path lies within the webservers document-root
//
function in_docroot($path)
{
$docroots = array(PHPGW_SERVER_ROOT,$GLOBALS['HTTP_SERVER_VARS']['DOCUMENT_ROOT']);
foreach ($docroots as $docroot)
{
$len = strlen($docroot);
if ($docroot == substr($path,0,$len))
{
$rest = substr($path,$len);
if (!strlen($rest) || $rest[0] == DIRECTORY_SEPARATOR)
{
return True;
}
}
}
return False;
}
$setup_tpl->set_file(array(
'T_head' => 'head.tpl',
'T_footer' => 'footer.tpl',
'T_alert_msg' => 'msg_alert_msg.tpl',
'T_config_pre_script' => 'config_pre_script.tpl',
'T_config_post_script' => 'config_post_script.tpl'
));
/* Following to ensure windows file paths are saved correctly */
set_magic_quotes_runtime(0);
$GLOBALS['phpgw_setup']->loaddb();
/* Guessing default values. */
$GLOBALS['current_config']['hostname'] = $_SERVER['HTTP_HOST'];
// files-dir is not longer allowed in document root, for security reasons !!!
$GLOBALS['current_config']['files_dir'] = '/outside/webserver/docroot';
if(@is_dir('/tmp'))
{
$GLOBALS['current_config']['temp_dir'] = '/tmp';
}
else
{
$GLOBALS['current_config']['temp_dir'] = '/path/to/temp/dir';
}
// guessing the phpGW url
$parts = explode('/',$_SERVER['PHP_SELF']);
unset($parts[count($parts)-1]); // config.php
unset($parts[count($parts)-1]); // setup
$GLOBALS['current_config']['webserver_url'] = implode('/',$parts);
if(@get_var('cancel',Array('POST')))
{
Header('Location: index.php');
exit;
}
/* Check api version, use correct table */
$setup_info = $GLOBALS['phpgw_setup']->detection->get_db_versions();
if($GLOBALS['phpgw_setup']->alessthanb($setup_info['phpgwapi']['currentver'], '0.9.10pre7'))
{
$configtbl = 'config';
}
else
{
$configtbl = 'phpgw_config';
}
$newsettings = get_var('newsettings',Array('POST'));
$files_in_docroot = in_docroot($GLOBALS['HTTP_POST_VARS']['newsettings']['files_dir']);
if(@get_var('submit',Array('POST')) && @$newsettings && !$files_in_docroot)
{
$datetime = CreateObject('phpgwapi.datetime');
switch (intval($newsettings['daytime_port']))
{
case 13:
$newsettings['tz_offset'] = $datetime->getntpoffset();
break;
case 80:
$newsettings['tz_offset'] = $datetime->gethttpoffset();
break;
default:
$newsettings['tz_offset'] = $datetime->getbestguess();
break;
}
unset($datetime);
print_debug('TZ_OFFSET',$newsettings['tz_offset']);
$GLOBALS['phpgw_setup']->db->transaction_begin();
/* This is only temp: */
$GLOBALS['phpgw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='useframes'");
$GLOBALS['phpgw_setup']->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) values ('phpgwapi','useframes','never')");
while(list($setting,$value) = @each($newsettings))
{
/* echo '
Updating: ' . $setting . '=' . $value; */
/* Don't erase passwords, since we also do not print them below */
if($value || (!ereg('passwd',$setting) && !ereg('password',$setting) && !ereg('root_pw',$setting)))
{
@$GLOBALS['phpgw_setup']->db->query("DELETE FROM $configtbl WHERE config_name='" . $setting . "'");
}
if($value)
{
$GLOBALS['phpgw_setup']->db->query("INSERT INTO $configtbl (config_app,config_name, config_value) VALUES ('phpgwapi','" . $GLOBALS['phpgw_setup']->db->db_addslashes($setting)
. "','" . $GLOBALS['phpgw_setup']->db->db_addslashes($value) . "')");
}
}
$GLOBALS['phpgw_setup']->db->transaction_commit();
/* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */
$tablenames = $GLOBALS['phpgw_setup']->db->table_names();
while(list($key,$val) = @each($tablenames))
{
$tables[] = $val['table_name'];
}
if(in_array('phpgw_app_sessions',$tables))
{
$GLOBALS['phpgw_setup']->db->lock(array('phpgw_app_sessions'));
@$GLOBALS['phpgw_setup']->db->query("DELETE FROM phpgw_app_sessions WHERE sessionid = '0' and loginid = '0' and app = 'phpgwapi' and location = 'config'",__LINE__,__FILE__);
@$GLOBALS['phpgw_setup']->db->query("DELETE FROM phpgw_app_sessions WHERE app = 'phpgwapi' and location = 'phpgw_info_cache'",__LINE__,__FILE__);
$GLOBALS['phpgw_setup']->db->unlock();
}
if($newsettings['auth_type'] == 'ldap')
{
Header('Location: '.$newsettings['webserver_url'].'/setup/ldap.php');
exit;
}
else
{
Header('Location: index.php');
exit;
}
}
if($newsettings['auth_type'] != 'ldap')
{
$GLOBALS['phpgw_setup']->html->show_header(lang('Configuration'),False,'config',$ConfigDomain . '(' . $phpgw_domain[$ConfigDomain]["db_type"] . ')');
}
@$GLOBALS['phpgw_setup']->db->query("SELECT * FROM $configtbl");
while(@$GLOBALS['phpgw_setup']->db->next_record())
{
$GLOBALS['current_config'][$GLOBALS['phpgw_setup']->db->f('config_name')] = $GLOBALS['phpgw_setup']->db->f('config_value');
}
// are we here because of an error: files-dir in docroot
if (is_array($GLOBALS['HTTP_POST_VARS']['newsettings']) && $files_in_docroot)
{
echo '
'.lang('Path to user and group files HAS TO BE OUTSIDE of the webservers document-root!!!')."
\n"; foreach($GLOBALS['HTTP_POST_VARS']['newsettings'] as $key => $val) { $GLOBALS['current_config'][$key] = $val; } } if($GLOBALS['error'] == 'badldapconnection') { /* Please check the number and dial again :) */ $GLOBALS['phpgw_setup']->html->show_alert_msg('Error', lang('There was a problem trying to connect to your LDAP server.