Skip to content

Commit ac71249

Browse files
fix DID destination type multiple IPs
1 parent 21375dd commit ac71249

25 files changed

+807
-784
lines changed

build/MagnusBilling-current.tar.gz

360 Bytes
Binary file not shown.

classic/src/view/diddestination/Controller.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ Ext.define('MBilling.view.diddestination.Controller', {
8383
case 10:
8484
method = t('Context');
8585
break;
86+
case 11:
87+
method = t('Multiples IPs');
88+
break;
8689
}
8790
showFields = me.formPanel.down('didtypecombo').store.findRecord('name', method).getData().showFields;
8891
me.showFieldsRelated(showFields);

protected/commands/BackupCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class BackupCommand extends ConsoleCommand
2121
{
2222
public function run($args)
2323
{
24+
25+
LinuxAccess::exec("rm -f /var/wwww/html/mbilling/assets/*");
2426
$dbString = explode('dbname=', Yii::app()->db->connectionString);
2527
$dataBase = end($dbString);
2628

protected/commands/ConvertAudiotoGSMCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function run($args)
3535
foreach ($audios as $key => $audio) {
3636

3737
echo 'Convert ' . $audio . " to GSM\n";
38-
exec('sox ' . $this->diretory . $audio . ' ' . $this->diretory . substr($audio, 0, -4) . '.gsm');
39-
exec('rm -rf ' . $this->diretory . $audio);
38+
LinuxAccess::exec('sox ' . $this->diretory . $audio . ' ' . $this->diretory . substr($audio, 0, -4) . '.gsm');
39+
LinuxAccess::exec('rm -rf ' . $this->diretory . $audio);
4040
}
4141
}
4242

@@ -45,7 +45,7 @@ public function run($args)
4545
public function scan_dir($dir)
4646
{
4747

48-
$files = array();
48+
$files = [];
4949
foreach (scandir($dir) as $file) {
5050
if (substr($file, -4) != '.wav') {
5151
continue;

protected/commands/DidwwwCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function run($args)
3131
foreach ($modelDid as $key => $did) {
3232

3333
$order_id = explode('=', $did->description);
34-
if (!isset($order_id[1])) {
34+
if ( ! isset($order_id[1])) {
3535
continue;
3636
}
3737

38-
$result = exec("
38+
$result = LinuxAccess::exec("
3939
curl -H 'Content-Type: application/vnd.api+json' \
4040
-H 'Accept: application/vnd.api+json' \
4141
-H 'Api-Key: " . $api_key . "' \
@@ -49,7 +49,7 @@ public function run($args)
4949
//discount credit of customer
5050
$priceDid = $did->connection_charge + $did->fixrate;
5151

52-
$modelSip = Sip::model()->find('id_user = :key', array(':key' => $did->id_user));
52+
$modelSip = Sip::model()->find('id_user = :key', [':key' => $did->id_user]);
5353

5454
$modelDiddestination = new Diddestination;
5555
$modelDiddestination->id_user = $did->id_user;

protected/commands/SipTraceCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function run($args)
2121
define('DEBUG', 0);
2222
}
2323

24-
if (!defined('PID')) {
24+
if ( ! defined('PID')) {
2525
define("PID", "/var/run/magnus/SipTracepid.php");
2626
}
2727

@@ -45,7 +45,7 @@ public function run($args)
4545
continue;
4646
}
4747

48-
exec('pkill -f ngrep');
48+
LinuxAccess::exec('pkill -f ngrep');
4949
echo $command = "ngrep -p -W byline " . $modelTrace->filter . " -t port " . $modelTrace->port . $device . " >> " . $this->file_name;
5050

5151
$output = $this->PsExecute($command, $modelTrace->timeout, $modelTrace->filter);
@@ -72,7 +72,7 @@ public function PsExecute($command, $timeout = 58, $filter, $sleep = 2)
7272

7373
if ($cur % 5 == 0) {
7474
$modelTrace = SipTrace::model()->find();
75-
if (!isset($modelTrace)) {
75+
if ( ! isset($modelTrace)) {
7676
SipTrace::model()->deleteAll();
7777
$this->PsKill($pid);
7878
break;
@@ -91,7 +91,7 @@ public function PsExec($commandJob)
9191

9292
$command = $commandJob . ' 2>&1 & echo $!';
9393

94-
exec($command, $op);
94+
$op = LinuxAccess::exec($command);
9595

9696
$pid = (int) $op[0];
9797

@@ -105,7 +105,7 @@ public function PsExec($commandJob)
105105
public function PsExists($pid)
106106
{
107107

108-
exec("ps ax | grep $pid|wc -l 2>&1", $output);
108+
$output = LinuxAccess::exec("ps ax | grep $pid|wc -l 2>&1");
109109

110110
if ($output[0] > 0) {
111111
return true;
@@ -117,7 +117,7 @@ public function PsExists($pid)
117117
public function PsKill($pid)
118118
{
119119
echo "End process $pid";
120-
exec('pkill ngrep');
120+
LinuxAccess::exec('pkill ngrep');
121121
try {
122122
posix_kill($pid, 2);
123123
} catch (Exception $e) {

protected/commands/TrunkSIPCodesCommand.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function run($args)
2525
$time = time();
2626

2727
$cache_path = '/tmp/cache_mbilling_codes.sqlite';
28-
exec('rm -rf ' . $cache_path);
28+
LinuxAccess::exec('rm -rf ' . $cache_path);
2929
$fields = "data,ip,code,msg";
3030
try {
3131
$db = new SQLite3($cache_path);
@@ -34,16 +34,16 @@ public function run($args)
3434

3535
}
3636

37-
if (!file_exists('/var/log/asterisk/magnus_processed ')) {
38-
exec('touch /var/log/asterisk/magnus_processed ');
37+
if ( ! file_exists('/var/log/asterisk/magnus_processed ')) {
38+
LinuxAccess::exec('touch /var/log/asterisk/magnus_processed ');
3939
}
4040

41-
exec('cp -rf /var/log/asterisk/magnus /var/log/asterisk/magnus_new');
41+
LinuxAccess::exec('cp -rf /var/log/asterisk/magnus /var/log/asterisk/magnus_new');
4242

43-
exec('diff -u /var/log/asterisk/magnus_processed /var/log/asterisk/magnus_new ', $lines);
43+
LinuxAccess::exec('diff -u /var/log/asterisk/magnus_processed /var/log/asterisk/magnus_new ', $lines);
4444

45-
exec('rm -rf /var/log/asterisk/magnus_processed');
46-
exec('mv /var/log/asterisk/magnus_new /var/log/asterisk/magnus_processed');
45+
LinuxAccess::exec('rm -rf /var/log/asterisk/magnus_processed');
46+
LinuxAccess::exec('mv /var/log/asterisk/magnus_new /var/log/asterisk/magnus_processed');
4747

4848
$values = '';
4949

@@ -52,7 +52,7 @@ public function run($args)
5252

5353
preg_match_all('/\[(.*)\] DEBUG.*\<sip\:.*@(.*)\>.*\|(.*)\|(.*)/', $line, $output_array);
5454

55-
if (count($output_array) < 4 || !isset($output_array[1][0])) {
55+
if (count($output_array) < 4 || ! isset($output_array[1][0])) {
5656

5757
continue;
5858
}

protected/commands/update.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ php /var/www/html/mbilling/cron.php UpdateMysql
3636
## remove unnecessary directories
3737
rm -rf /var/www/html/mbilling/doc
3838
rm -rf /var/www/html/mbilling/script
39+
rm -rf /var/www/html/mbilling/assets/*
3940
## set default permissions
4041
touch /etc/asterisk/extensions_magnus_did.conf
4142
chown -R asterisk:asterisk /var/lib/php/session*

protected/components/BaseController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,10 @@ public function actionCsv()
870870

871871
$columns = json_decode($_GET['columns'], true);
872872

873+
if (json_last_error() !== 0) {
874+
exit;
875+
}
876+
873877
$columns = $this->repaceColumns($columns);
874878

875879
$columns = $this->removeColumns($columns);

protected/components/LinuxAccess.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,8 @@ class LinuxAccess
1111

1212
public static function exec($command)
1313
{
14-
return exec($command);
15-
}
16-
17-
public static function system($command)
18-
{
19-
return exec($command);
14+
Yii::log($command, 'error');
15+
return exec($command, $output);
2016
}
2117

2218
public static function getDirectoryDiskSpaceUsed($filter = '*', $directory = '/var/spool/asterisk/monitor/')

0 commit comments

Comments
 (0)