Merge pull request #88 from LDAPAccountManager/phpMailer

Php mailer
This commit is contained in:
gruberroland 2020-03-19 20:20:25 +01:00 committed by GitHub
commit 802b16797a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 37 additions and 46 deletions

View File

@ -1400,12 +1400,12 @@ class moduleCache {
* @param String $scope module scope (e.g. user)
*/
public static function getModule($name, $scope) {
if (isset(moduleCache::$cache[$name . ':' . $scope])) {
return moduleCache::$cache[$name . ':' . $scope];
if (isset(self::$cache[$name . ':' . $scope])) {
return self::$cache[$name . ':' . $scope];
}
else {
moduleCache::$cache[$name . ':' . $scope] = new $name($scope);
return moduleCache::$cache[$name . ':' . $scope];
self::$cache[$name . ':' . $scope] = new $name($scope);
return self::$cache[$name . ':' . $scope];
}
}

View File

@ -1543,7 +1543,7 @@ class accountContainer {
foreach ($attr_names as $i => $name) {
// find deleted attributes
if (isset($orig[$name]) && is_array($orig[$name])) {
foreach ($orig[$name] as $j => $value) {
foreach ($orig[$name] as $value) {
if (is_array($attributes[$name])) {
if (!in_array($value, $attributes[$name], true)
&& ($value !== null)
@ -1558,7 +1558,7 @@ class accountContainer {
}
// find new attributes
if (isset($attributes[$name]) && is_array($attributes[$name])) {
foreach ($attributes[$name] as $j => $value) {
foreach ($attributes[$name] as $value) {
if (isset($orig[$name]) && is_array($orig[$name])) {
if (!in_array($value, $orig[$name], true)
&& ($value !== null)
@ -1572,7 +1572,7 @@ class accountContainer {
}
// find unchanged attributes
if (isset($orig[$name]) && is_array($orig[$name]) && is_array($attributes[$name])) {
foreach ($attributes[$name] as $j => $value) {
foreach ($attributes[$name] as $value) {
if (($value !== null) && ($value !== '') && in_array($value, $orig[$name], true)) {
$notchanged[$name][] = $value;
}

View File

@ -432,17 +432,12 @@ By default, the nodes are configured as H-Nodes which fits for small networks. I
if (!empty($_POST['dns'])) {
$_POST['dns'] = trim($_POST['dns']);
$ex = explode(",", $_POST['dns']);
$dns = "";
$is_first=true;
$invalid = false;
foreach($ex AS $string) {
if ($is_first) {
$dns .= $string;
$is_first=false;
}
else {
$dns .= ",$string";
}
if (!check_ip($string)) {
$invalid = true;

View File

@ -2,7 +2,7 @@
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2011 - 2019 Roland Gruber
Copyright (C) 2011 - 2020 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
@ -509,7 +509,7 @@ class freeRadius extends baseModule {
$date = new DateTime('@' . (time() + 3600*24*365), new DateTimeZone('UTC'));
$year = $date->format('Y');
$month = $date->format('m');
$month = freeRadius::$monthList[$month];
$month = self::$monthList[$month];
$day = $date->format('d');
$hour = '00';
$minute = '00';
@ -541,7 +541,7 @@ class freeRadius extends baseModule {
$daySelect = new htmlSelect('expire_day', $dayList, array($day));
$daySelect->setWidth('3rem');
$dateGroup->addElement($daySelect);
$monthSelect = new htmlSelect('expire_mon', freeRadius::$monthList, array($month));
$monthSelect = new htmlSelect('expire_mon', self::$monthList, array($month));
$monthSelect->setHasDescriptiveElements(true);
$monthSelect->setWidth('3rem');
$dateGroup->addElement($monthSelect);
@ -649,7 +649,7 @@ class freeRadius extends baseModule {
if (preg_match('/^[0-9]{1,2}.[0-9]{1,2}.[0-9]{4} [0-9]{1,2}:[0-9]{1,2}$/', $rawAccounts[$i][$ids['freeRadius_radiusExpiration']])) {
$dateParts = explode(' ', $rawAccounts[$i][$ids['freeRadius_radiusExpiration']]);
$dateParts1 = explode('.', $dateParts[0]);
$radiusExpiration = str_pad($dateParts1[0], 2, '0', STR_PAD_LEFT) . ' ' . freeRadius::$monthList[str_pad($dateParts1[1], 2, '0', STR_PAD_LEFT)] . ' ' . $dateParts1[2];
$radiusExpiration = str_pad($dateParts1[0], 2, '0', STR_PAD_LEFT) . ' ' . self::$monthList[str_pad($dateParts1[1], 2, '0', STR_PAD_LEFT)] . ' ' . $dateParts1[2];
$dateParts2 = explode(':', $dateParts[1]);
$radiusExpiration .= ' ' . str_pad($dateParts2[0], 2, '0', STR_PAD_LEFT) . ':' . str_pad($dateParts2[1], 2, '0', STR_PAD_LEFT);
$partialAccounts[$i]['radiusExpiration'] = $radiusExpiration;
@ -750,7 +750,7 @@ class freeRadius extends baseModule {
if (is_null($date) || ($date == '')) {
return $date;
}
foreach (freeRadius::$monthList as $replace => $search) {
foreach (self::$monthList as $replace => $search) {
$date = str_replace($search, $replace, $date);
}
$dateParts = explode(' ', $date);

View File

@ -1657,7 +1657,6 @@ class inetOrgPerson extends baseModule implements passwordService {
private function uploadPhoto() {
$messages = array();
if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) {
$name = $_FILES['photoFile']['name'];
$handle = fopen($_FILES['photoFile']['tmp_name'], "r");
$data = fread($handle, 100000000);
if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) && (strlen($data) > (1024 * $this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]))) {

View File

@ -5,7 +5,7 @@ use \LAM\PDF\PDFTableRow;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2004 - 2018 Roland Gruber
Copyright (C) 2004 - 2020 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
@ -668,7 +668,6 @@ class kolabUser extends baseModule {
}
uksort($delegates, 'compareDN');
$_SESSION['kolabUser_kolabDelegate'] = $kolabDelegate;
$delegateFields = array();
$delegateContainer = new htmlTable();
for ($i = 0; $i < sizeof($kolabDelegate); $i++) {
$delegateContainer->addElement(new htmlOutputText($kolabDelegate[$i]));

View File

@ -2,7 +2,7 @@
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2013 - 2019 Roland Gruber
Copyright (C) 2013 - 2020 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
@ -273,7 +273,7 @@ class pykotaBillingCode extends baseModule {
if ($this->codeCache == null) {
$this->loadCodeCache();
}
foreach ($this->codeCache as $dn => $bCode) {
foreach ($this->codeCache as $bCode) {
if (!empty($bCode) && ($bCode == $code)) {
return true;
}

View File

@ -2,7 +2,7 @@
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2013 - 2019 Roland Gruber
Copyright (C) 2013 - 2020 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
@ -620,7 +620,7 @@ class pykotaPrinter extends baseModule {
if ($this->printerCache == null) {
$this->loadPrinterNameCache();
}
foreach ($this->printerCache as $dn => $attrs) {
foreach ($this->printerCache as $attrs) {
if (!empty($attrs['cn']) && ($attrs['cn'] == $cn)) {
return true;
}

View File

@ -6,7 +6,7 @@ use \LAM\PDF\PDFTableRow;
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2003 - 2006 Tilo Lutz
2007 - 2019 Roland Gruber
2007 - 2020 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
@ -193,7 +193,7 @@ class quota extends baseModule {
// get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($lamdaemonServer);
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope())));
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array($userName, "quota", "get", $this->get_scope())));
$remote->disconnect();
if (empty($quotas)) {
continue;
@ -201,10 +201,10 @@ class quota extends baseModule {
$allQuotas = explode(":", $quotas);
array_pop($allQuotas); // remove empty element at the end
for ($i = 0; $i < sizeof($allQuotas); $i++) {
if (strpos($allQuotas[$i], quota::$QUOTA_PREFIX) !== 0) {
if (strpos($allQuotas[$i], self::$QUOTA_PREFIX) !== 0) {
continue;
}
$allQuotas[$i] = substr($allQuotas[$i], strlen(quota::$QUOTA_PREFIX));
$allQuotas[$i] = substr($allQuotas[$i], strlen(self::$QUOTA_PREFIX));
$singleQuota = explode(",", $allQuotas[$i]);
$this->quota[$server][$i] = $singleQuota;
if ($this->quota[$server][$i][4] < time()) {
@ -295,7 +295,7 @@ class quota extends baseModule {
$remote = new \LAM\REMOTE\Remote();
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
$remote->connect($remoteServer);
$remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
$remote->execute(implode(self::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
$remote->disconnect();
}
return $messages;
@ -374,7 +374,7 @@ class quota extends baseModule {
$remote = new \LAM\REMOTE\Remote();
$remoteServer = $_SESSION['config']->getScriptServerByName($server);
$remote->connect($remoteServer);
$remote->execute(implode(quota::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
$remote->execute(implode(self::$SPLIT_DELIMITER, array($id, "quota", "set", $this->get_scope(), "$quotastring\n")));
$remote->disconnect();
}
return array();
@ -535,7 +535,7 @@ class quota extends baseModule {
// Get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($lamdaemonServer);
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
$remote->disconnect();
if (empty($quotas)) {
continue;
@ -543,13 +543,13 @@ class quota extends baseModule {
$dirs = explode(":", $quotas);
array_pop($dirs); // remove empty element at the end
for ($i = 0; $i < sizeof($dirs); $i++) {
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
if (strpos($dirs[$i], self::$QUOTA_PREFIX) !== 0) {
unset($dirs[$i]);
$dirs = array_values($dirs);
$i--;
continue;
}
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
$dirs[$i] = substr($dirs[$i], strlen(self::$QUOTA_PREFIX));
$dirs[$i] = explode(",", $dirs[$i]);
$dirs[$i] = $dirs[$i][0];
}
@ -599,17 +599,17 @@ class quota extends baseModule {
// Get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($lamdaemonServer);
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
$remote->disconnect();
$dirs = explode(":", $quotas);
array_pop($dirs); // remove empty element at the end
for ($i = 0; $i < sizeof($dirs); $i++) {
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
if (strpos($dirs[$i], self::$QUOTA_PREFIX) !== 0) {
unset($dirs[$i]);
$i--;
continue;
}
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
$dirs[$i] = substr($dirs[$i], strlen(self::$QUOTA_PREFIX));
$dirs[$i] = explode(",", $dirs[$i]);
$dirs[$i] = $dirs[$i][0];
}
@ -760,17 +760,17 @@ class quota extends baseModule {
// Get quotas
$remote = new \LAM\REMOTE\Remote();
$remote->connect($lamdaemonServer);
$quotas = $remote->execute(implode(quota::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
$quotas = $remote->execute(implode(self::$SPLIT_DELIMITER, array("+", "quota", "get", $this->get_scope())));
$remote->disconnect();
$dirs = explode(":", $quotas);
array_pop($dirs); // remove empty element at the end
for ($i = 0; $i < sizeof($dirs); $i++) {
if (strpos($dirs[$i], quota::$QUOTA_PREFIX) !== 0) {
if (strpos($dirs[$i], self::$QUOTA_PREFIX) !== 0) {
unset($dirs[$i]);
$i--;
continue;
}
$dirs[$i] = substr($dirs[$i], strlen(quota::$QUOTA_PREFIX));
$dirs[$i] = substr($dirs[$i], strlen(self::$QUOTA_PREFIX));
$dirs[$i] = explode(",", $dirs[$i]);
$dirs[$i] = $dirs[$i][0];
}
@ -886,7 +886,7 @@ class quota extends baseModule {
$mpParts = explode(":", $mountPoints[$m]);
$server = $mpParts[0];
$dir = $mpParts[1];
$quotaString = implode(quota::$SPLIT_DELIMITER, array($name, "quota", "set", $this->get_scope(), $dir . ',' .
$quotaString = implode(self::$SPLIT_DELIMITER, array($name, "quota", "set", $this->get_scope(), $dir . ',' .
implode(',', $temp['accounts'][$name][$mountPoints[$m]]) . "\n"));
$remote = new \LAM\REMOTE\Remote();
$remoteServer = $_SESSION['config']->getScriptServerByName($server);

View File

@ -3,7 +3,7 @@
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2008 Thomas Manninger
2009 - 2018 Roland Gruber
2009 - 2020 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
@ -189,7 +189,7 @@ class lamDHCPList extends lamList {
$entries = searchLDAP($data['dn'], 'objectClass=dhcpHost', array('dhcpstatements', 'dhcphwaddress', 'cn'));
if (sizeof($entries) > 0) {
foreach ($entries as $entry) {
foreach ($entry as $attrName => $attrValues) {
foreach ($entry as $attrValues) {
if (!is_array($attrValues)) {
continue;
}
@ -294,7 +294,7 @@ class lamDHCPList extends lamList {
$table = new htmlTable();
$table->setCSSClasses(array('nowrap'));
$ranges = array();
foreach($entry['dhcprange'] AS $id => $value) {
foreach($entry['dhcprange'] AS $value) {
if (!empty($value) && !is_numeric($value)) {
$ex = explode(" ", $value);
$row = new htmlTableRow(
@ -327,7 +327,7 @@ class lamDHCPList extends lamList {
}
}
uksort($ranges, 'strnatcasecmp');
foreach ($ranges as $text => $row) {
foreach ($ranges as $row) {
$table->addElement($row);
}
return $table;

View File

@ -3,7 +3,6 @@ namespace LAM\UPLOAD;
use ZipArchive;
use accountContainer;
/*
$Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2016 - 2020 Roland Gruber
@ -309,7 +308,6 @@ class Uploader {
}
}
// load account
$typeManager = new \LAM\TYPES\TypeManager();
$_SESSION['mass_pdfAccount'] = new accountContainer($this->type, 'mass_pdfAccount');
$pdfErrors = $_SESSION['mass_pdfAccount']->load_account($dn, $infoAttributes);
if (sizeof($pdfErrors) > 0) {