Skip to content

Commit

Permalink
allow use other cryptocurrency and network
Browse files Browse the repository at this point in the history
  • Loading branch information
magnussolution committed May 8, 2023
1 parent 0b04a89 commit e8a6beb
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 49 deletions.
Binary file modified build/MagnusBilling-current.tar.gz
Binary file not shown.
12 changes: 12 additions & 0 deletions protected/commands/UpdateMysqlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions protected/components/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,8 @@ public function actionReport()

$this->setfilter($_GET);

$this->applyFilterToLimitedAdmin();

$fieldGroup = json_decode($_GET['group']);
$sort = json_decode($_GET['sort']);

Expand Down
3 changes: 2 additions & 1 deletion protected/models/Methodpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
138 changes: 96 additions & 42 deletions protected/views/buyCredit/cryptocurrency.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php header('Content-type: text/html; charset=utf-8');?>
<link rel="stylesheet" type="text/css" href="../../../resources/css/signup.css" />
<?php
/**
* Modelo para a tabela "Balance".
Expand All @@ -19,81 +21,133 @@
* 04/01/2018
*/

if (Yii::app()->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']);
?>

<br>
<form id="contactform" align="center" method="get">
<table width="100%" border="0" align="center">
<tr>
<td class="banco">
<table width="100%" border="0">
<select style="width: 100%" name="network" id="network">
<option value="">SELECT THE CURRENCY AND NETWORK</option>
<?php foreach ($wallets as $key => $wallet): ?>
<option value="<?php echo $key ?>"><?php echo $wallet ?></option>
<?php endforeach;?>
</select>
<input type='hidden' name='amount' value='<?php echo $_GET['amount'] ?>' />
<input type='hidden' name='id_method' value='<?php echo $_GET['id_method'] ?>' />
<br> <br>
<input type="submit" value="Confirm">
</table>
</td>
</tr>
</tr>
</table>
</form>
<?php

$amountCrypto = number_format($bitcoinPrice, 6) . rand(11, 99);
} else {

//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);
$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();

?>
<?php header('Content-type: text/html; charset=utf-8');?>

<link rel="stylesheet" type="text/css" href="../../../resources/css/signup.css" />
$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();

?>


<form id="contactform" align="center">
<table width="100%" border="0" align="center">
<tr>
<td class="banco">
<table width="100%" border="0">
<tr><td>&nbsp;</td></tr>
<tr>
<td width="350"><p style="text-align: right;"><b>Account:&nbsp;</b></p></td>
<td><p style="text-align: left;"><?php echo $modelMethodPay->username; ?></p></td>
<td width="350"><p style="text-align: right;"><b>Address:&nbsp;</b></p></td>
<td><p style="text-align: left;"><?php echo $address; ?></p></td>
</tr>
<tr>
<td width="350"><p style="text-align: right;"><b><?php echo $currency ?> Amount: &nbsp;</b></p></td>
<td width="400"><p style="text-align: left;"><?php echo $currency ?> <?php echo number_format($_GET['amount'], 2) ?></p></td>
<td width="350"><p style="text-align: right;"><b><?php echo strtoupper($MB_currency) ?> Credit: &nbsp;</b></p></td>
<td width="400"><p style="text-align: left;"><?php echo $MB_currency ?> <?php echo number_format($_GET['amount'], 2) ?></p></td>
</tr>
<tr>
<td width="350"><p style="text-align: right;"><b>BitCoin amount: &nbsp;</b></p></td>
<td width="400"><p style="text-align: left;">BTC <?php echo $amountCrypto ?></p></td>
<td width="350"><p style="text-align: right;"><b>Crypto amount: &nbsp;</b></p></td>
<td width="400"><p style="text-align: left;"><?php echo $crypto ?> <?php echo $amountCrypto ?></p></td>
</tr>
<tr>
<td width="350"><p style="text-align: right;"><b>Crypto Network: &nbsp;</b></p></td>
<td width="400"><p style="text-align: left;"><?php echo $network ?> </p></td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td width="350" colspan="2" style="text-align: center; font:bold 13px Arial, Helvetica, sans-serif; color:#0e119b;">
Send the exact amount above in the next 30 min.
</td>
</tr>

<tr>
<td width="350" colspan="2" style="text-align: center; font:bold 13px Arial, Helvetica, sans-serif; color:#fc0404;">
If you send different amount or after 30 min the refill not be automatic.
If you send different amount or after 30 min the refill not be released.
</td>
</tr>

<tr><td>&nbsp;</td></tr>

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

</table>
</td>
</tr>
</tr>
</table>
</form>
</form>

<?php }?>
38 changes: 33 additions & 5 deletions resources/asterisk/DidAgi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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)
{

Expand Down
2 changes: 1 addition & 1 deletion script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ installBr() {
clear
language='br'
cd /var/lib/asterisk
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
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
tar xzf Disc-OS-Sounds-1.0-pt_BR.tar.gz
rm -rf Disc-OS-Sounds-1.0-pt_BR.tar.gz

Expand Down

0 comments on commit e8a6beb

Please sign in to comment.