2001-07-30 17:59:25 +02:00
< ? php
/************************************************************************** \
* phpGroupWare *
* http :// www . phpgroupware . org *
* -------------------------------------------- *
* This program is free software ; you can redistribute it and / or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation ; either version 2 of the License , or ( at your *
* option ) any later version . *
\ **************************************************************************/
/* $Id$ */
2002-03-03 22:53:00 +01:00
$phpgw_info = array ();
$GLOBALS [ 'phpgw_info' ][ 'flags' ] = array (
2002-01-02 16:47:54 +01:00
'nocachecontrol' => True ,
2001-07-30 17:59:25 +02:00
'noheader' => True ,
'nonavbar' => True ,
2001-08-21 20:48:50 +02:00
'currentapp' => 'home' ,
2001-07-30 17:59:25 +02:00
'noapi' => True
);
2001-08-21 20:48:50 +02:00
include ( './inc/functions.inc.php' );
2001-07-30 17:59:25 +02:00
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'versions' ][ 'current_header' ] = $setup_info [ 'phpgwapi' ][ 'versions' ][ 'current_header' ];
2003-09-23 15:08:40 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'versions' ][ 'phpgwapi' ] = $setup_info [ 'phpgwapi' ][ 'version' ];
2001-08-21 20:48:50 +02:00
unset ( $setup_info );
#include('../version.inc.php');
2001-07-30 17:59:25 +02:00
2003-12-27 16:58:08 +01:00
/* 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 ))
2002-04-08 01:56:03 +02:00
{
2003-12-27 16:58:08 +01:00
if ( PHP_OS == 'Windows' )
{
$realpath = 'Drive:\\\\Path' ;
}
else
{
$realpath = '/path/to/egroupware' ;
}
2002-04-08 01:56:03 +02:00
}
2003-12-27 16:58:08 +01:00
$adddomain = get_var ( 'adddomain' , Array ( 'POST' ));
2003-12-22 03:59:09 +01:00
$default_db_ports = array (
'pgsql' => 5432 ,
'mysql' => 3306 ,
'mssql' => 1433 ,
'oracle' => 1521
);
2001-08-21 20:48:50 +02:00
function check_form_values ()
2001-07-30 17:59:25 +02:00
{
2003-12-22 12:41:17 +01:00
// PHP will automatically replace any dots in incoming
// variable names with underscores.
2002-04-09 16:15:04 +02:00
$errors = '' ;
2002-04-29 21:49:24 +02:00
$domains = get_var ( 'domains' , Array ( 'POST' ));
@ reset ( $domains );
while ( list ( $k , $v ) = @ each ( $domains ))
2003-12-27 16:58:08 +01:00
{
2003-12-22 12:41:17 +01:00
$variableName = str_replace ( '.' , '_' , $k );
2002-04-29 21:49:24 +02:00
$deletedomain = get_var ( 'deletedomain' , Array ( 'POST' ));
2003-12-22 12:41:17 +01:00
if ( isset ( $deletedomain [ $variableName ]))
2002-04-08 01:56:03 +02:00
{
continue ;
}
2003-12-22 12:41:17 +01:00
$dom = get_var ( 'setting_' . $variableName , Array ( 'POST' ));
2002-04-08 01:56:03 +02:00
if ( ! $dom [ 'config_pass' ])
{
2003-05-18 17:06:15 +02:00
$errors .= '<br>' . lang ( " You didn't enter a config password for domain %1 " , $v );
2002-04-08 01:56:03 +02:00
}
2001-08-21 20:48:50 +02:00
}
2002-04-08 01:56:03 +02:00
2002-04-29 21:49:24 +02:00
$setting = get_var ( 'setting' , Array ( 'POST' ));
if ( ! $setting [ 'HEADER_ADMIN_PASSWORD' ])
2001-08-21 20:48:50 +02:00
{
2002-04-07 06:11:50 +02:00
$errors .= '<br>' . lang ( " You didn't enter a header admin password " );
2001-08-21 20:48:50 +02:00
}
2002-04-08 01:56:03 +02:00
if ( $errors )
2001-08-21 20:48:50 +02:00
{
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( 'Error' , True );
2001-08-21 20:48:50 +02:00
echo $errors ;
2003-09-23 15:08:40 +02:00
echo '<p><input type="submit" value="' . lang ( 'Back to the previous screen' ) . '" onClick="history.back()"></p>' ;
2001-08-21 20:48:50 +02:00
exit ;
}
2001-07-30 17:59:25 +02:00
}
/* authentication phase */
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'stage' ][ 'header' ] = $GLOBALS [ 'phpgw_setup' ] -> detection -> check_header ();
2001-07-30 17:59:25 +02:00
// added these to let the app work, need to templatize still
2002-03-03 22:53:00 +01:00
$tpl_root = $GLOBALS [ 'phpgw_setup' ] -> html -> setup_tpl_dir ( 'setup' );
2002-08-12 01:54:58 +02:00
$setup_tpl = CreateObject ( 'setup.Template' , $tpl_root );
2001-08-21 20:48:50 +02:00
$setup_tpl -> set_file ( array (
2001-07-30 17:59:25 +02:00
'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' ,
2002-04-07 06:11:50 +02:00
'T_setup_manage' => 'manageheader.tpl'
2001-07-30 17:59:25 +02:00
));
2001-08-21 20:48:50 +02:00
$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' );
2002-04-29 02:27:32 +02:00
$setup_tpl -> set_block ( 'T_setup_manage' , 'manageheader' , 'manageheader' );
2002-04-08 01:56:03 +02:00
$setup_tpl -> set_block ( 'T_setup_manage' , 'domain' , 'domain' );
2001-07-30 17:59:25 +02:00
2002-04-07 06:11:50 +02:00
/* Detect current mode */
2002-03-03 22:53:00 +01:00
switch ( $GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'stage' ][ 'header' ])
2001-08-21 20:48:50 +02:00
{
case '1' :
2002-04-07 06:11:50 +02:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderFormMSG' ] = lang ( 'Create your header.inc.php' );
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'PageMSG' ] = lang ( 'You have not created your header.inc.php yet!<br> You can create it now.' );
2001-08-21 20:48:50 +02:00
break ;
case '2' :
2002-04-07 06:11:50 +02:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderFormMSG' ] = lang ( 'Your header admin password is NOT set. Please set it now!' );
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'PageMSG' ] = lang ( 'Your header admin password is NOT set. Please set it now!' );
2001-08-21 20:48:50 +02:00
break ;
case '3' :
2003-10-22 13:28:17 +02:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderFormMSG' ] = lang ( 'You need to add some domains to your header.inc.php.' );
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'PageMSG' ] = lang ( 'You need to add some domains to your header.inc.php.' );
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderLoginMSG' ] = lang ( 'You need to add some domains to your header.inc.php.' );
if ( ! $GLOBALS [ 'phpgw_setup' ] -> auth ( 'Header' ))
{
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( 'Please login' , True );
$GLOBALS [ 'phpgw_setup' ] -> html -> login_form ();
$GLOBALS [ 'phpgw_setup' ] -> html -> show_footer ();
exit ;
}
break ;
case '4' :
2002-04-07 06:11:50 +02:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderFormMSG' ] = lang ( 'Your header.inc.php needs upgrading.' );
2003-08-28 16:31:11 +02:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'PageMSG' ] = lang ( 'Your header.inc.php needs upgrading.<br><blink><b class="msg">WARNING!</b></blink><br><b>MAKE BACKUPS!</b>' );
2002-04-07 06:11:50 +02:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderLoginMSG' ] = lang ( 'Your header.inc.php needs upgrading.' );
2003-10-22 13:28:17 +02:00
if ( ! $GLOBALS [ 'phpgw_setup' ] -> auth ( 'Header' ))
2001-08-21 20:48:50 +02:00
{
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( 'Please login' , True );
$GLOBALS [ 'phpgw_setup' ] -> html -> login_form ();
2002-03-04 03:55:53 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_footer ();
2001-08-21 20:48:50 +02:00
exit ;
}
break ;
case '10' :
2003-10-22 13:28:17 +02:00
if ( ! $GLOBALS [ 'phpgw_setup' ] -> auth ( 'Header' ))
2001-08-21 20:48:50 +02:00
{
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( 'Please login' , True );
$GLOBALS [ 'phpgw_setup' ] -> html -> login_form ();
2002-03-04 03:55:53 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_footer ();
2001-08-21 20:48:50 +02:00
exit ;
}
2002-04-07 06:11:50 +02:00
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderFormMSG' ] = lang ( 'Edit your header.inc.php' );
$GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'PageMSG' ] = lang ( 'Edit your existing header.inc.php' );
2001-08-21 20:48:50 +02:00
break ;
}
2001-07-30 17:59:25 +02:00
2003-08-28 16:31:11 +02:00
$action = @ get_var ( 'action' , Array ( 'POST' ));
list ( $action ) = @ each ( $action );
switch ( $action )
2001-08-21 20:48:50 +02:00
{
case 'download' :
check_form_values ();
2002-08-12 01:54:58 +02:00
$header_template = CreateObject ( 'setup.Template' , '../' );
2002-04-07 06:11:50 +02:00
$b = CreateObject ( 'phpgwapi.browser' );
$b -> content_header ( 'header.inc.php' , 'application/octet-stream' );
/*
2001-08-21 20:48:50 +02:00
header ( 'Content-disposition: attachment; filename="header.inc.php"' );
header ( 'Content-type: application/octet-stream' );
header ( 'Pragma: no-cache' );
header ( 'Expires: 0' );
2002-04-07 06:11:50 +02:00
*/
2002-03-03 22:53:00 +01:00
$newheader = $GLOBALS [ 'phpgw_setup' ] -> html -> generate_header ();
2001-08-21 20:48:50 +02:00
echo $newheader ;
break ;
case 'view' :
check_form_values ();
2002-08-12 01:54:58 +02:00
$header_template = CreateObject ( 'setup.Template' , '../' );
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( 'Generated header.inc.php' , False , 'header' );
2003-10-10 01:08:04 +02:00
echo '<table width="90%"><tr><td>' ;
2002-04-07 06:11:50 +02:00
echo '<br>' . lang ( 'Save this text as contents of your header.inc.php' ) . '<br><hr>' ;
2002-03-03 22:53:00 +01:00
$newheader = $GLOBALS [ 'phpgw_setup' ] -> html -> generate_header ();
2001-08-21 20:48:50 +02:00
echo '<pre>' ;
echo htmlentities ( $newheader );
echo '</pre><hr>' ;
2002-04-07 06:11:50 +02:00
echo '<form action="index.php" method="post">' ;
echo '<br>' . lang ( 'After retrieving the file, put it into place as the header.inc.php. Then, click "continue".' ) . '<br>' ;
echo '<input type="hidden" name="FormLogout" value="header">' ;
2003-08-28 16:31:11 +02:00
echo '<input type="submit" name="junk" value="' . lang ( 'Continue' ) . '">' ;
2001-07-30 17:59:25 +02:00
echo '</form>' ;
2003-10-10 01:08:04 +02:00
echo '</td></tr></table>' ;
$GLOBALS [ 'phpgw_setup' ] -> html -> show_footer ();
2001-07-30 17:59:25 +02:00
break ;
2003-08-28 16:31:11 +02:00
case 'write' :
2001-08-21 20:48:50 +02:00
check_form_values ();
2002-08-12 01:54:58 +02:00
$header_template = CreateObject ( 'setup.Template' , '../' );
2002-04-07 06:11:50 +02:00
if ( is_writeable ( '../header.inc.php' ) || ( ! file_exists ( '../header.inc.php' ) && is_writeable ( '../' )))
2001-08-21 20:48:50 +02:00
{
2002-03-03 22:53:00 +01:00
$newheader = $GLOBALS [ 'phpgw_setup' ] -> html -> generate_header ();
2001-08-21 20:48:50 +02:00
$fsetup = fopen ( '../header.inc.php' , 'wb' );
fwrite ( $fsetup , $newheader );
fclose ( $fsetup );
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( 'Saved header.inc.php' , False , 'header' );
2002-04-07 06:11:50 +02:00
echo '<form action="index.php" method="post">' ;
2001-08-21 20:48:50 +02:00
echo '<br>Created header.inc.php! ' ;
2002-04-07 06:11:50 +02:00
echo '<input type="hidden" name="FormLogout" value="header">' ;
2003-08-28 16:31:11 +02:00
echo '<input type="submit" name="junk" value="' . lang ( 'Continue' ) . '">' ;
2001-08-21 20:48:50 +02:00
echo '</form>' ;
echo '</body></html>' ;
break ;
}
else
{
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( 'Error generating header.inc.php' , False , 'header' );
2002-04-07 06:11:50 +02:00
echo lang ( 'Could not open header.inc.php for writing!' ) . '<br>' . " \n " ;
echo lang ( 'Please check read/write permissions on directories, or back up and use another option.' ) . '<br>' ;
2001-08-21 20:48:50 +02:00
echo '</td></tr></table></body></html>' ;
}
break ;
default :
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_header ( $GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'HeaderFormMSG' ], False , 'header' );
2003-10-10 01:08:04 +02:00
2003-08-28 16:31:11 +02:00
$detected = '' ;
2003-03-09 15:28:26 +01:00
2003-10-22 13:28:17 +02:00
if ( ! get_var ( 'ConfigLang' , array ( 'POST' , 'COOKIE' )))
2003-08-28 16:31:11 +02:00
{
2003-09-23 15:08:40 +02:00
$detected .= '<br><form action="manageheader.php" method="Post">Please Select your language ' . lang_select ( True , 'en' ) . " </form> \n " ;
2003-08-28 16:31:11 +02:00
}
2003-10-10 01:08:04 +02:00
$detected .= '<table border="0" width="100%" cellspacing="0" cellpadding="0">' . " \n " ;
2003-08-28 16:31:11 +02:00
$detected .= '<tr><td colspan="2"><p>' . $GLOBALS [ 'phpgw_info' ][ 'setup' ][ 'PageMSG' ] . '<br /> </p></td></tr>' ;
2003-12-19 13:34:45 +01:00
$manual = '<a href="../doc/en_US/html/admin/" target="manual">' . lang ( 'eGroupWare Administration Manual' ) . '</a>' ;
2003-08-28 16:31:11 +02:00
$detected .= '<tr><td colspan="2"><p><b>' . lang ( 'Please consult the %1.' , $manual ) . '</b><br> </td></tr>' . " \n " ;
2003-03-09 15:28:26 +01:00
2003-08-28 16:31:11 +02:00
$detected .= '<tr class="th"><td colspan="2">' . lang ( 'Analysis' ) . '</td></tr><tr><td colspan="2">' . " \n " ;
2001-07-30 17:59:25 +02:00
2001-08-21 20:48:50 +02:00
$supported_db = array ();
2003-10-22 13:28:17 +02:00
if ( extension_loaded ( 'mysql' ) || function_exists ( 'mysql_connect' ))
2001-07-30 17:59:25 +02:00
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'You appear to have MySQL support enabled' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
$supported_db [] = 'mysql' ;
2003-12-08 05:50:23 +01:00
$default_db_ports [ 'mysql' ] = '3306' ;
2001-07-30 17:59:25 +02:00
}
else
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'No MySQL support found. Disabling' ) . '<br>' . " \n " ;
2001-07-30 17:59:25 +02:00
}
2003-10-22 13:28:17 +02:00
if ( extension_loaded ( 'pgsql' ) || function_exists ( 'pg_connect' ))
2001-08-21 20:48:50 +02:00
{
2003-11-07 18:26:28 +01:00
$detected .= lang ( 'You appear to have PostgreSQL support enabled' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
$supported_db [] = 'pgsql' ;
}
else
{
2003-11-07 18:26:28 +01:00
$detected .= lang ( 'No PostgreSQL support found. Disabling' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
}
2003-10-22 13:28:17 +02:00
if ( extension_loaded ( 'mssql' ) || function_exists ( 'mssql_connect' ))
2001-07-30 17:59:25 +02:00
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'You appear to have Microsoft SQL Server support enabled' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
$supported_db [] = 'mssql' ;
2001-07-30 17:59:25 +02:00
}
else
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'No Microsoft SQL Server support found. Disabling' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
}
2003-10-22 13:28:17 +02:00
if ( extension_loaded ( 'oci8' ))
2001-08-21 20:48:50 +02:00
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'You appear to have Oracle V8 (OCI) support enabled' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
$supported_db [] = 'oracle' ;
}
else
{
if ( extension_loaded ( 'oracle' ))
2001-07-30 17:59:25 +02:00
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'You appear to have Oracle support enabled' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
$supported_db [] = 'oracle' ;
}
else
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'No Oracle-DB support found. Disabling' ) . '<br>' . " \n " ;
2001-07-30 17:59:25 +02:00
}
}
2001-08-21 20:48:50 +02:00
if ( ! count ( $supported_db ))
2001-07-30 17:59:25 +02:00
{
2003-08-28 16:31:11 +02:00
$detected .= '<b><p align="center" class="msg">'
2002-04-07 06:11:50 +02:00
. lang ( 'Did not find any valid DB support!' )
2003-08-28 16:31:11 +02:00
. " <br> \n "
2003-12-19 13:34:45 +01:00
. lang ( 'Try to configure your php to support one of the above mentioned DBMS, or install eGroupWare by hand.' )
2003-08-28 16:31:11 +02:00
. '</p></b><td></tr></table></body></html>' ;
2002-04-07 06:11:50 +02:00
echo $detected ;
2001-08-21 20:48:50 +02:00
exit ;
2001-07-30 17:59:25 +02:00
}
2002-01-02 16:47:54 +01:00
2003-10-22 13:28:17 +02:00
if ( ! function_exists ( 'version_compare' ))
2002-01-02 16:47:54 +01:00
{
2003-08-28 16:31:11 +02:00
$detected .= '<b><p align="center" class="msg">'
2003-12-19 13:34:45 +01:00
. lang ( 'You appear to be using PHP earlier than 4.1.0. eGroupWare now requires 4.1.0 or later' ) . " \n "
2003-08-28 16:31:11 +02:00
. '</p></b><td></tr></table></body></html>' ;
echo $detected ;
exit ;
2002-01-02 16:47:54 +01:00
}
else
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'You appear to be using PHP4. Enabling PHP4 sessions support' ) . '<br>' . " \n " ;
2002-01-02 16:47:54 +01:00
$supported_sessions_type [] = 'db' ;
$supported_sessions_type [] = 'php4' ;
}
2003-12-08 05:50:23 +01:00
@ 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 );
2002-04-07 06:11:50 +02:00
/*
2003-10-22 13:28:17 +02:00
if ( extension_loaded ( 'xml' ) || function_exists ( 'xml_parser_create' ))
2002-04-07 06:11:50 +02:00
{
$detected .= lang ( 'You appear to have XML support enabled' ) . '<br>' . " \n " ;
$xml_enabled = 'True' ;
}
else
{
$detected .= lang ( 'No XML support found. Disabling' ) . '<br>' . " \n " ;
}
*/
$no_guess = False ;
2003-03-09 15:28:26 +01:00
if ( file_exists ( '../header.inc.php' ) && is_file ( '../header.inc.php' ) && is_readable ( '../header.inc.php' ))
2001-07-30 17:59:25 +02:00
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'Found existing configuration file. Loading settings from the file...' ) . '<br>' . " \n " ;
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'noapi' ] = True ;
2001-08-21 20:48:50 +02:00
$no_guess = true ;
2002-04-07 06:11:50 +02:00
/* This code makes sure the newer multi-domain supporting header.inc.php is being used */
2002-04-29 02:27:32 +02:00
if ( ! isset ( $GLOBALS [ 'phpgw_domain' ]))
2001-08-21 20:48:50 +02:00
{
2003-10-22 13:28:17 +02:00
$detected .= lang ( 'You need to add some domains to your header.inc.php.' ) . '<br>' . " \n " ;
$GLOBALS [ 'phpgw_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' );
2003-12-08 05:50:23 +01:00
$setup_tpl -> set_var ( 'db_port' , '3306' );
2003-10-22 13:28:17 +02:00
$setup_tpl -> set_var ( 'db_name' , 'egroupware' );
$setup_tpl -> set_var ( 'db_user' , 'egroupware' );
$setup_tpl -> set_var ( 'db_pass' , 'your_password' );
$setup_tpl -> set_var ( 'db_type' , 'mysql' );
$setup_tpl -> set_var ( 'config_pass' , 'changeme' );
while ( list ( $k , $v ) = @ each ( $supported_db ))
{
if ( $v == $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_type' ])
{
$selected = ' selected ' ;
$found_dbtype = true ;
}
else
{
$selected = '' ;
}
$dbtype_options .= '<option ' . $selected . 'value="' . $v . '">' . $v . " \n " ;
}
$setup_tpl -> set_var ( 'dbtype_options' , $dbtype_options );
$setup_tpl -> parse ( 'domains' , 'domain' , True );
2001-08-21 20:48:50 +02:00
}
else
{
2002-04-29 02:27:32 +02:00
if ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'header_version' ] != @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'current_header_version' ])
2001-08-21 20:48:50 +02:00
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( " You're using an old header.inc.php version... " ) . '<br>' . " \n " ;
$detected .= lang ( 'Importing old settings into the new format....' ) . '<br>' . " \n " ;
2001-08-21 20:48:50 +02:00
}
2002-04-29 02:27:32 +02:00
reset ( $GLOBALS [ 'phpgw_domain' ]);
$default_domain = each ( $GLOBALS [ 'phpgw_domain' ]);
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ] = $default_domain [ 0 ];
2002-04-07 06:11:50 +02:00
unset ( $default_domain ); // we kill this for security reasons
2002-04-29 02:27:32 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'config_passwd' ] = $GLOBALS [ 'phpgw_domain' ][ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'default_domain' ]][ 'config_passwd' ];
2002-04-08 01:56:03 +02:00
2002-04-29 21:49:24 +02:00
if ( @ $adddomain )
2002-04-08 01:56:03 +02:00
{
2002-04-29 02:27:32 +02:00
$GLOBALS [ 'phpgw_domain' ][ lang ( 'new' )] = array ();
2002-04-08 01:56:03 +02:00
}
2002-04-29 02:27:32 +02:00
reset ( $GLOBALS [ 'phpgw_domain' ]);
while ( list ( $key , $val ) = each ( $GLOBALS [ 'phpgw_domain' ]))
2002-04-08 01:56:03 +02:00
{
$setup_tpl -> set_var ( 'lang_domain' , lang ( 'Domain' ));
$setup_tpl -> set_var ( 'lang_delete' , lang ( 'Delete' ));
$setup_tpl -> set_var ( 'db_domain' , $key );
2002-04-29 02:27:32 +02:00
$setup_tpl -> set_var ( 'db_host' , $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_host' ]);
2003-12-10 12:40:31 +01:00
/* Set default here if the admin didn't set a port yet */
$setup_tpl -> set_var ( 'db_port' , $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_port' ]
? $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_port' ]
: @ $default_db_ports [ $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_type' ]]
);
2002-04-29 02:27:32 +02:00
$setup_tpl -> set_var ( 'db_name' , $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_name' ]);
$setup_tpl -> set_var ( 'db_user' , $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_user' ]);
$setup_tpl -> set_var ( 'db_pass' , $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_pass' ]);
$setup_tpl -> set_var ( 'db_type' , $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_type' ]);
$setup_tpl -> set_var ( 'config_pass' , $GLOBALS [ 'phpgw_domain' ][ $key ][ 'config_passwd' ]);
2002-04-08 01:56:03 +02:00
$selected = '' ;
2002-04-29 02:27:32 +02:00
$dbtype_options = '' ;
2002-04-08 01:56:03 +02:00
$found_dbtype = False ;
2002-08-12 01:57:56 +02:00
@ reset ( $supported_db );
while ( list ( $k , $v ) = @ each ( $supported_db ))
2002-04-08 01:56:03 +02:00
{
2002-04-29 02:27:32 +02:00
if ( $v == $GLOBALS [ 'phpgw_domain' ][ $key ][ 'db_type' ])
2002-04-08 01:56:03 +02:00
{
$selected = ' selected ' ;
$found_dbtype = true ;
}
else
{
$selected = '' ;
}
2002-04-29 02:27:32 +02:00
$dbtype_options .= '<option ' . $selected . 'value="' . $v . '">' . $v . " \n " ;
2002-04-08 01:56:03 +02:00
}
$setup_tpl -> set_var ( 'dbtype_options' , $dbtype_options );
2002-04-29 02:27:32 +02:00
$setup_tpl -> parse ( 'domains' , 'domain' , True );
2002-04-08 01:56:03 +02:00
}
$setup_tpl -> set_var ( 'domain' , '' );
2001-08-21 20:48:50 +02:00
}
2003-10-22 13:28:17 +02:00
if ( defined ( 'PHPGW_SERVER_ROOT' ))
2001-08-21 20:48:50 +02:00
{
2003-12-27 16:58:08 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'server_root' ] = ( PHPGW_SERVER_ROOT == '..' ) ? $realpath : PHPGW_SERVER_ROOT ;
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'include_root' ] = ( PHPGW_INCLUDE_ROOT == '..' ) ? $realpath : PHPGW_SERVER_ROOT ;
2001-08-21 20:48:50 +02:00
}
2002-04-29 02:27:32 +02:00
elseif ( !@ isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'include_root' ]) && @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'header_version' ] <= 1.6 )
2001-08-21 20:48:50 +02:00
{
2002-04-29 02:27:32 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'include_root' ] = @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'server_root' ];
2001-08-21 20:48:50 +02:00
}
2002-04-29 02:27:32 +02:00
elseif ( !@ isset ( $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'header_version' ]) && @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'header_version' ] <= 1.6 )
2001-08-21 20:48:50 +02:00
{
2002-04-29 02:27:32 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'include_root' ] = @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'server_root' ];
2001-08-21 20:48:50 +02:00
}
2001-07-30 17:59:25 +02:00
}
2001-08-21 20:48:50 +02:00
else
2001-07-30 17:59:25 +02:00
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'Sample configuration not found. using built in defaults' ) . '<br>' . " \n " ;
2003-12-27 16:58:08 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'server_root' ] = $realpath ;
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'include_root' ] = $realpath ;
2003-12-19 13:34:45 +01:00
/* This is the basic include needed on each page for eGroupWare application compliance */
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'flags' ][ 'htmlcompliant' ] = True ;
2002-01-08 03:12:43 +01:00
/* These are the settings for the database system */
2002-04-08 01:56:03 +02:00
$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' );
2003-12-22 03:45:24 +01:00
$setup_tpl -> set_var ( 'db_port' , '' );
2003-08-29 00:48:52 +02:00
$setup_tpl -> set_var ( 'db_name' , 'egroupware' );
$setup_tpl -> set_var ( 'db_user' , 'egroupware' );
2002-04-08 01:56:03 +02:00
$setup_tpl -> set_var ( 'db_pass' , 'your_password' );
$setup_tpl -> set_var ( 'db_type' , 'mysql' );
$setup_tpl -> set_var ( 'config_pass' , 'changeme' );
while ( list ( $k , $v ) = each ( $supported_db ))
{
$dbtype_options .= '<option value="' . $v . '">' . $v . " \n " ;
}
$setup_tpl -> set_var ( 'dbtype_options' , $dbtype_options );
2002-04-29 02:27:32 +02:00
$setup_tpl -> parse ( 'domains' , 'domain' , True );
2002-04-08 01:56:03 +02:00
$setup_tpl -> set_var ( 'domain' , '' );
$setup_tpl -> set_var ( 'comment_l' , '<!-- ' );
$setup_tpl -> set_var ( 'comment_r' , ' -->' );
2001-07-30 17:59:25 +02:00
/* These are a few of the advanced settings */
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_persistent' ] = True ;
2003-05-18 17:06:15 +02:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mcrypt_enabled' ] = extension_loaded ( 'mcrypt' );
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'versions' ][ 'mcrypt' ] = '' ;
2001-07-30 17:59:25 +02:00
2001-08-21 20:48:50 +02:00
srand (( double ) microtime () * 1000000 );
$random_char = array (
'0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' ,
2001-07-30 17:59:25 +02:00
'g' , 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' ,
'w' , 'x' , 'y' , 'z' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' ,
2002-04-07 06:11:50 +02:00
'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z'
);
2001-07-30 17:59:25 +02:00
2002-04-07 06:11:50 +02:00
for ( $i = 0 ; $i < 30 ; $i ++ )
2001-08-21 20:48:50 +02:00
{
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mcrypt_iv' ] .= $random_char [ rand ( 1 , count ( $random_char ))];
2001-08-21 20:48:50 +02:00
}
2001-07-30 17:59:25 +02:00
}
// now guessing better settings then the default ones
2001-08-21 20:48:50 +02:00
if ( ! $no_guess )
{
2002-04-07 06:11:50 +02:00
$detected .= lang ( 'Now guessing better values for defaults...' ) . '<br>' . " \n " ;
2003-05-18 17:06:15 +02:00
$this_dir = dirname ( $_SERVER [ 'SCRIPT_FILENAME' ]);
$updir = str_replace ( '/setup' , '' , $this_dir );
2002-03-03 22:53:00 +01:00
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'server_root' ] = $updir ;
$GLOBALS [ 'phpgw_info' ][ 'server' ][ 'include_root' ] = $updir ;
2001-08-21 20:48:50 +02:00
}
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'detected' , $detected );
/* End of detected settings, now display the form with the detected or prior values */
2002-04-29 02:27:32 +02:00
$setup_tpl -> set_var ( 'server_root' , @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'server_root' ]);
$setup_tpl -> set_var ( 'include_root' , @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'include_root' ]);
$setup_tpl -> set_var ( 'header_admin_password' , @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'header_admin_password' ]);
2002-04-07 06:11:50 +02:00
2002-04-29 02:27:32 +02:00
if ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_persistent' ])
2002-04-07 06:11:50 +02:00
{
$setup_tpl -> set_var ( 'db_persistent_yes' , ' selected' );
2001-07-30 17:59:25 +02:00
}
else
{
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'db_persistent_no' , ' selected' );
2001-07-30 17:59:25 +02:00
}
2002-04-07 06:11:50 +02:00
$selected = '' ;
2002-04-29 02:27:32 +02:00
$session_options = '' ;
2002-04-07 06:11:50 +02:00
while ( list ( $k , $v ) = each ( $supported_sessions_type ))
{
2002-04-29 02:27:32 +02:00
if ( $v == @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'sessions_type' ])
2002-04-07 06:11:50 +02:00
{
$selected = ' selected ' ;
}
else
{
$selected = '' ;
}
2002-04-29 02:27:32 +02:00
$session_options .= '<option ' . $selected . 'value="' . $v . '">' . $v . " \n " ;
2002-04-07 06:11:50 +02:00
}
$setup_tpl -> set_var ( 'session_options' , $session_options );
2002-04-29 02:27:32 +02:00
if ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mcrypt_enabled' ])
2002-01-02 16:47:54 +01:00
{
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'mcrypt_enabled_yes' , ' selected' );
2002-01-02 16:47:54 +01:00
}
else
{
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'mcrypt_enabled_no' , ' selected' );
2002-01-02 16:47:54 +01:00
}
2001-07-30 17:59:25 +02:00
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'mcrypt' , $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'versions' ][ 'mcrypt' ]);
$setup_tpl -> set_var ( 'mcrypt_iv' , $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'mcrypt_iv' ]);
2002-04-27 01:54:22 +02:00
$setup_tpl -> set_var ( 'lang_setup_acl' , lang ( 'Limit access to setup to the following addresses or networks (e.g. 10.1.1,127.0.0.1)' ));
$setup_tpl -> set_var ( 'setup_acl' , $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'setup_acl' ]);
2003-05-19 00:06:01 +02:00
if ( @ $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'show_domain_selectbox' ])
2002-04-07 06:11:50 +02:00
{
$setup_tpl -> set_var ( 'domain_selectbox_yes' , ' selected' );
}
else
{
$setup_tpl -> set_var ( 'domain_selectbox_no' , ' selected' );
}
$errors = '' ;
if ( ! $found_dbtype )
{
2002-04-08 01:56:03 +02:00
/*
2002-04-07 06:11:50 +02:00
$errors .= '<br><font color="red">' . lang ( 'Warning!' ) . '<br>'
2003-05-18 17:06:15 +02:00
. lang ( 'The db_type in defaults (%1) is not supported on this server. using first supported type.' , $GLOBALS [ 'phpgw_info' ][ 'server' ][ 'db_type' ])
2002-04-07 06:11:50 +02:00
. '</font>' ;
2002-04-08 01:56:03 +02:00
*/
2002-04-07 06:11:50 +02:00
}
if ( is_writeable ( '../header.inc.php' ) ||
( ! file_exists ( '../header.inc.php' ) && is_writeable ( '../' )))
{
2003-08-28 16:31:11 +02:00
$errors .= '<br><input type="submit" name="action[write]" value="' . lang ( 'Write config' ) . '"> '
. lang ( 'or' ) . ' <input type="submit" name="action[download]" value="' . lang ( 'Download' ) . '"> '
. lang ( 'or' ) . ' <input type=submit name="action[view]" value="' . lang ( 'View' ) . '"> ' . lang ( 'the file' ) . '.</form>' ;
2002-04-07 06:11:50 +02:00
}
else
{
$errors .= '<br>'
2003-05-18 17:06:15 +02:00
. lang ( 'Cannot create the header.inc.php due to file permission restrictions.<br> Instead you can %1 the file.' ,
2003-08-28 16:31:11 +02:00
'<input type="submit" name="action[download]" value="' . lang ( 'Download' ) . '">' . lang ( 'or' ) . ' <input type="submit" name="action[view]" value="' . lang ( 'View' ) . '">' )
2002-04-07 06:11:50 +02:00
. '</form>' ;
}
2003-08-28 16:31:11 +02:00
// set domain and password for the continue button
@ reset ( $GLOBALS [ 'phpgw_domain' ]);
list ( $firstDomain ) = @ each ( $GLOBALS [ 'phpgw_domain' ]);
$setup_tpl -> set_var ( array (
'FormDomain' => $firstDomain ,
'FormPW' => $GLOBALS [ 'phpgw_domain' ][ $firstDomain ][ 'config_passwd' ]
));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'errors' , $errors );
$setup_tpl -> set_var ( 'lang_settings' , lang ( 'Settings' ));
2002-04-08 01:56:03 +02:00
$setup_tpl -> set_var ( 'lang_adddomain' , lang ( 'Add a domain' ));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'lang_serverroot' , lang ( 'Server Root' ));
$setup_tpl -> set_var ( 'lang_includeroot' , lang ( 'Include Root (this should be the same as Server Root unless you know what you are doing)' ));
$setup_tpl -> set_var ( 'lang_adminpass' , lang ( 'Admin password to header manager' ));
$setup_tpl -> set_var ( 'lang_dbhost' , lang ( 'DB Host' ));
2002-04-08 01:56:03 +02:00
$setup_tpl -> set_var ( 'lang_dbhostdescr' , lang ( 'Hostname/IP of database server' ));
2003-12-08 05:50:23 +01:00
$setup_tpl -> set_var ( 'lang_dbport' , lang ( 'DB Port' ));
$setup_tpl -> set_var ( 'lang_dbportdescr' , lang ( 'TCP port number of database server' ));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'lang_dbname' , lang ( 'DB Name' ));
2002-04-08 01:56:03 +02:00
$setup_tpl -> set_var ( 'lang_dbnamedescr' , lang ( 'Name of database' ));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'lang_dbuser' , lang ( 'DB User' ));
2003-12-19 13:34:45 +01:00
$setup_tpl -> set_var ( 'lang_dbuserdescr' , lang ( 'Name of db user eGroupWare uses to connect' ));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'lang_dbpass' , lang ( 'DB Password' ));
2002-04-08 01:56:03 +02:00
$setup_tpl -> set_var ( 'lang_dbpassdescr' , lang ( 'Password of db user' ));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'lang_dbtype' , lang ( 'DB Type' ));
2003-12-19 13:34:45 +01:00
$setup_tpl -> set_var ( 'lang_whichdb' , lang ( 'Which database type do you want to use with eGroupWare?' ));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'lang_configpass' , lang ( 'Configuration Password' ));
$setup_tpl -> set_var ( 'lang_passforconfig' , lang ( 'Password needed for configuration' ));
$setup_tpl -> set_var ( 'lang_persist' , lang ( 'Persistent connections' ));
$setup_tpl -> set_var ( 'lang_persistdescr' , lang ( 'Do you want persistent connections (higher performance, but consumes more resources)' ));
$setup_tpl -> set_var ( 'lang_sesstype' , lang ( 'Sessions Type' ));
$setup_tpl -> set_var ( 'lang_sesstypedescr' , lang ( 'What type of sessions management do you want to use (PHP4 session management may perform better)?' ));
$setup_tpl -> set_var ( 'lang_enablemcrypt' , lang ( 'Enable MCrypt' ));
2003-11-03 23:21:55 +01:00
$setup_tpl -> set_var ( 'lang_mcrypt_warning' , lang ( 'Not all mcrypt algorithms and modes work with eGroupWare. If you experience problems try switching it off.' ));
2002-04-07 06:11:50 +02:00
$setup_tpl -> set_var ( 'lang_mcryptversion' , lang ( 'MCrypt version' ));
$setup_tpl -> set_var ( 'lang_mcryptversiondescr' , lang ( 'Set this to "old" for versions < 2.4, otherwise the exact mcrypt version you use.' ));
$setup_tpl -> set_var ( 'lang_mcryptiv' , lang ( 'MCrypt initialization vector' ));
$setup_tpl -> set_var ( 'lang_mcryptivdescr' , lang ( 'This should be around 30 bytes in length.<br>Note: The default has been randomly generated.' ));
$setup_tpl -> set_var ( 'lang_domselect' , lang ( 'Domain select box on login' ));
$setup_tpl -> set_var ( 'lang_finaldescr' , lang ( 'After retrieving the file, put it into place as the header.inc.php. Then, click "continue".' ));
2003-08-28 16:31:11 +02:00
$setup_tpl -> set_var ( 'lang_continue' , lang ( 'Continue' ));
2002-04-07 06:11:50 +02:00
2002-04-29 02:27:32 +02:00
$setup_tpl -> pfp ( 'out' , 'manageheader' );
2003-10-22 13:28:17 +02:00
2003-10-10 01:08:04 +02:00
$GLOBALS [ 'phpgw_setup' ] -> html -> show_footer ();
2003-10-22 13:28:17 +02:00
2002-04-07 06:11:50 +02:00
break ; // ending the switch default
2001-08-21 20:48:50 +02:00
}
2001-07-30 17:59:25 +02:00
?>