From 7f565c305c65114282dcc6e09923939fe214f561 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 15 Dec 2013 14:38:53 +0100 Subject: [PATCH] migrate more stuff to new Settings class, refs #1325 Signed-off-by: Michael Kaufmann (d00p) --- actions/admin/settings/180.dkim.php | 8 +- .../updates/froxlor/0.9/update_0.9.inc.php | 78 +++++++++---------- install/updates/froxlor/upgrade_syscp.inc.php | 4 +- .../preconfig/0.9/preconfig_0.9.inc.php | 56 ++++++------- install/updatesql.php | 4 +- lib/configfiles_index.inc.php | 48 ++++++------ lib/cron_init.php | 40 ++++++---- lib/cron_shutdown.php | 2 +- .../filedir/function.isConfigDir.php | 33 +++----- .../system/function.makeCryptPassword.php | 2 +- lib/init.php | 23 +++--- scripts/jobs/cron_tasks.php | 8 -- 12 files changed, 146 insertions(+), 160 deletions(-) diff --git a/actions/admin/settings/180.dkim.php b/actions/admin/settings/180.dkim.php index 25f10648..60d08477 100644 --- a/actions/admin/settings/180.dkim.php +++ b/actions/admin/settings/180.dkim.php @@ -17,8 +17,6 @@ * */ -global $settings; - return array( 'groups' => array( 'dkim' => array( @@ -82,8 +80,8 @@ return array( ), 'dkim_keylength' => array( 'label' => array( - 'title' => $lng['dkim']['dkim_keylength']['title'], - 'description' => sprintf($lng['dkim']['dkim_keylength']['description'],$settings['dkim']['dkim_prefix']) + 'title' => $lng['dkim']['dkim_keylength']['title'], + 'description' => sprintf($lng['dkim']['dkim_keylength']['description'],Settings::Get('dkim.dkim_prefix')) ), 'settinggroup' => 'dkim', 'varname' => 'dkim_keylength', @@ -133,4 +131,4 @@ return array( ), ); -?> \ No newline at end of file +?> diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index c1d149c6..54ebf984 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -21,13 +21,12 @@ if (isFroxlorVersion('0.9-r0')) { showUpdateStep("Performing database updates"); // add missing database-updates if necessary (old: update/update_database.php) - if (isset($settings['system']['dbversion']) && (int)$settings['system']['dbversion'] < 1) { + if (Settings::Get('system.dbversion') !== null && (int)Settings::Get('system.dbversion') < 1) { Database::query(" ALTER TABLE `panel_databases` ADD `dbserver` INT( 11 ) UNSIGNED NOT NULL default '0';" ); } - if(isset($settings['system']['dbversion']) && (int)$settings['system']['dbversion'] < 2) - { + if (Settings::Get('system.dbversion') !== null && (int)Settings::Get('system.dbversion') < 2) { Database::query("ALTER TABLE `panel_ipsandports` CHANGE `ssl_cert` `ssl_cert_file` VARCHAR( 255 ) NOT NULL, ADD `ssl_key_file` VARCHAR( 255 ) NOT NULL, ADD `ssl_ca_file` VARCHAR( 255 ) NOT NULL, @@ -181,22 +180,19 @@ if (isFroxlorVersion('0.9-r0')) { if (isFroxlorVersion('0.9-r1')) { showUpdateStep("Updating from 0.9-r1 to 0.9-r2", false); - showUpdateStep("Updating settings table"); + showUpdateStep("Updating settings table"); Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('spf', 'use_spf', '0');"); Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('spf', 'spf_entry', '@ IN TXT \"v=spf1 a mx -all\"');"); Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `varname` = 'froxlor_graphic' WHERE `varname` = 'syscp_graphic'"); - if(isset($settings['admin']['syscp_graphic']) - && $settings['admin']['syscp_graphic'] != '' + if (Settings::Get('admin.syscp_graphic') !== null + && Settings::Get('admin.syscp_graphic') != '' ){ - $settings['admin']['froxlor_graphic'] = $settings['admin']['syscp_graphic']; + Settings::Set('admin.froxlor_graphic', Settings::Get('admin.syscp_graphic')); + } else { + Settings::Set('admin.froxlor_graphic', 'images/header.gif'); } - else - { - $settings['admin']['froxlor_graphic'] = 'images/header.gif'; - } - lastStepStatus(0); updateToVersion('0.9-r2'); @@ -236,19 +232,19 @@ if (isFroxlorVersion('0.9-r3')) { // checking for active ticket-module $ticket_active = 0; - if ((int)$settings['ticket']['enabled'] == 1) { + if ((int)Settings::Get('ticket.enabled') == 1) { $ticket_active = 1; } // checking for active aps-module $aps_active = 0; - if ((int)$settings['aps']['aps_active'] == 1) { + if ((int)Settings::Get('aps.aps_active') == 1) { $aps_active = 1; } // checking for active autoresponder-module $ar_active = 0; - if ((int)$settings['autoresponder']['autoresponder_active'] == 1) { + if ((int)Settings::Get('autoresponder.autoresponder_active') == 1) { $ar_active = 1; } @@ -297,7 +293,7 @@ if (isFroxlorVersion('0.9.1')) { if (isset($result['latestguid']) && (int)$result['latestguid'] > 0 - && $result['latestguid'] != $settings['system']['lastguid'] + && $result['latestguid'] != Settings::Get('system.lastguid') ) { checkLastGuid(); lastStepStatus(1, 'fixed'); @@ -399,22 +395,22 @@ if (isFroxlorVersion('0.9.4')) { * because we already had this back in older versions. * To not confuse Froxlor, we just update old settings. */ - if(isset($settings['system']['awstats_path']) - && $settings['system']['awstats_path'] != '' + if(Settings::Get('system.awstats_path') !== null + && Settings::Get('system.awstats_path') != '' ) { showUpdateStep("Updating awstats path setting"); Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '/usr/bin/' WHERE `settinggroup` = 'system' AND `varname` = 'awstats_path';"); lastStepStatus(0); } - elseif(!isset($settings['system']['awstats_path'])) + elseif(Settings::Get('system.awstats_path') == null) { showUpdateStep("Adding new awstats path setting"); Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('system', 'awstats_path', '/usr/bin/');"); lastStepStatus(0); } - if(isset($settings['system']['awstats_domain_file']) - && $settings['system']['awstats_domain_file'] != '' + if(Settings::Get('system.awstats_domain_file') !== null + && Settings::Get('system.awstats_domain_file') != '' ) { showUpdateStep("Updating awstats configuration path setting"); Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `varname` = 'awstats_conf' WHERE `varname` = 'awstats_domain_file';"); @@ -635,7 +631,7 @@ if (isFroxlorVersion('0.9.6-svn5')) { while ($row_ftp_users = $result_ftp_users_stmt->fetch(PDO::FETCH_ASSOC)) { $result_ftp_quota_stmt = Database::query(" SELECT diskspace_used FROM `" . TABLE_PANEL_CUSTOMERS . "` - WHERE loginname = SUBSTRING_INDEX('" . $row_ftp_users['username'] . "', '" . $settings['customer']['ftpprefix'] . "', 1);" + WHERE loginname = SUBSTRING_INDEX('" . $row_ftp_users['username'] . "', '" . Settings::Get('customer.ftpprefix') . "', 1);" ); $row_ftp_quota = $result_ftp_quota_stmt->fetch(PDO::FETCH_ASSOC); Database::query("INSERT INTO `ftp_quotatallies` (`name`, `quota_type`, `bytes_in_used`, `bytes_out_used`, `bytes_xfer_used`, `files_in_used`, `files_out_used`, `files_xfer_used`) VALUES ('" . $row_ftp_users['username'] . "', 'user', '" . $row_ftp_quota[0] . "'*1024, '0', '0', '0', '0', '0');"); @@ -697,13 +693,13 @@ if (isFroxlorVersion('0.9.6')) { // need to fix default-error-copy-and-paste-shizzle showUpdateStep("Checking if anything is ok with the default-error-handler"); - if (!isset($settings['defaultwebsrverrhandler']['err404'])) { + if (Settings::Get('defaultwebsrverrhandler.err404') == null) { Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('defaultwebsrverrhandler', 'err404', '');"); } - if (!isset($settings['defaultwebsrverrhandler']['err403'])) { + if (Settings::Get('defaultwebsrverrhandler.err403') == null) { Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('defaultwebsrverrhandler', 'err403', '');"); } - if (!isset($settings['defaultwebsrverrhandler']['err401'])) { + if (Settings::Get('defaultwebsrverrhandler.err401') == null) { Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` (`settinggroup`, `varname`, `value`) VALUES ('defaultwebsrverrhandler', 'err401', '');"); } lastStepStatus(0); @@ -1009,7 +1005,7 @@ if (isFroxlorVersion('0.9.12-svn3')) { showUpdateStep("Updating from 0.9.12-svn3 to 0.9.12-svn4", false); - $update_awstats_awstatspath = isset($_POST['update_awstats_awstatspath']) ? makeCorrectDir($_POST['update_awstats_awstatspath']) : $settings['system']['awstats_path']; + $update_awstats_awstatspath = isset($_POST['update_awstats_awstatspath']) ? makeCorrectDir($_POST['update_awstats_awstatspath']) : Settings::Get('system.awstats_path'); showUpdateStep("Adding new settings for awstats"); $stmt = Database::prepare(" @@ -1066,7 +1062,7 @@ if (isFroxlorVersion('0.9.12')) { Database::query("ALTER TABLE `".TABLE_PANEL_CUSTOMERS."` ADD `email_autoresponder_used` int(5) NOT NULL default '0' AFTER `email_autoresponder`;"); lastStepStatus(0); - if ((int)$settings['autoresponder']['autoresponder_active'] == 1) { + if ((int)Settings::Get('autoresponder.autoresponder_active') == 1) { $update_autoresponder_default = isset($_POST['update_autoresponder_default']) ? intval_ressource($_POST['update_autoresponder_default']) : 0; if (isset($_POST['update_autoresponder_default_ul'])) { $update_autoresponder_default = -1; @@ -1121,9 +1117,9 @@ if (isFroxlorVersion('0.9.14-svn1')) { if (isFroxlorVersion('0.9.13.1')) { showUpdateStep("Updating from 0.9.13.1 to 0.9.14-svn2", false); - if ($settings['ticket']['enabled'] == '1') { + if (Settings::Get('ticket.enabled') == '1') { showUpdateStep("Setting INTERVAL for used-tickets cronjob"); - setCycleOfCronjob(null, null, $settings['ticket']['reset_cycle'], null); + setCycleOfCronjob(null, null, Settings::Get('ticket.reset_cycle'), null); lastStepStatus(0); } updateToVersion('0.9.14-svn2'); @@ -1132,7 +1128,7 @@ if (isFroxlorVersion('0.9.13.1')) { if (isFroxlorVersion('0.9.14-svn2')) { showUpdateStep("Updating from 0.9.14-svn2 to 0.9.14-svn3", false); - $update_awstats_icons = isset($_POST['update_awstats_icons']) ? makeCorrectDir($_POST['update_awstats_icons']) : $settings['system']['awstats_icons']; + $update_awstats_icons = isset($_POST['update_awstats_icons']) ? makeCorrectDir($_POST['update_awstats_icons']) : Settings::Get('system.awstats_icons'); showUpdateStep("Adding AWStats icons path to the settings"); $stmt = Database::prepare(" @@ -1504,7 +1500,7 @@ if (isFroxlorVersion('0.9.17')) { `varname` = 'httpgroup', `value` = :value" ); - Database::pexecute($stmt, array('value' => $settings['system']['httpuser'])); + Database::pexecute($stmt, array('value' => Settings::Get('system.httpuser'))); lastStepStatus(0); } @@ -1984,7 +1980,7 @@ if (isFroxlorVersion('0.9.28-svn3')) { showUpdateStep('Setting replacement for the discontinued and removed Classic theme (if active)', true); // Updating default theme setting - if ($settings['panel']['default_theme'] == 'Classic') { + if (Settings::Get('panel.default_theme') == 'Classic') { $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = :theme @@ -2159,7 +2155,7 @@ if (isFroxlorVersion('0.9.28.1')) { // don't advertise security questions - just set a default silently Database::query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'passwordcryptfunc', '1');"); - $fastcgiparams = $settings['nginx']['fastcgiparams']; + $fastcgiparams = Settings::Get('nginx.fastcgiparams'); // check the faulty value explicitly if ($fastcgiparams == '/etc/nginx/fastcgi_params/') { $fastcgiparams = makeCorrectFile(substr($fastcgiparams,0,-1)); @@ -2272,9 +2268,9 @@ if (isFroxlorVersion('0.9.29-dev4')) { `varname` = :varname, `value` = :value" ); - $dval = (isset($settings['system']['mod_fcgid_defaultini']) ? $settings['system']['mod_fcgid_defaultini'] : '1'); + $dval = (Settings::Get('system.mod_fcgid_defaultini') !== null ? Settings::Get('system.mod_fcgid_defaultini') : '1'); Database::pexecute($stmt, array('varname' => 'defaultini', 'value' => $dval)); - $dval = (isset($settings['system']['mod_fcgid_ownvhost']) ? $settings['system']['mod_fcgid_ownvhost'] : '1'); + $dval = (Settings::Get('system.mod_fcgid_ownvhost') !== null ? Settings::Get('system.mod_fcgid_ownvhost') : '1'); Database::pexecute($stmt, array('varname' => 'vhost_defaultini', 'value' => $dval)); lastStepStatus(0); @@ -2434,11 +2430,11 @@ if (isFroxlorVersion('0.9.31-dev1')) { INSERT INTO `".TABLE_PANEL_SETTINGS."` SET `settinggroup` = 'phpfpm', `varname` = 'fastcgi_ipcdir', `value` = :value "); $params = array(); - if ($settings['system']['webserver'] == 'apache2') { + if (Settings::Get('system.webserver') == 'apache2') { $params['value'] = '/var/lib/apache2/fastcgi/'; - } elseif ($settings['system']['webserver'] == 'lighttpd') { + } elseif (Settings::Get('system.webserver') == 'lighttpd') { $params['value'] = '/var/run/lighttpd/'; - } elseif ($settings['system']['webserver'] == 'nginx') { + } elseif (Settings::Get('system.webserver') == 'nginx') { $params['value'] = '/var/run/nginx/'; } Database::pexecute($ins_stmt, $params); @@ -2548,13 +2544,13 @@ if (isFroxlorVersion('0.9.31-rc2')) { "); $frxvhostconfid = Database::lastInsertId(); // update default vhosts-config for froxlor if they are on the system-default - if ($settings['system']['mod_fcgid_defaultini_ownvhost'] == '1') { + if (Settings::Get('system.mod_fcgid_defaultini_ownvhost') == '1') { $upd_stmt = Database::prepare(" UPDATE `".TABLE_PANEL_SETTINGS."` SET `value` = :value WHERE `settinggroup` = 'system' AND `varname` = 'mod_fcgid_defaultini_ownvhost' "); Database::pexecute($upd_stmt, array('value' => $frxvhostconfid)); } - if ($settings['phpfpm']['vhost_defaultini'] == '1') { + if (Settings::Get('phpfpm.vhost_defaultini') == '1') { $upd_stmt = Database::prepare(" UPDATE `".TABLE_PANEL_SETTINGS."` SET `value` = :value WHERE `settinggroup` = 'phpfpm' AND `varname` = 'vhost_defaultini' "); @@ -2613,7 +2609,7 @@ if (isFroxlorVersion('0.9.31')) { lastStepStatus(0); showUpdateStep("Updating ftp-groups entries"); - Database::query("UPDATE `".TABLE_FTP_GROUPS."` SET `members` = CONCAT(`members`, ',".$settings['system']['httpuser']."');"); + Database::query("UPDATE `".TABLE_FTP_GROUPS."` SET `members` = CONCAT(`members`, ',".Settings::Get('system.httpuser')."');"); lastStepStatus(0); updateToVersion('0.9.32-dev1'); diff --git a/install/updates/froxlor/upgrade_syscp.inc.php b/install/updates/froxlor/upgrade_syscp.inc.php index a12ff28e..a974532e 100644 --- a/install/updates/froxlor/upgrade_syscp.inc.php +++ b/install/updates/froxlor/upgrade_syscp.inc.php @@ -18,7 +18,7 @@ $updateto = '0.9-r0'; $frontend = 'froxlor'; -showUpdateStep("Upgrading SysCP ".$settings['panel']['version']." to Froxlor ". $updateto, false); +showUpdateStep("Upgrading SysCP ".Settings::Get('panel.version')." to Froxlor ". $updateto, false); updateToVersion($updateto); // add field frontend @@ -27,4 +27,4 @@ Database::query("INSERT INTO `" . TABLE_PANEL_SETTINGS . "` SET `varname` = 'frontend', `value` = 'froxlor'" ); -$settings['panel']['frontend'] = $frontend; +Settings::Set('panel.frontend', $frontend); diff --git a/install/updates/preconfig/0.9/preconfig_0.9.inc.php b/install/updates/preconfig/0.9/preconfig_0.9.inc.php index cf59e47c..95396007 100644 --- a/install/updates/preconfig/0.9/preconfig_0.9.inc.php +++ b/install/updates/preconfig/0.9/preconfig_0.9.inc.php @@ -24,9 +24,9 @@ * * @return null */ -function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) -{ - global $settings, $lng; +function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) { + + global $lng; if(versionInUpdate($current_version, '0.9.4-svn2')) { @@ -42,11 +42,11 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if(versionInUpdate($current_version, '0.9.6-svn2')) { - if(!PHPMailer::ValidateAddress($settings['panel']['adminmail'])) + if(!PHPMailer::ValidateAddress(Settings::Get('panel.adminmail'))) { $has_preconfig = true; $description = 'Froxlor uses a newer version of the phpMailerClass and determined that your current admin-mail address is invalid.'; - $question = 'Please specify a new admin-email address: '; + $question = 'Please specify a new admin-email address: '; eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } } @@ -57,7 +57,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) $description = 'You now have the possibility to define default error-documents for your webserver which replace the default webserver error-messages.'; $question = 'Do you want to enable default error-documents?: '; $question .= makeyesno('update_deferr_enable', '1', '0', '0').'

'; - if($settings['system']['webserver'] == 'apache2') + if(Settings::Get('system.webserver') == 'apache2') { $question .= 'Path/URL for error 500: 

'; $question .= 'Path/URL for error 401: 

'; @@ -244,7 +244,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if(versionInUpdate($current_version, '0.9.12-svn1')) { - if($settings['system']['mod_fcgid'] == 1) + if(Settings::Get('system.mod_fcgid') == 1) { $has_preconfig = true; $description = 'You can chose whether you want Froxlor to use FCGID itself too now.'; @@ -273,19 +273,19 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if(versionInUpdate($current_version, '0.9.12-svn4')) { - if((int)$settings['system']['awstats_enabled'] == 1) + if((int)Settings::Get('system.awstats_enabled') == 1) { $has_preconfig = true; $description = 'Due to different paths of awstats_buildstaticpages.pl and awstats.pl you can set a different path for awstats.pl now.'; $question = 'Path to \'awstats.pl\'?: '; - $question.= '
'; + $question.= '
'; eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } } if(versionInUpdate($current_version, '0.9.13-svn1')) { - if((int)$settings['autoresponder']['autoresponder_active'] == 1) + if((int)Settings::Get('autoresponder.autoresponder_active') == 1) { $has_preconfig = true; $description = 'Froxlor can now limit the number of autoresponder-entries for each user. Here you can set the value which will be available for each customer (Of course you can change the value for each customer separately after the update).'; @@ -297,7 +297,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if(versionInUpdate($current_version, '0.9.13.1')) { - if((int)$settings['system']['mod_fcgid_ownvhost'] == 1) + if((int)Settings::Get('system.mod_fcgid_ownvhost') == 1) { $has_preconfig = true; $description = 'You have FCGID for Froxlor itself activated. You can now specify a PHP-configuration for this.'; @@ -316,24 +316,24 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if(versionInUpdate($current_version, '0.9.14-svn3')) { - if((int)$settings['system']['awstats_enabled'] == 1) + if((int)Settings::Get('system.awstats_enabled') == 1) { $has_preconfig = true; $description = 'To have icons in AWStats statistic-pages please enter the path to AWStats icons folder.'; $question = 'Path to AWSTats icons folder: '; - $question.= ''; + $question.= ''; eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } } if(versionInUpdate($current_version, '0.9.14-svn4')) { - if((int)$settings['system']['use_ssl'] == 1) + if((int)Settings::Get('system.use_ssl') == 1) { $has_preconfig = true; $description = 'Froxlor now has the possibility to set \'SSLCertificateChainFile\' for the apache webserver.'; $question = 'Enter filename (leave empty for none): '; - $question.= ''; + $question.= ''; eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } } @@ -390,7 +390,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if(versionInUpdate($current_version, '0.9.16-svn2')) { - if((int)$settings['phpfpm']['enabled'] == 1) + if((int)Settings::Get('phpfpm.enabled') == 1) { $has_preconfig = true; $description = 'You can chose whether you want Froxlor to use PHP-FPM itself too now.'; @@ -398,9 +398,9 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) $question.= makeyesno('update_phpfpm_enabled_ownvhost', '1', '0', '0').'

'; $question.= 'If \'yes\', please specify local user/group (have to exist, Froxlor does not add them automatically):

'; $question.= 'Local user: '; - $question.= '

'; + $question.= '

'; $question.= 'Local group: '; - $question.= '
'; + $question.= '
'; eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";"); } } @@ -457,7 +457,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if (versionInUpdate($current_version, '0.9.28-svn6')) { - if ($settings['system']['webserver'] == 'apache2') { + if (Settings::Get('system.webserver') == 'apache2') { $has_preconfig = true; $description = 'Froxlor now supports the new Apache 2.4. Please be aware that you need to load additional apache-modules in ordner to use it.
'; $description.= '
LoadModule authz_core_module modules/mod_authz_core.so
@@ -465,7 +465,7 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version)
 			$question = 'Do you want to enable the Apache-2.4 modification?: ';
 			$question.= makeyesno('update_system_apache24', '1', '0', '0');
 			eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");
-		} elseif ($settings['system']['webserver'] == 'nginx') {
+		} elseif (Settings::Get('system.webserver') == 'nginx') {
 			$has_preconfig = true;
 			$description = 'The path to nginx\'s fastcgi_params file is now customizable.

'; $question = 'Please enter full path to you nginx/fastcgi_params file (including filename): '; @@ -494,8 +494,8 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) $description = 'Froxlor changed the default parameter-set of sendmail (php.ini)
'; $description .= 'sendmail_path = "/usr/sbin/sendmail -t -i -f {CUSTOMER_EMAIL}"

'; $description .= 'If you don\'t have any problems with sending mails, you don\'t need to change this'; - if ($settings['system']['mod_fcgid'] == '1' - || $settings['phpfpm']['enabled'] == '1' + if (Settings::Get('system.mod_fcgid') == '1' + || Settings::Get('phpfpm.enabled') == '1' ) { // information about removal of php's safe_mode $description .= '

The php safe_mode flag has been removed as current versions of PHP
'; @@ -509,8 +509,8 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) if (versionInUpdate($current_version, '0.9.29-dev1')) { // we only need to ask if fcgid|php-fpm is enabled - if ($settings['system']['mod_fcgid'] == '1' - || $settings['phpfpm']['enabled'] == '1' + if (Settings::Get('system.mod_fcgid') == '1' + || Settings::Get('phpfpm.enabled') == '1' ) { $has_preconfig = true; $description = 'Standard-subdomains can now be hidden from the php-configuration overview.
'; @@ -555,8 +555,8 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) // let the apache+fpm users know that they MUST change their config // for the domains / webserver to work after the update if (versionInUpdate($current_version, '0.9.30-dev1')) { - if ($settings['system']['webserver'] == 'apache2' - && $settings['phpfpm']['enabled'] == '1' + if (Settings::Get('system.webserver') == 'apache2' + && Settings::Get('phpfpm.enabled') == '1' ) { $has_preconfig = true; $description = 'The PHP-FPM implementation for apache2 has changed. Please look for the "fastcgi.conf" (Debian/Ubuntu) or "70_fastcgi.conf" (Gentoo) within /etc/apache2/ and change it as shown below:

'; @@ -575,8 +575,8 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) } if (versionInUpdate($current_version, '0.9.31-dev2')) { - if ($settings['system']['webserver'] == 'apache2' - && $settings['phpfpm']['enabled'] == '1' + if (Settings::Get('system.webserver') == 'apache2' + && Settings::Get('phpfpm.enabled') == '1' ) { $has_preconfig = true; $description = 'The FPM socket directory is now a setting in froxlor. Its default is /var/lib/apache2/fastcgi/.
If you are using /var/run/apache2 in the "fastcgi.conf" (Debian/Ubuntu) or "70_fastcgi.conf" (Gentoo) please correct this path accordingly
'; diff --git a/install/updatesql.php b/install/updatesql.php index f22bfc75..312dd52c 100644 --- a/install/updatesql.php +++ b/install/updatesql.php @@ -17,10 +17,10 @@ * */ -$updatelog = FroxlorLogger::getInstanceOf(array('loginname' => 'updater'), $settings); +$updatelog = FroxlorLogger::getInstanceOf(array('loginname' => 'updater')); $updatelogfile = validateUpdateLogFile(makeCorrectFile(dirname(__FILE__).'/update.log')); -$filelog = FileLogger::getInstanceOf(array('loginname' => 'updater'), $settings); +$filelog = FileLogger::getInstanceOf(array('loginname' => 'updater')); $filelog->setLogFile($updatelogfile); // if first writing does not work we'll stop, tell the user to fix it diff --git a/lib/configfiles_index.inc.php b/lib/configfiles_index.inc.php index bffc97e1..ca47f5ef 100644 --- a/lib/configfiles_index.inc.php +++ b/lib/configfiles_index.inc.php @@ -19,31 +19,33 @@ $configcommand = array(); -if(isConfigDir($settings['system']['apacheconf_vhost'])) -{ - $configcommand['vhost'] = 'mkdir -p ' . $settings['system']['apacheconf_vhost']; - $configcommand['include'] = 'echo -e "\\nInclude ' . makeCorrectDir($settings['system']['apacheconf_vhost']) . '*.conf" >> ' . makeCorrectFile(makeCorrectDir('/etc/apache2/httpd.conf')); - $configcommand['v_inclighty'] = 'echo -e \'\\ninclude_shell "cat ' . makeCorrectDir($settings['system']['apacheconf_vhost']) . '*.conf"\' >> /etc/lighttpd/lighttpd.conf'; -} -else -{ - $configcommand['vhost'] = 'touch ' . $settings['system']['apacheconf_vhost']; - $configcommand['include'] = 'echo -e "\\nInclude ' . $settings['system']['apacheconf_vhost'] . '" >> ' . makeCorrectFile('/etc/apache2/httpd.conf'); - $configcommand['v_inclighty'] = 'echo -e \'\\ninclude "' . $settings['system']['apacheconf_vhost'] . '"\' >> /etc/lighttpd/lighttpd.conf'; +if (isConfigDir(Settings::Get('system.apacheconf_vhost'))) { + $configcommand['vhost'] = 'mkdir -p ' . Settings::Get('system.apacheconf_vhost'); + $configcommand['include'] = 'echo -e "\\nInclude ' . makeCorrectDir(Settings::Get('system.apacheconf_vhost')) . '*.conf" >> ' . makeCorrectFile(makeCorrectDir('/etc/apache2/httpd.conf')); + $configcommand['v_inclighty'] = 'echo -e \'\\ninclude_shell "cat ' . makeCorrectDir(Settings::Get('system.apacheconf_vhost')) . '*.conf"\' >> /etc/lighttpd/lighttpd.conf'; +} else { + $configcommand['vhost'] = 'touch ' . Settings::Get('system.apacheconf_vhost'); + $configcommand['include'] = 'echo -e "\\nInclude ' . Settings::Get('system.apacheconf_vhost') . '" >> ' . makeCorrectFile('/etc/apache2/httpd.conf'); + $configcommand['v_inclighty'] = 'echo -e \'\\ninclude "' . Settings::Get('system.apacheconf_vhost') . '"\' >> /etc/lighttpd/lighttpd.conf'; } -if(isConfigDir($settings['system']['apacheconf_diroptions'])) -{ - $configcommand['diroptions'] = 'mkdir -p ' . $settings['system']['apacheconf_diroptions']; - $configcommand['d_inclighty'] = 'echo -e \'\\ninclude_shell "cat ' . makeCorrectDir($settings['system']['apacheconf_diroptions']) . '*.conf"\' >> /etc/lighttpd/lighttpd.conf'; -} -else -{ - $configcommand['diroptions'] = 'touch ' . $settings['system']['apacheconf_diroptions']; - $configcommand['d_inclighty'] = 'echo -e \'\\ninclude "' . $settings['system']['apacheconf_diroptions'] . '"\' >> /etc/lighttpd/lighttpd.conf'; +if (isConfigDir(Settings::Get('system.apacheconf_diroptions'))) { + $configcommand['diroptions'] = 'mkdir -p ' . Settings::Get('system.apacheconf_diroptions'); + $configcommand['d_inclighty'] = 'echo -e \'\\ninclude_shell "cat ' . makeCorrectDir(Settings::Get('system.apacheconf_diroptions')) . '*.conf"\' >> /etc/lighttpd/lighttpd.conf'; +} else { + $configcommand['diroptions'] = 'touch ' . Settings::Get('system.apacheconf_diroptions'); + $configcommand['d_inclighty'] = 'echo -e \'\\ninclude "' . Settings::Get('system.apacheconf_diroptions') . '"\' >> /etc/lighttpd/lighttpd.conf'; } $cfgPath = 'lib/configfiles/'; -$configfiles = Array(); -$configfiles = array_merge(include $cfgPath . 'wheezy.inc.php', include $cfgPath . 'squeeze.inc.php', include $cfgPath . 'precise.inc.php', include $cfgPath . 'lucid.inc.php', include $cfgPath . 'gentoo.inc.php', include $cfgPath . 'suse11.inc.php', include $cfgPath . 'sle10.inc.php', include $cfgPath . 'freebsd.inc.php'); - +$configfiles = array(); +$configfiles = array_merge( + include $cfgPath . 'wheezy.inc.php', + include $cfgPath . 'squeeze.inc.php', + include $cfgPath . 'precise.inc.php', + include $cfgPath . 'lucid.inc.php', + include $cfgPath . 'gentoo.inc.php', + include $cfgPath . 'suse11.inc.php', + include $cfgPath . 'sle10.inc.php', + include $cfgPath . 'freebsd.inc.php' +); diff --git a/lib/cron_init.php b/lib/cron_init.php index 9b02bd2d..08eb35c9 100644 --- a/lib/cron_init.php +++ b/lib/cron_init.php @@ -127,11 +127,12 @@ try { } fwrite($debugHandler, 'Database-connection established' . "\n"); + +// TODO remove when fully migrated to new Settings class $result_stmt = Database::query(" SELECT `settingid`, `settinggroup`, `varname`, `value` FROM `" . TABLE_PANEL_SETTINGS . "` "); - while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { $settings[$row['settinggroup']][$row['varname']] = $row['value']; } @@ -140,26 +141,37 @@ unset($row); fwrite($debugHandler, 'Froxlor settings have been loaded from the database' . "\n"); /** - * if settings['system']['mod_fcgid_ownvhost'] is set, we have to check + * if using fcgid or fpm for froxlor-vhost itself, we have to check * whether the permission of the files are still correct */ -if ((int)$settings['system']['mod_fcgid'] == 1 - && (int)$settings['system']['mod_fcgid_ownvhost'] == 1 +fwrite($debugHandler, 'Checking froxlor file permissions'); +$_mypath = makeCorrectDir(FROXLOR_INSTALL_DIR); + +if (((int)Settings::Get('system.mod_fcgid') == 1 && (int)Settings::Get('system.mod_fcgid_ownvhost') == 1) + || ((int)Settings::Get('phpfpm.enabled') == 1 && (int)Settings::Get('phpfpm.enabled_ownvhost') == 1) ) { - fwrite($debugHandler, 'Checking froxlor file permissions'); - $mypath = makeCorrectDir(FROXLOR_INSTALL_DIR); - $user = $settings['system']['mod_fcgid_httpuser']; - $group = $settings['system']['mod_fcgid_httpgroup']; + $user = Settings::Get('system.mod_fcgid_httpuser'); + $group = Settings::Get('system.mod_fcgid_httpgroup'); + + if (Settings::Get('phpfpm.enabled') == 1) { + $user = Settings::Get('phpfpm.vhost_httpuser'); + $group = Settings::Get('phpfpm.vhost_httpgroup'); + } // all the files and folders have to belong to the local user // now because we also use fcgid for our own vhost - safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($mypath)); + safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($_mypath)); +} else { + // back to webserver permission + $user = Settings::Get('system.httpuser'); + $group = Settings::Get('system.httpgroup'); + safe_exec('chown -R ' . $user . ':' . $group . ' ' . escapeshellarg($_mypath)); } // be sure HTMLPurifier's cache folder is writable safe_exec('chmod -R 0755 '.escapeshellarg(dirname(__FILE__).'/classes/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer')); -if (!isset($settings['panel']['version']) - || $settings['panel']['version'] != $version +if (Settings::Get('panel.version') == null + || Settings::Get('panel.version') != $version ) { /** * Do not proceed further if the Database version is not the same as the script version @@ -168,18 +180,18 @@ if (!isset($settings['panel']['version']) unlink($lockfile); $errormessage = "Version of file doesnt match version of database. Exiting...\n\n"; $errormessage.= "Possible reason: Froxlor update\n"; - $errormessage.= "Information: Current version in database: ".$settings['panel']['version']." - version of Froxlor files: ".$version."\n"; + $errormessage.= "Information: Current version in database: ".Settings::Get('panel.version')." - version of Froxlor files: ".$version."\n"; $errormessage.= "Solution: Please visit your Foxlor admin interface for further information.\n"; die($errormessage); } fwrite($debugHandler, 'Froxlor version and database version are correct' . "\n"); -$cronscriptDebug = ($settings['system']['debug_cron'] == '1') ? true : false; +$cronscriptDebug = (Settings::Get('system.debug_cron') == '1') ? true : false; // Create a new idna converter $idna_convert = new idna_convert_wrapper(); // Initialize logging -$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'), $settings); +$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob')); fwrite($debugHandler, 'Logger has been included' . "\n"); diff --git a/lib/cron_shutdown.php b/lib/cron_shutdown.php index 68c72645..71a262fa 100644 --- a/lib/cron_shutdown.php +++ b/lib/cron_shutdown.php @@ -17,7 +17,7 @@ * */ -if ($settings['logger']['log_cron'] == '1') { +if (Settings::Get('logger.log_cron') == '1') { $cronlog->setCronLog(0); fwrite($debugHandler, 'Logging for cron has been shutdown' . "\n"); } diff --git a/lib/functions/filedir/function.isConfigDir.php b/lib/functions/filedir/function.isConfigDir.php index 41d6a3f4..574308ad 100644 --- a/lib/functions/filedir/function.isConfigDir.php +++ b/lib/functions/filedir/function.isConfigDir.php @@ -26,38 +26,23 @@ * * @author Florian Lippert */ - -function isConfigDir($dir, $ifexists = false) -{ - if(file_exists($dir)) - { - if(is_dir($dir)) - { +function isConfigDir($dir, $ifexists = false) { + if (file_exists($dir)) { + if (is_dir($dir)) { $returnval = true; - } - else - { + } else { $returnval = false; } - } - else - { - if(!$ifexists) - { - if(substr($dir, -1) == '/') - { + } else { + if (!$ifexists) { + if (substr($dir, -1) == '/') { $returnval = true; - } - else - { + } else { $returnval = false; } - } - else - { + } else { $returnval = false; } } - return $returnval; } diff --git a/lib/functions/system/function.makeCryptPassword.php b/lib/functions/system/function.makeCryptPassword.php index 5758a279..03af5013 100644 --- a/lib/functions/system/function.makeCryptPassword.php +++ b/lib/functions/system/function.makeCryptPassword.php @@ -34,7 +34,7 @@ */ function makeCryptPassword ($password) { - $type = isset(Settings::Get('system.passwordcryptfunc')) ? (int)Settings::Get('system.passwordcryptfunc') : 1; + $type = Settings::Get('system.passwordcryptfunc') !== null ? (int)Settings::Get('system.passwordcryptfunc') : 1; switch ($type) { case 0: diff --git a/lib/init.php b/lib/init.php index a21d913a..a9fe74a2 100644 --- a/lib/init.php +++ b/lib/init.php @@ -145,6 +145,7 @@ if (get_magic_quotes_gpc()) { /** * Selects settings from MySQL-Table + * TODO remove when completely migrated to new Settings class */ $settings_data = loadConfigArrayDir('actions/admin/settings/'); $settings = loadSettings($settings_data); @@ -176,7 +177,7 @@ if (isset($_POST['s'])) { $nosession = 1; } -$timediff = time() - $settings['session']['sessiontimeout']; +$timediff = time() - Settings::Get('session.sessiontimeout'); $del_stmt = Database::prepare(" DELETE FROM `" . TABLE_PANEL_SESSIONS . "` WHERE `lastactivity` < :timediff "); @@ -270,7 +271,7 @@ foreach ($langs as $key => $value) { // set default langauge before anything else to // ensure that we can display messages -$language = $settings['panel']['standardlanguage']; +$language = Settings::Get('panel.standardlanguage'); if (isset($userinfo['language']) && isset($languages[$userinfo['language']])) { // default: use language from session, #277 @@ -299,7 +300,7 @@ if (isset($userinfo['language']) && isset($languages[$userinfo['language']])) { // if HTTP_ACCEPT_LANGUAGES has no valid langs, use default (very unlikely) if (!strlen($language)>0) { - $language = $settings['panel']['standardlanguage']; + $language = Settings::Get('panel.standardlanguage'); } } } @@ -329,7 +330,7 @@ $linker = new linker('index.php', $s); /** * global Theme-variable */ -$theme = isset($settings['panel']['default_theme']) ? $settings['panel']['default_theme'] : 'Sparkle'; +$theme = (Settings::Get('panel.default_theme') !== null) ? Settings::Get('panel.default_theme') : 'Sparkle'; /** * overwrite with customer/admin theme if defined @@ -374,7 +375,7 @@ if (isset($userinfo['loginname']) ) { $lng['menue']['main']['username'].= $userinfo['loginname']; //Initialize logging - $log = FroxlorLogger::getInstanceOf($userinfo, $settings); + $log = FroxlorLogger::getInstanceOf($userinfo); } /** @@ -428,7 +429,7 @@ if (AREA == 'admin' || AREA == 'customer') { */ $awaitingtickets = 0; $awaitingtickets_text = ''; -if ($settings['ticket']['enabled'] == '1') { +if (Settings::Get('ticket.enabled') == '1') { $opentickets = 0; @@ -460,7 +461,7 @@ if ($settings['ticket']['enabled'] == '1') { } } -$webfont = str_replace('+', ' ', $settings['panel']['webfont']); +$webfont = str_replace('+', ' ', Settings::Get('panel.webfont')); eval("\$header = \"" . getTemplate('header', '1') . "\";"); $current_year = date('Y', time()); @@ -496,10 +497,10 @@ if ($page == '') { $mail = new PHPMailer(true); $mail->CharSet = "UTF-8"; -if (PHPMailer::ValidateAddress($settings['panel']['adminmail']) !== false) { +if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) { // set return-to address and custom sender-name, see #76 - $mail->SetFrom($settings['panel']['adminmail'], $settings['panel']['adminmail_defname']); - if ($settings['panel']['adminmail_return'] != '') { - $mail->AddReplyTo($settings['panel']['adminmail_return'], $settings['panel']['adminmail_defname']); + $mail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname')); + if (Settings::Get('panel.adminmail_return') != '') { + $mail->AddReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname')); } } diff --git a/scripts/jobs/cron_tasks.php b/scripts/jobs/cron_tasks.php index cae0f840..7c913ef0 100644 --- a/scripts/jobs/cron_tasks.php +++ b/scripts/jobs/cron_tasks.php @@ -86,14 +86,6 @@ while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) { } else { echo "Please check you Webserver settings\n"; } - - /** - * FIXME - * as we might have a change from mod_php to fcgid/fpm or the other way around - * we need to check customer directory permissions - * -> 0.9.31 - */ - } /**