Skip to content

Commit e8a6beb

Browse files
author
magnussolution
committed
allow use other cryptocurrency and network
1 parent 0b04a89 commit e8a6beb

File tree

7 files changed

+146
-49
lines changed

7 files changed

+146
-49
lines changed

build/MagnusBilling-current.tar.gz

2.18 KB
Binary file not shown.

protected/commands/UpdateMysqlCommand.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,6 +1908,18 @@ public function run($args)
19081908
$version = '7.8.3.6';
19091909
$this->update($version);
19101910
}
1911+
1912+
//2023-05-03
1913+
if ($version == '7.8.3.6') {
1914+
$sql = "ALTER TABLE `pkg_method_pay` CHANGE `username` `username` VARCHAR(1000) NOT NULL";
1915+
$this->executeDB($sql);
1916+
1917+
$sql = "UPDATE pkg_method_pay SET username = CONCAT('BTC(BTC)=>',username) WHERE payment_method = 'cryptocurrency';";
1918+
$this->executeDB($sql);
1919+
1920+
$version = '7.8.3.7';
1921+
$this->update($version);
1922+
}
19111923
}
19121924

19131925
public function executeDB($sql)

protected/components/BaseController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ public function actionReport()
816816

817817
$this->setfilter($_GET);
818818

819+
$this->applyFilterToLimitedAdmin();
820+
819821
$fieldGroup = json_decode($_GET['group']);
820822
$sort = json_decode($_GET['sort']);
821823

protected/models/Methodpay.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ public function rules()
6464
array('active, id_user, fee, SLIdProduto,min,max', 'numerical', 'integerOnly' => true),
6565
array('obs, client_id, client_secret', 'length', 'max' => 500),
6666
array('P2P_tax_amount', 'length', 'max' => 10),
67-
array('P2P_CustomerSiteID, P2P_KeyID, P2P_Passphrase, P2P_RecipientKeyID, username', 'length', 'max' => 100),
67+
array('P2P_CustomerSiteID, P2P_KeyID, P2P_Passphrase, P2P_RecipientKeyID', 'length', 'max' => 100),
6868
array('pagseguro_TOKEN,url, show_name, SLvalidationtoken', 'length', 'max' => 100),
6969
array('SLAppToken,SLAccessToken,SLSecret', 'length', 'max' => 50),
70+
array('username', 'length', 'max' => 1000),
7071
);
7172
return $this->getExtraField($rules);
7273
}
Lines changed: 96 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<?php header('Content-type: text/html; charset=utf-8');?>
2+
<link rel="stylesheet" type="text/css" href="../../../resources/css/signup.css" />
13
<?php
24
/**
35
* Modelo para a tabela "Balance".
@@ -19,81 +21,133 @@
1921
* 04/01/2018
2022
*/
2123

22-
if (Yii::app()->session['currency'] == 'U$S' || Yii::app()->session['currency'] == '$') {
23-
$currency = 'USD';
24-
} else if (Yii::app()->session['currency'] == 'R$') {
25-
$currency = 'BRL';
26-
} elseif (Yii::app()->session['currency'] == '') {
27-
$currency = 'EUR';
28-
} elseif (Yii::app()->session['currency'] == 'AUD$') {
29-
$currency = 'AUD';
30-
} else {
31-
$currency = Yii::app()->session['currency'];
32-
}
24+
$wallets = explode('|', $modelMethodPay->username);
25+
26+
if (!isset($_GET['network']) || !strlen($_GET['network'])) {
3327

34-
$bitcoinPrice = file_get_contents('https://blockchain.info/tobtc?currency=' . $currency . '&value=' . $_GET['amount']);
28+
?>
29+
30+
<br>
31+
<form id="contactform" align="center" method="get">
32+
<table width="100%" border="0" align="center">
33+
<tr>
34+
<td class="banco">
35+
<table width="100%" border="0">
36+
<select style="width: 100%" name="network" id="network">
37+
<option value="">SELECT THE CURRENCY AND NETWORK</option>
38+
<?php foreach ($wallets as $key => $wallet): ?>
39+
<option value="<?php echo $key ?>"><?php echo $wallet ?></option>
40+
<?php endforeach;?>
41+
</select>
42+
<input type='hidden' name='amount' value='<?php echo $_GET['amount'] ?>' />
43+
<input type='hidden' name='id_method' value='<?php echo $_GET['id_method'] ?>' />
44+
<br> <br>
45+
<input type="submit" value="Confirm">
46+
</table>
47+
</td>
48+
</tr>
49+
</tr>
50+
</table>
51+
</form>
52+
<?php
3553

36-
$amountCrypto = number_format($bitcoinPrice, 6) . rand(11, 99);
54+
} else {
3755

38-
//avoid some amount in the same day
39-
for (;;) {
40-
$modelCryptocurrency = Cryptocurrency::model()->find('amountCrypto = :key AND date > :key1',
41-
array(':key' => $amountCrypto, ':key1' => date('Y-m-d')));
42-
if (isset($modelCryptocurrency->id)) {
43-
$amountCrypto = number_format($bitcoinPrice, 6) . rand(11, 99);
56+
$data = explode('=>', $wallets[$_GET['network']]);
57+
$address = $data[1];
58+
$crypto = strtoupper(strtok($data[0], '('));
59+
$network = '(' . strtok('');
4460

61+
if (Yii::app()->session['currency'] == 'U$S' || Yii::app()->session['currency'] == '$') {
62+
$MB_currency = 'USD';
63+
} else if (Yii::app()->session['currency'] == 'R$') {
64+
$MB_currency = 'BRL';
65+
} elseif (Yii::app()->session['currency'] == '') {
66+
$MB_currency = 'EUR';
67+
} elseif (Yii::app()->session['currency'] == 'AUD$') {
68+
$MB_currency = 'AUD';
4569
} else {
46-
break;
70+
$MB_currency = Yii::app()->session['currency'];
4771
}
48-
}
49-
$modelCryptocurrency = new Cryptocurrency();
50-
$modelCryptocurrency->id_user = Yii::app()->session['id_user'];
51-
$modelCryptocurrency->currency = 'BTC';
52-
$modelCryptocurrency->amountCrypto = $amountCrypto;
53-
$modelCryptocurrency->amount = $_GET['amount'];
54-
$modelCryptocurrency->status = 0;
55-
$modelCryptocurrency->save();
56-
57-
?>
58-
<?php header('Content-type: text/html; charset=utf-8');?>
5972

60-
<link rel="stylesheet" type="text/css" href="../../../resources/css/signup.css" />
73+
$mb_credit = $_GET['amount'] + (rand(0, 10) / 10);
74+
75+
$url = 'https://api.coinconvert.net/convert/' . $MB_currency . '/' . $crypto . '?amount=' . $_GET['amount'];
76+
77+
$amountCrypto = file_get_contents($url);
78+
$amountCrypto = json_decode($amountCrypto);
79+
80+
$amountCrypto = $amountCrypto->$crypto;
81+
82+
$amountCrypto = number_format($amountCrypto, 6) . rand(11, 99);
83+
84+
//avoid some amount in the same day
85+
for (;;) {
86+
$modelCryptocurrency = Cryptocurrency::model()->find('amountCrypto = :key AND date > :key1',
87+
array(':key' => $amountCrypto, ':key1' => date('Y-m-d')));
88+
if (isset($modelCryptocurrency->id)) {
89+
$amountCrypto = number_format($bitcoinPrice, 6) . rand(11, 99);
90+
91+
} else {
92+
break;
93+
}
94+
}
95+
$modelCryptocurrency = new Cryptocurrency();
96+
$modelCryptocurrency->id_user = Yii::app()->session['id_user'];
97+
$modelCryptocurrency->currency = $crypto;
98+
$modelCryptocurrency->amountCrypto = $amountCrypto;
99+
$modelCryptocurrency->amount = $_GET['amount'];
100+
$modelCryptocurrency->status = 0;
101+
$modelCryptocurrency->save();
102+
103+
?>
104+
105+
61106
<form id="contactform" align="center">
62107
<table width="100%" border="0" align="center">
63108
<tr>
64109
<td class="banco">
65110
<table width="100%" border="0">
111+
<tr><td>&nbsp;</td></tr>
66112
<tr>
67-
<td width="350"><p style="text-align: right;"><b>Account:&nbsp;</b></p></td>
68-
<td><p style="text-align: left;"><?php echo $modelMethodPay->username; ?></p></td>
113+
<td width="350"><p style="text-align: right;"><b>Address:&nbsp;</b></p></td>
114+
<td><p style="text-align: left;"><?php echo $address; ?></p></td>
69115
</tr>
70116
<tr>
71-
<td width="350"><p style="text-align: right;"><b><?php echo $currency ?> Amount: &nbsp;</b></p></td>
72-
<td width="400"><p style="text-align: left;"><?php echo $currency ?> <?php echo number_format($_GET['amount'], 2) ?></p></td>
117+
<td width="350"><p style="text-align: right;"><b><?php echo strtoupper($MB_currency) ?> Credit: &nbsp;</b></p></td>
118+
<td width="400"><p style="text-align: left;"><?php echo $MB_currency ?> <?php echo number_format($_GET['amount'], 2) ?></p></td>
73119
</tr>
74120
<tr>
75-
<td width="350"><p style="text-align: right;"><b>BitCoin amount: &nbsp;</b></p></td>
76-
<td width="400"><p style="text-align: left;">BTC <?php echo $amountCrypto ?></p></td>
121+
<td width="350"><p style="text-align: right;"><b>Crypto amount: &nbsp;</b></p></td>
122+
<td width="400"><p style="text-align: left;"><?php echo $crypto ?> <?php echo $amountCrypto ?></p></td>
77123
</tr>
124+
<tr>
125+
<td width="350"><p style="text-align: right;"><b>Crypto Network: &nbsp;</b></p></td>
126+
<td width="400"><p style="text-align: left;"><?php echo $network ?> </p></td>
127+
</tr>
128+
<tr><td>&nbsp;</td></tr>
78129
<tr>
79130
<td width="350" colspan="2" style="text-align: center; font:bold 13px Arial, Helvetica, sans-serif; color:#0e119b;">
80131
Send the exact amount above in the next 30 min.
81132
</td>
82133
</tr>
134+
83135
<tr>
84136
<td width="350" colspan="2" style="text-align: center; font:bold 13px Arial, Helvetica, sans-serif; color:#fc0404;">
85-
If you send different amount or after 30 min the refill not be automatic.
137+
If you send different amount or after 30 min the refill not be released.
86138
</td>
87139
</tr>
88-
140+
<tr><td>&nbsp;</td></tr>
89141

90142
<td style="text-align: center;" colspan="2" class="banco" style="top: 100px;font:bold 13px Arial, Helvetica, sans-serif; color:#333;">
91-
HOW BUY BITCOIN <br> https://www.bitcoin.com/buy-bitcoin <br> https://localbitcoins.com<br> https://binance.com
143+
HOW BUY BITCOIN <br> https://www.bitcoin.com/buy-bitcoin <br> https://localbitcoins.com<br> https://poloniex.com<br> https://binance.com
92144
</td>
93145

94146
</table>
95147
</td>
96148
</tr>
97149
</tr>
98150
</table>
99-
</form>
151+
</form>
152+
153+
<?php }?>

resources/asterisk/DidAgi.php

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,21 @@ public function checkIfIsDidCall(&$agi, &$MAGNUS, &$CalcAgi)
101101

102102
if ($this->modelDid->calllimit > 0) {
103103
$agi->verbose('Check DID channels');
104-
$calls = AsteriskAccess::getCallsPerDid($this->modelDid->did);
105-
$agi->verbose('Did ' . $this->modelDid->did . ' have ' . $calls . ' Calls');
104+
$asmanager = new AGI_AsteriskManager();
105+
$asmanager->connect('localhost', 'magnus', 'magnussolution');
106+
$channelsData = $asmanager->command('core show channels concise');
107+
108+
$channelsData = explode("\n", $channelsData["data"]);
109+
110+
$calls = 0;
111+
foreach ($channelsData as $key => $line) {
112+
if (preg_match("/AppDial.*$this->did/", $line)) {
113+
$calls++;
114+
}
115+
}
116+
$asmanager->disconnect();
117+
118+
$agi->verbose('Did ' . $this->did . ' have ' . $calls . ' Calls');
106119
if ($calls >= $this->modelDid->calllimit) {
107120

108121
if ($MAGNUS->modelUser->calllimit_error == 403) {
@@ -120,12 +133,15 @@ public function checkIfIsDidCall(&$agi, &$MAGNUS, &$CalcAgi)
120133

121134
$sql = "SELECT * FROM pkg_did WHERE id_user = " . $MAGNUS->modelUser->id;
122135
$modelDIDAll = $agi->query($sql)->fetchAll(PDO::FETCH_OBJ);
123-
136+
$asmanager = new AGI_AsteriskManager();
137+
$asmanager->connect('localhost', 'magnus', 'magnussolution');
138+
$channelsData = $asmanager->command('core show channels concise');
139+
$channelsData = explode("\n", $channelsData["data"]);
140+
$asmanager->disconnect();
124141
$calls = 0;
125142
foreach ($modelDIDAll as $key => $value) {
126-
$calls += AsteriskAccess::getCallsPerDid($value->did);
143+
$calls += $this->getCallsPerDid($value->did, $agi, $channelsData);
127144
}
128-
129145
if ($calls >= $MAGNUS->modelUser->inbound_call_limit) {
130146
if ($MAGNUS->modelUser->calllimit_error == 403) {
131147
$agi->execute((busy), busy);
@@ -149,6 +165,18 @@ public function checkIfIsDidCall(&$agi, &$MAGNUS, &$CalcAgi)
149165
}
150166

151167
}
168+
169+
public function getCallsPerDid($did, $agi = null, $channelsData)
170+
{
171+
$calls = 0;
172+
foreach ($channelsData as $key => $line) {
173+
if (preg_match("/$did\!.*\!Dial\!/", $line)) {
174+
$calls++;
175+
}
176+
}
177+
return $calls;
178+
}
179+
152180
public function checkDidDestinationType(&$agi, &$MAGNUS, &$CalcAgi)
153181
{
154182

script/install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ installBr() {
507507
clear
508508
language='br'
509509
cd /var/lib/asterisk
510-
wget --no-check-certificate https://sourceforge.net/projects/disc-os/files/Disc-OS%20Sounds/1.0-RELEASE/Disc-OS-Sounds-1.0-pt_BR.tar.gz
510+
wget --no-check-certificate https://ufpr.dl.sourceforge.net/project/disc-os/Disc-OS%20Sounds/1.0-RELEASE/Disc-OS-Sounds-1.0-pt_BR.tar.gz
511511
tar xzf Disc-OS-Sounds-1.0-pt_BR.tar.gz
512512
rm -rf Disc-OS-Sounds-1.0-pt_BR.tar.gz
513513

0 commit comments

Comments
 (0)