From 08a329eb7d9d1042b3a8fa92e56789d3c038ef43 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 21 Aug 2016 11:16:44 +0200 Subject: [PATCH] added license key --- lam/help/help.inc | 2 ++ lam/lib/config.inc | 26 +++++++++++++++++++++++++- lam/style/500_layout.css | 5 +++++ lam/templates/config/mainlogin.php | 17 ++++++++++++++--- lam/templates/config/mainmanage.php | 20 +++++++++++++++++++- lam/templates/login.php | 7 ++++++- 6 files changed, 71 insertions(+), 6 deletions(-) diff --git a/lam/help/help.inc b/lam/help/help.inc index af132335..eac5dbb7 100644 --- a/lam/help/help.inc +++ b/lam/help/help.inc @@ -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.')), '286' => array ("Headline" => _('SSH key password'), "Text" => _('Password to unlock SSH key file.')), + '287' => array ("Headline" => _('License'), + "Text" => _('Please enter your license key.')), // 300 - 399 // profile editor, file upload "301" => array ("Headline" => _("RDN identifier"), diff --git a/lam/lib/config.inc b/lam/lib/config.inc index c29705f6..43e73b60 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -2113,13 +2113,18 @@ class LAMCfgMain { /** error reporting */ public $errorReporting = self::ERROR_REPORTING_DEFAULT; + /** license data */ + private $license = ''; + /** list of data fields to save in config file */ private $settings = array("password", "default", "sessionTimeout", "logLevel", "logDestination", "allowedHosts", "passwordMinLength", "passwordMinUpper", "passwordMinLower", "passwordMinNumeric", "passwordMinClasses", "passwordMinSymbol", 'checkedRulesCount', 'passwordMustNotContainUser', 'passwordMustNotContain3Chars', - "mailEOL", 'errorReporting', 'encryptSession', 'allowedHostsSelfService'); + "mailEOL", 'errorReporting', 'encryptSession', 'allowedHostsSelfService', + 'license' + ); /** * 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("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("license", $saved)) array_push($file_array, "\n\n# License\n" . "license: " . $this->license); $file = @fopen($this->conffile, "w"); if ($file) { for ($i = 0; $i < sizeof($file_array); $i++) fputs($file, $file_array[$i]); @@ -2492,6 +2498,24 @@ class LAMCfgMain { 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); + } + } ?> diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index df41e806..25dd1fe3 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -519,6 +519,11 @@ div.confModList { overflow-y: auto; } +div.licenseInfo { + display: inline-block; + padding: 20px; + min-width: 200px; +} /* schema browser */ diff --git a/lam/templates/config/mainlogin.php b/lam/templates/config/mainlogin.php index 5c034d70..434d74a9 100644 --- a/lam/templates/config/mainlogin.php +++ b/lam/templates/config/mainlogin.php @@ -3,7 +3,7 @@ $Id$ 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 it under the terms of the GNU General Public License as published by @@ -34,6 +34,9 @@ $Id$ include_once('../../lib/config.inc'); /** Used to print status messages */ include_once('../../lib/status.inc'); +if (isLAMProVersion()) { + include_once("../../lib/env.inc"); +} // start session if (strtolower(session_module_name()) == 'files') { @@ -63,7 +66,6 @@ if (isset($_POST['passwd'])) { } } - echo $_SESSION['header']; ?> @@ -132,6 +134,9 @@ echo $_SESSION['header']; 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.'); } + if (!empty($_GET['invalidLicense'])) { + StatusMessage('WARN', _('Invalid license'), _('Please setup your license data.')); + } ?>
@@ -181,8 +186,14 @@ echo $_SESSION['header']; -



+ printLicenseInfo(); + } + ?> +



diff --git a/lam/templates/config/mainmanage.php b/lam/templates/config/mainmanage.php index 6797c35e..6f5193a9 100644 --- a/lam/templates/config/mainmanage.php +++ b/lam/templates/config/mainmanage.php @@ -3,7 +3,7 @@ $Id$ 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 it under the terms of the GNU General Public License as published by @@ -34,6 +34,8 @@ $Id$ include_once('../../lib/config.inc'); /** Used to print status messages */ include_once('../../lib/status.inc'); +/** LAM Pro */ +include_once('../../lib/selfService.inc'); // start session if (strtolower(session_module_name()) == 'files') { @@ -81,6 +83,12 @@ if (isset($_POST['submitFormData'])) { } 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 $cfg->sessionTimeout = $_POST['sessionTimeout']; // 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); } +// 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 $container->addElement(new htmlSubTitle(_("Security settings")), true); $securityTable = new htmlTable(); diff --git a/lam/templates/login.php b/lam/templates/login.php index ff8b1dea..ff8ac733 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -41,7 +41,12 @@ include_once("../lib/security.inc"); /** self service functions */ include_once("../lib/selfService.inc"); /** 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 */ include_once("../lib/upgrade.inc");