-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e7d526e
Showing
337 changed files
with
49,949 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deny from all |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/** | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v2.1 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues | ||
* ======================================= | ||
* Magnusbilling.com <[email protected]> | ||
* | ||
*/ | ||
class BackupCommand extends ConsoleCommand | ||
{ | ||
public function run($args) | ||
{ | ||
$dbString = explode('dbname=', Yii::app()->db->connectionString); | ||
$dataBase = end($dbString); | ||
|
||
$username = Yii::app()->db->username; | ||
$password = Yii::app()->db->password; | ||
$data = date("d-m-Y"); | ||
$comando = "mysqldump -u" . $username . " -p" . $password . " " . $dataBase . " --ignore-table=" . $dataBase . ".pkg_portabilidade --ignore-table=" . $dataBase . ".pkg_cdr_archive --ignore-table=" . $dataBase . ".pkg_cdr_failed > /tmp/base.sql"; | ||
LinuxAccess::exec($comando); | ||
LinuxAccess::exec("tar czvf /usr/local/src/magnus/backup/backup_voip_Magnus.$data.tgz /tmp/base.sql /etc/asterisk"); | ||
LinuxAccess::exec("rm -f /tmp/base.sql"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
/** | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v2.1 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues | ||
* ======================================= | ||
* Magnusbilling.com <[email protected]> | ||
* | ||
*/ | ||
class CallArchiveCommand extends ConsoleCommand | ||
{ | ||
public function run($args) | ||
{ | ||
$prior_x_month = $this->config['global']['archive_call_prior_x_month']; | ||
|
||
$condition = "DATE_SUB(NOW(),INTERVAL $prior_x_month MONTH) > starttime"; | ||
|
||
CallFailed::model()->createDataBaseIfNotExist(); | ||
|
||
$c = 0; | ||
$tables = array('pkg_cdr', 'pkg_cdr_failed'); | ||
foreach ($tables as $key => $table) { | ||
|
||
$sql = "SELECT count(*) AS count FROM $table WHERE $condition "; | ||
$result = Yii::app()->db->createCommand($sql)->queryAll(); | ||
|
||
$loop = number_format($result[0]['count'] / 10000, 0); | ||
|
||
if ($table == 'pkg_cdr') { | ||
$func_fields = "id_user, id_plan, id_prefix, id_trunk, sessionid, uniqueid, starttime, stoptime, sessiontime, calledstation, sessionbill, sipiax, src, buycost, real_sessiontime, terminatecauseid, agent_bill"; | ||
} else { | ||
$func_fields = "id_user, id_plan, id_prefix, id_trunk, sessionid, uniqueid, starttime, calledstation, sipiax, src, terminatecauseid"; | ||
} | ||
|
||
if ($c == 0) { | ||
$condition = $condition . " ORDER BY id LIMIT 10000"; | ||
$c++; | ||
} | ||
|
||
for ($i = 0; $i < $loop; $i++) { | ||
echo "New insert \n"; | ||
$sql = "INSERT INTO " . $table . "_archive ($func_fields) SELECT $func_fields FROM " . $table . " WHERE $condition"; | ||
try { | ||
Yii::app()->db->createCommand($sql)->execute(); | ||
} catch (Exception $e) { | ||
|
||
} | ||
$sql = "DELETE FROM $table WHERE $condition"; | ||
Yii::app()->db->createCommand($sql)->execute(); | ||
sleep(60); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
/** | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v2.1 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues | ||
* ======================================= | ||
* Magnusbilling.com <[email protected]> | ||
* | ||
*/ | ||
class CallChartCommand extends ConsoleCommand | ||
{ | ||
public function run($args) | ||
{ | ||
for ($i = 0; $i < 5; $i++) { | ||
|
||
$channelsData = AsteriskAccess::instance()->coreShowChannelsConcise(); | ||
$arr = explode("\n", $channelsData["data"]); | ||
|
||
$total = 0; | ||
|
||
foreach ($arr as $key => $value) { | ||
if (preg_match("/Up/", $value)) { | ||
$total++; | ||
} | ||
} | ||
|
||
$total = intval($total / 2); | ||
|
||
if ($i == 0) { | ||
$modelCallOnlineChart = new CallOnlineChart(); | ||
$modelCallOnlineChart->date = date('Y-m-d H:i:s'); | ||
$modelCallOnlineChart->answer = $total; | ||
$modelCallOnlineChart->total = 0; | ||
$modelCallOnlineChart->save(); | ||
|
||
$id = $modelCallOnlineChart->id; | ||
$total1 = $total; | ||
} else { | ||
if ($total > $total1) { | ||
$modelCallOnlineChart = CallOnlineChart::model()->findByPk((int) $id); | ||
$modelCallOnlineChart->answer = $total; | ||
$modelCallOnlineChart->save(); | ||
} | ||
} | ||
|
||
if (date('H:i') == '23:52') { | ||
CallOnlineChart::model()->deleteAll('date < :key', array(':key' => date('Y-m-d'))); | ||
} | ||
|
||
sleep(12); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?php | ||
/** | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v2.1 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues | ||
* ======================================= | ||
* Magnusbilling.com <[email protected]> | ||
* | ||
*/ | ||
class CriaClienteSLCommand extends ConsoleCommand | ||
{ | ||
|
||
public function run($args) | ||
{ | ||
$modelUser = User::model()->findAll('id_sacado_sac IS NULL AND id_group > 1'); | ||
foreach ($modelUser as $key => $user) { | ||
$modelMethodPay = Methodpay::model()->find('payment_method = :key AND active = 0', array(':key' => 'SuperLogica')); | ||
if (count($modelMethodPay) > 0) { | ||
|
||
$response = $this->saveUserSLCurl($user, $modelMethodPay->SLAppToken | ||
, $modelMethodPay->SLAccessToken); | ||
|
||
$user->id_sacado_sac = isset($response[0]->data->id_sacado_sac) | ||
? $response[0]->data->id_sacado_sac | ||
: -1; | ||
$user->save(); | ||
} | ||
} | ||
|
||
} | ||
|
||
public function saveUserSLCurl($model, $SLAppToken, $SLAccessToken) | ||
{ | ||
$url = "http://api.superlogica.net:80/v2/financeiro/clientes"; | ||
|
||
$params = array("ST_NOME_SAC" => $model->firstname . ' ' . $model->lastname, | ||
"ST_NOMEREF_SAC" => $model->username, | ||
"ST_DIAVENCIMENTO_SAC" => date('d'), | ||
"ST_CGC_SAC " => $model->vat, | ||
"ST_RG_SAC" => $model->doc, | ||
"ST_CEP_SAC" => $model->zipcode, | ||
"ST_ENDERECO_SAC" => $model->address, | ||
"ST_CIDADE_SAC" => $model->city, | ||
"ST_ESTADO_SAC" => $model->state, | ||
"ST_EMAIL_SAC" => $model->email, | ||
"SENHA" => $model->password, | ||
"SENHA_CONFIRMACAO" => $model->password, | ||
"ST_TELEFONE_SAC" => $model->phone, | ||
); | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, $url); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | ||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | ||
|
||
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded", | ||
"app_token: " . $SLAppToken, | ||
"access_token:" . $SLAccessToken, | ||
)); | ||
|
||
$params['identificador'] = '10000' . $model->id; | ||
|
||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); | ||
$response = (array) json_decode(curl_exec($ch)); | ||
|
||
print_r($response); | ||
curl_close($ch); | ||
if (isset($response[0]->status) && $response[0]->status != 200) { | ||
|
||
echo json_encode(array( | ||
'success' => false, | ||
'rows' => array(), | ||
'errors' => Yii::t('yii', $response[0]->msg), | ||
)); | ||
|
||
} | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v2.1 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues | ||
* ======================================= | ||
* Magnusbilling.com <[email protected]> | ||
* | ||
*/ | ||
class CuentaDigitalCommand extends ConsoleCommand | ||
{ | ||
public function run($args) | ||
{ | ||
$url = "http://finance.yahoo.com/d/quotes.csv?s=ARSUSD=X&f=l1"; | ||
$handle = @fopen($url, 'r'); | ||
if ($handle) { | ||
$result = fgets($handle, 4096); | ||
fclose($handle); | ||
} | ||
$cambio = trim($result); | ||
|
||
$date = date('Ymd'); | ||
|
||
$lines = file('https://www.cuentadigital.com/exportacion.php?control=50dccff9ad9dc1946ff9b9020b5acafe&fecha=' . $date . ''); | ||
|
||
for ($i = 0; $i < count($lines); $i++) { | ||
if (list($fecha, $monto_pago, $monto, $codigo_barras, $codigo_opcional, $medio_pago, $num_pago) = preg_split("/\//", $lines[$i])) { | ||
$identification = Util::getDataFromMethodPay($codigo_opcional); | ||
if (!is_array($identification)) { | ||
exit; | ||
} | ||
|
||
$username = $identification['username']; | ||
$id_user = $identification['id_user']; | ||
|
||
$monto = preg_replace("/\.|\,/", "", $monto); | ||
$monto = ($monto * $cambio) * 0.875; | ||
|
||
$description = $medio_pago . ' ' . $codigo_barras; | ||
$modelUser = User::model()->findByPk((int) $id_user); | ||
|
||
if (count($modelUser)) { | ||
UserCreditManager::releaseUserCredit($modelUser->id, $monto, $description, 1, $codigo_barras); | ||
} | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v2.1 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues | ||
* ======================================= | ||
* Magnusbilling.com <[email protected]> | ||
* | ||
*/ | ||
class DeleteCallCommand extends ConsoleCommand | ||
{ | ||
public function run($args) | ||
{ | ||
ini_set('memory_limit', '-1'); | ||
$backdate = $this->subDayIntoDate(date('Ymd'), 15); | ||
|
||
Call::model()->deleteAll(array( | ||
'condition' => 'sessiontime = 0 AND starttime < :key', | ||
'params' => array(':key' => $backdate), | ||
'limit' => 1000, | ||
)); | ||
} | ||
|
||
public function subDayIntoDate($date, $days) | ||
{ | ||
$thisyear = substr($date, 0, 4); | ||
$thismonth = substr($date, 4, 2); | ||
$thisday = substr($date, 6, 2); | ||
$nextdate = mktime(0, 0, 0, $thismonth, $thisday - $days, $thisyear); | ||
return strftime("%Y-%m-%d", $nextdate); | ||
} | ||
} |
Oops, something went wrong.