added license key

This commit is contained in:
Roland Gruber 2016-08-21 11:16:44 +02:00
parent 619b715a60
commit 08a329eb7d
6 changed files with 71 additions and 6 deletions

View File

@ -217,6 +217,8 @@ $helpArray = array (
"Text" => _('Path to SSH key file to connect to lamdaemon server. If empty then password authentication with the person\'s password who is logged into LAM will be used.')), "Text" => _('Path to SSH key file to connect to lamdaemon server. If empty then password authentication with the person\'s password who is logged into LAM will be used.')),
'286' => array ("Headline" => _('SSH key password'), '286' => array ("Headline" => _('SSH key password'),
"Text" => _('Password to unlock SSH key file.')), "Text" => _('Password to unlock SSH key file.')),
'287' => array ("Headline" => _('License'),
"Text" => _('Please enter your license key.')),
// 300 - 399 // 300 - 399
// profile editor, file upload // profile editor, file upload
"301" => array ("Headline" => _("RDN identifier"), "301" => array ("Headline" => _("RDN identifier"),

View File

@ -2113,13 +2113,18 @@ class LAMCfgMain {
/** error reporting */ /** error reporting */
public $errorReporting = self::ERROR_REPORTING_DEFAULT; public $errorReporting = self::ERROR_REPORTING_DEFAULT;
/** license data */
private $license = '';
/** list of data fields to save in config file */ /** list of data fields to save in config file */
private $settings = array("password", "default", "sessionTimeout", private $settings = array("password", "default", "sessionTimeout",
"logLevel", "logDestination", "allowedHosts", "passwordMinLength", "logLevel", "logDestination", "allowedHosts", "passwordMinLength",
"passwordMinUpper", "passwordMinLower", "passwordMinNumeric", "passwordMinUpper", "passwordMinLower", "passwordMinNumeric",
"passwordMinClasses", "passwordMinSymbol", 'checkedRulesCount', "passwordMinClasses", "passwordMinSymbol", 'checkedRulesCount',
'passwordMustNotContainUser', 'passwordMustNotContain3Chars', 'passwordMustNotContainUser', 'passwordMustNotContain3Chars',
"mailEOL", 'errorReporting', 'encryptSession', 'allowedHostsSelfService'); "mailEOL", 'errorReporting', 'encryptSession', 'allowedHostsSelfService',
'license'
);
/** /**
* Loads preferences from config file * Loads preferences from config file
@ -2213,6 +2218,7 @@ class LAMCfgMain {
if (!in_array("passwordMustNotContainUser", $saved)) array_push($file_array, "\n\n# Password: must not contain user name\n" . "passwordMustNotContainUser: " . $this->passwordMustNotContainUser); if (!in_array("passwordMustNotContainUser", $saved)) array_push($file_array, "\n\n# Password: must not contain user name\n" . "passwordMustNotContainUser: " . $this->passwordMustNotContainUser);
if (!in_array("mailEOL", $saved)) array_push($file_array, "\n\n# Email format (default/unix)\n" . "mailEOL: " . $this->mailEOL); if (!in_array("mailEOL", $saved)) array_push($file_array, "\n\n# Email format (default/unix)\n" . "mailEOL: " . $this->mailEOL);
if (!in_array("errorReporting", $saved)) array_push($file_array, "\n\n# PHP error reporting (default/system)\n" . "errorReporting: " . $this->errorReporting); if (!in_array("errorReporting", $saved)) array_push($file_array, "\n\n# PHP error reporting (default/system)\n" . "errorReporting: " . $this->errorReporting);
if (!in_array("license", $saved)) array_push($file_array, "\n\n# License\n" . "license: " . $this->license);
$file = @fopen($this->conffile, "w"); $file = @fopen($this->conffile, "w");
if ($file) { if ($file) {
for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]);
@ -2492,6 +2498,24 @@ class LAMCfgMain {
return $list; return $list;
} }
/**
* Returns the license key as multiple lines.
*
* @return String license
*/
public function getLicenseLines() {
return explode(LAMConfig::LINE_SEPARATOR, $this->license);
}
/**
* Sets the license key as multiple lines.
*
* @param String $license license
*/
public function setLicenseLines($licenseLines) {
$this->license = implode(LAMConfig::LINE_SEPARATOR, $licenseLines);
}
} }
?> ?>

View File

@ -519,6 +519,11 @@ div.confModList {
overflow-y: auto; overflow-y: auto;
} }
div.licenseInfo {
display: inline-block;
padding: 20px;
min-width: 200px;
}
/* schema browser */ /* schema browser */

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2015 Roland Gruber Copyright (C) 2003 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -34,6 +34,9 @@ $Id$
include_once('../../lib/config.inc'); include_once('../../lib/config.inc');
/** Used to print status messages */ /** Used to print status messages */
include_once('../../lib/status.inc'); include_once('../../lib/status.inc');
if (isLAMProVersion()) {
include_once("../../lib/env.inc");
}
// start session // start session
if (strtolower(session_module_name()) == 'files') { if (strtolower(session_module_name()) == 'files') {
@ -63,7 +66,6 @@ if (isset($_POST['passwd'])) {
} }
} }
echo $_SESSION['header']; echo $_SESSION['header'];
?> ?>
@ -132,6 +134,9 @@ echo $_SESSION['header'];
if (!$cfgMain->isWritable()) { if (!$cfgMain->isWritable()) {
StatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.'); StatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.');
} }
if (!empty($_GET['invalidLicense'])) {
StatusMessage('WARN', _('Invalid license'), _('Please setup your license data.'));
}
?> ?>
<br> <br>
<!-- form to change main options --> <!-- form to change main options -->
@ -181,8 +186,14 @@ echo $_SESSION['header'];
</table> </table>
</form> </form>
<p><br><br></p> <?php
if (isLAMProVersion()) {
$printer = new \LAM\ENV\LAMLicenseInfoPrinter();
$printer->printLicenseInfo();
}
?>
<p><br><br></p>
</body> </body>
</html> </html>

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2014 Roland Gruber Copyright (C) 2003 - 2016 Roland Gruber
This program is free software; you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@ -34,6 +34,8 @@ $Id$
include_once('../../lib/config.inc'); include_once('../../lib/config.inc');
/** Used to print status messages */ /** Used to print status messages */
include_once('../../lib/status.inc'); include_once('../../lib/status.inc');
/** LAM Pro */
include_once('../../lib/selfService.inc');
// start session // start session
if (strtolower(session_module_name()) == 'files') { if (strtolower(session_module_name()) == 'files') {
@ -81,6 +83,12 @@ if (isset($_POST['submitFormData'])) {
} }
else $errors[] = _("Master passwords are different or empty!"); else $errors[] = _("Master passwords are different or empty!");
} }
// set license
if (isLAMProVersion()) {
$licenseLines = explode("\n", $_POST['license']);
$licenseLines = array_map('trim', $licenseLines);
$cfg->setLicenseLines($licenseLines);
}
// set session timeout // set session timeout
$cfg->sessionTimeout = $_POST['sessionTimeout']; $cfg->sessionTimeout = $_POST['sessionTimeout'];
// set allowed hosts // set allowed hosts
@ -291,6 +299,16 @@ if (!$cfg->isWritable()) {
$container->addElement(new htmlStatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.'), true); $container->addElement(new htmlStatusMessage('WARN', 'The config file is not writable.', 'Your changes cannot be saved until you make the file writable for the webserver user.'), true);
} }
// license
if (isLAMProVersion()) {
$container->addElement(new htmlSubTitle(_('License')), true);
$licenseTable = new htmlTable();
$licenseTable->addElement(new htmlTableExtendedInputTextarea('license', implode("\n", $cfg->getLicenseLines()), 50, 10, _('License'), '287'));
$container->addElement($licenseTable, true);
$container->addElement(new htmlSpacer(null, '10px'), true);
}
// security settings // security settings
$container->addElement(new htmlSubTitle(_("Security settings")), true); $container->addElement(new htmlSubTitle(_("Security settings")), true);
$securityTable = new htmlTable(); $securityTable = new htmlTable();

View File

@ -41,7 +41,12 @@ include_once("../lib/security.inc");
/** self service functions */ /** self service functions */
include_once("../lib/selfService.inc"); include_once("../lib/selfService.inc");
/** access to configuration options */ /** access to configuration options */
include_once("../lib/config.inc"); // Include config.inc which provides Config class include_once("../lib/config.inc");
if (isLAMProVersion()) {
include_once("../lib/env.inc");
$validator = new \LAM\ENV\LAMLicenseValidator();
$validator->validateAndRedirect();
}
/** Upgrade functions */ /** Upgrade functions */
include_once("../lib/upgrade.inc"); include_once("../lib/upgrade.inc");