intriduce DB version (again) so we can keep release-version numbers while updating the database; added enable/disable switch for Let's Encrypt

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2016-03-07 13:47:22 +01:00
parent 9d6ee0d08f
commit 604f37bd17
16 changed files with 149 additions and 36 deletions

View File

@@ -177,8 +177,7 @@ if (((int)Settings::Get('system.mod_fcgid') == 1 && (int)Settings::Get('system.m
$cronlog = FroxlorLogger::getInstanceOf(array('loginname' => 'cronjob'));
fwrite($debugHandler, 'Logger has been included' . "\n");
if (Settings::Get('panel.version') == null
|| Settings::Get('panel.version') != $version
if (hasUpdates($version) || hasDbUpdates($dbversion)
) {
if (Settings::Get('system.cron_allowautoupdate') == null
|| Settings::Get('system.cron_allowautoupdate') == 0
@@ -190,7 +189,7 @@ if (Settings::Get('panel.version') == null
unlink($lockfile);
$errormessage = "Version of file doesn't match version of database. Exiting...\n\n";
$errormessage.= "Possible reason: Froxlor update\n";
$errormessage.= "Information: Current version in database: ".Settings::Get('panel.version')." - version of Froxlor files: ".$version."\n";
$errormessage.= "Information: Current version in database: ".Settings::Get('panel.version')." (DB: ".Settings::Get('panel.db_version').") - version of Froxlor files: ".$version." (DB: ".$dbversion.")\n";
$errormessage.= "Solution: Please visit your Foxlor admin interface for further information.\n";
dieWithMail($errormessage);
}

View File

@@ -74,7 +74,7 @@ return array(
'type' => 'text',
'size' => 10
),
'termination_date' => array(
'termination_date' => array(
'label' => $lng['domains']['termination_date'],
'desc' => $lng['panel']['dateformat'],
'type' => 'text',
@@ -120,7 +120,7 @@ return array(
'value' => array()
),
'letsencrypt' => array(
'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? true : false) : false),
'visible' => (Settings::Get('system.use_ssl') == '1' ? (Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? true : false) : false) : false),
'label' => $lng['admin']['letsencrypt']['title'],
'desc' => $lng['admin']['letsencrypt']['description'],
'type' => 'checkbox',

View File

@@ -132,7 +132,7 @@ return array(
'value' => array($result['ssl_redirect'])
),
'letsencrypt' => array(
'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? true : false) : false),
'visible' => (Settings::Get('system.use_ssl') == '1' ? (Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? true : false) : false) : false),
'label' => $lng['admin']['letsencrypt']['title'],
'desc' => $lng['admin']['letsencrypt']['description'],
'type' => 'checkbox',

View File

@@ -71,7 +71,7 @@ return array(
'value' => array()
),
'letsencrypt' => array(
'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? true : false) : false),
'visible' => (Settings::Get('system.use_ssl') == '1' ? (Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? true : false) : false) : false),
'label' => $lng['customer']['letsencrypt']['title'],
'desc' => $lng['customer']['letsencrypt']['description'],
'type' => 'checkbox',

View File

@@ -87,7 +87,7 @@ return array(
'value' => array($result['ssl_redirect'])
),
'letsencrypt' => array(
'visible' => (Settings::Get('system.use_ssl') == '1' ? ($ssl_ipsandports != '' ? (domainHasSslIpPort($result['id']) ? true : false) : false) : false),
'visible' => (Settings::Get('system.use_ssl') == '1' ? (Settings::Get('system.leenabled') == '1' ? ($ssl_ipsandports != '' ? (domainHasSslIpPort($result['id']) ? true : false) : false) : false) : false),
'label' => $lng['customer']['letsencrypt']['title'],
'desc' => $lng['customer']['letsencrypt']['description'],
'type' => 'checkbox',

View File

@@ -188,3 +188,65 @@ function validateUpdateLogFile($filename) {
}
return '/tmp/froxlor_update.log';
}
/**
* Function isDatabaseVersion
*
* checks if a given database-version is the current one
*
* @param int $to_check version to check
*
* @return bool true if version to check matches, else false
*/
function isDatabaseVersion($to_check = null) {
if (Settings::Get('panel.frontend') == 'froxlor'
&& Settings::Get('panel.db_version') == $to_check
) {
return true;
}
return false;
}
/**
* Function hasUpdates
*
* checks if a given database-version is not equal the current one
*
* @param int $to_check version to check
*
* @return bool true if version to check does not match, else false
*/
function hasDbUpdates($to_check = null) {
if (Settings::Get('panel.db_version') == null
|| Settings::Get('panel.db_version') != $to_check
) {
return true;
}
return false;
}
/**
* Function updateToDbVersion
*
* updates the panel.version field
* to the given value (no checks here!)
*
* @param string $new_version new-version
*
* @return bool true on success, else false
*/
function updateToDbVersion($new_version = null) {
if ($new_version !== null && $new_version != '') {
$upd_stmt = Database::prepare("
UPDATE `".TABLE_PANEL_SETTINGS."` SET `value` = :newversion
WHERE `settinggroup` = 'panel' AND `varname` = 'db_version'"
);
Database::pexecute($upd_stmt, array('newversion' => $new_version));
Settings::Set('panel.db_version', $new_version);
return true;
}
return false;
}

View File

@@ -408,7 +408,7 @@ if (isset($userinfo['loginname'])
*/
$navigation = "";
if (AREA == 'admin' || AREA == 'customer') {
if (hasUpdates($version)) {
if (hasUpdates($version) || hasDbUpdates($dbversion)) {
/*
* if froxlor-files have been updated
* but not yet configured by the admin

View File

@@ -18,8 +18,8 @@
// Main version variable
$version = '0.9.35-rc1';
// Database version (unused, old stuff from SysCP)
$dbversion = '2';
// Database version (YYYYMMDDC where C is a daily counter)
$dbversion = '201603070';
// Distribution branding-tag (used for Debian etc.)
$branding = '';