diff --git a/build/MagnusBilling-current.tar.gz b/build/MagnusBilling-current.tar.gz
index 75e5e8450..14ff56b4a 100644
Binary files a/build/MagnusBilling-current.tar.gz and b/build/MagnusBilling-current.tar.gz differ
diff --git a/protected/commands/UpdateMysqlCommand.php b/protected/commands/UpdateMysqlCommand.php
index 38fc3ab15..2e85a721c 100755
--- a/protected/commands/UpdateMysqlCommand.php
+++ b/protected/commands/UpdateMysqlCommand.php
@@ -1908,6 +1908,18 @@ public function run($args)
$version = '7.8.3.6';
$this->update($version);
}
+
+ //2023-05-03
+ if ($version == '7.8.3.6') {
+ $sql = "ALTER TABLE `pkg_method_pay` CHANGE `username` `username` VARCHAR(1000) NOT NULL";
+ $this->executeDB($sql);
+
+ $sql = "UPDATE pkg_method_pay SET username = CONCAT('BTC(BTC)=>',username) WHERE payment_method = 'cryptocurrency';";
+ $this->executeDB($sql);
+
+ $version = '7.8.3.7';
+ $this->update($version);
+ }
}
public function executeDB($sql)
diff --git a/protected/components/BaseController.php b/protected/components/BaseController.php
index 341a6e364..9e0aa8e9e 100755
--- a/protected/components/BaseController.php
+++ b/protected/components/BaseController.php
@@ -816,6 +816,8 @@ public function actionReport()
$this->setfilter($_GET);
+ $this->applyFilterToLimitedAdmin();
+
$fieldGroup = json_decode($_GET['group']);
$sort = json_decode($_GET['sort']);
diff --git a/protected/models/Methodpay.php b/protected/models/Methodpay.php
index 2aab2d9a5..abfb1fa7d 100755
--- a/protected/models/Methodpay.php
+++ b/protected/models/Methodpay.php
@@ -64,9 +64,10 @@ public function rules()
array('active, id_user, fee, SLIdProduto,min,max', 'numerical', 'integerOnly' => true),
array('obs, client_id, client_secret', 'length', 'max' => 500),
array('P2P_tax_amount', 'length', 'max' => 10),
- array('P2P_CustomerSiteID, P2P_KeyID, P2P_Passphrase, P2P_RecipientKeyID, username', 'length', 'max' => 100),
+ array('P2P_CustomerSiteID, P2P_KeyID, P2P_Passphrase, P2P_RecipientKeyID', 'length', 'max' => 100),
array('pagseguro_TOKEN,url, show_name, SLvalidationtoken', 'length', 'max' => 100),
array('SLAppToken,SLAccessToken,SLSecret', 'length', 'max' => 50),
+ array('username', 'length', 'max' => 1000),
);
return $this->getExtraField($rules);
}
diff --git a/protected/views/buyCredit/cryptocurrency.php b/protected/views/buyCredit/cryptocurrency.php
index 0fe1624b8..852e698b0 100755
--- a/protected/views/buyCredit/cryptocurrency.php
+++ b/protected/views/buyCredit/cryptocurrency.php
@@ -1,3 +1,5 @@
+
+
session['currency'] == 'U$S' || Yii::app()->session['currency'] == '$') {
- $currency = 'USD';
-} else if (Yii::app()->session['currency'] == 'R$') {
- $currency = 'BRL';
-} elseif (Yii::app()->session['currency'] == '€') {
- $currency = 'EUR';
-} elseif (Yii::app()->session['currency'] == 'AUD$') {
- $currency = 'AUD';
-} else {
- $currency = Yii::app()->session['currency'];
-}
+$wallets = explode('|', $modelMethodPay->username);
+
+if (!isset($_GET['network']) || !strlen($_GET['network'])) {
-$bitcoinPrice = file_get_contents('https://blockchain.info/tobtc?currency=' . $currency . '&value=' . $_GET['amount']);
+ ?>
+
+
+
+find('amountCrypto = :key AND date > :key1',
- array(':key' => $amountCrypto, ':key1' => date('Y-m-d')));
- if (isset($modelCryptocurrency->id)) {
- $amountCrypto = number_format($bitcoinPrice, 6) . rand(11, 99);
+ $data = explode('=>', $wallets[$_GET['network']]);
+ $address = $data[1];
+ $crypto = strtoupper(strtok($data[0], '('));
+ $network = '(' . strtok('');
+ if (Yii::app()->session['currency'] == 'U$S' || Yii::app()->session['currency'] == '$') {
+ $MB_currency = 'USD';
+ } else if (Yii::app()->session['currency'] == 'R$') {
+ $MB_currency = 'BRL';
+ } elseif (Yii::app()->session['currency'] == '€') {
+ $MB_currency = 'EUR';
+ } elseif (Yii::app()->session['currency'] == 'AUD$') {
+ $MB_currency = 'AUD';
} else {
- break;
+ $MB_currency = Yii::app()->session['currency'];
}
-}
-$modelCryptocurrency = new Cryptocurrency();
-$modelCryptocurrency->id_user = Yii::app()->session['id_user'];
-$modelCryptocurrency->currency = 'BTC';
-$modelCryptocurrency->amountCrypto = $amountCrypto;
-$modelCryptocurrency->amount = $_GET['amount'];
-$modelCryptocurrency->status = 0;
-$modelCryptocurrency->save();
-
-?>
-
-
+ $mb_credit = $_GET['amount'] + (rand(0, 10) / 10);
+
+ $url = 'https://api.coinconvert.net/convert/' . $MB_currency . '/' . $crypto . '?amount=' . $_GET['amount'];
+
+ $amountCrypto = file_get_contents($url);
+ $amountCrypto = json_decode($amountCrypto);
+
+ $amountCrypto = $amountCrypto->$crypto;
+
+ $amountCrypto = number_format($amountCrypto, 6) . rand(11, 99);
+
+ //avoid some amount in the same day
+ for (;;) {
+ $modelCryptocurrency = Cryptocurrency::model()->find('amountCrypto = :key AND date > :key1',
+ array(':key' => $amountCrypto, ':key1' => date('Y-m-d')));
+ if (isset($modelCryptocurrency->id)) {
+ $amountCrypto = number_format($bitcoinPrice, 6) . rand(11, 99);
+
+ } else {
+ break;
+ }
+ }
+ $modelCryptocurrency = new Cryptocurrency();
+ $modelCryptocurrency->id_user = Yii::app()->session['id_user'];
+ $modelCryptocurrency->currency = $crypto;
+ $modelCryptocurrency->amountCrypto = $amountCrypto;
+ $modelCryptocurrency->amount = $_GET['amount'];
+ $modelCryptocurrency->status = 0;
+ $modelCryptocurrency->save();
+
+ ?>
+
+
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/resources/asterisk/DidAgi.php b/resources/asterisk/DidAgi.php
index 90ca08061..97c63c815 100755
--- a/resources/asterisk/DidAgi.php
+++ b/resources/asterisk/DidAgi.php
@@ -101,8 +101,21 @@ public function checkIfIsDidCall(&$agi, &$MAGNUS, &$CalcAgi)
if ($this->modelDid->calllimit > 0) {
$agi->verbose('Check DID channels');
- $calls = AsteriskAccess::getCallsPerDid($this->modelDid->did);
- $agi->verbose('Did ' . $this->modelDid->did . ' have ' . $calls . ' Calls');
+ $asmanager = new AGI_AsteriskManager();
+ $asmanager->connect('localhost', 'magnus', 'magnussolution');
+ $channelsData = $asmanager->command('core show channels concise');
+
+ $channelsData = explode("\n", $channelsData["data"]);
+
+ $calls = 0;
+ foreach ($channelsData as $key => $line) {
+ if (preg_match("/AppDial.*$this->did/", $line)) {
+ $calls++;
+ }
+ }
+ $asmanager->disconnect();
+
+ $agi->verbose('Did ' . $this->did . ' have ' . $calls . ' Calls');
if ($calls >= $this->modelDid->calllimit) {
if ($MAGNUS->modelUser->calllimit_error == 403) {
@@ -120,12 +133,15 @@ public function checkIfIsDidCall(&$agi, &$MAGNUS, &$CalcAgi)
$sql = "SELECT * FROM pkg_did WHERE id_user = " . $MAGNUS->modelUser->id;
$modelDIDAll = $agi->query($sql)->fetchAll(PDO::FETCH_OBJ);
-
+ $asmanager = new AGI_AsteriskManager();
+ $asmanager->connect('localhost', 'magnus', 'magnussolution');
+ $channelsData = $asmanager->command('core show channels concise');
+ $channelsData = explode("\n", $channelsData["data"]);
+ $asmanager->disconnect();
$calls = 0;
foreach ($modelDIDAll as $key => $value) {
- $calls += AsteriskAccess::getCallsPerDid($value->did);
+ $calls += $this->getCallsPerDid($value->did, $agi, $channelsData);
}
-
if ($calls >= $MAGNUS->modelUser->inbound_call_limit) {
if ($MAGNUS->modelUser->calllimit_error == 403) {
$agi->execute((busy), busy);
@@ -149,6 +165,18 @@ public function checkIfIsDidCall(&$agi, &$MAGNUS, &$CalcAgi)
}
}
+
+ public function getCallsPerDid($did, $agi = null, $channelsData)
+ {
+ $calls = 0;
+ foreach ($channelsData as $key => $line) {
+ if (preg_match("/$did\!.*\!Dial\!/", $line)) {
+ $calls++;
+ }
+ }
+ return $calls;
+ }
+
public function checkDidDestinationType(&$agi, &$MAGNUS, &$CalcAgi)
{