Skip to content

Commit 83e2f61

Browse files
fix trunkSIPcodes
1 parent be0cb79 commit 83e2f61

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

protected/commands/TrunkSIPCodesCommand.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* =======================================
45
* ###################################
@@ -31,20 +32,19 @@ public function run($args)
3132
$db = new SQLite3($cache_path);
3233
$db->exec('CREATE TABLE IF NOT EXISTS sipcodes (' . $fields . ');');
3334
} catch (Exception $e) {
34-
3535
}
3636

37-
if ( ! file_exists('/var/log/asterisk/magnus_processed ')) {
37+
if (! file_exists('/var/log/asterisk/magnus_processed ')) {
3838

3939
file_put_contents('/var/log/asterisk/magnus_processed', '');
4040
}
4141

42-
copy('cp -rf /var/log/asterisk/magnus /var/log/asterisk/magnus_new');
42+
copy('/var/log/asterisk/magnus', '/var/log/asterisk/magnus_new');
4343

4444
$lines = LinuxAccess::exec('diff -u /var/log/asterisk/magnus_processed /var/log/asterisk/magnus_new');
4545

46-
unlinkc('/var/log/asterisk/magnus_processed');
47-
rename('/var/log/asterisk/magnus_new /var/log/asterisk/magnus_processed');
46+
unlink('/var/log/asterisk/magnus_processed');
47+
rename('/var/log/asterisk/magnus_new', '/var/log/asterisk/magnus_processed');
4848

4949
$values = '';
5050

@@ -75,7 +75,6 @@ public function run($args)
7575
} else {
7676
$i++;
7777
}
78-
7978
}
8079

8180
if ($i < 200 && $i > 0) {
@@ -115,7 +114,6 @@ public function run($args)
115114
}
116115
}
117116
}
118-
119117
}
120118
}
121119
}

protected/components/LinuxAccess.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ public static function exec($command)
1414
{
1515

1616
Yii::log('LinuxAccess::exec -> ' . $command, 'error');
17-
$sanitized = escapeshellcmd($command);
18-
exec($sanitized, $output);
17+
exec($command, $output);
1918
return $output;
2019
}
2120

protected/controllers/DidwwController.php

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Acoes do modulo "Call".
45
*
@@ -31,11 +32,17 @@ class DidwwController extends Controller
3132

3233
public function init()
3334
{
35+
36+
3437
parent::init();
3538
$this->api_key = $this->config['global']['didww_api_key'];
3639
$this->url = $this->config['global']['didww_url'];
3740
$this->profit = '1.' . $this->config['global']['didww_profit'];
3841
$this->currency_converter = $this->config['global']['didww_curreny_converter'];
42+
43+
if (strlen($this->api_key) < 10) {
44+
exit;
45+
}
3946
}
4047

4148
public function actionAdd()
@@ -50,7 +57,6 @@ public function actionAdd()
5057
'status' => $this->orderDid(),
5158

5259
]);
53-
5460
} else if (isset($_POST['Did']['did'])) {
5561

5662
$this->render('confirmation', [
@@ -59,34 +65,30 @@ public function actionAdd()
5965
'profit' => $this->profit,
6066

6167
]);
62-
6368
} elseif (isset($_POST['Did']['city'])) {
6469
$this->render('did', [
6570
'did' => $did,
6671
'dids' => $this->getDids($_POST['Did']['city']),
6772

6873
]);
69-
7074
} else if (isset($_POST['Did']['country'])) {
7175

7276
$this->render('city', [
7377
'did' => $did,
7478
'cities' => $this->getCities($_POST['Did']['country']),
7579
]);
76-
7780
} else {
7881
$this->render('country', [
7982
'did' => $did,
8083
'countries' => $this->getCountries(),
8184
]);
8285
}
83-
8486
}
8587

8688
public function confirmeDid($id_did)
8789
{
8890

89-
if ( ! is_numeric($id_did)) {
91+
if (! is_numeric($id_did)) {
9092
exit;
9193
}
9294

@@ -146,14 +148,15 @@ public function orderDid()
146148
'type' => 'orders',
147149
'attributes' => [
148150
'allow_back_ordering' => true,
149-
'items' => [[
150-
'type' => 'did_order_items',
151-
'attributes' => [
152-
'qty' => '1',
153-
'sku_id' => Yii::app()->session['sku_id'],
154-
],
151+
'items' => [
152+
[
153+
'type' => 'did_order_items',
154+
'attributes' => [
155+
'qty' => '1',
156+
'sku_id' => Yii::app()->session['sku_id'],
157+
],
155158

156-
],
159+
],
157160
],
158161
],
159162
],
@@ -209,13 +212,12 @@ public function orderDid()
209212
}
210213

211214
return $order->data->attributes->status;
212-
213215
}
214216

215217
public function getDids($id_city)
216218
{
217219

218-
if ( ! is_numeric($id_city)) {
220+
if (! is_numeric($id_city)) {
219221
exit;
220222
}
221223

@@ -247,7 +249,7 @@ public function getDids($id_city)
247249

248250
$dids = json_decode($result);
249251

250-
if ( ! isset($dids->data[0]->id)) {
252+
if (! isset($dids->data[0]->id)) {
251253

252254
echo 'We not have DID to this city. <a href="' . $_SERVER['REQUEST_URI'] . '"> Click here to restart<a/>';
253255
exit;
@@ -262,7 +264,6 @@ public function getDids($id_city)
262264
}
263265

264266
return $result;
265-
266267
}
267268

268269
public function getCities($country_id)
@@ -313,17 +314,15 @@ public function getCities($country_id)
313314
if (count($did_groups->data) >= 1000) {
314315
break;
315316
}
316-
317317
}
318318

319-
if ( ! isset($result[0])) {
319+
if (! isset($result[0])) {
320320

321321
echo 'We not have DID to this city. <a href="' . $_SERVER['REQUEST_URI'] . '"> Click here to restart<a/>';
322322
exit;
323323
}
324324

325325
return $result;
326-
327326
}
328327

329328
public function getCountries()
@@ -377,7 +376,5 @@ public function getCountries()
377376
exit('Invalid data');
378377
}
379378
return $result;
380-
381379
}
382-
383380
}

0 commit comments

Comments
 (0)