array( 'nocachecontrol' => True, 'noheader' => True, 'nonavbar' => True, 'currentapp' => 'home', 'noapi' => True )); include('./inc/functions.inc.php'); // some constanst for pre php4.3 if (!defined('PHP_SHLIB_SUFFIX')) { define('PHP_SHLIB_SUFFIX',strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ? 'dll' : 'so'); } if (!defined('PHP_SHLIB_PREFIX')) { define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); } /** * checks if a named extension is loaded or loadable */ function check_load_extension($extension) { return extension_loaded($extension) || function_exists('dl') && @dl(PHP_SHLIB_PREFIX.$extension.'.'.PHP_SHLIB_SUFFIX); } $GLOBALS['egw_info']['server']['versions']['current_header'] = $setup_info['phpgwapi']['versions']['current_header']; $GLOBALS['egw_info']['server']['versions']['phpgwapi'] = $setup_info['phpgwapi']['version']; unset($setup_info); /* Fetch the current real path. * If this is in the server document root, then it is probably ok. * Otherwise, don't guess, just show the usual instructive default. */ $realpath = realpath('..'); if(!ereg('^' . $_SERVER['DOCUMENT_ROOT'],$realpath)) { if(PHP_OS == 'Windows') { $realpath = 'Drive:\\\\Path'; } else { $realpath = '/path/to/egroupware'; } } $adddomain = get_var('adddomain',Array('POST')); $db_fullnames = array( 'pgsql' => 'PostgreSQL', 'mysql' => 'MySQL', 'mssql' => 'MS SQL Server', 'odbc_mssql' => 'MS SQL Server via ODBC', 'oracle' => 'Oracle', 'odbc_oracle' => 'Oracle via ODBC', 'sapdb' => 'SAP/Max DB via ODBC', ); $default_db_ports = array( 'pgsql' => 5432, 'mysql' => 3306, 'mssql' => 1433, 'odbc_mssql' => '', 'oracle' => 1521, 'odbc_oracle' => '', 'sapdb' => '', ); function check_form_values() { // PHP will automatically replace any dots in incoming // variable names with underscores. $errors = ''; $domains = get_var('domains',Array('POST')); @reset($domains); while(list($k,$v) = @each($domains)) { $variableName = str_replace('.','_',$k); $deletedomain = get_var('deletedomain',Array('POST')); if(isset($deletedomain[$variableName])) { continue; } $dom = get_var('setting_'.$variableName,Array('POST')); if(!$dom['config_pass'] && !$dom['config_password']) { $errors .= '
' . lang("You didn't enter a config password for domain %1",$v); } if(!$dom['config_user']) { $errors .= '
' . lang("You didn't enter a config username for domain %1",$v); } } $setting = get_var('setting',Array('POST')); if(!$setting['HEADER_ADMIN_PASSWORD'] && !$setting['HEADER_ADMIN_PASS']) { $errors .= '
' . lang("You didn't enter a header admin password"); } if(!$setting['HEADER_ADMIN_USER']) { $errors .= '
' . lang("You didn't enter a header admin username"); } if($errors) { $GLOBALS['egw_setup']->html->show_header('Error',True); echo $errors; echo '

'; exit; } } /* authentication phase */ $GLOBALS['egw_info']['setup']['stage']['header'] = $GLOBALS['egw_setup']->detection->check_header(); // added these to let the app work, need to templatize still $tpl_root = $GLOBALS['egw_setup']->html->setup_tpl_dir('setup'); $setup_tpl = CreateObject('setup.Template',$tpl_root); $setup_tpl->set_file(array( 'T_head' => 'head.tpl', 'T_footer' => 'footer.tpl', 'T_alert_msg' => 'msg_alert_msg.tpl', 'T_login_main' => 'login_main.tpl', 'T_login_stage_header' => 'login_stage_header.tpl', 'T_setup_manage' => 'manageheader.tpl' )); $setup_tpl->set_block('T_login_stage_header','B_multi_domain','V_multi_domain'); $setup_tpl->set_block('T_login_stage_header','B_single_domain','V_single_domain'); $setup_tpl->set_block('T_setup_manage','manageheader','manageheader'); $setup_tpl->set_block('T_setup_manage','domain','domain'); /* Detect current mode */ switch($GLOBALS['egw_info']['setup']['stage']['header']) { case '1': $GLOBALS['egw_info']['setup']['HeaderFormMSG'] = lang('Create your header.inc.php'); $GLOBALS['egw_info']['setup']['PageMSG'] = lang('You have not created your header.inc.php yet!
You can create it now.'); break; case '2': $GLOBALS['egw_info']['setup']['HeaderFormMSG'] = lang('Your header admin password is NOT set. Please set it now!'); $GLOBALS['egw_info']['setup']['PageMSG'] = lang('Your header admin password is NOT set. Please set it now!'); break; case '3': $GLOBALS['egw_info']['setup']['HeaderFormMSG'] = lang('You need to add some domains to your header.inc.php.'); $GLOBALS['egw_info']['setup']['PageMSG'] = lang('You need to add some domains to your header.inc.php.'); $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] = lang('You need to add some domains to your header.inc.php.'); if(!$GLOBALS['egw_setup']->auth('Header')) { $GLOBALS['egw_setup']->html->show_header('Please login',True); $GLOBALS['egw_setup']->html->login_form(); $GLOBALS['egw_setup']->html->show_footer(); exit; } break; case '4': $GLOBALS['egw_info']['setup']['HeaderFormMSG'] = lang('Your header.inc.php needs upgrading.'); $GLOBALS['egw_info']['setup']['PageMSG'] = lang('Your header.inc.php needs upgrading.
WARNING!
MAKE BACKUPS!'); $GLOBALS['egw_info']['setup']['HeaderLoginMSG'] = lang('Your header.inc.php needs upgrading.'); if(!$GLOBALS['egw_setup']->auth('Header')) { $GLOBALS['egw_setup']->html->show_header('Please login',True); $GLOBALS['egw_setup']->html->login_form(); $GLOBALS['egw_setup']->html->show_footer(); exit; } break; case '10': if(!$GLOBALS['egw_setup']->auth('Header')) { $GLOBALS['egw_setup']->html->show_header('Please login',True); $GLOBALS['egw_setup']->html->login_form(); $GLOBALS['egw_setup']->html->show_footer(); exit; } $GLOBALS['egw_info']['setup']['HeaderFormMSG'] = lang('Edit your header.inc.php'); $GLOBALS['egw_info']['setup']['PageMSG'] = lang('Edit your existing header.inc.php'); break; } $action = @get_var('action',Array('POST')); list($action) = @each($action); switch($action) { case 'download': check_form_values(); $header_template = CreateObject('setup.Template','../'); $b = CreateObject('phpgwapi.browser'); $b->content_header('header.inc.php','application/octet-stream'); /* header('Content-disposition: attachment; filename="header.inc.php"'); header('Content-type: application/octet-stream'); header('Pragma: no-cache'); header('Expires: 0'); */ $newheader = $GLOBALS['egw_setup']->html->generate_header(); echo $newheader; break; case 'view': check_form_values(); $header_template = CreateObject('setup.Template','../'); $GLOBALS['egw_setup']->html->show_header('Generated header.inc.php', False, 'header'); echo '
'; echo '
' . lang('Save this text as contents of your header.inc.php') . '

'; $newheader = $GLOBALS['egw_setup']->html->generate_header(); echo '
';
			echo htmlentities($newheader);
			echo '

'; echo '
'; echo '
' . lang('After retrieving the file, put it into place as the header.inc.php. Then, click "continue".') . '
'; echo ''; echo ''; echo '
'; echo '
'; $GLOBALS['egw_setup']->html->show_footer(); break; case 'write': check_form_values(); $header_template = CreateObject('setup.Template','../'); if(is_writeable('../header.inc.php') || (!file_exists('../header.inc.php') && is_writeable('../'))) { $newheader = $GLOBALS['egw_setup']->html->generate_header(); $fsetup = fopen('../header.inc.php','wb'); fwrite($fsetup,$newheader); fclose($fsetup); $GLOBALS['egw_setup']->html->show_header('Saved header.inc.php', False, 'header'); echo '
'; echo '
' . lang('Created header.inc.php!'); echo ''; echo ''; echo '
'; echo ''; break; } else { $GLOBALS['egw_setup']->html->show_header('Error generating header.inc.php', False, 'header'); echo lang('Could not open header.inc.php for writing!') . '
' . "\n"; echo lang('Please check read/write permissions on directories, or back up and use another option.') . '
'; echo ''; } break; default: $GLOBALS['egw_setup']->html->show_header($GLOBALS['egw_info']['setup']['HeaderFormMSG'], False, 'header'); $detected = ''; if(!get_var('ConfigLang',array('POST','COOKIE'))) { $detected .= '
Please Select your language '.lang_select(True,'en')."
\n"; } $detected .= '' . "\n"; $detected .= ''; $detected .= '

' . $GLOBALS['egw_info']['setup']['PageMSG'] . '
 

' . lang('Analysis') . '
'. "\n"; $supported_db = array(); if(check_load_extension('mysql') || function_exists('mysql_connect')) { $detected .= lang('You appear to have MySQL support enabled') . '
' . "\n"; $supported_db[] = 'mysql'; } else { $detected .= lang('No MySQL support found. Disabling') . '
' . "\n"; } if(check_load_extension('pgsql') || function_exists('pg_connect')) { $detected .= lang('You appear to have PostgreSQL support enabled') . '
' . "\n"; $supported_db[] = 'pgsql'; } else { $detected .= lang('No PostgreSQL support found. Disabling') . '
' . "\n"; } if(check_load_extension('mssql') || function_exists('mssql_connect')) { $detected .= lang('You appear to have Microsoft SQL Server support enabled') . '
' . "\n"; $supported_db[] = 'mssql'; } else { $detected .= lang('No Microsoft SQL Server support found. Disabling') . '
' . "\n"; } if(check_load_extension('odbc')) { $detected .= lang('You appear to have ODBC support enabled') . '
' . "\n"; // databases supported by the ODBC driver $supported_db[] = 'sapdb'; $supported_db[] = 'odbc_mssql'; $supported_db[] = 'odbc_oracle'; } else { $detected .= lang('No ODBC support found. Disabling') . '
' . "\n"; } if(check_load_extension('oci8')) { $detected .= lang('You appear to have Oracle V8 (OCI) support enabled') . '
' . "\n"; $supported_db[] = 'oracle'; } else { $detected .= lang('No Oracle-DB support found. Disabling') . '
' . "\n"; } if(!count($supported_db)) { $detected .= '

' . lang('Did not find any valid DB support!') . "
\n" . lang('Try to configure your php to support one of the above mentioned DBMS, or install eGroupWare by hand.') . '

'; echo $detected; exit; } if(!function_exists('version_compare')) { $detected .= '

' . lang('You appear to be using PHP earlier than 4.1.0. eGroupWare now requires 4.1.0 or later'). "\n" . '

'; echo $detected; exit; } if (check_load_extension('session')) { $detected .= lang('You appear to have PHP4 session support. Enabling PHP4 sessions.') . '
' . "\n"; $supported_sessions_type[] = 'php4'; // makeing php4 sessions the default } $supported_sessions_type[] = 'db'; @reset($default_db_ports); $js_default_db_ports = 'var default_db_ports = new Array();'."\n"; while(list($k,$v) = @each($default_db_ports)) { $js_default_db_ports .= ' default_db_ports["'.$k.'"]="'.$v.'";'."\n"; } $setup_tpl->set_var('js_default_db_ports',$js_default_db_ports); /* if(check_load_extension('xml') || function_exists('xml_parser_create')) { $detected .= lang('You appear to have XML support enabled') . '
' . "\n"; $xml_enabled = 'True'; } else { $detected .= lang('No XML support found. Disabling') . '
' . "\n"; } */ $no_guess = False; if(file_exists('../header.inc.php') && is_file('../header.inc.php') && is_readable('../header.inc.php')) { $detected .= lang('Found existing configuration file. Loading settings from the file...') . '
' . "\n"; $GLOBALS['egw_info']['flags']['noapi'] = True; $no_guess = true; /* This code makes sure the newer multi-domain supporting header.inc.php is being used */ if(!isset($GLOBALS['egw_domain'])) { $detected .= lang('You need to add some domains to your header.inc.php.') . '
' . "\n"; $GLOBALS['egw_domain']['default'] = array(); $setup_tpl->set_var('lang_domain',lang('Domain')); $setup_tpl->set_var('lang_delete',lang('Delete')); $setup_tpl->set_var('db_domain','default'); $setup_tpl->set_var('db_host','localhost'); $setup_tpl->set_var('db_name','egroupware'); $setup_tpl->set_var('db_user','egroupware'); $setup_tpl->set_var('db_pass',''); $setup_tpl->set_var('config_user','changeme'); $setup_tpl->set_var('config_pass',''); while(list($k,$v) = @each($supported_db)) { $dbtype_options .= '