Initial Commit of AgileBill Open Source

This commit is contained in:
unknown
2008-11-26 14:50:40 -08:00
parent ae5a0fc25e
commit 02306ccc47
2954 changed files with 410976 additions and 0 deletions

12
modules/voip/auth.inc.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
$auth_methods = Array
(
Array ('module' => 'voip', 'method' => 'menu_countries'),
Array ('module' => 'voip', 'method' => 'menu_location'),
Array ('module' => 'voip', 'method' => 'menu_station'),
Array ('module' => 'voip', 'method' => 'features'),
Array ('module' => 'voip', 'method' => 'update_features'),
Array ('module' => 'voip', 'method' => 'activity'),
Array ('module' => 'voip', 'method' => 'overview')
);
?>

View File

@@ -0,0 +1,179 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* For questions, help, comments, discussion, etc., please join the
* Agileco community forums at http://forum.agileco.com/
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com> and Thralling Penguin, LLC <http://www.thrallingpenguin.com>
* @package AgileBill
* @version 1.4.93
*/
require_once PATH_MODULES.'product/base_product_plugin.inc.php';
class base_voip_plugin extends base_product_plugin
{
function delete_cart($VAR, $cart, $checkDID = false)
{
if(!isset($cart['product_attr'])) return;
$db =& DB();
$attr = unserialize($cart['product_attr']);
if(!empty($attr['station']))
{
$did = $attr['station'];
if($checkDID) {
// check if user owns did && is in did pool (if so we can assume it was a topup and return)
$didrs = $db->Execute(sqlSelect($db,"voip_did","id,did","did = ::{$did}:: AND account_id=".SESS_ACCOUNT));
if($didrs && $didrs->RecordCount()>0) return;
}
// get E164 so we can determine the country code and did npa/nxx/station and find the did and plugin
include_once(PATH_MODULES.'voip/voip.inc.php');
$v = new voip;
$did_arr = $v->get_did_e164($did);
if(!$did_arr) return;
$plugin_id = $did_arr['voip_did_plugin_id'];
// Get the plugin detials
$rs = & $db->Execute(sqlSelect($db,"voip_did_plugin","plugin,avail_countries","id = $plugin_id"));
if($rs && $rs->RecordCount() > 0) {
$plugin = $rs->fields['plugin'];
} else {
return;
}
// load the plugin and call release();
$file = PATH_PLUGINS.'voip_did/'.$plugin.'.php';
if(is_file($file)) {
include_once($file);
eval('$plg = new plgn_voip_did_'.$plugin.';');
if(is_object($plg)) {
if(is_callable(array($plg, 'release'))) {
$plg->id = $did_arr['voip_did_plugin_id'];;
$plg->did = $did;
$plg->did_id = $did_arr['id'];
$plg->release();
}
}
}
}
}
function validate_cart($VAR, $product, $did, $ported)
{
// get E164 so we can determine the country code and did npa/nxx/station
$db =& DB();
include_once(PATH_MODULES.'voip/voip.inc.php');
$v = new voip;
$cc = ""; $npa = ""; $nxx = ""; $e164 = "";
if ($v->e164($did, $e164, $cc, $npa, $nxx))
{
if ($ported) return true;
// verify this did is in voip_pool, and is not assigned to an account, and is not reserved
if ($cc == '1') {
$station = substr($e164, 8);
$sql = sqlSelect($db,"voip_pool","*",
"(date_reserved IS NULL OR date_reserved=0) AND (account_id IS NULL OR account_id=0) AND country_code=$cc AND npa=$npa AND nxx=$nxx AND station=$station");
} else {
$station = substr($e164, 4 + strlen($cc));
$sql = sqlSelect($db,"voip_pool","*",
"(date_reserved IS NULL OR date_reserved=0) AND (account_id IS NULL OR account_id=0) AND country_code=$cc AND station=$station");
}
$rs = $db->Execute($sql);
if($rs && $rs->RecordCount() > 0) {
$did_id = $rs->fields['id'];
$plugin_id = $rs->fields['voip_did_plugin_id'];
} else {
return "Sorry, the selected number is not available or has been removed from our system, please go back and select another.";
}
} else {
return "The format for the provided number is incorrect.";
}
// get the id of the current country calling code
$country_id = 0;
$country = $db->Execute($sql = sqlSelect($db,"voip_iso_country_code_map","iso_country_code","country_code = $cc"));
if($country && $country->RecordCount() == 1) {
$countryc = & $db->Execute($sql = sqlSelect($db,"voip_iso_country_code","id","code = ::{$country->fields['iso_country_code']}::"));
if($countryc && $countryc->RecordCount() == 1) {
$country_id = $countryc->fields['id'];
} else {
return "Sorry, the selected number is not available as the country is disallowed for the current product";
}
}
// validate that the country is available for the selected plugin
$country_auth = false;
$rs = $db->Execute(sqlSelect($db,"voip_did_plugin","plugin,avail_countries","id = $plugin_id"));
if($rs && $rs->RecordCount()) {
$plugin = $rs->fields['plugin'];
$carr = unserialize($rs->fields['avail_countries']);
foreach($carr as $cid) {
if($country_id == $cid) { $country_auth=true; break; }
}
}
if(!$country_auth) return "Sorry, the selected number is not available as the country is disallowed for the current product";
// Get the plugin details and load plugin as an object
$file = PATH_PLUGINS.'voip_did/'.$plugin.'.php';
if(is_file($file)) {
include_once($file);
eval('$plg = new plgn_voip_did_'.$plugin.';');
if(is_object($plg)) {
if(is_callable(array($plg, 'reserve'))) {
$plg->id = $plugin_id;
$plg->did = $did;
$plg->did_id = $did_id;
$plg->country = $cc;
$result = $plg->reserve();
if($result === true) {
return true;
} else {
return $result;
}
}
} else {
return "VoIP DID object couldn't be created.";
}
} else {
return "VoIP DID plugin not found.";
}
// something failed...
return "An unknown error occurred while attempting to reserve your requested number, please try again later.";
}
/**
* Retrieve the DID assigned to a service ID
*/
function get_parent_did($id)
{
$db = &DB();
$sql = 'SELECT prod_attr_cart FROM '.AGILE_DB_PREFIX.'service WHERE
id = '.$db->qstr($id).' AND
site_id = '.$db->qstr(DEFAULT_SITE);
$rs = $db->Execute($sql);
@$a = unserialize($rs->fields['prod_attr_cart']);
$did = "";
if (!empty($a['station'])) {
$did = str_replace("-", "", $a['station']);
}
if (!empty($a['ported'])) {
$did = $a['ported'];
}
return $did;
}
}
?>

View File

@@ -0,0 +1,134 @@
<?php
/**
* AgileBill - Open Billing Software
*
* This body of work is free software; you can redistribute it and/or
* modify it under the terms of the Open AgileBill License
* License as published at http://www.agileco.com/agilebill/license1-4.txt
*
* For questions, help, comments, discussion, etc., please join the
* Agileco community forums at http://forum.agileco.com/
*
* @link http://www.agileco.com/
* @copyright 2004-2008 Agileco, LLC.
* @license http://www.agileco.com/agilebill/license1-4.txt
* @author Tony Landis <tony@agileco.com> and Thralling Penguin, LLC <http://www.thrallingpenguin.com>
* @package AgileBill
* @version 1.4.93
*/
header("Pragma: no-cache" );
header("Cache-Control: no-cache, must-revalidate" );
if (!file_exists("/usr/bin/munge_monitor") || !file_exists("/var/log/asteriskmem")) {
echo '<center>Sorry, the required scripts for processing memory reports are not installed.</center>';
exit;
}
if (GD == false) {
echo '<center>Sorry, this report requires GD support inside of PHP';
exit;
}
ob_start();
require_once ('../../config.inc.php');
require_once (PATH_INCLUDES."jpgraph/jpgraph.php");
require_once (PATH_INCLUDES."jpgraph/jpgraph_line.php");
$keys = array();
function get_index($v) {
global $keys;
if (in_array($v,$keys)) {
return array_search($v,$keys);
}
$keys[] = $v;
return array_search($v,$keys);
}
function get_index_name($v) {
global $keys;
return $keys[$v];
}
$fp = popen("/usr/bin/munge_monitor </var/log/asteriskmem","r");
$data = "";
while(!feof($fp))
$data .= fread($fp,65536);
fclose($fp);
$lines = explode("\n",$data); $prev = ""; $i=-1; $j=0;
foreach ($lines as $line) {
$col = explode("|",$line);
if($col[2]>10) {
#echo "<pre>"; print_r($col); echo "</pre>";
if ($prev != $col[0]) {
$prev = $col[0];
$i++;
$j=0;
for($t=0;$t<40;$t++)
$datay[$i][$t] = 0;
}
$datay[get_index($col[3])][$i] = $col[2];
$datax[$i] = date("H:j",$col[0]);
$j++;
}
}
#echo "<pre>"; print_r($datay); echo "</pre>"; exit;
$graph = new Graph(800,768,"auto");
$graph->SetShadow();
$graph->SetBackgroundGradient('#8e8e8e','#e1e1e1');
// Use an integer X-scale
$graph->SetScale("textlin");
// Set title and subtitle
$graph->title->Set("Memory Leaks");
$graph->subtitle->Set("Shows the number of unfreed blocks requested by each module");
// Use built in font
$graph->title->SetFont(FF_FONT1,FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$graph->img->SetMargin(40,140,40,80);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.05,0.5,"right","center");
// Display every 10:th datalabel
$graph->xaxis->SetTextTickInterval(6);
$graph->xaxis->SetTextLabelInterval(6);
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(90);
$rgb = new RGB();
$i = 0;
foreach($datay as $dy) {
// Create a red line plot
$p[$i] = new LinePlot($dy);
reset($rgb->rgb_table);
for($j=0;$j<=$i;$j += 1) {
for($k=0;$k<=10;$k++) {
next($rgb->rgb_table);
}
if( current($rgb->rgb_table) == "" ) {
reset($rgb->rgb_table);
}
}
$p[$i]->SetColor(current($rgb->rgb_table));
$p[$i]->SetLegend(get_index_name($i));
// The order the plots are added determines who's ontop
$graph->Add($p[$i]);
// $graph->Add($b1);
#$i++;
#echo "<pre>"; print_r($dy); echo "</pre>";
$i++;
}
// Finally output the image
$graph->Stroke();
ob_end_flush();
exit;
?>

2142
modules/voip/voip.inc.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<construct>
<module>voip</module>
<table>voip</table>
<dependancy></dependancy>
<cache>0</cache>
<order_by>id</order_by>
<limit>35</limit>
<index>
<id>id</id>
</index>
<field>
<id>
<type>I4</type>
</id>
<site_id>
<type>I4</type>
</site_id>
<voip_intrastate>
<type>C(255)</type>
</voip_intrastate>
<voip_secret_gen>
<type>L</type>
<validate>any</validate>
</voip_secret_gen>
<voip_vm_passwd>
<type>C(4)</type>
<min_len>4</min_len>
<max_len>4</max_len>
<validate>numeric</validate>
</voip_vm_passwd>
<voip_default_prefix>
<type>C(8)</type>
<validate>any</validate>
</voip_default_prefix>
<prepaid_low_balance>
<type>F</type>
<validate>any</validate>
</prepaid_low_balance>
<auth_domain>
<type>C(32)</type>
<validate>any</validate>
</auth_domain>
<perform_normalization>
<type>L</type>
<validate>any</validate>
</perform_normalization>
<normalization_min_len>
<type>L</type>
<validate>any</validate>
</normalization_min_len>
</field>
<method>0</method>
<trigger>0</trigger>
</construct>

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<install>
<module_properties>
<name>voip</name>
<parent>voip</parent>
<notes><![CDATA[AgileVoice modules for AgileBill Core]]></notes>
<dependancy></dependancy>
<sub_modules>voip_rate,voip_rate_prod,voip_did,voip_pool,voip_in_network,voip_sip,voip_fax,voip_fax_data,voip_vm,voip_blacklist,voip_cdr,voip_did_plugin,voip_prepaid</sub_modules>
<menu_display>1</menu_display>
</module_properties>
<sql_inserts>
<module_method>
<config>
<page><![CDATA[%%:config]]></page>
<menu_display>1</menu_display>
</config>
</module_method>
</sql_inserts>
</install>