Skip to content

Commit e7d526e

Browse files
commit protected directory
0 parents  commit e7d526e

File tree

337 files changed

+49949
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

337 files changed

+49949
-0
lines changed

protected/.DS_Store

8 KB
Binary file not shown.

protected/.htaccess

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deny from all

protected/commands/.DS_Store

6 KB
Binary file not shown.

protected/commands/BackupCommand.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* =======================================
4+
* ###################################
5+
* MagnusBilling
6+
*
7+
* @package MagnusBilling
8+
* @author Adilson Leffa Magnus.
9+
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved.
10+
* ###################################
11+
*
12+
* This software is released under the terms of the GNU Lesser General Public License v2.1
13+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
14+
*
15+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
16+
* =======================================
17+
* Magnusbilling.com <[email protected]>
18+
*
19+
*/
20+
class BackupCommand extends ConsoleCommand
21+
{
22+
public function run($args)
23+
{
24+
$dbString = explode('dbname=', Yii::app()->db->connectionString);
25+
$dataBase = end($dbString);
26+
27+
$username = Yii::app()->db->username;
28+
$password = Yii::app()->db->password;
29+
$data = date("d-m-Y");
30+
$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";
31+
LinuxAccess::exec($comando);
32+
LinuxAccess::exec("tar czvf /usr/local/src/magnus/backup/backup_voip_Magnus.$data.tgz /tmp/base.sql /etc/asterisk");
33+
LinuxAccess::exec("rm -f /tmp/base.sql");
34+
}
35+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* =======================================
4+
* ###################################
5+
* MagnusBilling
6+
*
7+
* @package MagnusBilling
8+
* @author Adilson Leffa Magnus.
9+
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved.
10+
* ###################################
11+
*
12+
* This software is released under the terms of the GNU Lesser General Public License v2.1
13+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
14+
*
15+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
16+
* =======================================
17+
* Magnusbilling.com <[email protected]>
18+
*
19+
*/
20+
class CallArchiveCommand extends ConsoleCommand
21+
{
22+
public function run($args)
23+
{
24+
$prior_x_month = $this->config['global']['archive_call_prior_x_month'];
25+
26+
$condition = "DATE_SUB(NOW(),INTERVAL $prior_x_month MONTH) > starttime";
27+
28+
CallFailed::model()->createDataBaseIfNotExist();
29+
30+
$c = 0;
31+
$tables = array('pkg_cdr', 'pkg_cdr_failed');
32+
foreach ($tables as $key => $table) {
33+
34+
$sql = "SELECT count(*) AS count FROM $table WHERE $condition ";
35+
$result = Yii::app()->db->createCommand($sql)->queryAll();
36+
37+
$loop = number_format($result[0]['count'] / 10000, 0);
38+
39+
if ($table == 'pkg_cdr') {
40+
$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";
41+
} else {
42+
$func_fields = "id_user, id_plan, id_prefix, id_trunk, sessionid, uniqueid, starttime, calledstation, sipiax, src, terminatecauseid";
43+
}
44+
45+
if ($c == 0) {
46+
$condition = $condition . " ORDER BY id LIMIT 10000";
47+
$c++;
48+
}
49+
50+
for ($i = 0; $i < $loop; $i++) {
51+
echo "New insert \n";
52+
$sql = "INSERT INTO " . $table . "_archive ($func_fields) SELECT $func_fields FROM " . $table . " WHERE $condition";
53+
try {
54+
Yii::app()->db->createCommand($sql)->execute();
55+
} catch (Exception $e) {
56+
57+
}
58+
$sql = "DELETE FROM $table WHERE $condition";
59+
Yii::app()->db->createCommand($sql)->execute();
60+
sleep(60);
61+
}
62+
}
63+
64+
}
65+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* =======================================
4+
* ###################################
5+
* MagnusBilling
6+
*
7+
* @package MagnusBilling
8+
* @author Adilson Leffa Magnus.
9+
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved.
10+
* ###################################
11+
*
12+
* This software is released under the terms of the GNU Lesser General Public License v2.1
13+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
14+
*
15+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
16+
* =======================================
17+
* Magnusbilling.com <[email protected]>
18+
*
19+
*/
20+
class CallChartCommand extends ConsoleCommand
21+
{
22+
public function run($args)
23+
{
24+
for ($i = 0; $i < 5; $i++) {
25+
26+
$channelsData = AsteriskAccess::instance()->coreShowChannelsConcise();
27+
$arr = explode("\n", $channelsData["data"]);
28+
29+
$total = 0;
30+
31+
foreach ($arr as $key => $value) {
32+
if (preg_match("/Up/", $value)) {
33+
$total++;
34+
}
35+
}
36+
37+
$total = intval($total / 2);
38+
39+
if ($i == 0) {
40+
$modelCallOnlineChart = new CallOnlineChart();
41+
$modelCallOnlineChart->date = date('Y-m-d H:i:s');
42+
$modelCallOnlineChart->answer = $total;
43+
$modelCallOnlineChart->total = 0;
44+
$modelCallOnlineChart->save();
45+
46+
$id = $modelCallOnlineChart->id;
47+
$total1 = $total;
48+
} else {
49+
if ($total > $total1) {
50+
$modelCallOnlineChart = CallOnlineChart::model()->findByPk((int) $id);
51+
$modelCallOnlineChart->answer = $total;
52+
$modelCallOnlineChart->save();
53+
}
54+
}
55+
56+
if (date('H:i') == '23:52') {
57+
CallOnlineChart::model()->deleteAll('date < :key', array(':key' => date('Y-m-d')));
58+
}
59+
60+
sleep(12);
61+
}
62+
}
63+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
/**
3+
* =======================================
4+
* ###################################
5+
* MagnusBilling
6+
*
7+
* @package MagnusBilling
8+
* @author Adilson Leffa Magnus.
9+
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved.
10+
* ###################################
11+
*
12+
* This software is released under the terms of the GNU Lesser General Public License v2.1
13+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
14+
*
15+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
16+
* =======================================
17+
* Magnusbilling.com <[email protected]>
18+
*
19+
*/
20+
class CriaClienteSLCommand extends ConsoleCommand
21+
{
22+
23+
public function run($args)
24+
{
25+
$modelUser = User::model()->findAll('id_sacado_sac IS NULL AND id_group > 1');
26+
foreach ($modelUser as $key => $user) {
27+
$modelMethodPay = Methodpay::model()->find('payment_method = :key AND active = 0', array(':key' => 'SuperLogica'));
28+
if (count($modelMethodPay) > 0) {
29+
30+
$response = $this->saveUserSLCurl($user, $modelMethodPay->SLAppToken
31+
, $modelMethodPay->SLAccessToken);
32+
33+
$user->id_sacado_sac = isset($response[0]->data->id_sacado_sac)
34+
? $response[0]->data->id_sacado_sac
35+
: -1;
36+
$user->save();
37+
}
38+
}
39+
40+
}
41+
42+
public function saveUserSLCurl($model, $SLAppToken, $SLAccessToken)
43+
{
44+
$url = "http://api.superlogica.net:80/v2/financeiro/clientes";
45+
46+
$params = array("ST_NOME_SAC" => $model->firstname . ' ' . $model->lastname,
47+
"ST_NOMEREF_SAC" => $model->username,
48+
"ST_DIAVENCIMENTO_SAC" => date('d'),
49+
"ST_CGC_SAC " => $model->vat,
50+
"ST_RG_SAC" => $model->doc,
51+
"ST_CEP_SAC" => $model->zipcode,
52+
"ST_ENDERECO_SAC" => $model->address,
53+
"ST_CIDADE_SAC" => $model->city,
54+
"ST_ESTADO_SAC" => $model->state,
55+
"ST_EMAIL_SAC" => $model->email,
56+
"SENHA" => $model->password,
57+
"SENHA_CONFIRMACAO" => $model->password,
58+
"ST_TELEFONE_SAC" => $model->phone,
59+
);
60+
61+
$ch = curl_init();
62+
curl_setopt($ch, CURLOPT_URL, $url);
63+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
64+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
65+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
66+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
67+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
68+
69+
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded",
70+
"app_token: " . $SLAppToken,
71+
"access_token:" . $SLAccessToken,
72+
));
73+
74+
$params['identificador'] = '10000' . $model->id;
75+
76+
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
77+
$response = (array) json_decode(curl_exec($ch));
78+
79+
print_r($response);
80+
curl_close($ch);
81+
if (isset($response[0]->status) && $response[0]->status != 200) {
82+
83+
echo json_encode(array(
84+
'success' => false,
85+
'rows' => array(),
86+
'errors' => Yii::t('yii', $response[0]->msg),
87+
));
88+
89+
}
90+
91+
return $response;
92+
}
93+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* =======================================
4+
* ###################################
5+
* MagnusBilling
6+
*
7+
* @package MagnusBilling
8+
* @author Adilson Leffa Magnus.
9+
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved.
10+
* ###################################
11+
*
12+
* This software is released under the terms of the GNU Lesser General Public License v2.1
13+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
14+
*
15+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
16+
* =======================================
17+
* Magnusbilling.com <[email protected]>
18+
*
19+
*/
20+
class CuentaDigitalCommand extends ConsoleCommand
21+
{
22+
public function run($args)
23+
{
24+
$url = "http://finance.yahoo.com/d/quotes.csv?s=ARSUSD=X&f=l1";
25+
$handle = @fopen($url, 'r');
26+
if ($handle) {
27+
$result = fgets($handle, 4096);
28+
fclose($handle);
29+
}
30+
$cambio = trim($result);
31+
32+
$date = date('Ymd');
33+
34+
$lines = file('https://www.cuentadigital.com/exportacion.php?control=50dccff9ad9dc1946ff9b9020b5acafe&fecha=' . $date . '');
35+
36+
for ($i = 0; $i < count($lines); $i++) {
37+
if (list($fecha, $monto_pago, $monto, $codigo_barras, $codigo_opcional, $medio_pago, $num_pago) = preg_split("/\//", $lines[$i])) {
38+
$identification = Util::getDataFromMethodPay($codigo_opcional);
39+
if (!is_array($identification)) {
40+
exit;
41+
}
42+
43+
$username = $identification['username'];
44+
$id_user = $identification['id_user'];
45+
46+
$monto = preg_replace("/\.|\,/", "", $monto);
47+
$monto = ($monto * $cambio) * 0.875;
48+
49+
$description = $medio_pago . ' ' . $codigo_barras;
50+
$modelUser = User::model()->findByPk((int) $id_user);
51+
52+
if (count($modelUser)) {
53+
UserCreditManager::releaseUserCredit($modelUser->id, $monto, $description, 1, $codigo_barras);
54+
}
55+
56+
}
57+
}
58+
}
59+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* =======================================
4+
* ###################################
5+
* MagnusBilling
6+
*
7+
* @package MagnusBilling
8+
* @author Adilson Leffa Magnus.
9+
* @copyright Copyright (C) 2005 - 2016 MagnusBilling. All rights reserved.
10+
* ###################################
11+
*
12+
* This software is released under the terms of the GNU Lesser General Public License v2.1
13+
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html
14+
*
15+
* Please submit bug reports, patches, etc to https://github.com/magnusbilling/mbilling/issues
16+
* =======================================
17+
* Magnusbilling.com <[email protected]>
18+
*
19+
*/
20+
class DeleteCallCommand extends ConsoleCommand
21+
{
22+
public function run($args)
23+
{
24+
ini_set('memory_limit', '-1');
25+
$backdate = $this->subDayIntoDate(date('Ymd'), 15);
26+
27+
Call::model()->deleteAll(array(
28+
'condition' => 'sessiontime = 0 AND starttime < :key',
29+
'params' => array(':key' => $backdate),
30+
'limit' => 1000,
31+
));
32+
}
33+
34+
public function subDayIntoDate($date, $days)
35+
{
36+
$thisyear = substr($date, 0, 4);
37+
$thismonth = substr($date, 4, 2);
38+
$thisday = substr($date, 6, 2);
39+
$nextdate = mktime(0, 0, 0, $thismonth, $thisday - $days, $thisyear);
40+
return strftime("%Y-%m-%d", $nextdate);
41+
}
42+
}

0 commit comments

Comments
 (0)