From 0a221d0479f9dc6e107750347a4a7c3fa6ee25e8 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Thu, 6 Mar 2025 09:08:51 +0100 Subject: [PATCH] only show 'move to another admin' if current admin can see other admin-resources; append domainid to pagination of email-domain adresses list; check for invalid lockfile in cron management Signed-off-by: Michael Kaufmann --- .github/ISSUE_TEMPLATE/bug_report.md | 3 ++- admin_customers.php | 25 ++++++++++--------- composer.lock | 36 +++++++++++++++------------- customer_email.php | 3 +-- lib/Froxlor/Cli/MasterCron.php | 11 ++++++--- lib/Froxlor/Froxlor.php | 2 +- lib/functions.php | 2 +- 7 files changed, 47 insertions(+), 35 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index facf73f6..9976c391 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -15,7 +15,8 @@ assignees: '' A clear and concise description of what the bug is. **System information** -* Froxlor version: $version/$gitSHA1 +* Froxlor version: \$version/\$gitSHA1 +* PHP sapi & version: php-fpm 8.3 / fcgid 8.0 / etc. * Web server: apache2/nginx/lighttpd * DNS server: Bind/PowerDNS (standalone)/PowerDNS (Bind-backend) * POP/IMAP server: Courier/Dovecot diff --git a/admin_customers.php b/admin_customers.php index 785145f9..1ce34e34 100644 --- a/admin_customers.php +++ b/admin_customers.php @@ -307,17 +307,20 @@ if (($page == 'customers' || $page == 'overview') && $userinfo['customers'] != ' $hosting_plans[$row['id']] = $row['name']; } - $available_admins_stmt = Database::prepare(" - SELECT * FROM `" . TABLE_PANEL_ADMINS . "` - WHERE (`customers` = '-1' OR `customers` > `customers_used`) - AND adminid <> :currentadmin - "); - Database::pexecute($available_admins_stmt, ['currentadmin' => $result['adminid']]); - $admin_select = [ - 0 => "---" - ]; - while ($available_admin = $available_admins_stmt->fetch()) { - $admin_select[$available_admin['adminid']] = $available_admin['name'] . " (" . $available_admin['loginname'] . ")"; + $admin_select = []; + if ($userinfo['customers_see_all'] == '1') { + $available_admins_stmt = Database::prepare(" + SELECT * FROM `" . TABLE_PANEL_ADMINS . "` + WHERE (`customers` = '-1' OR `customers` > `customers_used`) + AND adminid <> :currentadmin + "); + Database::pexecute($available_admins_stmt, ['currentadmin' => $result['adminid']]); + $admin_select = [ + 0 => "---" + ]; + while ($available_admin = $available_admins_stmt->fetch()) { + $admin_select[$available_admin['adminid']] = $available_admin['name'] . " (" . $available_admin['loginname'] . ")"; + } } $customer_edit_data = include_once dirname(__FILE__) . '/lib/formfields/admin/customer/formfield.customer_edit.php'; diff --git a/composer.lock b/composer.lock index 3378416d..ecf9b77d 100644 --- a/composer.lock +++ b/composer.lock @@ -2561,16 +2561,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.12.1", + "version": "1.13.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845" + "reference": "024473a478be9df5fdaca2c793f2232fe788e414" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/123267b2c49fbf30d78a7b2d333f6be754b94845", - "reference": "123267b2c49fbf30d78a7b2d333f6be754b94845", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/024473a478be9df5fdaca2c793f2232fe788e414", + "reference": "024473a478be9df5fdaca2c793f2232fe788e414", "shasum": "" }, "require": { @@ -2609,7 +2609,7 @@ ], "support": { "issues": "https://github.com/myclabs/DeepCopy/issues", - "source": "https://github.com/myclabs/DeepCopy/tree/1.12.1" + "source": "https://github.com/myclabs/DeepCopy/tree/1.13.0" }, "funding": [ { @@ -2617,7 +2617,7 @@ "type": "tidelift" } ], - "time": "2024-11-08T17:47:46+00:00" + "time": "2025-02-12T12:17:51+00:00" }, { "name": "nikic/php-parser", @@ -3066,16 +3066,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.12.15", + "version": "1.12.20", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "c91d4e8bc056f46cf653656e6f71004b254574d1" + "reference": "3240b1972042c7f73cf1045e879ea5bd5f761bb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c91d4e8bc056f46cf653656e6f71004b254574d1", - "reference": "c91d4e8bc056f46cf653656e6f71004b254574d1", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/3240b1972042c7f73cf1045e879ea5bd5f761bb7", + "reference": "3240b1972042c7f73cf1045e879ea5bd5f761bb7", "shasum": "" }, "require": { @@ -3120,7 +3120,7 @@ "type": "github" } ], - "time": "2025-01-05T16:40:22+00:00" + "time": "2025-03-05T13:37:43+00:00" }, { "name": "phpunit/php-code-coverage", @@ -4571,16 +4571,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.11.2", + "version": "3.11.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079" + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/1368f4a58c3c52114b86b1abe8f4098869cb0079", - "reference": "1368f4a58c3c52114b86b1abe8f4098869cb0079", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", + "reference": "ba05f990e79cbe69b9f35c8c1ac8dca7eecc3a10", "shasum": "" }, "require": { @@ -4645,9 +4645,13 @@ { "url": "https://opencollective.com/php_codesniffer", "type": "open_collective" + }, + { + "url": "https://thanks.dev/phpcsstandards", + "type": "thanks_dev" } ], - "time": "2024-12-11T16:04:26+00:00" + "time": "2025-01-23T17:04:15+00:00" }, { "name": "symfony/config", diff --git a/customer_email.php b/customer_email.php index b3f6c251..bd530fc9 100644 --- a/customer_email.php +++ b/customer_email.php @@ -30,7 +30,6 @@ use Froxlor\Api\Commands\EmailAccounts; use Froxlor\Api\Commands\EmailDomains; use Froxlor\Api\Commands\EmailForwarders; use Froxlor\Api\Commands\Emails; -use Froxlor\Cron\Mail\Rspamd; use Froxlor\CurrentUser; use Froxlor\Database\Database; use Froxlor\FroxlorLogger; @@ -105,7 +104,7 @@ if ($page == 'email_domain') { $email_list_data = include_once dirname(__FILE__) . '/lib/tablelisting/customer/tablelisting.emails.php'; $collection = (new Collection(Emails::class, $userinfo, $sql_search)) ->withPagination($email_list_data['email_list']['columns'], - $email_list_data['email_list']['default_sorting']); + $email_list_data['email_list']['default_sorting'], ['domainid=' . $email_domainid]); } catch (Exception $e) { Response::dynamicError($e->getMessage()); } diff --git a/lib/Froxlor/Cli/MasterCron.php b/lib/Froxlor/Cli/MasterCron.php index a8e93f0f..564a2e0c 100644 --- a/lib/Froxlor/Cli/MasterCron.php +++ b/lib/Froxlor/Cli/MasterCron.php @@ -215,9 +215,14 @@ final class MasterCron extends CliCommand if (file_exists($this->lockFile)) { $jobinfo = json_decode(file_get_contents($this->lockFile), true); - $check_pid_return = null; - // get status of process - system("kill -CHLD " . (int)$jobinfo['pid'] . " 1> /dev/null 2> /dev/null", $check_pid_return); + if ($jobinfo === false || !is_array($jobinfo)) { + // looks like an invalid lockfile + $check_pid_return = 1; + } else { + $check_pid_return = null; + // get status of process + system("kill -CHLD " . (int)$jobinfo['pid'] . " 1> /dev/null 2> /dev/null", $check_pid_return); + } if ($check_pid_return == 1) { // Process does not seem to run, most likely it has died $this->unlockJob(); diff --git a/lib/Froxlor/Froxlor.php b/lib/Froxlor/Froxlor.php index a2e3a465..6f386560 100644 --- a/lib/Froxlor/Froxlor.php +++ b/lib/Froxlor/Froxlor.php @@ -316,7 +316,7 @@ final class Froxlor * @param array|null $arr * @return void */ - private static function parseVersionArray(array &$arr = null) + private static function parseVersionArray(?array &$arr) { // -dev or -beta or -rc ? if (stripos($arr[count($arr) - 1], '-') !== false) { diff --git a/lib/functions.php b/lib/functions.php index a2f0a2aa..274e60de 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -61,7 +61,7 @@ function lng(string $identifier, array $arguments = []) * @param string|null $session * @return mixed|string|null */ -function old(string $identifier, string $default = null, string $session = null) +function old(string $identifier, ?string $default, ?string $session = null) { if ($session && isset($_SESSION[$session])) { return $_SESSION[$session][$identifier] ?? $default;