2001-07-30 17:59:25 +02:00
< ? php
2002-12-20 00:33:44 +01:00
/************************************************************************** \
2004-01-27 21:49:25 +01:00
* eGroupWare *
* http :// www . egroupware . org *
2002-12-20 00:33:44 +01:00
* -------------------------------------------- *
* 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-01-05 22:20:52 +01:00
2002-02-18 17:18:34 +01:00
$GLOBALS [ 'DEBUG' ] = False ;
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ] = array (
'flags' => array (
'noheader' => True ,
'nonavbar' => True ,
'currentapp' => 'home' ,
'noapi' => True ,
'nocachecontrol' => True
));
2001-07-30 17:59:25 +02:00
include ( './inc/functions.inc.php' );
2002-03-26 03:34:38 +01:00
@ set_time_limit ( 0 );
2002-01-20 17:04:25 +01:00
2005-03-04 13:40:28 +01:00
$tpl_root = $GLOBALS [ 'egw_setup' ] -> html -> setup_tpl_dir ( 'setup' );
2002-08-12 01:54:58 +02:00
$setup_tpl = CreateObject ( 'setup.Template' , $tpl_root );
2002-12-20 00:33:44 +01:00
$setup_tpl -> set_file ( array
(
2004-01-06 14:38:45 +01: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' ,
'T_setup_main' => 'setup_main.tpl' ,
'T_setup_db_blocks' => 'setup_db_blocks.tpl'
2001-07-30 17:59:25 +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' );
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_1' , 'V_db_stage_1' );
2004-08-14 17:02:24 +02:00
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_1a' , 'V_db_stage_1a' );
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_2' , 'V_db_stage_2' );
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_3' , 'V_db_stage_3' );
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_4' , 'V_db_stage_4' );
2001-12-16 17:35:39 +01:00
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_5' , 'V_db_stage_5' );
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_6_pre' , 'V_db_stage_6_pre' );
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_6_post' , 'V_db_stage_6_post' );
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_10' , 'V_db_stage_10' );
$setup_tpl -> set_block ( 'T_setup_db_blocks' , 'B_db_stage_default' , 'V_db_stage_default' );
// Check header and authentication
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'header' ] = $GLOBALS [ 'egw_setup' ] -> detection -> check_header ();
if ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'header' ] != '10' )
2001-07-30 17:59:25 +02:00
{
2005-03-04 13:40:28 +01:00
if ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'header' ] == 4 ) // header needs update, go there direct
2004-07-04 12:30:42 +02:00
{
Header ( 'Location: manageheader.php' );
}
else // run check-install first
{
Header ( 'Location: check_install.php?intro=1' );
}
2001-07-30 17:59:25 +02:00
exit ;
}
2005-03-04 13:40:28 +01:00
elseif ( ! $GLOBALS [ 'egw_setup' ] -> auth ( 'Config' ))
2001-07-30 17:59:25 +02:00
{
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> html -> show_header ( lang ( 'Please login' ), True );
$GLOBALS [ 'egw_setup' ] -> html -> login_form ();
$GLOBALS [ 'egw_setup' ] -> html -> show_footer ();
2001-07-30 17:59:25 +02:00
exit ;
}
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> loaddb ();
2002-01-14 13:14:40 +01:00
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> html -> show_header (
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'header_msg' ],
2004-10-16 01:06:34 +02:00
False ,
'config' ,
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> ConfigDomain . '(' . $GLOBALS [ 'egw_domain' ][ $GLOBALS [ 'egw_setup' ] -> ConfigDomain ][ 'db_type' ] . ')'
2004-10-16 01:06:34 +02:00
);
2002-01-14 13:14:40 +01:00
/* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */
2005-03-04 13:40:28 +01:00
/* $GLOBALS['egw_setup']->clear_session_cache(); */
2002-01-14 13:14:40 +01:00
// Database actions
2005-03-04 13:40:28 +01:00
$setup_info = $GLOBALS [ 'egw_setup' ] -> detection -> get_versions ();
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] = $GLOBALS [ 'egw_setup' ] -> detection -> check_db ( $setup_info );
if ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] != 1 )
2001-07-30 17:59:25 +02:00
{
2005-03-04 13:40:28 +01:00
$setup_info = $GLOBALS [ 'egw_setup' ] -> detection -> get_versions ();
$setup_info = $GLOBALS [ 'egw_setup' ] -> detection -> get_db_versions ( $setup_info );
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] = $GLOBALS [ 'egw_setup' ] -> detection -> check_db ( $setup_info );
2002-02-18 17:18:34 +01:00
if ( $GLOBALS [ 'DEBUG' ])
2002-01-07 11:50:42 +01:00
{
_debug_array ( $setup_info );
}
2001-07-30 17:59:25 +02:00
}
2005-03-04 13:40:28 +01:00
if ( $GLOBALS [ 'DEBUG' ]) { echo 'Stage: ' . $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ]; }
2001-07-30 17:59:25 +02:00
// begin DEBUG code
2005-03-04 13:40:28 +01:00
//$GLOBALS['egw_info']['setup']['stage']['db'] = 0;
2001-07-30 17:59:25 +02:00
//$action = 'Upgrade';
2002-01-08 03:12:43 +01:00
// end DEBUG code
2001-07-30 17:59:25 +02:00
2002-04-29 21:49:24 +02:00
switch ( @ get_var ( 'action' , Array ( 'POST' )))
2001-07-30 17:59:25 +02:00
{
2001-12-16 17:35:39 +01:00
case 'Uninstall all applications' :
$subtitle = lang ( 'Deleting Tables' );
2003-06-17 23:37:40 +02:00
$submsg = lang ( 'Are you sure you want to delete your existing tables and data?' ) . '.' ;
2003-08-28 16:31:11 +02:00
$subaction = lang ( 'uninstall' );
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ] = 'predrop' ;
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] = 5 ;
2001-12-16 17:35:39 +01:00
break ;
2001-07-30 17:59:25 +02:00
case 'Create Database' :
$subtitle = lang ( 'Create Database' );
$submsg = lang ( 'At your request, this script is going to attempt to create the database and assign the db user rights to it' );
2003-08-28 16:31:11 +02:00
$subaction = lang ( 'created' );
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ] = 'dbcreate' ;
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] = 6 ;
2001-07-30 17:59:25 +02:00
break ;
2001-12-16 17:35:39 +01:00
case 'REALLY Uninstall all applications' :
2001-07-30 17:59:25 +02:00
$subtitle = lang ( 'Deleting Tables' );
2001-12-16 17:35:39 +01:00
$submsg = lang ( 'At your request, this script is going to take the evil action of uninstalling all your apps, which deletes your existing tables and data' ) . '.' ;
2003-08-28 16:31:11 +02:00
$subaction = lang ( 'uninstalled' );
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ] = 'drop' ;
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] = 6 ;
2001-07-30 17:59:25 +02:00
break ;
case 'Upgrade' :
$subtitle = lang ( 'Upgrading Tables' );
$submsg = lang ( 'At your request, this script is going to attempt to upgrade your old applications to the current versions' ) . '.' ;
2004-10-16 01:06:34 +02:00
if ( $_POST [ 'backup' ])
{
$submsg .= ' ' . lang ( 'After backing up your tables first.' );
}
2003-08-28 16:31:11 +02:00
$subaction = lang ( 'upgraded' );
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ] = 'oldversion' ;
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] = 6 ;
2001-07-30 17:59:25 +02:00
break ;
case 'Install' :
$subtitle = lang ( 'Creating Tables' );
2004-10-16 01:06:34 +02:00
if ( $_POST [ 'upload' ])
{
$submsg = lang ( 'At your request, this script is going to attempt to install a previous backup' ) . '.' ;
}
else
{
$submsg = lang ( 'At your request, this script is going to attempt to install the core tables and the admin and preferences applications for you' ) . '.' ;
}
2003-08-28 16:31:11 +02:00
$subaction = lang ( 'installed' );
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ] = 'new' ;
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ] = 6 ;
2001-07-30 17:59:25 +02:00
break ;
}
2002-01-14 13:14:40 +01:00
$setup_tpl -> set_var ( 'subtitle' , @ $subtitle );
$setup_tpl -> set_var ( 'submsg' , @ $submsg );
2003-08-28 16:31:11 +02:00
$setup_tpl -> set_var ( 'subaction' , @ $subaction );
2001-07-30 17:59:25 +02:00
// Old PHP
2003-08-29 18:42:25 +02:00
if ( ! function_exists ( 'version_compare' )) //version_compare() is only available in PHP4.1+
2001-07-30 17:59:25 +02:00
{
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> html -> show_header ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'header_msg' ], True );
$GLOBALS [ 'egw_setup' ] -> html -> show_alert_msg ( 'Error' ,
2005-07-11 20:02:19 +02:00
lang ( 'You appear to be running an old version of PHP <br />It its recommend that you upgrade to a new version. <br />Older version of PHP might not run eGroupWare correctly, if at all. <br /><br />Please upgrade to at least version %1' , '4.1' ));
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> html -> show_footer ();
2001-07-30 17:59:25 +02:00
exit ;
}
2003-12-19 13:34:45 +01:00
2001-07-30 17:59:25 +02:00
// BEGIN setup page
2003-12-19 13:34:45 +01:00
2005-03-04 13:40:28 +01:00
//$GLOBALS['egw_setup']->app_status();
$GLOBALS [ 'egw_info' ][ 'server' ][ 'app_images' ] = 'templates/default/images' ;
$incomplete = $GLOBALS [ 'egw_info' ][ 'server' ][ 'app_images' ] . '/incomplete.png' ;
$completed = $GLOBALS [ 'egw_info' ][ 'server' ][ 'app_images' ] . '/completed.png' ;
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'img_incomplete' , $incomplete );
$setup_tpl -> set_var ( 'img_completed' , $completed );
2004-05-02 14:11:35 +02:00
$setup_tpl -> set_var ( 'db_step_text' , lang ( 'Step %1 - Simple Application Management' , 1 ));
2001-07-30 17:59:25 +02:00
2005-03-04 13:40:28 +01:00
switch ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ])
2001-07-30 17:59:25 +02:00
{
case 1 :
2005-03-04 13:40:28 +01:00
$setup_tpl -> set_var ( 'dbnotexist' , lang ( 'Your Database is not working!' ) . ':<p>' . $GLOBALS [ 'egw_setup' ] -> db -> Error );
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'makesure' , lang ( 'makesure' ));
$setup_tpl -> set_var ( 'notcomplete' , lang ( 'not complete' ));
$setup_tpl -> set_var ( 'oncesetup' , lang ( 'Once the database is setup correctly' ));
$setup_tpl -> set_var ( 'createdb' , lang ( 'Or we can attempt to create the database for you:' ));
2003-08-28 16:31:11 +02:00
$setup_tpl -> set_var ( 'create_database' , lang ( 'Create database' ));
2005-03-04 13:40:28 +01:00
$info = $GLOBALS [ 'egw_domain' ][ $GLOBALS [ 'egw_setup' ] -> ConfigDomain ];
2003-08-29 18:42:25 +02:00
switch ( $info [ 'db_type' ])
2001-07-30 17:59:25 +02:00
{
case 'mysql' :
2003-08-29 18:42:25 +02:00
$setup_tpl -> set_var ( 'instr' ,
2004-01-06 14:38:45 +01:00
lang ( " Instructions for creating the database in %1: " , 'MySql' )
2005-07-11 20:02:19 +02:00
. '<br />' . lang ( 'Login to mysql -' )
. '<br /><i>[user@server user]# mysql -u root -p</i><br />'
2004-01-06 14:38:45 +01:00
. lang ( 'Create the empty database and grant user permissions -' )
2005-07-11 20:02:19 +02:00
. " <br /><i>mysql> create database $info[db_name] ;</i> "
. " <br /><i>mysql> grant all on " . $info [ 'db_name' ]
2004-01-06 14:38:45 +01:00
. " .* to " . $info [ 'db_user' ] . " @localhost identified by ' " . $info [ 'db_pass' ] . " ';</i> " );
2004-08-14 17:02:24 +02:00
$setup_tpl -> parse ( 'V_db_stage_1' , 'B_db_stage_1' );
2001-07-30 17:59:25 +02:00
break ;
case 'pgsql' :
2003-08-29 18:42:25 +02:00
$setup_tpl -> set_var ( 'instr' ,
2004-01-06 14:38:45 +01:00
lang ( 'Instructions for creating the database in %1:' , 'PostgreSQL' )
2005-07-11 20:02:19 +02:00
. '<br />' . lang ( 'Start the postmaster' )
. " <br /><i>[user@server user]# postmaster -i -D /home/[username]/[dataDir]</i><br /> "
2004-01-06 14:38:45 +01:00
. lang ( 'Create the empty database -' )
2005-07-11 20:02:19 +02:00
. " <br /><i>[user@server user]# createdb " . $info [ 'db_name' ] . " </i> " );
2004-08-14 17:02:24 +02:00
$setup_tpl -> parse ( 'V_db_stage_1' , 'B_db_stage_1' );
2001-07-30 17:59:25 +02:00
break ;
2004-01-06 14:38:45 +01:00
default :
2004-08-14 17:02:24 +02:00
$setup_tpl -> parse ( 'V_db_stage_1' , 'B_db_stage_1a' );
2001-07-30 17:59:25 +02:00
}
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_1' );
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
case 2 :
2005-07-11 20:02:19 +02:00
$setup_tpl -> set_var ( 'prebeta' , lang ( 'You appear to be running a pre-beta version of eGroupWare.<br />These versions are no longer supported, and there is no upgrade path for them in setup.<br /> You may wish to first upgrade to 0.9.10 (the last version to support pre-beta upgrades) <br />and then upgrade from there with the current version.' ));
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'notcomplete' , lang ( 'not complete' ));
$setup_tpl -> parse ( 'V_db_stage_2' , 'B_db_stage_2' );
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_2' );
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
case 3 :
$setup_tpl -> set_var ( 'dbexists' , lang ( 'Your database is working, but you dont have any applications installed' ));
$setup_tpl -> set_var ( 'install' , lang ( 'Install' ));
$setup_tpl -> set_var ( 'proceed' , lang ( 'We can proceed' ));
2004-07-21 15:27:25 +02:00
$setup_tpl -> set_var ( 'coreapps' , lang ( 'all applications' ));
$setup_tpl -> set_var ( 'lang_debug' , lang ( 'enable for extra debug-messages' ));
2004-11-21 10:44:02 +01:00
$setup_tpl -> set_var ( 'lang_system_charset' , lang ( '<b>charset to use</b> (use utf-8 if you plan to use languages with different charsets):' ));
2005-03-04 13:40:28 +01:00
$setup_tpl -> set_var ( 'system_charset' , $GLOBALS [ 'egw_setup' ] -> translation -> get_charsets ( 'system_charset' , lang ( 'charset' )));
2004-10-16 01:06:34 +02:00
$setup_tpl -> set_var ( 'lang_restore' , lang ( 'Or you can install a previous backup.' ));
$setup_tpl -> set_var ( 'upload' , '<input type="file" name="uploaded" /> ' .
'<input type="submit" name="upload" value="' . htmlspecialchars ( lang ( 'install backup' )) . '" title="' . htmlspecialchars ( lang ( " uploads a backup and installs it on your DB " )) . '" />' );
2001-07-30 17:59:25 +02:00
$setup_tpl -> parse ( 'V_db_stage_3' , 'B_db_stage_3' );
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_3' );
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
case 4 :
2003-12-19 13:34:45 +01:00
$setup_tpl -> set_var ( 'oldver' , lang ( 'You appear to be running version %1 of eGroupWare' , $setup_info [ 'phpgwapi' ][ 'currentver' ]));
2003-06-17 23:37:40 +02:00
$setup_tpl -> set_var ( 'automatic' , lang ( 'We will automatically update your tables/records to %1' , $setup_info [ 'phpgwapi' ][ 'version' ]));
2005-07-11 20:02:19 +02:00
$setup_tpl -> set_var ( 'backupwarn' , lang ( 'but we <u>highly recommend backing up</u> your tables in case the script causes damage to your data.<br /><strong>These automated scripts can easily destroy your data.</strong>' ));
2004-10-16 01:06:34 +02:00
$setup_tpl -> set_var ( 'lang_backup' , lang ( 'create a backup before upgrading the DB' ));
2004-07-23 02:50:36 +02:00
$setup_tpl -> set_var ( 'lang_debug' , lang ( 'enable for extra debug-messages' ));
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'upgrade' , lang ( 'Upgrade' ));
2001-09-28 16:26:26 +02:00
$setup_tpl -> set_var ( 'goto' , lang ( 'Go to' ));
$setup_tpl -> set_var ( 'configuration' , lang ( 'configuration' ));
2004-06-27 11:06:05 +02:00
$setup_tpl -> set_var ( 'admin_account' , lang ( 'Create admin account' ));
2001-09-28 16:26:26 +02:00
$setup_tpl -> set_var ( 'applications' , lang ( 'Manage Applications' ));
2004-10-16 01:06:34 +02:00
$setup_tpl -> set_var ( 'db_backup' , lang ( 'DB backup and restore' ));
2001-09-28 16:26:26 +02:00
$setup_tpl -> set_var ( 'language_management' , lang ( 'Manage Languages' ));
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'uninstall_all_applications' , lang ( 'Uninstall all applications' ));
$setup_tpl -> set_var ( 'dont_touch_my_data' , lang ( 'Dont touch my data' ));
2004-10-23 17:01:58 +02:00
$setup_tpl -> set_var ( 'dropwarn' , lang ( 'Your tables will be dropped and you will lose data' ));
2001-07-30 17:59:25 +02:00
$setup_tpl -> parse ( 'V_db_stage_4' , 'B_db_stage_4' );
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_4' );
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
case 5 :
2001-12-16 17:35:39 +01:00
$setup_tpl -> set_var ( 'are_you_sure' , lang ( 'ARE YOU SURE?' ));
$setup_tpl -> set_var ( 'really_uninstall_all_applications' , lang ( 'REALLY Uninstall all applications' ));
$setup_tpl -> set_var ( 'dropwarn' , lang ( 'Your tables will be dropped and you will lose data' ));
$setup_tpl -> set_var ( 'cancel' , lang ( 'cancel' ));
$setup_tpl -> parse ( 'V_db_stage_5' , 'B_db_stage_5' );
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_5' );
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
case 6 :
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'status' , lang ( 'Status' ));
$setup_tpl -> set_var ( 'notcomplete' , lang ( 'not complete' ));
$setup_tpl -> set_var ( 'tblchange' , lang ( 'Table Change Messages' ));
2001-12-16 17:35:39 +01:00
$setup_tpl -> parse ( 'V_db_stage_6_pre' , 'B_db_stage_6_pre' );
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_6_pre' );
2004-10-16 01:06:34 +02:00
$setup_tpl -> set_var ( 'tableshave' , lang ( 'If you did not receive any errors, your applications have been' ));
2004-01-06 14:38:45 +01:00
2001-07-30 17:59:25 +02:00
// FIXME : CAPTURE THIS OUTPUT
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> db -> Halt_On_Error = 'report' ;
2001-07-30 17:59:25 +02:00
2005-03-04 13:40:28 +01:00
switch ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ])
2001-07-30 17:59:25 +02:00
{
2001-08-21 20:48:50 +02:00
case 'dbcreate' :
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> db -> create_database ( $_POST [ 'db_root' ], $_POST [ 'db_pass' ]);
2001-07-30 17:59:25 +02:00
break ;
2001-08-21 20:48:50 +02:00
case 'drop' :
2005-03-04 13:40:28 +01:00
$setup_info = $GLOBALS [ 'egw_setup' ] -> detection -> get_versions ( $setup_info );
$setup_info = $GLOBALS [ 'egw_setup' ] -> process -> droptables ( $setup_info );
2001-07-30 17:59:25 +02:00
break ;
2001-08-21 20:48:50 +02:00
case 'new' :
2004-10-16 01:06:34 +02:00
// use uploaded backup, instead installing from scratch
if ( $_POST [ 'upload' ])
{
$db_backup = CreateObject ( 'phpgwapi.db_backup' );
if ( is_array ( $_FILES [ 'uploaded' ]) && ! $_FILES [ 'uploaded' ][ 'error' ] &&
is_uploaded_file ( $_FILES [ 'uploaded' ][ 'tmp_name' ]))
{
if ( preg_match ( '/\.(bz2|gz)$/i' , $_FILES [ 'uploaded' ][ 'name' ], $matches ))
{
$ext = '.' . $matches [ 1 ];
move_uploaded_file ( $_FILES [ 'uploaded' ][ 'tmp_name' ], $_FILES [ 'uploaded' ][ 'tmp_name' ] . $ext );
$_FILES [ 'uploaded' ][ 'tmp_name' ] .= $ext ;
}
if ( is_resource ( $f = $db_backup -> fopen_backup ( $_FILES [ 'uploaded' ][ 'tmp_name' ], true )))
{
echo '<p align="center">' . lang ( 'restore started, this might take a view minutes ...' ) . " </p> \n " . str_repeat ( ' ' , 4096 );
$db_backup -> restore ( $f );
fclose ( $f );
echo '<p align="center">' . lang ( 'restore finished' ) . " </p> \n " ;
unlink ( $_FILES [ 'uploaded' ][ 'tmp_name' ]);
}
else // backup failed ==> dont start the upgrade
{
$setup_tpl -> set_var ( 'submsg' , lang ( 'Restore failed' ));
$setup_tpl -> set_var ( 'tableshave' , '<b>' . $f . '</b>' );
$setup_tpl -> set_var ( 'subaction' , '' );
}
}
}
else
{
2005-03-04 13:40:28 +01:00
$setup_info = $GLOBALS [ 'egw_setup' ] -> detection -> upgrade_exclude ( $setup_info );
2004-11-21 10:44:02 +01:00
// Set the DB's client charset if a system-charset is set
if ( $_REQUEST [ 'system_charset' ])
{
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> db -> Link_ID -> SetCharSet ( $_REQUEST [ 'system_charset' ]);
2004-11-21 10:44:02 +01:00
}
2005-03-04 13:40:28 +01:00
$setup_info = $GLOBALS [ 'egw_setup' ] -> process -> pass ( $setup_info , 'new' , $_REQUEST [ 'debug' ], True , $_REQUEST [ 'system_charset' ]);
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ] = 'oldversion' ;
2004-10-16 01:06:34 +02:00
}
2001-07-30 17:59:25 +02:00
break ;
2001-08-21 20:48:50 +02:00
case 'oldversion' :
2004-10-16 01:06:34 +02:00
// create a backup, before upgrading the tables
if ( $_POST [ 'backup' ])
{
$db_backup = CreateObject ( 'phpgwapi.db_backup' );
if ( is_resource ( $f = $db_backup -> fopen_backup ()))
{
echo '<p align="center">' . lang ( 'backup started, this might take a view minutes ...' ) . " </p> \n " . str_repeat ( ' ' , 4096 );
$db_backup -> backup ( $f );
fclose ( $f );
echo '<p align="center">' . lang ( 'backup finished' ) . " </p> \n " ;
}
else // backup failed ==> dont start the upgrade
{
$setup_tpl -> set_var ( 'submsg' , lang ( 'Backup failed' ));
$setup_tpl -> set_var ( 'tableshave' , '<b>' . $f . '</b>' );
$setup_tpl -> set_var ( 'subaction' , '' );
}
}
if ( !@ $_POST [ 'backup' ] || ! is_string ( $f ))
{
2005-03-04 13:40:28 +01:00
$setup_info = $GLOBALS [ 'egw_setup' ] -> process -> pass ( $setup_info , 'upgrade' , $_REQUEST [ 'debug' ]);
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'currentver' ][ 'phpgwapi' ] = 'oldversion' ;
2004-10-16 01:06:34 +02:00
}
2001-07-30 17:59:25 +02:00
break ;
}
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> db -> Halt_On_Error = 'no' ;
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 're-check_my_installation' , lang ( 'Re-Check My Installation' ));
2001-12-16 17:35:39 +01:00
$setup_tpl -> parse ( 'V_db_stage_6_post' , 'B_db_stage_6_post' );
$db_filled_block = $db_filled_block . $setup_tpl -> get_var ( 'V_db_stage_6_post' );
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
case 10 :
$setup_tpl -> set_var ( 'tablescurrent' , lang ( 'Your applications are current' ));
$setup_tpl -> set_var ( 'uninstall_all_applications' , lang ( 'Uninstall all applications' ));
$setup_tpl -> set_var ( 'insanity' , lang ( 'Insanity' ));
$setup_tpl -> set_var ( 'dropwarn' , lang ( 'Your tables will be dropped and you will lose data' ));
$setup_tpl -> set_var ( 'deletetables' , lang ( 'Uninstall all applications' ));
$setup_tpl -> parse ( 'V_db_stage_10' , 'B_db_stage_10' );
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_10' );
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
default :
$setup_tpl -> set_var ( 'dbnotexist' , lang ( 'Your database does not exist' ));
$setup_tpl -> parse ( 'V_db_stage_default' , 'B_db_stage_default' );
$db_filled_block = $setup_tpl -> get_var ( 'V_db_stage_default' );
$setup_tpl -> set_var ( 'V_db_filled_block' , $db_filled_block );
break ;
}
2004-10-16 01:06:34 +02:00
function check_dir ( $dir , & $msg , $check_in_docroot = false )
{
if ( !@ is_dir ( $dir ))
{
$msg = lang ( 'does not exist' );
return false ;
}
if ( !@ is_writeable ( $dir ))
{
$msg = lang ( 'is not writeable by the webserver' );
return false ;
}
if ( $check_in_docroot )
{
2005-03-04 13:40:28 +01:00
$docroots = array ( EGW_SERVER_ROOT , $_SERVER [ 'DOCUMENT_ROOT' ]);
2004-10-16 01:06:34 +02:00
$dir = realpath ( $dir );
foreach ( $docroots as $docroot )
{
$len = strlen ( $docroot );
if ( $docroot == substr ( $dir , 0 , $len ))
{
$rest = substr ( $dir , $len );
if ( ! strlen ( $rest ) || $rest [ 0 ] == DIRECTORY_SEPARATOR )
{
$msg = lang ( 'is in the webservers docroot' );
return false ;
}
}
}
}
return true ;
}
2001-07-30 17:59:25 +02:00
// Config Section
2004-05-02 14:11:35 +02:00
$setup_tpl -> set_var ( 'config_step_text' , lang ( 'Step %1 - Configuration' , 2 ));
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'config' ] = $GLOBALS [ 'egw_setup' ] -> detection -> check_config ();
2001-07-30 17:59:25 +02:00
// begin DEBUG code
2005-03-04 13:40:28 +01:00
//$GLOBALS['egw_info']['setup']['stage']['config'] = 10;
2001-07-30 17:59:25 +02:00
// end DEBUG code
2004-10-16 01:06:34 +02:00
$setup_tpl -> set_var ( 'config_status_img' , $incomplete );
$setup_tpl -> set_var ( 'config_status_alt' , lang ( 'not completed' ));
2005-03-04 13:40:28 +01:00
switch ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'config' ])
2001-07-30 17:59:25 +02:00
{
case 1 :
2005-03-04 13:40:28 +01:00
$btn_config_now = $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2003-12-19 13:34:45 +01:00
lang ( 'Please configure eGroupWare for your environment' ),
2005-07-11 20:02:19 +02:00
'post' , 'config.php' ,
2001-07-30 17:59:25 +02:00
'submit' , lang ( 'Configure Now' ),
'' );
$setup_tpl -> set_var ( 'config_table_data' , $btn_config_now );
$setup_tpl -> set_var ( 'ldap_table_data' , ' ' );
break ;
case 10 :
2005-11-02 12:45:52 +01:00
$GLOBALS [ 'egw_setup' ] -> db -> select ( $GLOBALS [ 'egw_setup' ] -> config_table , 'config_name,config_value' , array ( 'config_app' => 'phpgwapi' ), __LINE__ , __FILE__ );
2005-03-04 13:40:28 +01:00
while ( $GLOBALS [ 'egw_setup' ] -> db -> next_record ())
2004-10-16 01:06:34 +02:00
{
2005-03-04 13:40:28 +01:00
$config [ $GLOBALS [ 'egw_setup' ] -> db -> f ( 0 )] = $GLOBALS [ 'egw_setup' ] -> db -> f ( 1 );
2004-10-16 01:06:34 +02:00
}
// set and create the default backup_dir
if ( @ is_writeable ( $config [ 'files_dir' ]) && ! isset ( $config [ 'backup_dir' ]) && $config [ 'file_store_contents' ] == 'filesystem' )
{
$config [ 'backup_dir' ] = $config [ 'files_dir' ] . '/db_backup' ;
if ( ! is_dir ( $config [ 'backup_dir' ]) && mkdir ( $config [ 'backup_dir' ]))
{
2005-11-02 12:45:52 +01:00
$GLOBALS [ 'egw_setup' ] -> db -> insert ( $GLOBALS [ 'egw_setup' ] -> config_table , array (
'config_value' => $config [ 'backup_dir' ],
), array (
'config_app' => 'phpgwapi' ,
'config_name' => 'backup_dir' ,
), __LINE__ , __FILE__ );
2004-10-16 01:06:34 +02:00
}
}
$config_msg = '' ;
if ( ! check_dir ( $config [ 'temp_dir' ], $error_msg ))
{
$config_msg = lang ( " Your temporary directory '%1' %2 " , $config [ 'temp_dir' ], $error_msg );
}
if ( ! check_dir ( $config [ 'files_dir' ], $error_msg , true ))
{
2005-07-11 20:02:19 +02:00
$config_msg .= ( $config_msg ? " <br /> \n " : '' ) . lang ( " Your files directory '%1' %2 " , $config [ 'files_dir' ], $error_msg );
2004-10-16 01:06:34 +02:00
}
if ( ! check_dir ( $config [ 'backup_dir' ], $error_msg , true ))
{
2005-07-11 20:02:19 +02:00
$config_msg .= ( $config_msg ? " <br /> \n " : '' ) . lang ( " Your backup directory '%1' %2 " , $config [ 'backup_dir' ], $error_msg );
2004-10-16 01:06:34 +02:00
}
if ( ! $config_msg )
{
$setup_tpl -> set_var ( 'config_status_img' , $completed );
$setup_tpl -> set_var ( 'config_status_alt' , lang ( 'completed' ));
$config_msg = lang ( 'Configuration completed' );
}
2005-03-04 13:40:28 +01:00
$btn_edit_config = $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2004-10-16 01:06:34 +02:00
$config_msg ,
2005-07-11 20:02:19 +02:00
'post' , 'config.php' ,
2001-07-30 17:59:25 +02:00
'submit' , lang ( 'Edit Current Configuration' ),
''
);
2004-10-16 01:06:34 +02:00
if ( $config [ 'auth_type' ] == 'ldap' )
2001-07-30 17:59:25 +02:00
{
2004-10-16 01:06:34 +02:00
if ( $config [ 'ldap_host' ] != '' )
2001-07-30 17:59:25 +02:00
{
2005-03-04 13:40:28 +01:00
$btn_config_ldap = $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2001-07-30 17:59:25 +02:00
lang ( 'LDAP account import/export' ),
2005-07-11 20:02:19 +02:00
'post' , 'ldap.php' ,
2001-07-30 17:59:25 +02:00
'submit' , lang ( 'Configure Now' ),
2001-12-11 05:36:40 +01:00
''
);
2001-07-30 17:59:25 +02:00
}
else
{
$btn_config_ldap = '' ;
2001-12-11 05:36:40 +01:00
}
2004-05-02 14:11:35 +02:00
}
$setup_tpl -> set_var ( 'config_table_data' , $btn_edit_config );
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'ldap_table_data' , $btn_config_ldap );
break ;
default :
$setup_tpl -> set_var ( 'config_status_img' , $incomplete );
$setup_tpl -> set_var ( 'config_status_alt' , lang ( 'not completed' ));
$setup_tpl -> set_var ( 'config_table_data' , lang ( 'Not ready for this stage yet' ));
$setup_tpl -> set_var ( 'ldap_table_data' , ' ' );
break ;
}
2004-05-02 14:11:35 +02:00
// Admin Account Section
$setup_tpl -> set_var ( 'admin_step_text' , lang ( 'Step %1 - Admin Account' , 3 ));
2005-03-04 13:40:28 +01:00
switch ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'config' ])
2004-05-02 14:11:35 +02:00
{
case 10 :
// check if there is already a user account (not the anonymous account of sitemgr or a group)
2005-10-15 09:57:06 +02:00
$no_accounts = ! $GLOBALS [ 'egw_setup' ] -> accounts_exist ();
2004-11-17 13:46:02 +01:00
$setup_tpl -> set_var ( 'admin_status_img' , $no_accounts ? $incomplete : $completed );
$setup_tpl -> set_var ( 'admin_status_alt' , $no_accounts ? lang ( 'not completed' ) : lang ( 'completed' ));
2005-03-04 13:40:28 +01:00
$setup_tpl -> set_var ( 'admin_table_data' , $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2004-05-02 14:11:35 +02:00
$no_accounts ? lang ( 'No accounts existing' ) : lang ( 'Accounts existing' ),
2005-07-11 20:02:19 +02:00
'post' , 'setup_demo.php' ,
2004-05-02 14:11:35 +02:00
'submit' , lang ( 'Create admin account' ),
''
));
break ;
default :
$setup_tpl -> set_var ( 'admin_status_img' , $incomplete );
$setup_tpl -> set_var ( 'admin_status_alt' , lang ( 'not completed' ));
$setup_tpl -> set_var ( 'admin_table_data' , lang ( 'Not ready for this stage yet' ));
break ;
}
2001-07-30 17:59:25 +02:00
// Lang Section
2004-05-02 14:11:35 +02:00
$setup_tpl -> set_var ( 'lang_step_text' , lang ( 'Step %1 - Language Management' , 4 ));
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'lang' ] = $GLOBALS [ 'egw_setup' ] -> detection -> check_lang ();
2001-07-30 17:59:25 +02:00
// begin DEBUG code
2005-03-04 13:40:28 +01:00
//$GLOBALS['egw_info']['setup']['stage']['lang'] = 0;
2001-07-30 17:59:25 +02:00
// end DEBUG code
2005-03-04 13:40:28 +01:00
switch ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'lang' ])
2001-07-30 17:59:25 +02:00
{
case 1 :
$setup_tpl -> set_var ( 'lang_status_img' , $incomplete );
$setup_tpl -> set_var ( 'lang_status_alt' , 'not completed' );
2005-03-04 13:40:28 +01:00
$btn_install_lang = $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2005-07-11 20:02:19 +02:00
lang ( 'You do not have any languages installed. Please install one now <br />' ),
'post' , 'lang.php' ,
2001-07-30 17:59:25 +02:00
'submit' , lang ( 'Install Language' ),
'' );
$setup_tpl -> set_var ( 'lang_table_data' , $btn_install_lang );
break ;
case 10 :
2004-06-13 23:31:21 +02:00
$langs_list = array ();
$languages = get_langs ();
2005-03-04 13:40:28 +01:00
foreach ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'installed_langs' ] as $key => $value )
2001-07-30 17:59:25 +02:00
{
2004-06-13 23:31:21 +02:00
$langs_list [] = isset ( $languages [ $key ]) ? $languages [ $key ][ 'descr' ] : $value ;
2001-07-30 17:59:25 +02:00
}
$setup_tpl -> set_var ( 'lang_status_img' , $completed );
$setup_tpl -> set_var ( 'lang_status_alt' , 'completed' );
2005-03-04 13:40:28 +01:00
$btn_manage_lang = $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2005-07-11 20:02:19 +02:00
lang ( 'This stage is completed<br />' ) . lang ( 'Currently installed languages: %1 <br />' , implode ( ', ' , $langs_list )),
'post' , 'lang.php' ,
2001-07-30 17:59:25 +02:00
'submit' , lang ( 'Manage Languages' ),
'' );
2003-10-05 04:06:11 +02:00
// show system-charset and offer conversation
2005-03-04 13:40:28 +01:00
include_once ( EGW_API_INC . '/class.translation_sql.inc.php' );
2003-10-05 04:06:11 +02:00
$translation = new translation ;
$btn_manage_lang .= lang ( 'Current system-charset is %1, click %2here%3 to change it.' ,
$translation -> system_charset ? " ' $translation->system_charset ' " : lang ( 'not set' ),
'<a href="system_charset.php">' , '</a>' );
2001-07-30 17:59:25 +02:00
$setup_tpl -> set_var ( 'lang_table_data' , $btn_manage_lang );
break ;
default :
$setup_tpl -> set_var ( 'lang_status_img' , $incomplete );
$setup_tpl -> set_var ( 'lang_status_alt' , lang ( 'not completed' ));
$setup_tpl -> set_var ( 'lang_table_data' , lang ( 'Not ready for this stage yet' ));
break ;
}
2004-05-02 14:11:35 +02:00
$setup_tpl -> set_var ( 'apps_step_text' , lang ( 'Step %1 - Advanced Application Management' , 5 ));
2005-03-04 13:40:28 +01:00
// $GLOBALS['egw_info']['setup']['stage']['apps'] = $GLOBALS['egw_setup']->check_apps();
switch ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ])
2001-07-30 17:59:25 +02:00
{
case 10 :
$setup_tpl -> set_var ( 'apps_status_img' , $completed );
$setup_tpl -> set_var ( 'apps_status_alt' , lang ( 'completed' ));
2004-06-27 11:06:05 +02:00
// check if we have apps to upgrade
$to_upgrade = array ();
foreach ( $setup_info as $app => $data )
{
if ( $data [ 'currentver' ] && $data [ 'version' ] && $data [ 'version' ] != $data [ 'currentver' ])
{
$to_upgrade [] = $app ;
}
}
2005-03-04 13:40:28 +01:00
$btn_manage_apps = $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2004-06-27 11:06:05 +02:00
count ( $to_upgrade ) ? '<b>' . lang ( 'The following applications need to be upgraded:' ) . '</b> ' . implode ( ', ' , $to_upgrade ) :
2005-07-11 20:02:19 +02:00
lang ( 'This stage is completed<br />' ),
'post' , 'applications.php' ,
2001-07-30 17:59:25 +02:00
'submit' , lang ( 'Manage Applications' ),
'' );
$setup_tpl -> set_var ( 'apps_table_data' , $btn_manage_apps );
break ;
default :
$setup_tpl -> set_var ( 'apps_status_img' , $incomplete );
$setup_tpl -> set_var ( 'apps_status_alt' , lang ( 'not completed' ));
$setup_tpl -> set_var ( 'apps_table_data' , lang ( 'Not ready for this stage yet' ));
break ;
}
2004-10-16 01:06:34 +02:00
// Backup and restore section
$setup_tpl -> set_var ( 'backup_step_text' , lang ( 'Step %1 - DB backup and restore' , 6 ));
2005-03-04 13:40:28 +01:00
switch ( $GLOBALS [ 'egw_info' ][ 'setup' ][ 'stage' ][ 'db' ])
2004-10-16 01:06:34 +02:00
{
case 10 :
$setup_tpl -> set_var ( 'backup_status_img' , $completed );
$setup_tpl -> set_var ( 'backup_status_alt' , lang ( 'completed' ));
2005-03-04 13:40:28 +01:00
$setup_tpl -> set_var ( 'backup_table_data' , $GLOBALS [ 'egw_setup' ] -> html -> make_frm_btn_simple (
2005-07-11 20:02:19 +02:00
'' /*lang('This stage is completed<br />')*/ ,
'post' , 'db_backup.php' ,
2004-10-16 01:06:34 +02:00
'submit' , lang ( 'backup and restore' ),
'' ));
break ;
default :
$setup_tpl -> set_var ( 'backup_status_img' , $incomplete );
$setup_tpl -> set_var ( 'backup_status_alt' , lang ( 'not completed' ));
$setup_tpl -> set_var ( 'backup_table_data' , lang ( 'Not ready for this stage yet' ));
break ;
}
2001-07-30 17:59:25 +02:00
$setup_tpl -> pparse ( 'out' , 'T_setup_main' );
2005-03-04 13:40:28 +01:00
$GLOBALS [ 'egw_setup' ] -> html -> show_footer ();
2001-07-30 17:59:25 +02:00
?>