2002-03-03 22:47:30 +01:00
|
|
|
<?php
|
2010-07-29 10:29:54 +02:00
|
|
|
/**
|
2016-05-01 17:56:49 +02:00
|
|
|
* EGroupware Setup
|
2010-07-29 10:29:54 +02:00
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @package setup
|
|
|
|
* @author Tony Puglisi (Angles) <angles@aminvestments.com>
|
|
|
|
* @author Miles Lott <milos@groupwhere.org>
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2016-05-01 17:56:49 +02:00
|
|
|
use EGroupware\Api;
|
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
/**
|
|
|
|
* Some static helper functions to generate html stuff in setup
|
|
|
|
*/
|
|
|
|
class setup_html
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* generate header.inc.php file output - NOT a generic html header function
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static function generate_header()
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
// PHP will automatically replace any dots in incoming
|
|
|
|
// variable names with underscores.
|
2003-12-22 12:43:06 +01:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template'));
|
|
|
|
$GLOBALS['header_template']->set_block('header','domain','domain');
|
|
|
|
$var = Array();
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2016-05-03 00:26:40 +02:00
|
|
|
$deletedomain = $_POST['deletedomain'];
|
|
|
|
$domains = $_POST['domains'];
|
2005-11-20 13:43:50 +01:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
foreach($domains as $k => $v)
|
|
|
|
{
|
|
|
|
if(is_array($deletedomain) && isset($deletedomain[$k]))
|
2002-04-08 01:56:03 +02:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
continue;
|
2002-04-08 01:56:03 +02:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
$variableName = str_replace('.','_',$k);
|
2016-05-03 00:26:40 +02:00
|
|
|
$dom = $_POST['setting_'.$variableName];
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->set_var('DB_DOMAIN',$v);
|
|
|
|
foreach($dom as $x => $y)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
if(strtoupper($x) == 'CONFIG_PASS')
|
2004-01-18 22:03:56 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->set_var(strtoupper($x),md5($y));
|
2004-01-18 22:03:56 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->set_var(strtoupper($x),$y);
|
2004-01-18 22:03:56 +01:00
|
|
|
}
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
/* Admin did not type a new password, so use the old one from the hidden field,
|
2004-01-20 14:16:45 +01:00
|
|
|
* which is already md5 encoded.
|
|
|
|
*/
|
2010-07-29 10:29:54 +02:00
|
|
|
if($dom['config_password'] && !$dom['config_pass'])
|
2004-01-20 14:16:45 +01:00
|
|
|
{
|
|
|
|
/* Real == hidden */
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->set_var('CONFIG_PASS',$dom['config_password']);
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
/* If the admin didn't select a db_port, set to the default */
|
|
|
|
if(!$dom['db_port'])
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->set_var('DB_PORT',$GLOBALS['default_db_ports'][$dom['db_type']]);
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->parse('domains','domain',True);
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['header_template']->set_var('domain','');
|
2012-10-31 18:17:28 +01:00
|
|
|
|
2016-05-03 00:26:40 +02:00
|
|
|
$setting = $_POST['setting'];
|
2019-02-12 22:13:45 +01:00
|
|
|
foreach($setting as $k => $v)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
if(strtoupper($k) == 'HEADER_ADMIN_PASSWORD')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$var[strtoupper($k)] = md5($v);
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$var[strtoupper($k)] = $v;
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
}
|
|
|
|
/* Admin did not type a new header password, so use the old one from the hidden field,
|
|
|
|
* which is already md5 encoded.
|
|
|
|
*/
|
|
|
|
if($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD']))
|
|
|
|
{
|
|
|
|
/* Real == hidden */
|
|
|
|
$var['HEADER_ADMIN_PASSWORD'] = $var['HEADER_ADMIN_PASS'];
|
|
|
|
}
|
|
|
|
$GLOBALS['header_template']->set_var($var);
|
|
|
|
return $GLOBALS['header_template']->parse('out','header');
|
|
|
|
}
|
2004-02-03 00:04:07 +01:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
static function setup_tpl_dir($app_name='setup')
|
|
|
|
{
|
|
|
|
/* hack to get tpl dir */
|
|
|
|
if (is_dir(EGW_SERVER_ROOT))
|
|
|
|
{
|
2016-05-03 00:26:40 +02:00
|
|
|
$srv_root = EGW_SERVER_ROOT . '/' . $app_name . '/';
|
2010-07-29 10:29:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$srv_root = '';
|
|
|
|
}
|
2004-02-03 00:07:07 +01:00
|
|
|
|
2016-05-03 00:26:40 +02:00
|
|
|
$tpl_typical = 'templates/default';
|
2010-07-29 10:29:54 +02:00
|
|
|
$tpl_root = "$srv_root" ."$tpl_typical";
|
|
|
|
return $tpl_root;
|
|
|
|
}
|
2006-04-06 13:19:56 +02:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
static function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='')
|
|
|
|
{
|
|
|
|
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv)
|
|
|
|
header('Content-type: text/html; charset='.$GLOBALS['egw_setup']->system_charset);
|
2006-04-06 13:19:56 +02:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->set_var('charset',$GLOBALS['egw_setup']->system_charset);
|
|
|
|
$style = array(
|
|
|
|
'th_bg' => '#486591',
|
|
|
|
'th_text' => '#FFFFFF',
|
|
|
|
'row_on' => '#DDDDDD',
|
|
|
|
'row_off' => '#EEEEEE',
|
|
|
|
'banner_bg' => '#4865F1',
|
|
|
|
'msg' => '#FF0000',
|
|
|
|
);
|
|
|
|
$GLOBALS['setup_tpl']->set_var($style);
|
|
|
|
if ($nologoutbutton)
|
|
|
|
{
|
|
|
|
$GLOBALS['setup_tpl']->set_block('T_head','loged_in');
|
|
|
|
$GLOBALS['setup_tpl']->set_var('loged_in','');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
else
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$btn_logout = '<a href="index.php?FormLogout=' . $logoutfrom . '" class="link">' . lang('Logout').'</a>';
|
|
|
|
$check_install = '<a class="textsidebox" href="check_install.php">'.lang('Check installation').'</a>';
|
2012-10-31 18:17:28 +01:00
|
|
|
$register_hooks = '<a class="textsidebox" href="applications.php?hooks=1">'.lang('Clear cache and register hooks').'</a>';
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup'));
|
|
|
|
$GLOBALS['setup_tpl']->set_var('page_title',$title);
|
|
|
|
if ($configdomain == '')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->set_var('configdomain','');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
else
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->set_var('configdomain',' - ' . lang('Domain') . ': ' . $configdomain);
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
if(basename($_SERVER['SCRIPT_FILENAME']) != 'index.php')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$index_btn = '<a href="index.php" class="link">' . lang('Setup Main Menu') . '</a>';
|
2022-08-04 10:46:13 +02:00
|
|
|
$index_img = '<img src="templates/default/images/bullet.png" />';
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_version',lang('version'));
|
2019-01-09 10:39:02 +01:00
|
|
|
if (!isset($GLOBALS['setup_info']) || !isset($GLOBALS['setup_info']['api']) ||
|
|
|
|
!isset($GLOBALS['setup_info']['api']['versions']) || !isset($GLOBALS['setup_info']['api']['versions']['maintenance_release']))
|
2016-04-02 22:25:01 +02:00
|
|
|
{
|
|
|
|
include(EGW_SERVER_ROOT.'/api/setup/setup.inc.php');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$setup_info = $GLOBALS['setup_info'];
|
|
|
|
}
|
2019-01-09 10:39:02 +01:00
|
|
|
$GLOBALS['setup_tpl']->set_var('pgw_ver', $nologoutbutton ?
|
|
|
|
(double)$setup_info['api']['version'] : // without login only show main version, not maintenance release
|
|
|
|
$setup_info['api']['versions']['maintenance_release']);
|
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->set_var(array(
|
|
|
|
'logoutbutton' => $btn_logout,
|
|
|
|
'indexbutton' => $index_btn,
|
|
|
|
'indeximg' => $index_img,
|
|
|
|
'check_install' => $check_install,
|
2011-03-23 17:19:32 +01:00
|
|
|
'register_hooks'=> $register_hooks,
|
2010-07-29 10:29:54 +02:00
|
|
|
'main_menu' => lang('Setup Main Menu'),
|
2018-01-29 10:03:25 +01:00
|
|
|
'user_login' => lang('Back to user login'),
|
|
|
|
'help_menu' => lang('Help and support'),
|
|
|
|
'documentation' => lang('Documentation'),
|
|
|
|
'commercial_support' => lang('Commercial support'),
|
|
|
|
'community_forum' => lang('Community forum'),
|
2010-07-29 10:29:54 +02:00
|
|
|
));
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_head');
|
|
|
|
}
|
|
|
|
|
|
|
|
static function show_footer()
|
|
|
|
{
|
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_footer');
|
|
|
|
unset($GLOBALS['setup_tpl']);
|
|
|
|
}
|
|
|
|
|
|
|
|
static function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)')
|
|
|
|
{
|
|
|
|
$GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word);
|
|
|
|
$GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg);
|
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_alert_msg');
|
|
|
|
}
|
|
|
|
|
|
|
|
static function make_frm_btn_simple($pre_frm_blurb='',$frm_method='post',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='')
|
|
|
|
{
|
|
|
|
/* a simple form has simple components */
|
|
|
|
$simple_form = $pre_frm_blurb ."\n"
|
|
|
|
. '<form method="' . $frm_method . '" action="' . $frm_action . '">' . "\n"
|
|
|
|
. '<input type="' . $input_type . '" value="' . $input_value . '" />' . "\n"
|
|
|
|
. '</form>' . "\n"
|
|
|
|
. $post_frm_blurb . "\n";
|
|
|
|
return $simple_form;
|
|
|
|
}
|
|
|
|
|
|
|
|
static function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='')
|
|
|
|
{
|
|
|
|
/* a simple href link has simple components */
|
|
|
|
$simple_link = $pre_link_blurb
|
|
|
|
. '<a href="' . $href_link . '">' . $href_text . '</a> '
|
|
|
|
. $post_link_blurb . "\n";
|
|
|
|
return $simple_link;
|
|
|
|
}
|
|
|
|
|
|
|
|
static function login_form()
|
|
|
|
{
|
|
|
|
/* begin use TEMPLATE login_main.tpl */
|
|
|
|
$GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',@$GLOBALS['egw_info']['setup']['ConfigLoginMSG']);
|
|
|
|
$GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',@$GLOBALS['egw_info']['setup']['HeaderLoginMSG']);
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_header_username',lang('Header Username'));
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_header_password',lang('Header Password'));
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_header_login',lang('Header Admin Login'));
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_config_login',lang('Setup/Config Admin Login'));
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_config_username',lang('Config Username'));
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_config_password',lang('Config Password'));
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_domain',lang('Domain'));
|
|
|
|
|
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_select',self::lang_select());
|
|
|
|
|
|
|
|
if ($GLOBALS['egw_info']['setup']['stage']['header'] == '10')
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Begin use SUB-TEMPLATE login_stage_header,
|
|
|
|
fills V_login_stage_header used inside of login_main.tpl
|
|
|
|
*/
|
|
|
|
if (count($GLOBALS['egw_domain']) > 1)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2016-05-01 17:56:49 +02:00
|
|
|
foreach(array_keys($GLOBALS['egw_domain']) as $domain)
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$domains .= "<option value=\"$domain\" ".($domain == @$GLOBALS['egw_info']['setup']['LastDomain'] ? ' selected="selected"' : '').">$domain</option>\n";
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->set_var('domains',$domains);
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
// use BLOCK B_multi_domain inside of login_stage_header
|
|
|
|
$GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain');
|
|
|
|
// in this case, the single domain block needs to be nothing
|
|
|
|
$GLOBALS['setup_tpl']->set_var('V_single_domain','');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
reset($GLOBALS['egw_domain']);
|
2019-02-12 22:13:45 +01:00
|
|
|
$default_domain = key($GLOBALS['egw_domain']);
|
|
|
|
$GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain);
|
2010-07-29 10:29:54 +02:00
|
|
|
|
|
|
|
/* Use BLOCK B_single_domain inside of login_stage_header */
|
|
|
|
$GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain');
|
|
|
|
/* in this case, the multi domain block needs to be nothing */
|
2002-03-03 22:47:30 +01:00
|
|
|
$GLOBALS['setup_tpl']->set_var('V_multi_domain','');
|
|
|
|
}
|
|
|
|
/*
|
2010-07-29 10:29:54 +02:00
|
|
|
End use SUB-TEMPLATE login_stage_header
|
|
|
|
put all this into V_login_stage_header for use inside login_main
|
2002-03-03 22:47:30 +01:00
|
|
|
*/
|
2010-07-29 10:29:54 +02:00
|
|
|
$GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header');
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
else
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
/* begin SKIP SUB-TEMPLATE login_stage_header */
|
|
|
|
$GLOBALS['setup_tpl']->set_var('V_multi_domain','');
|
|
|
|
$GLOBALS['setup_tpl']->set_var('V_single_domain','');
|
|
|
|
$GLOBALS['setup_tpl']->set_var('V_login_stage_header','');
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
end use TEMPLATE login_main.tpl
|
|
|
|
now out the login_main template
|
|
|
|
*/
|
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_login_main');
|
|
|
|
}
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
static function lang_select($onChange=False,$ConfigLang='')
|
|
|
|
{
|
2012-11-05 13:18:22 +01:00
|
|
|
if (empty($ConfigLang))
|
2010-07-29 10:29:54 +02:00
|
|
|
{
|
2018-01-29 11:05:55 +01:00
|
|
|
$ConfigLang = setup::get_lang(true); // true use Accept-Language header
|
2010-07-29 10:29:54 +02:00
|
|
|
}
|
2016-05-01 17:56:49 +02:00
|
|
|
return Api\Html::select('ConfigLang', $ConfigLang, Api\Translation::get_available_langs(false), true,
|
2012-11-05 13:18:22 +01:00
|
|
|
$onChange ? ' onchange="this.form.submit();"' : '');
|
2010-07-29 10:29:54 +02:00
|
|
|
}
|
2002-03-03 22:47:30 +01:00
|
|
|
|
2010-07-29 10:29:54 +02:00
|
|
|
static function get_template_list()
|
|
|
|
{
|
|
|
|
$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates');
|
|
|
|
|
2016-05-01 17:56:49 +02:00
|
|
|
$list = array();
|
2010-07-29 10:29:54 +02:00
|
|
|
while($entry = $d->read())
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
if ($entry != 'CVS' && $entry != '.' && $entry != '..')
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$list[$entry]['name'] = $entry;
|
|
|
|
$f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php';
|
|
|
|
if (file_exists ($f))
|
|
|
|
{
|
|
|
|
include($f);
|
|
|
|
$list[$entry]['title'] = 'Use ' . $GLOBALS['egw_info']['template'][$entry]['title'] . 'interface';
|
|
|
|
}
|
|
|
|
else
|
2002-03-03 22:47:30 +01:00
|
|
|
{
|
2010-07-29 10:29:54 +02:00
|
|
|
$list[$entry]['title'] = $entry;
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-29 10:29:54 +02:00
|
|
|
$d->close();
|
|
|
|
reset ($list);
|
|
|
|
return $list;
|
|
|
|
}
|
|
|
|
|
|
|
|
static function list_themes()
|
|
|
|
{
|
|
|
|
$dh = dir(EGW_SERVER_ROOT . '/phpgwapi/themes');
|
|
|
|
while ($file = $dh->read())
|
|
|
|
{
|
|
|
|
if (preg_match('/'."\.theme$".'/i', $file))
|
|
|
|
{
|
|
|
|
$list[] = substr($file,0,strpos($file,'.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$dh->close();
|
|
|
|
reset ($list);
|
|
|
|
return $list;
|
2002-03-03 22:47:30 +01:00
|
|
|
}
|
2022-08-04 10:46:13 +02:00
|
|
|
}
|