Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
77d262f
Added translation using Weblate (Thai)
weblate Feb 23, 2024
1c9d5ab
Translated using Weblate (Thai)
sumonchai May 30, 2024
4fcc692
Added translation using Weblate (Hungarian)
weblate Jul 30, 2024
035f0fb
Translated using Weblate (Hungarian)
Korfa84 Jul 30, 2024
f473933
Translated using Weblate (Hungarian)
Korfa84 Aug 22, 2024
3428ae1
Added translation using Weblate (Finnish)
weblate Sep 6, 2024
5aaa334
Added translation using Weblate (languages (generated) (languages))
weblate Sep 16, 2024
0bbb51d
Update for PHP 8.3 and Phalcon 5.8
jorikfon Oct 1, 2024
cdbf965
Update for PHP 8.3 and Phalcon 5.8
jorikfon Oct 7, 2024
e6bbcf8
Added translation using Weblate (Croatian)
weblate Nov 18, 2024
dd8230e
Перенес сборку в GitHub Actions
jorikfon Jun 5, 2025
7955315
Translated using Weblate (Thai)
sumonchai Jun 13, 2025
b83bce4
Доработал REST API для получения записей разговоров
boffart Jul 10, 2025
6bef3e1
Удалил неиспользуемые use
boffart Jul 17, 2025
5350658
Added translation using Weblate (Hebrew)
weblate Sep 29, 2025
89a413a
Added translation using Weblate (Persian)
weblate Sep 30, 2025
f86bcda
#963 Поправил ошибки генераци конфига
boffart Dec 19, 2025
eccc029
Доработал REST API CDR: фильтрация по src/dst, формат ответа xml/json…
Mar 12, 2026
ebe957b
Вернул min_pbx_version на 2023.2.150 — method_exists() в ядре делает …
Mar 12, 2026
b6482f3
Исправил совместимость с Pheanstalk 8.x — убрал использование удалённ…
Apr 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build and Publish

on:
push:
branches:
- master
- develop
workflow_dispatch:

jobs:
build:
uses: mikopbx/.github-workflows/.github/workflows/extension-publish.yml@master
with:
initial_version: "1.39"
secrets: inherit
46 changes: 27 additions & 19 deletions App/Controllers/ModulePT1CCoreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
* Proprietary and confidential
* Written by Alexey Portnov, 11 2018
*/


namespace Modules\ModulePT1CCore\App\Controllers;
use MikoPBX\AdminCabinet\Controllers\BaseController;
use MikoPBX\Modules\PbxExtensionUtils;
use Modules\ModulePT1CCore\App\Forms\ModulePT1CCoreForm;
use Modules\ModulePT1CCore\Models\ModulePT1CCore;
use MikoPBX\Common\Models\Providers;

class ModulePT1CCoreController extends BaseController
{
Expand Down Expand Up @@ -54,36 +55,43 @@ public function indexAction(): void
/**
* Save settings AJAX action
*/
/**
* Whitelist of fields allowed for mass assignment.
*/
private const ALLOWED_FIELDS = [
'interception_extension',
'conference_extension',
'get_peer_info_extension',
'get_auth_extension',
'get_statuses_extension',
'get_cdr_extension',
'listen_recordings_extension',
'get_recordings_extension',
];

public function saveAction() :void
{
if ( ! $this->request->isPost()) {
return;
}

// CSRF protection (compatible with Phalcon 4 and 5)
if ($this->di->has('security') && !$this->security->checkToken()) {
$this->flash->error('Invalid CSRF token');
$this->view->success = false;
return;
}

$data = $this->request->getPost();
$record = ModulePT1CCore::findFirst();

if ($record === null) {
$record = new ModulePT1CCore();
}
$this->db->begin();
foreach ($record as $key => $value) {
switch ($key) {
case 'id':
break;
case 'checkbox_field':
case 'toggle_field':
if (array_key_exists($key, $data)) {
$record->$key = ($data[$key] === 'on') ? '1' : '0';
} else {
$record->$key = '0';
}
break;
default:
if (array_key_exists($key, $data)) {
$record->$key = $data[$key];
} else {
$record->$key = '';
}
foreach (self::ALLOWED_FIELDS as $key) {
if (array_key_exists($key, $data)) {
$record->$key = $data[$key];
}
}

Expand Down
6 changes: 0 additions & 6 deletions App/Forms/ModulePT1CCoreForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
namespace Modules\ModulePT1CCore\App\Forms;

use Phalcon\Forms\Form;
use Phalcon\Forms\Element\Text;
use Phalcon\Forms\Element\Numeric;
use Phalcon\Forms\Element\Password;
use Phalcon\Forms\Element\Check;
use Phalcon\Forms\Element\TextArea;
use Phalcon\Forms\Element\Hidden;
use Phalcon\Forms\Element\Select;


class ModulePT1CCoreForm extends Form
Expand Down
4 changes: 4 additions & 0 deletions App/Views/index.volt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<form class="ui large grey segment form" id="module_pt1c_core-form">
<div class="ui grey top right attached label" id="status">{{ t._("module_pt1c_coreDisconnected") }}</div>
{{ form.render('id') }}
{% if security is defined %}
{{ security.getToken() }}
{{ security.getTokenKey() }}
{% endif %}
<h3 class="ui header">{{ t._('module_pt1c_core_LinksRussian') }}</h3>
<div class="ui bulleted link list">
<a class="item" href="https://wiki.miko.ru/#s_i_telefonija_redakcija_1">{{ t._('module_pt1c_core_WikiDocsRussian') }}</a>
Expand Down
102 changes: 102 additions & 0 deletions Lib/MikoPBXVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php

/*
* MikoPBX - free phone system for small business
* Copyright © 2017-2024 Alexey Portnov and Nikolay Beketov
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
namespace Modules\ModulePT1CCore\Lib;

use MikoPBX\Common\Models\PbxSettings;

class MikoPBXVersion
{
/**
* Return true if current version of PBX based on Phalcon 5+
* @return bool
*/
public static function isPhalcon5Version(): bool
{
$pbxVersion = PbxSettings::getValueByKey('PBXVersion');
return version_compare($pbxVersion, '2024.2.30', '>');
}

/**
* Return Di interface for the current version of PBX
* @return \Phalcon\Di\DiInterface|null
*/
public static function getDefaultDi()
{
if (self::isPhalcon5Version()) {
return \Phalcon\Di\Di::getDefault();
} else {
return \Phalcon\Di::getDefault();
}
}

/**
* Return Validation class for the current version of PBX
* @return class-string<\Phalcon\Filter\Validation>|class-string<\Phalcon\Validation>
*/
public static function getValidationClass(): string
{
if (self::isPhalcon5Version()) {
return \Phalcon\Filter\Validation::class;
} else {
return \Phalcon\Validation::class;
}
}

/**
* Return Uniqueness class for the current version of PBX
* @return class-string<\Phalcon\Filter\Validation\Validator\Uniqueness>|class-string<\Phalcon\Validation\Validator\Uniqueness>
*/
public static function getUniquenessClass(): string
{
if (self::isPhalcon5Version()) {
return \Phalcon\Filter\Validation\Validator\Uniqueness::class;
} else {
return \Phalcon\Validation\Validator\Uniqueness::class;
}
}

/**
* Return Text class for the current version of PBX
*
* @return class-string<\MikoPBX\Common\Library\Text>|class-string<\Phalcon\Text>
*/
public static function getTextClass(): string
{
if (self::isPhalcon5Version()) {
return \MikoPBX\Common\Library\Text::class;
} else {
return \Phalcon\Text::class;
}
}

/**
* Return Logger class for the current version of PBX
*
* @return class-string<\Phalcon\Logger\Logger>|class-string<\Phalcon\Logger>
*/
public static function getLoggerClass(): string
{
if (self::isPhalcon5Version()) {
return \Phalcon\Logger\Logger::class;
} else {
return \Phalcon\Logger::class;
}
}
}
22 changes: 19 additions & 3 deletions Lib/PT1CCoreConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ public function onAfterPbxStarted(): void
if (is_file('/var/etc/http_auth')) {
return;
}
$user_name = md5(random_bytes(20));
$pass = md5(random_bytes(12));
$user_name = bin2hex(random_bytes(16));
$pass = bin2hex(random_bytes(16));
file_put_contents('/var/etc/http_auth', "{$user_name}:{$pass}");
chmod('/var/etc/http_auth', 0600);
}


Expand Down Expand Up @@ -194,6 +195,7 @@ public function createNginxLocations(): string
public function getPBXCoreRESTAdditionalRoutes(): array
{
return [
[GetController::class, 'getRecordsPathByIdAction', '/pbxcore/api/cdr/records-path', 'get', '/', true],
[GetController::class, 'getDataAction', '/pbxcore/api/cdr/get_data', 'get', '/', true],
[GetController::class, 'recordsAction', '/pbxcore/api/cdr/records', 'get', '/', true],
[PostController::class,'callAction', '/pbxcore/api/fax/upload/{actionName}', 'post','/', true],
Expand All @@ -205,7 +207,7 @@ public function getPBXCoreRESTAdditionalRoutes(): array
*
* @return string
*/
public function generateFail2BanJails():string
public function generateFail2BanFilters():string
{
return "[INCLUDES]\n" .
"before = common.conf\n" .
Expand All @@ -216,6 +218,20 @@ public function generateFail2BanJails():string
"ignoreregex =\n";
}

/**
* Generates additional fail2ban jail conf rules
* Detects auth failures for:
* - REST API login attempts
* - Media file access attempts
* - WebSocket connection attempts
*
* @return string
*/
public function generateFail2BanJails(): string
{
return "#";
}

/**
* Returns array of additional firewall rules for module
*
Expand Down
4 changes: 0 additions & 4 deletions Lib/PT1CCoreMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

namespace Modules\ModulePT1CCore\Lib;


use MikoPBX\Core\System\Util;
use MikoPBX\Core\Workers\Cron\WorkerSafeScriptsCore;
use MikoPBX\Modules\PbxExtensionBase;
use MikoPBX\Modules\PbxExtensionUtils;
use MikoPBX\PBXCoreREST\Lib\PBXApiResult;

class PT1CCoreMain extends PbxExtensionBase
Expand Down
Loading
Loading