-
Notifications
You must be signed in to change notification settings - Fork 123
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
1 parent
1e92990
commit d807856
Showing
16 changed files
with
486 additions
and
9 deletions.
There are no files selected for viewing
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,43 @@ | ||
/** | ||
* Classe que define a model "TrunkSIPCodes" | ||
* | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v3 | ||
* 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]> | ||
* 25/03/2021 | ||
*/ | ||
Ext.define('MBilling.model.TrunkSipCodes', { | ||
extend: 'Ext.data.Model', | ||
fields: [{ | ||
name: 'id', | ||
type: 'int' | ||
}, { | ||
name: 'ip', | ||
type: 'string' | ||
}, { | ||
name: 'code', | ||
type: 'int' | ||
}, { | ||
name: 'total', | ||
type: 'int' | ||
}, { | ||
name: 'percentage', | ||
type: 'string' | ||
}], | ||
proxy: { | ||
type: 'uxproxy', | ||
module: 'trunkSipCodes' | ||
} | ||
}); |
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,25 @@ | ||
/** | ||
* Classe que define o store "TrunkSIPCodes" | ||
* | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v3 | ||
* 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]> | ||
* 25/03/2021 | ||
*/ | ||
Ext.define('MBilling.store.TrunkSipCodes', { | ||
extend: 'Ext.data.Store', | ||
model: 'MBilling.model.TrunkSipCodes', | ||
groupField: 'ip' | ||
}); |
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 |
---|---|---|
|
@@ -70,4 +70,5 @@ Ext.define('MBilling.view.trunk.Controller', { | |
} | ||
}); | ||
} | ||
|
||
}); |
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
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,24 @@ | ||
/** | ||
* Classe que define a lista de "CallShopCdr" | ||
* | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v3 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues | ||
* ======================================= | ||
* Magnusbilling.org <[email protected]> | ||
* 01/10/2013 | ||
*/ | ||
Ext.define('MBilling.view.trunkSipCodes.Controller', { | ||
extend: 'Ext.ux.app.ViewController', | ||
alias: 'controller.trunksipcodes' | ||
}); |
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,41 @@ | ||
/** | ||
* Classe que define o form de "Trunk" | ||
* | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v3 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues | ||
* ======================================= | ||
* Magnusbilling.org <[email protected]> | ||
* 25/06/2012 | ||
*/ | ||
Ext.define('MBilling.view.trunkSipCodes.Form', { | ||
extend: 'Ext.ux.form.Panel', | ||
alias: 'widget.trunksipcodesform', | ||
initComponent: function() { | ||
var me = this; | ||
me.items = [{ | ||
xtype: 'textfield', | ||
name: 'ip', | ||
fieldLabel: t('IP') | ||
}, { | ||
xtype: 'numberfield', | ||
name: 'code', | ||
fieldLabel: t('Code') | ||
}, { | ||
xtype: 'numberfield', | ||
name: 'total', | ||
fieldLabel: t('Total') | ||
}]; | ||
me.callParent(arguments); | ||
} | ||
}); |
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,53 @@ | ||
/** | ||
* Classe que define a lista de "Trunk" | ||
* | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2021 MagnusBilling. All rights reserved. | ||
* ################################### | ||
* | ||
* This software is released under the terms of the GNU Lesser General Public License v3 | ||
* A copy of which is available from http://www.gnu.org/copyleft/lesser.html | ||
* | ||
* Please submit bug reports, patches, etc to https://github.com/magnussolution/magnusbilling7/issues | ||
* ======================================= | ||
* Magnusbilling.org <[email protected]> | ||
* 25/06/2012 | ||
*/ | ||
Ext.define('MBilling.view.trunkSipCodes.List', { | ||
extend: 'Ext.ux.grid.Panel', | ||
alias: 'widget.trunksipcodeslist', | ||
store: 'TrunkSipCodes', | ||
fieldSearch: 'ip', | ||
initComponent: function() { | ||
var me = this; | ||
me.buttonCsv = false; | ||
me.allowPrint = false; | ||
me.buttonUpdateLot = false; | ||
me.allowCreate = false; | ||
me.allowUpdate = false; | ||
me.textDelete = t('Reset'); | ||
me.columns = me.columns || [{ | ||
header: t('Ip'), | ||
dataIndex: 'ip', | ||
flex: 3 | ||
}, { | ||
header: t('SIP Code'), | ||
dataIndex: 'code', | ||
flex: 3 | ||
}, { | ||
header: t('Total'), | ||
dataIndex: 'total', | ||
flex: 3 | ||
}, { | ||
header: t('Percentage'), | ||
dataIndex: 'percentage', | ||
flex: 3 | ||
}]; | ||
me.callParent(arguments); | ||
} | ||
}); |
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,11 @@ | ||
/** | ||
* Classe que define o panel de "Trunk" | ||
* | ||
* MagnusSolution.com <[email protected]> | ||
* 18/04/2012 | ||
*/ | ||
Ext.define('MBilling.view.trunkSipCodes.Module', { | ||
extend: 'Ext.ux.panel.Module', | ||
alias: 'widget.trunksipcodesmodule', | ||
controller: 'trunksipcodes' | ||
}); |
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
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,120 @@ | ||
<?php | ||
/** | ||
* ======================================= | ||
* ################################### | ||
* MagnusBilling | ||
* | ||
* @package MagnusBilling | ||
* @author Adilson Leffa Magnus. | ||
* @copyright Copyright (C) 2005 - 2021 MagnusSolution. 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 TrunkSIPCodesCommand extends ConsoleCommand | ||
{ | ||
public function run($args) | ||
{ | ||
|
||
$time = time(); | ||
|
||
$cache_path = '/tmp/cache_mbilling_codes.sqlite'; | ||
exec('rm -rf ' . $cache_path); | ||
$fields = "data,ip,code,msg"; | ||
try { | ||
$db = new SQLite3($cache_path); | ||
$db->exec('CREATE TABLE IF NOT EXISTS sipcodes (' . $fields . ');'); | ||
} catch (Exception $e) { | ||
|
||
} | ||
|
||
if (!file_exists('/var/log/asterisk/magnus_processed ')) { | ||
exec('touch /var/log/asterisk/magnus_processed '); | ||
} | ||
|
||
exec('cp -rf /var/log/asterisk/magnus /var/log/asterisk/magnus_new'); | ||
|
||
exec('diff -u /var/log/asterisk/magnus_processed /var/log/asterisk/magnus_new ', $lines); | ||
|
||
exec('rm -rf /var/log/asterisk/magnus_processed'); | ||
exec('mv /var/log/asterisk/magnus_new /var/log/asterisk/magnus_processed'); | ||
|
||
$values = ''; | ||
|
||
$i = 0; | ||
foreach ($lines as $key => $line) { | ||
|
||
preg_match_all('/\[(.*)\] DEBUG.*\<sip\:.*@(.*)\>.*\|(.*)\|(.*)/', $line, $output_array); | ||
|
||
if (count($output_array) < 4 || !isset($output_array[1][0])) { | ||
|
||
continue; | ||
} | ||
|
||
$output_array[4][0] = preg_replace("/'/", '', $output_array[4][0]); | ||
|
||
$values .= "('" . $output_array[1][0] . "','" . $output_array[2][0] . "','" . $output_array[3][0] . "','" . $output_array[4][0] . "'),"; | ||
|
||
if ($i == 200) { | ||
|
||
$sql = "INSERT INTO sipcodes ($fields) VALUES " . substr($values, 0, -1); | ||
try { | ||
$db->exec($sql); | ||
} catch (Exception $e) { | ||
// | ||
} | ||
$values = ''; | ||
$i = 0; | ||
} else { | ||
$i++; | ||
} | ||
|
||
} | ||
|
||
if ($i < 200 && $i > 0) { | ||
|
||
$sql = "INSERT INTO sipcodes ($fields) VALUES " . substr($values, 0, -1); | ||
try { | ||
$db->exec($sql); | ||
} catch (Exception $e) { | ||
// | ||
} | ||
$values = ''; | ||
$i = 0; | ||
} | ||
|
||
$sql = "SELECT ip FROM sipcodes GROUP BY ip"; | ||
$result = $db->query($sql); | ||
while ($ip = $result->fetchArray(SQLITE3_ASSOC)) { | ||
|
||
$sql = "SELECT count(code) as total, code FROM sipcodes WHERE ip = '" . $ip['ip'] . "' GROUP BY code"; | ||
$resultCodes = $db->query($sql); | ||
while ($code = $resultCodes->fetchArray(SQLITE3_ASSOC)) { | ||
|
||
$sql = "SELECT id FROM pkg_trunk WHERE host = '" . $ip['ip'] . "' "; | ||
$modelTrunk = Yii::app()->db->createCommand($sql)->queryAll(); | ||
if (isset($modelTrunk[0]['id'])) { | ||
$sql = "INSERT INTO pkg_trunk_error (ip, code,total) VALUES ( '" . $ip['ip'] . "', '" . $code['code'] . "', '" . $code['total'] . "')"; | ||
try { | ||
Yii::app()->db->createCommand($sql)->execute(); | ||
} catch (Exception $e) { | ||
|
||
$sql = "UPDATE pkg_trunk_error SET total = total + " . $code['total'] . " WHERE ip = '" . $ip['ip'] . "' AND code = '" . $code['code'] . "'"; | ||
try { | ||
Yii::app()->db->createCommand($sql)->execute(); | ||
} catch (Exception $e) { | ||
print_r($e); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.