diff --git a/lam-packaging/debian/control b/lam-packaging/debian/control index 07b11e03..b0f2ee89 100644 --- a/lam-packaging/debian/control +++ b/lam-packaging/debian/control @@ -10,7 +10,7 @@ Package: ldap-account-manager Architecture: all Depends: php5 (>= 5.4.26) | php (>= 7), php5-ldap | php-ldap, php5-gd | php-gd, php5-json | php-json, php5-imagick | php-imagick, php5-curl | php-curl, - php5 | php-zip, php5 | php-xml, + php5 | php-zip, php5 | php-xml, php-imagick, libapache2-mod-php5 | libapache2-mod-php | php5-fpm | php-fpm, apache2 | httpd, fonts-dejavu, debconf (>= 0.2.26) | debconf-2.0, ${misc:Depends} Recommends: php-apc | php-opcache diff --git a/lam/HISTORY b/lam/HISTORY index 76694490..ccbf908e 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,4 +1,5 @@ June 2018 6.4 + - Imagick PHP extension required - Passwords can be checked against external service (e.g. https://api.pwnedpasswords.com/range) - IMAP: create mailbox via file upload - PHP 7.2 support diff --git a/lam/lib/checkEnvironment.inc b/lam/lib/checkEnvironment.inc index 020dde0b..34d2902f 100644 --- a/lam/lib/checkEnvironment.inc +++ b/lam/lib/checkEnvironment.inc @@ -1,9 +1,8 @@ messages['uid'][3] = array('ERROR', _('Account %s:') . ' inetOrgPerson_userName', _('User name already exists!')); $this->messages['manager'][0] = array('ERROR', _('Account %s:') . ' inetOrgPerson_manager', _('This is not a valid DN!')); $this->messages['file'][0] = array('ERROR', _('No file selected.')); - $this->messages['file'][1] = array('ERROR', _('Please upload a .jpg/.jpeg file.')); $this->messages['file'][2] = array('ERROR', _('Unable to process this file.')); $this->messages['file'][3] = array('ERROR', _('File is too large. Maximum allowed size is %s kB.')); $this->messages['businessCategory'][0] = array('ERROR', _('Business category'), _('Please enter a valid business category!')); @@ -1620,10 +1619,6 @@ class inetOrgPerson extends baseModule implements passwordService { if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) { $name = $_FILES['photoFile']['name']; $extension = strtolower(substr($name, strpos($name, '.') + 1)); - if (!extension_loaded('imagick') && !($extension == 'jpg') && !($extension == 'jpeg')) { - $messages[] = $this->messages['file'][1]; - return $messages; - } $handle = fopen($_FILES['photoFile']['tmp_name'], "r"); $data = fread($handle, 10000000); if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]) && (strlen($data) > (1024 * $this->moduleSettings['inetOrgPerson_jpegPhoto_maxSize'][0]))) { @@ -1633,27 +1628,25 @@ class inetOrgPerson extends baseModule implements passwordService { return array($errMsg); } fclose($handle); - if (extension_loaded('imagick')) { - // convert to JPG if imagick extension is available - $image = new Imagick(); - try { - $image->readImageBlob($data); - // resize if maximum values specified - if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0])) { - $maxWidth = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]; - $maxHeight = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]; - $image->thumbnailimage($maxWidth, $maxHeight, true); - } - $image->setImageCompression(Imagick::COMPRESSION_JPEG); - $image->setImageFormat('jpeg'); - $data = $image->getimageblob(); - } - catch (Exception $e) { - $msg = $this->messages['file'][2]; - $msg[] = htmlspecialchars($e->getMessage()); - $messages[] = $msg; - return $messages; - } + // convert to JPG if imagick extension is available + $image = new Imagick(); + try { + $image->readImageBlob($data); + // resize if maximum values specified + if (!empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0])) { + $maxWidth = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxWidth'][0]; + $maxHeight = empty($this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $this->moduleSettings['inetOrgPerson_jpegPhoto_maxHeight'][0]; + $image->thumbnailimage($maxWidth, $maxHeight, true); + } + $image->setImageCompression(Imagick::COMPRESSION_JPEG); + $image->setImageFormat('jpeg'); + $data = $image->getimageblob(); + } + catch (Exception $e) { + $msg = $this->messages['file'][2]; + $msg[] = htmlspecialchars($e->getMessage()); + $messages[] = $msg; + return $messages; } $this->attributes['jpegPhoto'][0] = $data; } @@ -1670,10 +1663,7 @@ class inetOrgPerson extends baseModule implements passwordService { */ function display_html_photo() { $container = new htmlTable(); - $label = _('Photo file (JPG format)'); - if (extension_loaded('imagick')) { - $label = _('Photo file'); - } + $label = _('Photo file'); $container->addElement(new htmlTableExtendedInputFileUpload('photoFile', $label, 'photoUpload'), true); $buttonContainer = new htmlTable(); $buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'submit', _('Add photo'))); @@ -2434,10 +2424,8 @@ class inetOrgPerson extends baseModule implements passwordService { public function getSelfServiceSettings($profile) { $container = new htmlResponsiveRow(); $container->add(new htmlSubTitle(_('Photo')), 12); - if (extension_loaded('imagick')) { - $container->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, array('crop', get_class($this))), 12); - $container->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, array('crop', get_class($this))), 12); - } + $container->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, array('crop', get_class($this))), 12); + $container->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, array('crop', get_class($this))), 12); $container->add(new htmlResponsiveInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize'), 12); return $container; } @@ -3225,15 +3213,13 @@ class inetOrgPerson extends baseModule implements passwordService { $handle = fopen($_FILES['photoFile']['tmp_name'], "r"); $data = fread($handle, 100000000); fclose($handle); - if (extension_loaded('imagick')) { - try { - $data = inetOrgPerson::resizeAndConvertImage($data, $moduleSettings); - } - catch (Exception $e) { - $msg = $this->messages['file'][2]; - $msg[] = htmlspecialchars($e->getMessage()); - $return['messages'][] = $msg; - } + try { + $data = inetOrgPerson::resizeAndConvertImage($data, $moduleSettings); + } + catch (Exception $e) { + $msg = $this->messages['file'][2]; + $msg[] = htmlspecialchars($e->getMessage()); + $return['messages'][] = $msg; } if (isset($_POST['removeReplacePhoto']) && ($_POST['removeReplacePhoto'] == 'on')) { $return['mod']['jpegPhoto'][0] = $data; @@ -3352,20 +3338,18 @@ class inetOrgPerson extends baseModule implements passwordService { * @return array binary image data */ private static function resizeAndConvertImage($data, $settings) { - if (extension_loaded('imagick')) { - // convert to JPG if imagick extension is available - $image = new Imagick(); - $image->readImageBlob($data); - // resize if maximum values specified - if (!empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0])) { - $maxWidth = empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $settings['inetOrgPerson_jpegPhoto_maxWidth'][0]; - $maxHeight = empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $settings['inetOrgPerson_jpegPhoto_maxHeight'][0]; - $image->thumbnailimage($maxWidth, $maxHeight, true); - } - $image->setImageCompression(Imagick::COMPRESSION_JPEG); - $image->setImageFormat('jpeg'); - $data = $image->getimageblob(); + // convert to JPG if imagick extension is available + $image = new Imagick(); + $image->readImageBlob($data); + // resize if maximum values specified + if (!empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) || !empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0])) { + $maxWidth = empty($settings['inetOrgPerson_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $settings['inetOrgPerson_jpegPhoto_maxWidth'][0]; + $maxHeight = empty($settings['inetOrgPerson_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $settings['inetOrgPerson_jpegPhoto_maxHeight'][0]; + $image->thumbnailimage($maxWidth, $maxHeight, true); } + $image->setImageCompression(Imagick::COMPRESSION_JPEG); + $image->setImageFormat('jpeg'); + $data = $image->getimageblob(); return $data; } @@ -3718,10 +3702,8 @@ class inetOrgPerson extends baseModule implements passwordService { $advancedOptions->add(new htmlResponsiveInputCheckbox($id, false, $label, null, true), 12, 4); } $advancedOptions->add(new htmlSubTitle(_('Photo')), 12); - if (extension_loaded('imagick')) { - $advancedOptions->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, 'crop'), 12); - $advancedOptions->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, 'crop'), 12); - } + $advancedOptions->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'inetOrgPerson_jpegPhoto_maxWidth', null, 'crop'), 12); + $advancedOptions->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'inetOrgPerson_jpegPhoto_maxHeight', null, 'crop'), 12); $advancedOptions->add(new htmlResponsiveInputField(_('Maximum file size (kB)'), 'inetOrgPerson_jpegPhoto_maxSize'), 12); $advancedOptionsAccordion = new htmlAccordion('inetOrgPersonAdvancedOptions', array(_('Advanced options') => $advancedOptions), false); $configContainer->add($advancedOptionsAccordion, 12); diff --git a/lam/lib/modules/windowsUser.inc b/lam/lib/modules/windowsUser.inc index b61891db..11baceed 100644 --- a/lam/lib/modules/windowsUser.inc +++ b/lam/lib/modules/windowsUser.inc @@ -2,10 +2,9 @@ use \LAM\TYPES\TypeManager; use LAM\TYPES\ConfiguredType; /* -$Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) - Copyright (C) 2013 - 2017 Roland Gruber + Copyright (C) 2013 - 2018 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 @@ -1747,10 +1746,7 @@ class windowsUser extends baseModule implements passwordService { */ function display_html_photo() { $container = new htmlTable(); - $label = _('Photo file (JPG format)'); - if (extension_loaded('imagick')) { - $label = _('Photo file'); - } + $label = _('Photo file'); $container->addElement(new htmlTableExtendedInputFileUpload('photoFile', $label, 'photoUpload'), true); $buttonContainer = new htmlTable(); $buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'submit', _('Add photo'))); @@ -1770,10 +1766,6 @@ class windowsUser extends baseModule implements passwordService { if ($_FILES['photoFile'] && ($_FILES['photoFile']['size'] > 0)) { $name = $_FILES['photoFile']['name']; $extension = strtolower(substr($name, strpos($name, '.') + 1)); - if (!extension_loaded('imagick') && !($extension == 'jpg') && !($extension == 'jpeg')) { - $messages[] = $this->messages['file'][1]; - return $messages; - } $handle = fopen($_FILES['photoFile']['tmp_name'], "r"); $data = fread($handle, 10000000); if (!empty($this->moduleSettings['windowsUser_jpegPhoto_maxSize'][0]) && (strlen($data) > (1024 * $this->moduleSettings['windowsUser_jpegPhoto_maxSize'][0]))) { @@ -1783,27 +1775,25 @@ class windowsUser extends baseModule implements passwordService { return array($errMsg); } fclose($handle); - if (extension_loaded('imagick')) { - // convert to JPG if imagick extension is available - $image = new Imagick(); - try { - $image->readImageBlob($data); - // resize if maximum values specified - if (!empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0])) { - $maxWidth = empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]; - $maxHeight = empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0]; - $image->thumbnailimage($maxWidth, $maxHeight, true); - } - $image->setImageCompression(Imagick::COMPRESSION_JPEG); - $image->setImageFormat('jpeg'); - $data = $image->getimageblob(); - } - catch (Exception $e) { - $msg = $this->messages['file'][2]; - $msg[] = htmlspecialchars($e->getMessage()); - $messages[] = $msg; - return $messages; - } + // convert to JPG if imagick extension is available + $image = new Imagick(); + try { + $image->readImageBlob($data); + // resize if maximum values specified + if (!empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) || !empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0])) { + $maxWidth = empty($this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]) ? $image->getimagewidth() : $this->moduleSettings['windowsUser_jpegPhoto_maxWidth'][0]; + $maxHeight = empty($this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0]) ? $image->getimageheight() : $this->moduleSettings['windowsUser_jpegPhoto_maxHeight'][0]; + $image->thumbnailimage($maxWidth, $maxHeight, true); + } + $image->setImageCompression(Imagick::COMPRESSION_JPEG); + $image->setImageFormat('jpeg'); + $data = $image->getimageblob(); + } + catch (Exception $e) { + $msg = $this->messages['file'][2]; + $msg[] = htmlspecialchars($e->getMessage()); + $messages[] = $msg; + return $messages; } $this->attributes['jpegPhoto'][0] = $data; } @@ -3222,10 +3212,8 @@ class windowsUser extends baseModule implements passwordService { } $advancedOptions = new htmlResponsiveRow(); $advancedOptions->add(new htmlSubTitle(_('Photo')), 12); - if (extension_loaded('imagick')) { - $advancedOptions->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'windowsUser_jpegPhoto_maxWidth', null, 'crop'), 12); - $advancedOptions->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'windowsUser_jpegPhoto_maxHeight', null, 'crop'), 12); - } + $advancedOptions->add(new htmlResponsiveInputField(_('Maximum width (px)'), 'windowsUser_jpegPhoto_maxWidth', null, 'crop'), 12); + $advancedOptions->add(new htmlResponsiveInputField(_('Maximum height (px)'), 'windowsUser_jpegPhoto_maxHeight', null, 'crop'), 12); $advancedOptions->add(new htmlResponsiveInputField(_('Maximum file size (kB)'), 'windowsUser_jpegPhoto_maxSize'), 12); $advancedOptionsAccordion = new htmlAccordion('inetOrgPersonAdvancedOptions', array(_('Advanced options') => $advancedOptions), false); $advancedOptionsAccordion->colspan = 5;