Skip to content

Commit

Permalink
improve api
Browse files Browse the repository at this point in the history
  • Loading branch information
callcenter-magnus committed Feb 26, 2024
1 parent b1a9b4f commit d34e84f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
11 changes: 11 additions & 0 deletions protected/commands/UpdateMysqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,17 @@ public function run($args)
$this->update($version);
}

//2024-01-22
if ($version == '7.8.4.5') {
$sql = "INSERT INTO pkg_configuration VALUES
(NULL, 'API allow multiple user/email', 'api_allow_same_ip', '0', 'Allow create muiltiple clients with same email via API', 'global', '1');
";
$this->executeDB($sql);

$version = '7.8.4.6';
$this->update($version);
}

}

public function executeDB($sql)
Expand Down
18 changes: 11 additions & 7 deletions protected/components/ApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ private function checkPermissions($modelApi)
$action = 'r';
} else if ($_POST['action'] == 'resendActivationEmail') {
$action = 'r';
} else if ($_POST['action'] == 'spyCall') {
$action = 'r';
}

if ( ! preg_match('/' . $action . '/', $modelApi->action)) {
Expand All @@ -206,17 +208,19 @@ private function createUser($baseController)

$values = $_POST;

$modelUser = User::model()->find('email = :key', [':key' => $values['email']]);
if ($config['global']['api_allow_same_ip'] == 0) {
$modelUser = User::model()->find('email = :key', [':key' => $values['email']]);

if (isset($modelUser->id)) {
if (isset($modelUser->id)) {

echo json_encode([
'success' => false,
'errors' => 'This email already in use',
]);
echo json_encode([
'success' => false,
'errors' => 'This email already in use',
]);

exit;
exit;

}
}

if (isset($values['username'])) {
Expand Down
7 changes: 4 additions & 3 deletions protected/controllers/CallOnLineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ public function actionDestroy()

public function actionSpyCall()
{
if ( ! isset($_POST['id_sip'])) {
if (isset($_POST['sipuser'])) {
$dialstr = 'SIP/' . $_POST['sipuser'];
} elseif ( ! isset($_POST['id_sip'])) {
$dialstr = 'SIP/' . $this->config['global']['channel_spy'];
} else {
$modelSip = Sip::model()->findByPk((int) $_POST['id_sip']);
Expand All @@ -142,11 +144,9 @@ public function actionSpyCall()

$call = "Action: Originate\n";
$call .= "Channel: " . $dialstr . "\n";
$call .= "Callerid: " . Yii::app()->session['username'] . "\n";
$call .= "Context: billing\n";
$call .= "Extension: 5555\n";
$call .= "Priority: 1\n";
$call .= "Set:USERNAME=" . Yii::app()->session['username'] . "\n";
$call .= "Set:SPY=1\n";
$call .= "Set:SPYTYPE=" . $_POST['type'] . "\n";
$call .= "Set:CHANNELSPY=" . $_POST['channel'] . "\n";
Expand All @@ -156,6 +156,7 @@ public function actionSpyCall()
echo json_encode([
'success' => true,
'msg' => 'Start Spy',

]);
}

Expand Down

0 comments on commit d34e84f

Please sign in to comment.