MySQL support for jobs

This commit is contained in:
Roland Gruber 2015-07-26 07:59:24 +00:00
parent 75e7924770
commit 801f80ed47
1 changed files with 249 additions and 142 deletions

View File

@ -98,16 +98,16 @@ function checkChmod($right, $target, $chmod) {
if (!in_array($right, $right_arr) ||!in_array($target, $target_arr)) { if (!in_array($right, $right_arr) ||!in_array($target, $target_arr)) {
return false; return false;
} }
$chmod_num = -1; $chmod_num = -1;
// owner: // owner:
if ($target == "owner") $chmod_num = 0; if ($target == "owner") $chmod_num = 0;
if ($target == "group") $chmod_num = 1; if ($target == "group") $chmod_num = 1;
if ($target == "other") $chmod_num = 2; if ($target == "other") $chmod_num = 2;
// Cut the number from the chmod: // Cut the number from the chmod:
$chmod_num = $chmod{$chmod_num}; $chmod_num = $chmod{$chmod_num};
// Now check, if the chmod_num can be right with the $right // Now check, if the chmod_num can be right with the $right
// What numbers allow "read" // What numbers allow "read"
$read = array(4,5,6,7); $read = array(4,5,6,7);
@ -167,7 +167,7 @@ function getConfigTemplates() {
/** /**
* Creates a new server profile. * Creates a new server profile.
* *
* @param String $name profile name * @param String $name profile name
* @param String $password profile password * @param String $password profile password
* @param String $template name of template file * @param String $template name of template file
@ -179,7 +179,7 @@ function createConfigProfile($name, $password, $template) {
} }
// check if template exists // check if template exists
if (!is_file("../../config/" . $template)) { if (!is_file("../../config/" . $template)) {
return "The file config/$template was not found. Please restore it."; return "The file config/$template was not found. Please restore it.";
} }
// create new profile file // create new profile file
$path = "../../config/" . $name . ".conf"; $path = "../../config/" . $name . ".conf";
@ -200,7 +200,7 @@ function createConfigProfile($name, $password, $template) {
/** /**
* Deletes the given server profile. * Deletes the given server profile.
* *
* @param String $name profile name * @param String $name profile name
* @return String null if success or error message if failed * @return String null if success or error message if failed
*/ */
@ -258,7 +258,7 @@ function LAMVersion() {
/** /**
* Extracts config options from HTTP POST data. * Extracts config options from HTTP POST data.
* *
* @param array $confTypes array (option name => type (e.g. multiselect)) * @param array $confTypes array (option name => type (e.g. multiselect))
* @return array list of config options (name => array(values)) * @return array list of config options (name => array(values))
*/ */
@ -326,7 +326,7 @@ function metaRefresh($page) {
/** /**
* Checks if the given account type is hidden. * Checks if the given account type is hidden.
* *
* @param String $type account type (e.g. user) * @param String $type account type (e.g. user)
* @return boolean is hidden * @return boolean is hidden
*/ */
@ -337,7 +337,7 @@ function isAccountTypeHidden($type) {
/** /**
* Returns a list of all supported languages. * Returns a list of all supported languages.
* *
* @return array languages * @return array languages
*/ */
function getLanguages() { function getLanguages() {
@ -359,7 +359,7 @@ function getLanguages() {
/** /**
* Represents a supported language. * Represents a supported language.
* *
* @package configuration * @package configuration
*/ */
class LAMLanguage { class LAMLanguage {
@ -369,10 +369,10 @@ class LAMLanguage {
public $encoding; public $encoding;
/** description for GUI */ /** description for GUI */
public $description; public $description;
/** /**
* Constructor * Constructor
* *
* @param String $code language code (e.g. en_GB.utf8) * @param String $code language code (e.g. en_GB.utf8)
* @param String $encoding character encoding (e.g. UTF-8) * @param String $encoding character encoding (e.g. UTF-8)
* @param String $description description for GUI * @param String $description description for GUI
@ -391,35 +391,35 @@ class LAMLanguage {
* @package configuration * @package configuration
*/ */
class LAMConfig { class LAMConfig {
/* access levels */ /* access levels */
const ACCESS_ALL = 100; const ACCESS_ALL = 100;
const ACCESS_PASSWORD_CHANGE = 20; const ACCESS_PASSWORD_CHANGE = 20;
const ACCESS_READ_ONLY = 0; const ACCESS_READ_ONLY = 0;
/* return codes for saving configuration file */ /* return codes for saving configuration file */
const SAVE_OK = 0; const SAVE_OK = 0;
const SAVE_FAIL = 1; const SAVE_FAIL = 1;
/* login method: predefined list or LDAP search */ /* login method: predefined list or LDAP search */
const LOGIN_LIST = 'list'; const LOGIN_LIST = 'list';
const LOGIN_SEARCH = 'search'; const LOGIN_SEARCH = 'search';
/** line separator */ /** line separator */
const LINE_SEPARATOR = '+::+'; const LINE_SEPARATOR = '+::+';
/** Server address (e.g. ldap://127.0.0.1:389) */ /** Server address (e.g. ldap://127.0.0.1:389) */
private $ServerURL; private $ServerURL;
/** enables/disables TLS encryption */ /** enables/disables TLS encryption */
private $useTLS; private $useTLS;
/** automatically follow referrals */ /** automatically follow referrals */
private $followReferrals = 'false'; private $followReferrals = 'false';
/** use paged results */ /** use paged results */
private $pagedResults = 'false'; private $pagedResults = 'false';
/** Array of string: users with admin rights */ /** Array of string: users with admin rights */
private $Admins; private $Admins;
@ -439,7 +439,7 @@ class LAMConfig {
/** type settings */ /** type settings */
private $typeSettings = array(); private $typeSettings = array();
/** tool settings */ /** tool settings */
private $toolSettings = array(); private $toolSettings = array();
@ -466,7 +466,7 @@ class LAMConfig {
/** LDAP cache timeout */ /** LDAP cache timeout */
private $cachetimeout; private $cachetimeout;
/** LDAP search limit */ /** LDAP search limit */
private $searchLimit = 0; private $searchLimit = 0;
@ -475,52 +475,62 @@ class LAMConfig {
/** Name of configuration file */ /** Name of configuration file */
private $file; private $file;
/** access level */ /** access level */
private $accessLevel = LAMconfig::ACCESS_ALL; private $accessLevel = LAMconfig::ACCESS_ALL;
/** login method */ /** login method */
private $loginMethod = LAMconfig::LOGIN_LIST; private $loginMethod = LAMconfig::LOGIN_LIST;
/** search suffix for login */ /** search suffix for login */
private $loginSearchSuffix = 'dc=yourdomain,dc=org'; private $loginSearchSuffix = 'dc=yourdomain,dc=org';
/** search filter for login */ /** search filter for login */
private $loginSearchFilter = 'uid=%USER%'; private $loginSearchFilter = 'uid=%USER%';
/** bind user for login search */ /** bind user for login search */
private $loginSearchDN = ''; private $loginSearchDN = '';
/** bind password for login search */ /** bind password for login search */
private $loginSearchPassword = ''; private $loginSearchPassword = '';
/** specifies if HTTP authentication should be used */ /** specifies if HTTP authentication should be used */
private $httpAuthentication = 'false'; private $httpAuthentication = 'false';
/** email address for sender of password reset mails */ /** email address for sender of password reset mails */
private $lamProMailFrom = ''; private $lamProMailFrom = '';
/** reply-to email address for password reset mails */ /** reply-to email address for password reset mails */
private $lamProMailReplyTo = ''; private $lamProMailReplyTo = '';
/** subject for password reset mails */ /** subject for password reset mails */
private $lamProMailSubject = ''; private $lamProMailSubject = '';
/** treat password reset mail body as HTML */ /** treat password reset mail body as HTML */
private $lamProMailIsHTML = 'false'; private $lamProMailIsHTML = 'false';
/** allow sending mails to an alternative address */ /** allow sending mails to an alternative address */
private $lamProMailAllowAlternateAddress = 'true'; private $lamProMailAllowAlternateAddress = 'true';
/** mail body for password reset mails */ /** mail body for password reset mails */
private $lamProMailText = ''; private $lamProMailText = '';
/** LDAP user for jobs */ /** LDAP user for jobs */
private $jobsBindUser = null; private $jobsBindUser = null;
/** LDAP password for jobs */ /** LDAP password for jobs */
private $jobsBindPassword = null; private $jobsBindPassword = null;
/** database for jobs */ /** database type for jobs */
private $jobsDatabase = null; private $jobsDatabase = null;
/** host of job database */
private $jobsDBHost = null;
/** port of job database */
private $jobsDBPort = null;
/** user of job database */
private $jobsDBUser = null;
/** password of job database */
private $jobsDBPassword = null;
/** name of job database */
private $jobsDBName = null;
/** random job token */ /** random job token */
private $jobToken = null; private $jobToken = null;
/** job configuration */ /** job configuration */
@ -532,7 +542,9 @@ class LAMConfig {
"modules", "activeTypes", "types", "tools", "accessLevel", 'loginMethod', 'loginSearchSuffix', "modules", "activeTypes", "types", "tools", "accessLevel", 'loginMethod', 'loginSearchSuffix',
'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailReplyTo', 'lamProMailSubject', 'loginSearchFilter', 'searchLimit', 'lamProMailFrom', 'lamProMailReplyTo', 'lamProMailSubject',
'lamProMailText', 'lamProMailIsHTML', 'lamProMailAllowAlternateAddress', 'httpAuthentication', 'loginSearchDN', 'lamProMailText', 'lamProMailIsHTML', 'lamProMailAllowAlternateAddress', 'httpAuthentication', 'loginSearchDN',
'loginSearchPassword', 'timeZone', 'jobsBindUser', 'jobsBindPassword', 'jobsDatabase', 'jobToken', 'jobs'); 'loginSearchPassword', 'timeZone', 'jobsBindUser', 'jobsBindPassword', 'jobsDatabase', 'jobToken', 'jobs',
'jobsDBHost', 'jobsDBPort', 'jobsDBUser', 'jobsDBPassword', 'jobsDBName'
);
/** /**
@ -742,6 +754,11 @@ class LAMConfig {
if (!in_array("jobsBindPassword", $saved)) array_push($file_array, "\n" . "jobsBindPassword: " . $this->jobsBindPassword . "\n"); if (!in_array("jobsBindPassword", $saved)) array_push($file_array, "\n" . "jobsBindPassword: " . $this->jobsBindPassword . "\n");
if (!in_array("jobsBindUser", $saved)) array_push($file_array, "\n" . "jobsBindUser: " . $this->jobsBindUser . "\n"); if (!in_array("jobsBindUser", $saved)) array_push($file_array, "\n" . "jobsBindUser: " . $this->jobsBindUser . "\n");
if (!in_array("jobsDatabase", $saved)) array_push($file_array, "\n" . "jobsDatabase: " . $this->jobsDatabase . "\n"); if (!in_array("jobsDatabase", $saved)) array_push($file_array, "\n" . "jobsDatabase: " . $this->jobsDatabase . "\n");
if (!in_array("jobsDBHost", $saved)) array_push($file_array, "\n" . "jobsDBHost: " . $this->jobsDBHost . "\n");
if (!in_array("jobsDBPort", $saved)) array_push($file_array, "\n" . "jobsDBPort: " . $this->jobsDBPort . "\n");
if (!in_array("jobsDBUser", $saved)) array_push($file_array, "\n" . "jobsDBUser: " . $this->jobsDBUser . "\n");
if (!in_array("jobsDBPassword", $saved)) array_push($file_array, "\n" . "jobsDBPassword: " . $this->jobsDBPassword . "\n");
if (!in_array("jobsDBName", $saved)) array_push($file_array, "\n" . "jobsDBName: " . $this->jobsDBName . "\n");
if (!in_array("jobToken", $saved)) array_push($file_array, "\n" . "jobToken: " . $this->getJobToken() . "\n"); if (!in_array("jobToken", $saved)) array_push($file_array, "\n" . "jobToken: " . $this->getJobToken() . "\n");
// check if all module settings were added // check if all module settings were added
$m_settings = array_keys($this->moduleSettings); $m_settings = array_keys($this->moduleSettings);
@ -784,7 +801,7 @@ class LAMConfig {
return $saveResult; return $saveResult;
} }
} }
/** /**
* Returns the name of the config file * Returns the name of the config file
* *
@ -793,7 +810,7 @@ class LAMConfig {
public function getName() { public function getName() {
return $this->file; return $this->file;
} }
/** /**
* Returns if the file can be written on the filesystem. * Returns if the file can be written on the filesystem.
* *
@ -802,7 +819,7 @@ class LAMConfig {
public function isWritable() { public function isWritable() {
return is_writeable($this->getPath()); return is_writeable($this->getPath());
} }
/** /**
* Returns the path to the config file. * Returns the path to the config file.
* *
@ -834,19 +851,19 @@ class LAMConfig {
else return false; else return false;
return true; return true;
} }
/** /**
* Returns if TLS is activated. * Returns if TLS is activated.
* *
* @return String yes or no * @return String yes or no
*/ */
public function getUseTLS() { public function getUseTLS() {
return $this->useTLS; return $this->useTLS;
} }
/** /**
* Sets if TLS is activated. * Sets if TLS is activated.
* *
* @param String $useTLS yes or no * @param String $useTLS yes or no
* @return boolean true if $useTLS has correct format * @return boolean true if $useTLS has correct format
*/ */
@ -860,16 +877,16 @@ class LAMConfig {
/** /**
* Returns if referrals should be followed. * Returns if referrals should be followed.
* *
* @return String true or false * @return String true or false
*/ */
public function getFollowReferrals() { public function getFollowReferrals() {
return $this->followReferrals; return $this->followReferrals;
} }
/** /**
* Sets if referrals should be followed. * Sets if referrals should be followed.
* *
* @param String $followReferrals true or false * @param String $followReferrals true or false
*/ */
public function setFollowReferrals($followReferrals) { public function setFollowReferrals($followReferrals) {
@ -878,16 +895,16 @@ class LAMConfig {
/** /**
* Returns if paged results should be used. * Returns if paged results should be used.
* *
* @return String true or false * @return String true or false
*/ */
public function getPagedResults() { public function getPagedResults() {
return $this->pagedResults; return $this->pagedResults;
} }
/** /**
* Sets if paged results should be used. * Sets if paged results should be used.
* *
* @param String $pagedResults true or false * @param String $pagedResults true or false
*/ */
public function setPagedResults($pagedResults) { public function setPagedResults($pagedResults) {
@ -963,7 +980,7 @@ class LAMConfig {
return true; return true;
} }
else { else {
return false; return false;
} }
} }
@ -1106,7 +1123,7 @@ class LAMConfig {
else return false; else return false;
return true; return true;
} }
/** /**
* Returns the servers of the external script as a Array * Returns the servers of the external script as a Array
* *
@ -1115,7 +1132,7 @@ class LAMConfig {
public function get_scriptServers() { public function get_scriptServers() {
return $this->scriptServer; return $this->scriptServer;
} }
/** /**
* Sets the servers of the external script * Sets the servers of the external script
* *
@ -1171,10 +1188,10 @@ class LAMConfig {
return false; return false;
} }
} }
/** /**
* Returns the chmod value for new home directories. * Returns the chmod value for new home directories.
* *
* @return string rights * @return string rights
*/ */
public function get_scriptRights() { public function get_scriptRights() {
@ -1269,7 +1286,7 @@ class LAMConfig {
if (trim($mod) != '') { if (trim($mod) != '') {
$modules[] = $mod; $modules[] = $mod;
} }
} }
return $modules; return $modules;
} }
else { else {
@ -1361,7 +1378,7 @@ class LAMConfig {
/** /**
* Returns the tool settings. * Returns the tool settings.
* *
* @return array $toolSettings tool settings * @return array $toolSettings tool settings
*/ */
public function getToolSettings() { public function getToolSettings() {
@ -1370,7 +1387,7 @@ class LAMConfig {
/** /**
* Sets the tool settings. * Sets the tool settings.
* *
* @param array $toolSettings tool settings * @param array $toolSettings tool settings
* @return boolean true if ok * @return boolean true if ok
*/ */
@ -1388,7 +1405,7 @@ class LAMConfig {
public function getAccessLevel() { public function getAccessLevel() {
return $this->accessLevel; return $this->accessLevel;
} }
/** /**
* Sets the access level for this profile. * Sets the access level for this profile.
* *
@ -1397,10 +1414,10 @@ class LAMConfig {
public function setAccessLevel($level) { public function setAccessLevel($level) {
$this->accessLevel = $level; $this->accessLevel = $level;
} }
/** /**
* Returns the login method. * Returns the login method.
* *
* @return String login method * @return String login method
* @see LAMconfig::LOGIN_LIST * @see LAMconfig::LOGIN_LIST
* @see LAMconfig::LOGIN_SEARCH * @see LAMconfig::LOGIN_SEARCH
@ -1408,55 +1425,55 @@ class LAMConfig {
public function getLoginMethod() { public function getLoginMethod() {
return $this->loginMethod; return $this->loginMethod;
} }
/** /**
* Sets the login method. * Sets the login method.
* *
* @param String $loginMethod * @param String $loginMethod
*/ */
public function setLoginMethod($loginMethod) { public function setLoginMethod($loginMethod) {
$this->loginMethod = $loginMethod; $this->loginMethod = $loginMethod;
} }
/** /**
* Returns the login search filter. * Returns the login search filter.
* *
* @return String search filter * @return String search filter
*/ */
public function getLoginSearchFilter() { public function getLoginSearchFilter() {
return $this->loginSearchFilter; return $this->loginSearchFilter;
} }
/** /**
* Sets the login search filter. * Sets the login search filter.
* *
* @param String $loginSearchFilter search filter * @param String $loginSearchFilter search filter
*/ */
public function setLoginSearchFilter($loginSearchFilter) { public function setLoginSearchFilter($loginSearchFilter) {
$this->loginSearchFilter = $loginSearchFilter; $this->loginSearchFilter = $loginSearchFilter;
} }
/** /**
* Returns the login search suffix. * Returns the login search suffix.
* *
* @return String suffix * @return String suffix
*/ */
public function getLoginSearchSuffix() { public function getLoginSearchSuffix() {
return $this->loginSearchSuffix; return $this->loginSearchSuffix;
} }
/** /**
* Sets the login search suffix. * Sets the login search suffix.
* *
* @param String $loginSearchSuffix suffix * @param String $loginSearchSuffix suffix
*/ */
public function setLoginSearchSuffix($loginSearchSuffix) { public function setLoginSearchSuffix($loginSearchSuffix) {
$this->loginSearchSuffix = $loginSearchSuffix; $this->loginSearchSuffix = $loginSearchSuffix;
} }
/** /**
* Sets the DN for the login search bind user. * Sets the DN for the login search bind user.
* *
* @param String $loginSearchDN DN * @param String $loginSearchDN DN
* @return boolean true if DN is valid * @return boolean true if DN is valid
*/ */
@ -1470,7 +1487,7 @@ class LAMConfig {
/** /**
* Returns the DN for the login search bind user. * Returns the DN for the login search bind user.
* *
* @return String DN * @return String DN
*/ */
public function getLoginSearchDN() { public function getLoginSearchDN() {
@ -1479,7 +1496,7 @@ class LAMConfig {
/** /**
* Sets the password for the login search bind user. * Sets the password for the login search bind user.
* *
* @param String $loginSearchPassword password * @param String $loginSearchPassword password
*/ */
public function setLoginSearchPassword($loginSearchPassword) { public function setLoginSearchPassword($loginSearchPassword) {
@ -1488,7 +1505,7 @@ class LAMConfig {
/** /**
* Returns the password for the login search bind user. * Returns the password for the login search bind user.
* *
* @return String password * @return String password
*/ */
public function getLoginSearchPassword() { public function getLoginSearchPassword() {
@ -1497,7 +1514,7 @@ class LAMConfig {
/** /**
* Returns if HTTP authentication should be used. * Returns if HTTP authentication should be used.
* *
* @return String $httpAuthentication use HTTP authentication ('true' or 'false') * @return String $httpAuthentication use HTTP authentication ('true' or 'false')
*/ */
public function getHttpAuthentication() { public function getHttpAuthentication() {
@ -1506,7 +1523,7 @@ class LAMConfig {
/** /**
* Specifies if HTTP authentication should be used. * Specifies if HTTP authentication should be used.
* *
* @param String $httpAuthentication use HTTP authentication ('true' or 'false') * @param String $httpAuthentication use HTTP authentication ('true' or 'false')
*/ */
public function setHttpAuthentication($httpAuthentication) { public function setHttpAuthentication($httpAuthentication) {
@ -1515,16 +1532,16 @@ class LAMConfig {
/** /**
* Returns the sender address for password reset mails. * Returns the sender address for password reset mails.
* *
* @return String mail address * @return String mail address
*/ */
public function getLamProMailFrom() { public function getLamProMailFrom() {
return $this->lamProMailFrom; return $this->lamProMailFrom;
} }
/** /**
* Sets the sender address for password reset mails. * Sets the sender address for password reset mails.
* *
* @param String $lamProMailFrom mail address * @param String $lamProMailFrom mail address
* @return boolean true if address is valid * @return boolean true if address is valid
*/ */
@ -1535,10 +1552,10 @@ class LAMConfig {
} }
return true; return true;
} }
/** /**
* Returns the reply-to address for password reset mails. * Returns the reply-to address for password reset mails.
* *
* @return String mail address * @return String mail address
*/ */
public function getLamProMailReplyTo() { public function getLamProMailReplyTo() {
@ -1547,7 +1564,7 @@ class LAMConfig {
/** /**
* Sets the reply-to address for password reset mails. * Sets the reply-to address for password reset mails.
* *
* @param String $lamProMailReplyTo mail address * @param String $lamProMailReplyTo mail address
* @return boolean true if address is valid * @return boolean true if address is valid
*/ */
@ -1561,16 +1578,16 @@ class LAMConfig {
/** /**
* Returns the subject for password reset mails. * Returns the subject for password reset mails.
* *
* @return String subject * @return String subject
*/ */
public function getLamProMailSubject() { public function getLamProMailSubject() {
return $this->lamProMailSubject; return $this->lamProMailSubject;
} }
/** /**
* Sets the subject for password reset mails. * Sets the subject for password reset mails.
* *
* @param String $lamProMailSubject subject * @param String $lamProMailSubject subject
*/ */
public function setLamProMailSubject($lamProMailSubject) { public function setLamProMailSubject($lamProMailSubject) {
@ -1579,7 +1596,7 @@ class LAMConfig {
/** /**
* Returns if the password reset mail content should be treated as HTML. * Returns if the password reset mail content should be treated as HTML.
* *
* @return boolean HTML or text * @return boolean HTML or text
*/ */
public function getLamProMailIsHTML() { public function getLamProMailIsHTML() {
@ -1588,16 +1605,16 @@ class LAMConfig {
/** /**
* Sets if the password reset mail content should be treated as HTML. * Sets if the password reset mail content should be treated as HTML.
* *
* @param boolean $lamProMailIsHTML true if HTML * @param boolean $lamProMailIsHTML true if HTML
*/ */
public function setLamProMailIsHTML($lamProMailIsHTML) { public function setLamProMailIsHTML($lamProMailIsHTML) {
$this->lamProMailIsHTML = $lamProMailIsHTML; $this->lamProMailIsHTML = $lamProMailIsHTML;
} }
/** /**
* Returns if sending to an alternate address is allowed. * Returns if sending to an alternate address is allowed.
* *
* @return boolean alternate address allowed * @return boolean alternate address allowed
*/ */
public function getLamProMailAllowAlternateAddress() { public function getLamProMailAllowAlternateAddress() {
@ -1606,34 +1623,34 @@ class LAMConfig {
/** /**
* Sets if sending to an alternate address is allowed. * Sets if sending to an alternate address is allowed.
* *
* @param boolean $lamProMailAllowAlternateAddress alternate address allowed * @param boolean $lamProMailAllowAlternateAddress alternate address allowed
*/ */
public function setLamProMailAllowAlternateAddress($lamProMailAllowAlternateAddress) { public function setLamProMailAllowAlternateAddress($lamProMailAllowAlternateAddress) {
$this->lamProMailAllowAlternateAddress = $lamProMailAllowAlternateAddress; $this->lamProMailAllowAlternateAddress = $lamProMailAllowAlternateAddress;
} }
/** /**
* Returns the mail body for password reset mails. * Returns the mail body for password reset mails.
* *
* @return String body * @return String body
*/ */
public function getLamProMailText() { public function getLamProMailText() {
return implode("\r\n", explode(LAMConfig::LINE_SEPARATOR, $this->lamProMailText)); return implode("\r\n", explode(LAMConfig::LINE_SEPARATOR, $this->lamProMailText));
} }
/** /**
* Sets the mail body for password reset mails. * Sets the mail body for password reset mails.
* *
* @param String $lamProMailText body * @param String $lamProMailText body
*/ */
public function setLamProMailText($lamProMailText) { public function setLamProMailText($lamProMailText) {
$this->lamProMailText = implode(LAMConfig::LINE_SEPARATOR, explode("\r\n", $lamProMailText)); $this->lamProMailText = implode(LAMConfig::LINE_SEPARATOR, explode("\r\n", $lamProMailText));
} }
/** /**
* Returns the bind user for jobs. * Returns the bind user for jobs.
* *
* @return String $jobsBindUser bind user * @return String $jobsBindUser bind user
*/ */
public function getJobsBindUser() { public function getJobsBindUser() {
@ -1642,7 +1659,7 @@ class LAMConfig {
/** /**
* Sets the bind user for jobs. * Sets the bind user for jobs.
* *
* @param String $jobsBindUser bind user * @param String $jobsBindUser bind user
*/ */
public function setJobsBindUser($jobsBindUser) { public function setJobsBindUser($jobsBindUser) {
@ -1651,7 +1668,7 @@ class LAMConfig {
/** /**
* Returns the bind password for jobs. * Returns the bind password for jobs.
* *
* @return String $jobsBindPassword password * @return String $jobsBindPassword password
*/ */
public function getJobsBindPassword() { public function getJobsBindPassword() {
@ -1660,7 +1677,7 @@ class LAMConfig {
/** /**
* Sets the bind password for jobs. * Sets the bind password for jobs.
* *
* @param String $jobsBindPassword password * @param String $jobsBindPassword password
*/ */
public function setJobsBindPassword($jobsBindPassword) { public function setJobsBindPassword($jobsBindPassword) {
@ -1669,7 +1686,7 @@ class LAMConfig {
/** /**
* Returns the database type for jobs. * Returns the database type for jobs.
* *
* @return String $jobsDatabase database type * @return String $jobsDatabase database type
*/ */
public function getJobsDatabase() { public function getJobsDatabase() {
@ -1678,13 +1695,103 @@ class LAMConfig {
/** /**
* Sets the database type for jobs. * Sets the database type for jobs.
* *
* @param String $jobsDatabase database type * @param String $jobsDatabase database type
*/ */
public function setJobsDatabase($jobsDatabase) { public function setJobsDatabase($jobsDatabase) {
$this->jobsDatabase = $jobsDatabase; $this->jobsDatabase = $jobsDatabase;
} }
/**
* Returns the host.
*
* @return String host
*/
public function getJobsDBHost() {
return $this->jobsDBHost;
}
/**
* Sets the host.
*
* @param String $jobsDBHost host
*/
public function setJobsDBHost($jobsDBHost) {
$this->jobsDBHost = $jobsDBHost;
}
/**
* Returns the port.
*
* @return String port
*/
public function getJobsDBPort() {
return $this->jobsDBPort;
}
/**
* Sets the port.
*
* @param int $jobsDBPort port
*/
public function setJobsDBPort($jobsDBPort) {
$this->jobsDBPort = $jobsDBPort;
}
/**
* Returns the DB user.
*
* @return String user name
*/
public function getJobsDBUser() {
return $this->jobsDBUser;
}
/**
* Sets the DB user.
*
* @param String $jobsDBUser user name
*/
public function setJobsDBUser($jobsDBUser) {
$this->jobsDBUser = $jobsDBUser;
}
/**
* Returns the DB password.
*
* @return String password
*/
public function getJobsDBPassword() {
return $this->jobsDBPassword;
}
/**
* Sets the DB password.
*
* @param String $jobsDBPassword password
*/
public function setJobsDBPassword($jobsDBPassword) {
$this->jobsDBPassword = $jobsDBPassword;
}
/**
* Returns the database name.
*
* @return String DB name
*/
public function getJobsDBName() {
return $this->jobsDBName;
}
/**
* Sets the database name
*
* @param String $jobsDBName DB name
*/
public function setJobsDBName($jobsDBName) {
$this->jobsDBName = $jobsDBName;
}
/** /**
* Sets the settings for the jobs. * Sets the settings for the jobs.
* *
@ -1707,10 +1814,10 @@ class LAMConfig {
public function getJobSettings() { public function getJobSettings() {
return $this->jobSettings; return $this->jobSettings;
} }
/** /**
* Returns the job token. * Returns the job token.
* *
* @return String job token * @return String job token
*/ */
public function getJobToken() { public function getJobToken() {
@ -1736,7 +1843,7 @@ class LAMCfgMain {
const ERROR_REPORTING_SYSTEM = 'system'; const ERROR_REPORTING_SYSTEM = 'system';
/** PHP error reporting setting as E_ALL | E_STRICT */ /** PHP error reporting setting as E_ALL | E_STRICT */
const ERROR_REPORTING_ALL = 'all'; const ERROR_REPORTING_ALL = 'all';
/** Default profile */ /** Default profile */
public $default; public $default;
@ -1754,16 +1861,16 @@ class LAMCfgMain {
/** list of hosts which may access LAM */ /** list of hosts which may access LAM */
public $allowedHosts; public $allowedHosts;
/** list of hosts which may access LAM Pro self service */ /** list of hosts which may access LAM Pro self service */
public $allowedHostsSelfService; public $allowedHostsSelfService;
/** session encryption */ /** session encryption */
public $encryptSession; public $encryptSession;
/** minimum length for passwords */ /** minimum length for passwords */
public $passwordMinLength = 0; public $passwordMinLength = 0;
/** minimum uppercase characters */ /** minimum uppercase characters */
public $passwordMinUpper = 0; public $passwordMinUpper = 0;
@ -1778,28 +1885,28 @@ class LAMCfgMain {
/** minimum character classes (upper, lower, numeric, symbols) */ /** minimum character classes (upper, lower, numeric, symbols) */
public $passwordMinClasses = 0; public $passwordMinClasses = 0;
/** number of password rules that must match (-1 = all) */ /** number of password rules that must match (-1 = all) */
public $checkedRulesCount = -1; public $checkedRulesCount = -1;
/** password may contain the user name */ /** password may contain the user name */
public $passwordMustNotContainUser = 'false'; public $passwordMustNotContainUser = 'false';
/** password may contain more than 2 characters of user/first/last name */ /** password may contain more than 2 characters of user/first/last name */
public $passwordMustNotContain3Chars = 'false'; public $passwordMustNotContain3Chars = 'false';
/** path to config file */ /** path to config file */
private $conffile; private $conffile;
/** uploaded SSL certificate that is stored to disk on save() */ /** uploaded SSL certificate that is stored to disk on save() */
private $uploadedSSLCaCert = null; private $uploadedSSLCaCert = null;
/** SSL certificate should be deleted on save() */ /** SSL certificate should be deleted on save() */
private $delSSLCaCert = false; private $delSSLCaCert = false;
/** EOL for emails (default/unix) */ /** EOL for emails (default/unix) */
public $mailEOL = 'default'; public $mailEOL = 'default';
/** error reporting */ /** error reporting */
public $errorReporting = self::ERROR_REPORTING_DEFAULT; public $errorReporting = self::ERROR_REPORTING_DEFAULT;
@ -1933,7 +2040,7 @@ class LAMCfgMain {
} }
} }
} }
/** /**
* Sets a new config password. * Sets a new config password.
* *
@ -1944,9 +2051,9 @@ class LAMCfgMain {
$rand = getRandomNumber(); $rand = getRandomNumber();
$salt0 = substr(pack("h*", md5($rand)), 0, 8); $salt0 = substr(pack("h*", md5($rand)), 0, 8);
$salt = substr(pack("H*", sha1($salt0 . $password)), 0, 4); $salt = substr(pack("H*", sha1($salt0 . $password)), 0, 4);
$this->password = $this->hashPassword($password, $salt); $this->password = $this->hashPassword($password, $salt);
} }
/** /**
* Checks if the given password matches. * Checks if the given password matches.
* *
@ -1966,7 +2073,7 @@ class LAMCfgMain {
return ($password === $this->password); return ($password === $this->password);
} }
} }
/** /**
* Returns the hashed password. * Returns the hashed password.
* *
@ -1977,7 +2084,7 @@ class LAMCfgMain {
private function hashPassword($password, $salt) { private function hashPassword($password, $salt) {
return "{SSHA}" . base64_encode(convertHex2bin(sha1($password . $salt))) . " " . base64_encode($salt); return "{SSHA}" . base64_encode(convertHex2bin(sha1($password . $salt))) . " " . base64_encode($salt);
} }
/** /**
* Returns if the configuration file is writable. * Returns if the configuration file is writable.
* *
@ -1986,7 +2093,7 @@ class LAMCfgMain {
public function isWritable() { public function isWritable() {
return is_writeable($this->conffile); return is_writeable($this->conffile);
} }
/** /**
* Returns if the configuration file is existing. * Returns if the configuration file is existing.
* *
@ -1995,10 +2102,10 @@ class LAMCfgMain {
public function isConfigFileExisting() { public function isConfigFileExisting() {
return file_exists($this->conffile); return file_exists($this->conffile);
} }
/** /**
* Returns the path to the SSL CA certificate file that overrides the system certificates. * Returns the path to the SSL CA certificate file that overrides the system certificates.
* *
* @return String path to certificate file or null if certificate is not overridden * @return String path to certificate file or null if certificate is not overridden
*/ */
public function getSSLCaCertPath() { public function getSSLCaCertPath() {
@ -2008,19 +2115,19 @@ class LAMCfgMain {
} }
return null; return null;
} }
/** /**
* Returns the file name that will be used internally to store the CA file. * Returns the file name that will be used internally to store the CA file.
* *
* @return String file name * @return String file name
*/ */
private function getInternalSSLCaCertFileName() { private function getInternalSSLCaCertFileName() {
return dirname(__FILE__) . '/../config/serverCerts.pem'; return dirname(__FILE__) . '/../config/serverCerts.pem';
} }
/** /**
* Uploads a new SSL CA cert. * Uploads a new SSL CA cert.
* *
* @param String $cert file content in DER/PEM format * @param String $cert file content in DER/PEM format
* @return mixed TRUE if format is correct, error message if file is not accepted * @return mixed TRUE if format is correct, error message if file is not accepted
*/ */
@ -2051,11 +2158,11 @@ class LAMCfgMain {
$this->delSSLCaCert = false; $this->delSSLCaCert = false;
return true; return true;
} }
/** /**
* Returns the name of a temporary file in tmp that contains the SSL certificate. * Returns the name of a temporary file in tmp that contains the SSL certificate.
* The file contains either the stored data in serverCerts or the uploaded data. * The file contains either the stored data in serverCerts or the uploaded data.
* *
* @return String file name or null if no certificate was set * @return String file name or null if no certificate was set
*/ */
public function getSSLCaCertTempFileName() { public function getSSLCaCertTempFileName() {
@ -2081,11 +2188,11 @@ class LAMCfgMain {
} }
return $fileName; return $fileName;
} }
/** /**
* Marks a single or all SSL CA certificate files for deletion. * Marks a single or all SSL CA certificate files for deletion.
* The changes take effect on save(). * The changes take effect on save().
* *
* @param int $index certificate index, null deletes all certificates (default: null) * @param int $index certificate index, null deletes all certificates (default: null)
*/ */
public function deleteSSLCaCert($index = null) { public function deleteSSLCaCert($index = null) {
@ -2105,10 +2212,10 @@ class LAMCfgMain {
$this->uploadedSSLCaCert = implode("\n", $list); $this->uploadedSSLCaCert = implode("\n", $list);
} }
} }
/** /**
* Returns a list of all CA certificates. * Returns a list of all CA certificates.
* *
* @return array list of certificates as output of openssl_x509_parse() * @return array list of certificates as output of openssl_x509_parse()
*/ */
public function getSSLCaCertificates() { public function getSSLCaCertificates() {
@ -2128,7 +2235,7 @@ class LAMCfgMain {
/** /**
* Returns the content of the certificate file or uploaded data. * Returns the content of the certificate file or uploaded data.
* *
* @return String null or certificate content * @return String null or certificate content
*/ */
private function getSSLCaCertificateContent() { private function getSSLCaCertificateContent() {
@ -2149,10 +2256,10 @@ class LAMCfgMain {
} }
return $content; return $content;
} }
/** /**
* Splits the certificate content into single PEM data chunks. * Splits the certificate content into single PEM data chunks.
* *
* @param String $content PEM file content * @param String $content PEM file content
* @return array one element for each certificate chunk * @return array one element for each certificate chunk
*/ */
@ -2181,7 +2288,7 @@ class LAMCfgMain {
} }
return $list; return $list;
} }
} }
?> ?>