diff --git a/build/MagnusBilling-current.tar.gz b/build/MagnusBilling-current.tar.gz index 14ff56b4a..fe4f6c8c9 100644 Binary files a/build/MagnusBilling-current.tar.gz and b/build/MagnusBilling-current.tar.gz differ diff --git a/protected/commands/CryptocurrencyCommand.php b/protected/commands/CryptocurrencyCommand.php index aa320c723..47741de3a 100755 --- a/protected/commands/CryptocurrencyCommand.php +++ b/protected/commands/CryptocurrencyCommand.php @@ -21,33 +21,48 @@ class CryptocurrencyCommand extends CConsoleCommand { public function run($args) { + $modelMethodPay = Methodpay::model()->find('payment_method = :key', array(':key' => 'cryptocurrency')); if (!isset($modelMethodPay->id)) { + echo 'No method found'; exit; } - $poloniex = new Poloniex($modelMethodPay->client_id, $modelMethodPay->client_secret); - //'1314121820' - $ticker = $poloniex->get_deposits_and_withdrawals(time() - 18000, time()); - foreach ($ticker as $type => $payment) { - if ($type == 'deposits') { - foreach ($payment as $key => $value) { - $modelCryptocurrency = Cryptocurrency::model()->find('amountCrypto = :key AND date > :key1', - array(':key' => $value['amount'], ':key1' => date('Y-m-d'))); - if (isset($modelCryptocurrency->id_user)) { - if (Refill::model()->countRefill($value['txid'], $modelCryptocurrency->id_user) == 0) { - $description = 'CriptoCurrency ' . $value['currency'] . ', txid: ' . $value['txid']; - echo ($modelCryptocurrency->id_user . ' ' . $modelCryptocurrency->amount . ' ' . $description . ' ' . $value['txid']); - Yii::log($modelCryptocurrency->id_user . ' ' . $modelCryptocurrency->amount . ' ' . $description . ' ' . $value['txid'], 'error'); - UserCreditManager::releaseUserCredit($modelCryptocurrency->id_user, $modelCryptocurrency->amount, $description, 1, $value['txid']); + + $last_30_minutes = time() - 38000; + $modelCryptocurrency = Cryptocurrency::model()->findAll('date > :key1 AND status = 1', + array(':key1' => date('Y-m-d'))); + + foreach ($modelCryptocurrency as $key => $payment) { + + $result = ''; + + echo "try get payments\n"; + exec('python3.9 /var/www/html/mbilling/protected/commands/crypto.py ' . $modelMethodPay->client_id . ' ' . $modelMethodPay->client_secret . ' ' . $payment->currency . ' ' . $last_30_minutes, $result); + $result = implode("\n", $result); + $result = json_decode($result); + + foreach ($result as $key => $value) { + + if ($value->amount == $payment->amountCrypto) { + + if (isset($payment->id_user)) { + + if (Refill::model()->countRefill($value->txId, $payment->id_user) == 0) { + Cryptocurrency::model()->updateByPk($payment->id, array('status' => 0)); + $description = 'CriptoCurrency ' . $value->coin . ', txid: ' . $value->txId; + + echo ($payment->id_user . ' ' . $payment->amount . ' ' . $description . ' ' . $value->txId); + Yii::log($payment->id_user . ' ' . $payment->amount . ' ' . $description . ' ' . $value->txId, 'error'); + + UserCreditManager::releaseUserCredit($payment->id_user, $payment->amount, $description, 1, $value->txId); } else { echo "Paymente already released\n"; } } else { echo "Receive new deposit in your wallet but not found any refill in your MagnusBilling\n"; } + } - } else { - echo "Not found deposit in your wallet\n"; } } diff --git a/protected/commands/UpdateMysqlCommand.php b/protected/commands/UpdateMysqlCommand.php index 2e85a721c..a57a3334f 100755 --- a/protected/commands/UpdateMysqlCommand.php +++ b/protected/commands/UpdateMysqlCommand.php @@ -1920,6 +1920,15 @@ public function run($args) $version = '7.8.3.7'; $this->update($version); } + + //2023-05-18 + if ($version == '7.8.3.7') { + $sql = "ALTER TABLE `pkg_user` CHANGE `prefix_local` `prefix_local` VARCHAR(500) NOT NULL DEFAULT '';"; + $this->executeDB($sql); + + $version = '7.8.3.8'; + $this->update($version); + } } public function executeDB($sql) diff --git a/protected/commands/crypto.py b/protected/commands/crypto.py new file mode 100755 index 000000000..8334236c1 --- /dev/null +++ b/protected/commands/crypto.py @@ -0,0 +1,36 @@ +""" +DEBIAN 11 + +sudo apt install wget build-essential libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev + +sudo apt install python3 +sudo apt install python3.9-pip +python3.9 -m pip install python-binance + +CENTOS 7 +yum install libffi-devel -y + +curl -O https://www.python.org/ftp/python/3.9.1/Python-3.9.1.tgz +tar -xzf Python-3.9.1.tgz +cd Python-3.9.1 +./configure --enable-optimizations +make altinstall + +python3.9 -m pip install --upgrade pip +pip3.9 install urllib3==1.26.6 +python3.9 -m pip install python-binance + +python3.9 /var/www/html/mbilling/protected/commands/crypto.py + +""" +import sys +import getopt +from binance.client import Client +import json +from binance.client import Client +import json +client = Client(sys.argv[1], sys.argv[2]) + + +res = client.get_deposit_history(coin=sys.argv[3],startTime=sys.argv[4]+'000') +print(json.dumps(res, indent=2)) \ No newline at end of file diff --git a/protected/components/Controller.php b/protected/components/Controller.php index c5e590c48..ac764b372 100755 --- a/protected/components/Controller.php +++ b/protected/components/Controller.php @@ -31,6 +31,8 @@ class Controller extends BaseController 'invoices', 'statusSystem', 'firewall', + 'trunkGroup', + 'callSummaryPerDay', ); //Allowed controllers to no admin users use updateall diff --git a/protected/components/Poloniex.php b/protected/components/Poloniex.php deleted file mode 100755 index 9ed6532da..000000000 --- a/protected/components/Poloniex.php +++ /dev/null @@ -1,268 +0,0 @@ - - * - */ -class Poloniex -{ - protected $api_key; - protected $api_secret; - protected $trading_url = "https://poloniex.com/tradingApi"; - protected $public_url = "https://poloniex.com/public"; - - public function __construct($api_key, $api_secret) - { - $this->api_key = $api_key; - $this->api_secret = $api_secret; - } - - private function query(array $req = array()) - { - // API settings - $key = $this->api_key; - $secret = $this->api_secret; - - // generate a nonce to avoid problems with 32bit systems - $mt = explode(' ', microtime()); - $req['nonce'] = $mt[1] . substr($mt[0], 2, 6); - - // generate the POST data string - $post_data = http_build_query($req, '', '&'); - $sign = hash_hmac('sha512', $post_data, $secret); - - // generate the extra headers - $headers = array( - 'Key: ' . $key, - 'Sign: ' . $sign, - ); - - // curl handle (initialize if required) - static $ch = null; - if (is_null($ch)) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_USERAGENT, - 'Mozilla/4.0 (compatible; Poloniex PHP bot; ' . php_uname('a') . '; PHP/' . phpversion() . ')' - ); - } - curl_setopt($ch, CURLOPT_URL, $this->trading_url); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - - // run the query - $res = curl_exec($ch); - - if ($res === false) { - throw new Exception('Curl error: ' . curl_error($ch)); - } - - //echo $res; - $dec = json_decode($res, true); - if (!$dec) { - //throw new Exception('Invalid data: '.$res); - return false; - } else { - return $dec; - } - } - - public function get_deposits_and_withdrawals($start, $stop) - { - return $this->query( - array( - 'command' => 'returnDepositsWithdrawals', - 'start' => $start, - 'end' => $stop, - ) - ); - } - - public function generate_new_address($pair) - { - return $this->query( - array( - 'command' => 'generateNewAddress', - 'currency' => $pair, - ) - ); - } - - protected function retrieveJSON($URL) - { - $opts = array('http' => array( - 'method' => 'GET', - 'timeout' => 10, - ), - ); - $context = stream_context_create($opts); - $feed = file_get_contents($URL, false, $context); - $json = json_decode($feed, true); - return $json; - } - - public function get_balances() - { - return $this->query( - array( - 'command' => 'returnBalances', - ) - ); - } - - public function get_open_orders($pair) - { - return $this->query( - array( - 'command' => 'returnOpenOrders', - 'currencyPair' => strtoupper($pair), - ) - ); - } - - public function get_my_trade_history($pair) - { - return $this->query( - array( - 'command' => 'returnTradeHistory', - 'currencyPair' => strtoupper($pair), - ) - ); - } - - public function buy($pair, $rate, $amount) - { - return $this->query( - array( - 'command' => 'buy', - 'currencyPair' => strtoupper($pair), - 'rate' => $rate, - 'amount' => $amount, - ) - ); - } - - public function sell($pair, $rate, $amount) - { - return $this->query( - array( - 'command' => 'sell', - 'currencyPair' => strtoupper($pair), - 'rate' => $rate, - 'amount' => $amount, - ) - ); - } - - public function cancel_order($pair, $order_number) - { - return $this->query( - array( - 'command' => 'cancelOrder', - 'currencyPair' => strtoupper($pair), - 'orderNumber' => $order_number, - ) - ); - } - - public function withdraw($currency, $amount, $address) - { - return $this->query( - array( - 'command' => 'withdraw', - 'currency' => strtoupper($currency), - 'amount' => $amount, - 'address' => $address, - ) - ); - } - - public function get_trade_history($pair) - { - $trades = $this->retrieveJSON($this->public_url . '?command=returnTradeHistory¤cyPair=' . strtoupper($pair)); - return $trades; - } - - public function get_order_book($pair) - { - $orders = $this->retrieveJSON($this->public_url . '?command=returnOrderBook¤cyPair=' . strtoupper($pair)); - return $orders; - } - - public function get_volume() - { - $volume = $this->retrieveJSON($this->public_url . '?command=return24hVolume'); - return $volume; - } - - public function get_ticker($pair = "ALL") - { - $pair = strtoupper($pair); - $prices = $this->retrieveJSON($this->public_url . '?command=returnTicker'); - if ($pair == "ALL") { - return $prices; - } else { - $pair = strtoupper($pair); - if (isset($prices[$pair])) { - return $prices[$pair]; - } else { - return array(); - } - } - } - - public function get_trading_pairs() - { - $tickers = $this->retrieveJSON($this->public_url . '?command=returnTicker'); - return array_keys($tickers); - } - - public function get_total_btc_balance() - { - $balances = $this->get_balances(); - $prices = $this->get_ticker(); - - $tot_btc = 0; - - foreach ($balances as $coin => $amount) { - $pair = "BTC_" . strtoupper($coin); - - // convert coin balances to btc value - if ($amount > 0) { - if ($coin != "BTC") { - $tot_btc += $amount * $prices[$pair]; - } else { - $tot_btc += $amount; - } - } - - // process open orders as well - if ($coin != "BTC") { - $open_orders = $this->get_open_orders($pair); - foreach ($open_orders as $order) { - if ($order['type'] == 'buy') { - $tot_btc += $order['total']; - } elseif ($order['type'] == 'sell') { - $tot_btc += $order['amount'] * $prices[$pair]; - } - } - } - } - - return $tot_btc; - } -} diff --git a/protected/models/User.php b/protected/models/User.php index b60546937..b10aff7d9 100755 --- a/protected/models/User.php +++ b/protected/models/User.php @@ -75,11 +75,11 @@ public function rules() array('language,mix_monitor_format,calllimit_error', 'length', 'max' => 5), array('zipcode, phone, mobile, vat', 'length', 'max' => 20), array('city, state, country, loginkey', 'length', 'max' => 40), - array('lastname, firstname, redial, prefix_local,neighborhood', 'length', 'max' => 50), + array('lastname, firstname, redial,neighborhood', 'length', 'max' => 50), array('company_website, dist', 'length', 'max' => 100), array('address, email,email2, doc', 'length', 'max' => 100), array('username', 'length', 'max' => 20), - array('description', 'length', 'max' => 500), + array('description, prefix_local', 'length', 'max' => 500), array('credit, contract_value', 'type', 'type' => 'double'), array('expirationdate, password, lastuse,company_name, commercial_name', 'length', 'max' => 100), array('username', 'checkusername'), diff --git a/protected/views/buyCredit/cryptocurrency.php b/protected/views/buyCredit/cryptocurrency.php index 852e698b0..880e88b2d 100755 --- a/protected/views/buyCredit/cryptocurrency.php +++ b/protected/views/buyCredit/cryptocurrency.php @@ -1,4 +1,7 @@ +
- - - - + + + +
- - - ' /> - ' /> -

- -
-
+ + + ' /> + ' /> +

+ +
+
session['currency']; } - $mb_credit = $_GET['amount'] + (rand(0, 10) / 10); + if (isset($_SESSION[$crypto]) && $_SESSION[$crypto] == $_GET['amount'] && isset($_SESSION['modelCryptocurrency_id'])) { - $url = 'https://api.coinconvert.net/convert/' . $MB_currency . '/' . $crypto . '?amount=' . $_GET['amount']; + $amountCrypto = $_SESSION['amountCrypto']; + $modelCryptocurrency = Cryptocurrency::model()->find('id = :key AND status = 0', + array(':key' => $_SESSION['modelCryptocurrency_id'])); - $amountCrypto = file_get_contents($url); - $amountCrypto = json_decode($amountCrypto); + if (isset($modelCryptocurrency->id)) { + unset($_SESSION['modelCryptocurrency_id']); + unset($_SESSION[$crypto]); + echo '


Your PAYMENT was Accepted successfully!
'; + exit; + } + } else { + $mb_credit = $_GET['amount'] + (rand(0, 10) / 10); - $amountCrypto = $amountCrypto->$crypto; + $url = 'https://api.coinconvert.net/convert/' . $MB_currency . '/' . $crypto . '?amount=' . $_GET['amount']; - $amountCrypto = number_format($amountCrypto, 6) . rand(11, 99); + $amountCrypto = file_get_contents($url); + $amountCrypto = json_decode($amountCrypto); - //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); + $amountCrypto = $amountCrypto->$crypto; - } else { - break; + $amountCrypto = number_format($amountCrypto, 4) . 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 = 1; + $modelCryptocurrency->save(); + + $_SESSION[$crypto] = $_GET['amount']; + $_SESSION['amountCrypto'] = $amountCrypto; + $_SESSION['modelCryptocurrency_id'] = $modelCryptocurrency->id; } - $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(); ?>
- - - - + + + +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 

Address: 

Credit:  

Crypto amount:  

Crypto Network:  

 
- Send the exact amount above in the next 30 min. -
- If you send different amount or after 30 min the refill not be released. -
 
- HOW BUY BITCOIN
https://www.bitcoin.com/buy-bitcoin
https://localbitcoins.com
https://poloniex.com
https://binance.com -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 

Address: 

Credit:  

Crypto amount:  

Crypto Network:  

 
+ Send the exact amount above in the next 30 min. +
+ If you send different amount or after 30 min the refill not be released. +
 
+ HOW BUY BITCOIN
https://www.bitcoin.com/buy-bitcoin
https://localbitcoins.com
https://poloniex.com
https://binance.com +
+
diff --git a/resources/images/success.jpg b/resources/images/success.jpg new file mode 100755 index 000000000..418842f20 Binary files /dev/null and b/resources/images/success.jpg differ diff --git a/script/install.sh b/script/install.sh index bce65aae2..5ce55135a 100755 --- a/script/install.sh +++ b/script/install.sh @@ -759,7 +759,6 @@ echo " 0 2 * * * php /var/www/html/mbilling/cron.php Backup 0 4 * * * /var/www/html/mbilling/protected/commands/clear_memory */2 * * * * php /var/www/html/mbilling/cron.php SummaryTablesCdr -* * * * * php /var/www/html/mbilling/cron.php cryptocurrency */3 * * * * php /var/www/html/mbilling/cron.php PhoneBooksReprocess * * * * * php /var/www/html/mbilling/cron.php statussystem * * * * * php /var/www/html/mbilling/cron.php didwww @@ -769,6 +768,9 @@ echo " " > $CRONPATH chmod 600 $CRONPATH +echo " +* * * * * root php /var/www/html/mbilling/cron.php cryptocurrency +">> /etc/crontab echo "