1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* MikoPBX - free phone system for small business |
4
|
|
|
* Copyright (C) 2017-2020 Alexey Portnov and Nikolay Beketov |
5
|
|
|
* |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU General Public License as published by |
8
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* |
11
|
|
|
* This program is distributed in the hope that it will be useful, |
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14
|
|
|
* GNU General Public License for more details. |
15
|
|
|
* |
16
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
17
|
|
|
* If not, see <https://www.gnu.org/licenses/>. |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace MikoPBX\Core\System\Upgrade\Releases; |
21
|
|
|
|
22
|
|
|
use MikoPBX\Common\Models\FirewallRules; |
23
|
|
|
use MikoPBX\Common\Models\NetworkFilters; |
24
|
|
|
use MikoPBX\Core\System\Upgrade\UpgradeSystemConfigInterface; |
25
|
|
|
use Phalcon\Di\Injectable; |
26
|
|
|
|
27
|
|
|
class UpdateConfigsUpToVer20220201 extends Injectable implements UpgradeSystemConfigInterface |
28
|
|
|
{ |
29
|
|
|
public const PBX_VERSION = '2022.2.1'; |
30
|
|
|
|
31
|
|
|
private bool $isLiveCD; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Class constructor. |
35
|
|
|
*/ |
36
|
|
|
public function __construct() |
37
|
|
|
{ |
38
|
|
|
$this->isLiveCD = file_exists('/offload/livecd'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* https://github.com/mikopbx/Core/issues/269 |
43
|
|
|
*/ |
44
|
|
|
public function processUpdate():void |
45
|
|
|
{ |
46
|
|
|
if ($this->isLiveCD) { |
47
|
|
|
return; |
48
|
|
|
} |
49
|
|
|
$colName = 'TLS_PORT'; |
50
|
|
|
/** @var NetworkFilters $net */ |
51
|
|
|
$nets = NetworkFilters::find(['columns' => 'id']); |
52
|
|
|
foreach ($nets as $net){ |
53
|
|
|
$ruleTls = FirewallRules::findFirst([ |
54
|
|
|
"portFromKey='$colName' AND networkfilterid='$net->id'", |
55
|
|
|
'columns' => 'id'] |
56
|
|
|
); |
57
|
|
|
if($ruleTls){ |
58
|
|
|
continue; |
59
|
|
|
} |
60
|
|
|
$rules = FirewallRules::findFirst([ |
61
|
|
|
"portFromKey='SIPPort' AND networkfilterid='$net->id'", |
62
|
|
|
'columns' => 'action,networkfilterid,category,description'] |
63
|
|
|
); |
64
|
|
|
if(!$rules){ |
65
|
|
|
continue; |
66
|
|
|
} |
67
|
|
|
$ruleTls = new FirewallRules(); |
68
|
|
|
foreach ($rules->toArray() as $key => $value){ |
69
|
|
|
$ruleTls->$key = $value; |
70
|
|
|
} |
71
|
|
|
$ruleTls->portfrom = '5061'; |
|
|
|
|
72
|
|
|
$ruleTls->portto = '5061'; |
|
|
|
|
73
|
|
|
$ruleTls->protocol = 'tcp'; |
74
|
|
|
$ruleTls->portFromKey = $colName; |
75
|
|
|
$ruleTls->portToKey = $colName; |
76
|
|
|
$ruleTls->save(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..