egroupware_official/setup/index.php

438 lines
18 KiB
PHP
Raw Normal View History

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$ */
/*
Idea: This is so I don't forget. When they are preforming a new install, after config,
forward them right to index.php. Create a session for them and have a nice little intro
page explaining what to do from there (ie, create there own account)
*/
2001-07-30 17:59:25 +02:00
$DEBUG = False;
$GLOBALS['phpgw_info'] = array();
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['flags'] = array(
2001-07-30 17:59:25 +02:00
'noheader' => True,
'nonavbar' => True,
'currentapp' => 'home',
'noapi' => True
);
include('./inc/functions.inc.php');
$tpl_root = $phpgw_setup->setup_tpl_dir('setup');
$setup_tpl = CreateObject('phpgwapi.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_main' => 'setup_main.tpl',
'T_setup_db_blocks' => 'setup_db_blocks.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_db_blocks','B_db_stage_1','V_db_stage_1');
$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');
$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
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['stage']['header'] = $phpgw_setup->check_header();
if ($GLOBALS['phpgw_info']['setup']['stage']['header'] != '10')
2001-07-30 17:59:25 +02:00
{
Header('Location: manageheader.php');
2001-07-30 17:59:25 +02:00
exit;
}
elseif (!$phpgw_setup->auth('Config'))
{
$phpgw_setup->show_header(lang('Please login'),True);
$phpgw_setup->login_form();
$phpgw_setup->show_footer();
exit;
}
$phpgw_setup->loaddb();
/* Add cleaning of app_sessions per skeeter, but with a check for the table being there, just in case */
$phpgw_setup->clear_session_cache();
// Database actions
2001-07-30 17:59:25 +02:00
$setup_info = $phpgw_setup->get_versions();
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $phpgw_setup->check_db();
if ($GLOBALS['phpgw_info']['setup']['stage']['db'] != 1)
2001-07-30 17:59:25 +02:00
{
$setup_info = $phpgw_setup->get_versions();
$setup_info = $phpgw_setup->get_db_versions($setup_info);
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['stage']['db'] = $phpgw_setup->check_db();
if($DEBUG)
{
_debug_array($setup_info);
}
2001-07-30 17:59:25 +02:00
}
2001-11-21 16:01:43 +01:00
if ($DEBUG) { echo 'Stage: ' . $GLOBALS['phpgw_info']['setup']['stage']['db']; }
2001-07-30 17:59:25 +02:00
// begin DEBUG code
2002-01-08 03:12:43 +01:00
//$GLOBALS['phpgw_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
switch(@$GLOBALS['HTTP_POST_VARS']['action'])
2001-07-30 17:59:25 +02:00
{
case 'Uninstall all applications':
$subtitle = lang('Deleting Tables');
$submsg = lang('Are you sure delete your existing tables and data?') . '.';
$subaction = 'uninstall';
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'predrop';
$GLOBALS['phpgw_info']['setup']['stage']['db'] = 5;
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');
$subaction = 'created';
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'dbcreate';
$GLOBALS['phpgw_info']['setup']['stage']['db'] = 6;
2001-07-30 17:59:25 +02:00
break;
case 'REALLY Uninstall all applications':
2001-07-30 17:59:25 +02:00
$subtitle = lang('Deleting Tables');
$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') . '.';
2001-07-30 17:59:25 +02:00
$subaction = 'uninstalled';
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'drop';
$GLOBALS['phpgw_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').'.';
$subaction = 'upgraded';
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
$GLOBALS['phpgw_info']['setup']['stage']['db'] = 6;
2001-07-30 17:59:25 +02:00
break;
case 'Install':
$subtitle = lang('Creating Tables');
$submsg = lang('At your request, this script is going to attempt to install all the applications for you').'.';
$subaction = 'installed';
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'new';
$GLOBALS['phpgw_info']['setup']['stage']['db'] = 6;
2001-07-30 17:59:25 +02:00
break;
}
$setup_tpl->set_var('subtitle',@$subtitle);
$setup_tpl->set_var('submsg',@$submsg);
$setup_tpl->set_var('subaction',lang(@$subaction));
2001-07-30 17:59:25 +02:00
// Old PHP
if (phpversion() < '3.0.16')
{
2001-11-21 16:01:43 +01:00
$phpgw_setup->show_header($GLOBALS['phpgw_info']['setup']['header_msg'],True);
2001-07-30 17:59:25 +02:00
$phpgw_setup->show_alert_msg('Error',
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 phpGroupWare correctly, if at all. <br><br>Please upgrade to at least version 3.0.16'));
$phpgw_setup->show_footer();
exit;
}
// BEGIN setup page
//$phpgw_setup->app_status();
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['server']['app_images'] = 'templates/default/images';
$incomplete = $GLOBALS['phpgw_info']['server']['app_images'] . '/incomplete.gif';
$completed = $GLOBALS['phpgw_info']['server']['app_images'] . '/completed.gif';
2001-07-30 17:59:25 +02:00
$setup_tpl->set_var('img_incomplete',$incomplete);
$setup_tpl->set_var('img_completed',$completed);
$setup_tpl->set_var('db_step_text',lang('Step 1 - Simple Application Management'));
2001-11-21 16:01:43 +01:00
switch($GLOBALS['phpgw_info']['setup']['stage']['db'])
2001-07-30 17:59:25 +02:00
{
case 1:
$setup_tpl->set_var('dbnotexist',lang('Your Database is not working!'));
$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:'));
switch ($phpgw_domain[$GLOBALS['ConfigDomain']]['db_type'])
2001-07-30 17:59:25 +02:00
{
case 'mysql':
$setup_tpl->set_var('instr',lang('mysqlinstr'));
break;
case 'pgsql':
$setup_tpl->set_var('instr',lang('pgsqlinstr'));
break;
}
$setup_tpl->parse('V_db_stage_1','B_db_stage_1');
$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:
$setup_tpl->set_var('prebeta',lang('You appear to be running a pre-beta version of phpGroupWare.<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.'));
$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'));
$setup_tpl->set_var('allapps',lang('all applications'));
$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:
$setup_tpl->set_var('oldver',lang('You appear to be running version x of phpGroupWare',$setup_info['phpgwapi']['currentver']));
$setup_tpl->set_var('automatic',lang('We will automatically update your tables/records to x',$setup_info['phpgwapi']['version']));
$setup_tpl->set_var('backupwarn',lang('backupwarn'));
$setup_tpl->set_var('upgrade',lang('Upgrade'));
$setup_tpl->set_var('goto',lang('Go to'));
$setup_tpl->set_var('configuration',lang('configuration'));
$setup_tpl->set_var('applications',lang('Manage Applications'));
$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'));
$setup_tpl->set_var('dropwarn',lang('Your tables may be altered and you may lose data'));
$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:
$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'));
$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');
2001-07-30 17:59:25 +02:00
// FIXME : CAPTURE THIS OUTPUT
$phpgw_setup->db->Halt_On_Error = 'report';
2001-11-21 16:01:43 +01:00
switch ($GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'])
2001-07-30 17:59:25 +02:00
{
case 'dbcreate':
2001-07-30 17:59:25 +02:00
$phpgw_setup->db->create_database($db_root, $db_pass);
break;
case 'drop':
2001-07-30 17:59:25 +02:00
$setup_info = $phpgw_setup->get_versions($setup_info);
$setup_info = $phpgw_setup->process_droptables($setup_info);
break;
case 'new':
/* process all apps and langs(last param True) */
$setup_info = $phpgw_setup->process_pass($setup_info,'new',$DEBUG,True);
2001-07-30 17:59:25 +02:00
$included = True;
include('lang.php');
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
2001-07-30 17:59:25 +02:00
break;
case 'oldversion':
2001-07-30 17:59:25 +02:00
$setup_info = $phpgw_setup->process_pass($setup_info,'upgrade',$DEBUG);
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['currentver']['phpgwapi'] = 'oldversion';
2001-07-30 17:59:25 +02:00
break;
}
$phpgw_setup->db->Halt_On_Error = 'no';
$setup_tpl->set_var('tableshave',lang('If you did not receive any errors, your applications have been'));
$setup_tpl->set_var('re-check_my_installation',lang('Re-Check My Installation'));
$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;
}
// Config Section
$setup_tpl->set_var('config_step_text',lang('Step 2 - Configuration'));
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['stage']['config'] = $phpgw_setup->check_config();
2001-07-30 17:59:25 +02:00
// begin DEBUG code
2001-11-21 16:01:43 +01:00
//$GLOBALS['phpgw_info']['setup']['stage']['config'] = 10;
2001-07-30 17:59:25 +02:00
// end DEBUG code
2001-11-21 16:01:43 +01:00
switch($GLOBALS['phpgw_info']['setup']['stage']['config'])
2001-07-30 17:59:25 +02:00
{
case 1:
$setup_tpl->set_var('config_status_img',$incomplete);
$setup_tpl->set_var('config_status_alt',lang('not completed'));
$btn_config_now = $phpgw_setup->make_frm_btn_simple(
lang('Please configure phpGroupWare for your environment'),
'POST','config.php',
'submit',lang('Configure Now'),
'');
$setup_tpl->set_var('config_table_data',$btn_config_now);
$setup_tpl->set_var('ldap_table_data','&nbsp;');
break;
case 10:
$setup_tpl->set_var('config_status_img',$completed);
$setup_tpl->set_var('config_status_alt',lang('completed'));
$btn_edit_config = $phpgw_setup->make_frm_btn_simple(
lang('Configuration completed'),
'POST','config.php',
'submit',lang('Edit Current Configuration'),
''
);
$phpgw_setup->db->query("select config_value FROM phpgw_config WHERE config_name='auth_type'");
$phpgw_setup->db->next_record();
if ($phpgw_setup->db->f(0) == 'ldap')
{
$phpgw_setup->db->query("select config_value FROM phpgw_config WHERE config_name='ldap_host'");
$phpgw_setup->db->next_record();
if ($phpgw_setup->db->f(0) != '')
{
$btn_config_ldap = $phpgw_setup->make_frm_btn_simple(
lang('LDAP account import/export'),
'POST','ldap.php',
'submit',lang('Configure Now'),
''
);
2001-07-30 17:59:25 +02:00
}
else
{
$btn_config_ldap = '';
}
$phpgw_setup->db->query("select config_value FROM phpgw_config WHERE config_name='webserver_url'");
$phpgw_setup->db->next_record();
if ($phpgw_setup->db->f(0))
{
2001-07-30 17:59:25 +02:00
$link_make_accts = $phpgw_setup->make_href_link_simple(
'<br>',
'setup_demo.php',
lang('Click Here'),
lang('to setup 1 admin account and 3 demo accounts.<br><b>This will delete all existing accounts</b>')
. ' ' . lang('(account deletion in SQL Only)')
2001-07-30 17:59:25 +02:00
);
}
else
{
$link_make_accts = '&nbsp;';
}
2001-07-30 17:59:25 +02:00
}
else
{
$btn_config_ldap = '';
$link_make_accts = $phpgw_setup->make_href_link_simple(
'<br>',
'setup_demo.php',
lang('Click Here'),
lang('to setup 1 admin account and 3 demo accounts.<br><b>This will delete all existing accounts</b>')
);
}
$config_td = "$btn_edit_config" ."$link_make_accts";
$setup_tpl->set_var('config_table_data',$config_td);
$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','&nbsp;');
break;
}
// Lang Section
$setup_tpl->set_var('lang_step_text',lang('Step 3 - Language Management'));
2001-11-21 16:01:43 +01:00
$GLOBALS['phpgw_info']['setup']['stage']['lang'] = $phpgw_setup->check_lang();
2001-07-30 17:59:25 +02:00
// begin DEBUG code
2001-11-21 16:01:43 +01:00
//$GLOBALS['phpgw_info']['setup']['stage']['lang'] = 0;
2001-07-30 17:59:25 +02:00
// end DEBUG code
2001-11-21 16:01:43 +01:00
switch($GLOBALS['phpgw_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');
$btn_install_lang = $phpgw_setup->make_frm_btn_simple(
lang('You do not have any languages installed. Please install one now <br>'),
'POST','lang.php',
'submit',lang('Install Language'),
'');
$setup_tpl->set_var('lang_table_data',$btn_install_lang);
break;
case 10:
$langs_list = '';
2001-11-21 16:01:43 +01:00
reset ($GLOBALS['phpgw_info']['setup']['installed_langs']);
while (list ($key, $value) = each ($GLOBALS['phpgw_info']['setup']['installed_langs']))
2001-07-30 17:59:25 +02:00
{
$langs_list = ($langs_list?$langs_list.', ':'') . $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');
$btn_manage_lang = $phpgw_setup->make_frm_btn_simple(
lang('This stage is completed<br>'). lang('Currently installed languages: x <br>',$langs_list),
'POST','lang.php',
'submit',lang('Manage Languages'),
'');
$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;
}
$setup_tpl->set_var('apps_step_text',lang('Step 4 - Advanced Application Management'));
2001-11-21 16:01:43 +01:00
// $GLOBALS['phpgw_info']['setup']['stage']['apps'] = $phpgw_setup->check_apps();
switch($GLOBALS['phpgw_info']['setup']['stage']['db'])
2001-07-30 17:59:25 +02:00
{
case 1:
case 10:
$setup_tpl->set_var('apps_status_img',$completed);
$setup_tpl->set_var('apps_status_alt',lang('completed'));
$btn_manage_apps = $phpgw_setup->make_frm_btn_simple(
lang('This stage is completed<br>'),
'','applications.php',
'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;
}
$phpgw_setup->show_header($GLOBALS['phpgw_info']['setup']['header_msg'],False,'config',$GLOBALS['ConfigDomain'] . '(' . $GLOBALS['phpgw_domain'][$GLOBALS['ConfigDomain']]['db_type'] . ')');
2001-07-30 17:59:25 +02:00
$setup_tpl->pparse('out','T_setup_main');
$phpgw_setup->show_footer();
?>