Skip to content

Commit

Permalink
Update for PHP 8.3 and Phalcon 5.8, fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorikfon committed Nov 6, 2024
1 parent 25440c9 commit 8be088f
Show file tree
Hide file tree
Showing 8 changed files with 695 additions and 456 deletions.
22 changes: 13 additions & 9 deletions src/AdminCabinet/Controllers/FirewallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,22 +432,26 @@ public function disableAction(): void
}

/**
* Sort array. The localnet and 0.0.0.0 should be at the first position on the list
* Compare two network entries for sorting
*
* @param $a
* @param $b
*
* @return bool
* @param array $a First network entry
* @param array $b Second network entry
* @return int Returns -1 if $a should be placed before $b,
* 1 if $a should be placed after $b,
* 0 if they are considered equal
*/
private function sortArrayByNetwork($a, $b): bool
private function sortArrayByNetwork(array $a, array $b): int
{
// If second entry is permanent and first is not 0.0.0.0/0
if ($b['permanent'] && $a['network'] !== '0.0.0.0/0') {
return true;
return 1; // Move $a after $b
}

// If second entry is 0.0.0.0/0
if ($b['network'] === '0.0.0.0/0') {
return true;
return 1; // Move $a after $b
}

return false;
return -1; // In all other cases, move $a before $b
}
}
2 changes: 1 addition & 1 deletion src/AdminCabinet/Views/IncomingRoutes/modify.volt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{{ partial("partials/playAddNewSound", ['label': t._('iv_PlaySound'), 'id':'audio_message_id', 'fieldClass':'eleven wide field', 'fieldId':'']) }}
<h3 class="ui dividing header ">{{ t._("ir_CallTransferTo") }}</h3>

<div class="field max-width-500">
<div class="field max-width-800">
<label for="extension"></label>
{{ form.render('extension') }}
</div>
Expand Down
19 changes: 10 additions & 9 deletions src/PBXCoreREST/Middleware/AuthenticationMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* MikoPBX - free phone system for small business
* Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
Expand Down Expand Up @@ -30,7 +31,6 @@
use Phalcon\Mvc\Micro;
use Phalcon\Mvc\Micro\MiddlewareInterface;


/**
* Class AuthenticationMiddleware
*
Expand Down Expand Up @@ -70,18 +70,19 @@ public function call(Micro $application): bool
return false;
}

if (true !== $isNoAuthApi
&& true !== $request->isLocalHostRequest()
&& true !== $request->isAllowedAction($application)) {
if (
true !== $isNoAuthApi
&& true !== $request->isLocalHostRequest()
&& true !== $request->isAllowedAction($application)
) {
$this->halt(
$application,
$response::FORBIDDEN,
'The route is not allowed'
);
$response::FORBIDDEN,
'The route is not allowed'
);
return false;
}

return true;
}

}
}
Loading

0 comments on commit 8be088f

Please sign in to comment.