|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* MikoPBX - free phone system for small business |
|
4
|
|
|
* Copyright © 2017-2023 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\LanInterfaces; |
|
23
|
|
|
use MikoPBX\Common\Models\PbxSettings; |
|
24
|
|
|
use MikoPBX\Common\Models\PbxSettingsConstants; |
|
25
|
|
|
use MikoPBX\Core\System\Upgrade\UpgradeSystemConfigInterface; |
|
26
|
|
|
use Phalcon\Di\Injectable; |
|
27
|
|
|
|
|
28
|
|
|
class UpdateConfigsUpToVer20240194 extends Injectable implements UpgradeSystemConfigInterface |
|
29
|
|
|
{ |
|
30
|
|
|
public const PBX_VERSION = '2024.1.94'; |
|
31
|
|
|
|
|
32
|
|
|
private bool $isLiveCD; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Class constructor. |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->isLiveCD = file_exists('/offload/livecd'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Main function |
|
44
|
|
|
*/ |
|
45
|
|
|
public function processUpdate():void |
|
46
|
|
|
{ |
|
47
|
|
|
if ($this->isLiveCD) { |
|
48
|
|
|
return; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
$this->updateExternalSIPPort(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Setup en EXTERNAL_SIP_PORT value |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
private function updateExternalSIPPort(): void |
|
59
|
|
|
{ |
|
60
|
|
|
$res = LanInterfaces::find('disabled=0')->toArray(); |
|
61
|
|
|
foreach ($res as $item) { |
|
62
|
|
|
if ($item['topology']===LanInterfaces::TOPOLOGY_PRIVATE && $item['internet']==='1'){ |
|
63
|
|
|
$parts = explode(':', trim($item['exthostname'])); |
|
64
|
|
|
$extPort = PbxSettings::getDefaultArrayValues()[PbxSettingsConstants::EXTERNAL_SIP_PORT]; |
|
65
|
|
|
if (!empty($parts[1])){ |
|
66
|
|
|
$extPort=$parts[1]; |
|
67
|
|
|
} else { |
|
68
|
|
|
$parts = explode(':', trim($item['extipaddr'])); |
|
69
|
|
|
if (!empty($parts[1])){ |
|
70
|
|
|
$extPort=$parts[1]; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
PbxSettings::setValue(PbxSettingsConstants::EXTERNAL_SIP_PORT, $extPort); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
} |