// DID CARRIER STUFF
include("mysql.inc.php");
// GLOBAL DIDSEEN ARRAY
$didseen = array();
function check_didseen($prefix,$location) {
if (empty($prefix)) {
// we do a location check only
if ( in_array($location,$GLOBALS['didseen']) == TRUE ) {
return "present";
} else { return "notpresent"; }
}
else
{
// we do a prefix check only ..
// we check the length of the sorter prefix ..
foreach($GLOBALS['didseen'] as $value) {
if (strlen($value) < strlen($prefix)) {
$prefix_len = strlen($value);
}
else
{ $prefix_len = strlen($prefix); }
if ( substr($value,1,$prefix_len) == $prefix) return "present";
}
// we do a location again ..
if ( in_array($location,$GLOBALS['didseen']) == TRUE ) {
return "present";
}
else
{
return "notpresent";
}
}
}
function buydid($carrierid,$area,$countrycode,$clientid) {
if ( empty($clientid) ) {
echo $GLOBALS['not_auth_buyer'];
echo "
";
exit;
}
$carrier[0] = "carrier_local"; // local did table
// we retrive the correct carrier ...
$carrier_name = $carrier[$carrierid];
call_user_func($carrier_name,'buy',$area,$countrycode,$clientid,"");
}
function validate_carrier_array($value) {
if (in_array($value,$carrier) == TRUE)
return "yes";
}
// @PARAMS : DID Area code
// @RETURNS : bunch of location matching the area
function getdidbyarea($area,$country,$clientid) {
//echo "CLIENTID:".$clientid."
";
//echo "COUNTRY:".$country;
global $lang;
$carrier[0] = "carrier_local"; // local did table
$carrier[1] = "carrier_terravon";
// carrier selection and preserve order ..
$query = "select DISTINCT provider from did_map where locationcode='".$area."'";
$result = mysql_query($query);
$carrier_mysql = array();
array_push($carrier_mysql,"carrier_local");
while($row=mysql_fetch_array($result)) {
array_push($carrier_mysql,$row['provider']);
}
$carrier_mysql = array_unique($carrier_mysql);
$carrier_temp = array();
foreach($carrier_mysql as $value) {
if ( in_array($value,$carrier) == TRUE)
array_push($carrier_temp,$value);
}
require_once("listheader.php");
// we retrive the countrycode from did_map
$query = "select countrycode from did_map where country='".$country."'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$countrycode = $row['countrycode'];
echo '
'.$lang[72].' ('.$country.')
| '.$lang[73].' |
'.$lang[74].' |
'.$lang[75].' |
'.$lang[76].' |
'.$lang[77].' |
'.$lang[78].' |
|
';
// we loop the carriers and call each function matching carrier . :D
$carrier_count = count($carrier_temp);
$var = 0;
while ($var < $carrier_count) {
call_user_func($carrier_temp[$var],'search',$area,$countrycode,$clientid,$country);
//echo "CALLED:".$carrier_temp[$var]."
";
$var += 1;
}
echo '
'.$lang[70].' '.$lang[55].'
';
require_once("listfooter.php");
// we destroy didseen stuff ..
$didseen = NULL;
}
#########################################
// CARRIER LOCAL FUNCTION
// @PARAMS $action , $value
#########################################
function carrier_local($action,$area,$countrycode,$clientid,$country) {
global $did_remove;
global $lang;
if ($action == "search") {
// we check our local database table DIDS
$prefix_full = $countrycode.$area;
$query = "select * from dids where country='".$country."' and number like '".$prefix_full."%'
and assignedtouserid='N/A' and reserved !='CHECKED' LIMIT 1";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
// we have results , so we check if we have a packae matching etc .. :d
array_push($GLOBALS['didseen'],$row['number'],$row['city']);
$query = "select * from didpackage where telco='".$row['telco']."' and clientid='".$clientid."' and ".$prefix_full."
like
concat(number,'%') order by length(number) DESC";
$result2 = mysql_query($query);
$row2= mysql_fetch_array($result2);
if ( !empty($row2) ) {
// we display the package price
$price = $row2['price'];
$extraprice = $row2['extraprice'];
$setup = $row2['setup'];
$monthlypricing = $row2['monthlypricing'];
} else {
// we display the normal price ..
$price = $row['price'];
$extraprice = $row['extraprice'];
$setup = $row['setup'];
$monthlypricing = $row['monthlypricing'];
}
// we display the result ...
echo '
| '.$area.' |
'.$row['city'].' |
'.$setup.' |
'.$monthlypricing.' |
'.$price.' |
'.$extraprice.' |
'.$lang[149].' |
';
}
// end of number listing ..
}
// end of action="search"
if ($action=="buy") {
//echo "AREA TO BuY FOR LOCAL".$area;
// we check our local database table DIDS
$prefix_full = $area;
$query = "select * from dids where number ='".$prefix_full."' and assignedtouserid='N/A'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$number = $row['number'];
// we have results , so we check if we have a packae matching etc .. :d
$query = "select * from didpackage where telco='".$row['telco']."' and clientid='".$clientid."' and ".$prefix_full." like
concat(number,'%') order by length(number) DESC";
$result2 = mysql_query($query);
$row2= mysql_fetch_array($result2);
if ( !empty($row2) ) {
// we display the package price
echo '
'.$lang[79];
$price = $row2['price'];
$extraprice = $row2['extraprice'];
$setup = $row2['setup'];
$monthlypricing = $row2['monthlypricing'];
$clienttimecharge = $row2['clienttimecharge'];
} else {
// we display the normal price ..
$price = $row['price'];
$extraprice = $row['extraprice'];
$setup = $row['setup'];
$monthlypricing = $row['monthlypricing'];
$clienttimecharge = $row['clienttimecharge'];
}
// THIS IS WHERE WE TAKE ACTION BASED ON THE PRICE ETC ..
// we retrive prepaid or postpaid status ..
$query = "select * from billing where clientid='".$clientid."'";
$result6 = mysql_query($query);
$row6 = mysql_fetch_array($result6);
$flag = $row6['flag'];
if ($flag == "prepaid") {
// we calculate the prepaid remaining ..
$prepaidremain =
($row6['prepaid']-$row6['prepaidused']-$row6['monthlypricing']-$row6['balance']-$row6['currentbalance']-$row6['hardwareprice']-$row6['extramonthlypricing']);
if ($prepaidremain < ($setup+$monthlypricing) ) {
// do not have enough prepaid ..
echo '
'.$lang[80].'.';
} else {
// actual code to buy the did finally .....
//echo "
FAKE BUY";
// we update the user balance for setup ..
$query = "update billing set balance=balance+".$setup." where clientid='".$clientid."'";
$result17 = mysql_query($query);
// we actually assign the did to the userid ... number = $prefix_full
// we retrive the first userid of the clientid ..
$query = "select userid from userid where assignedtouserid='".$clientid."' order by id";
$result4 = mysql_query($query);
$row4 = mysql_fetch_array($result4);
$first_userid = $row4['userid'];
if ( empty($first_userid) ) {
echo '
We are sorry, we are not able to process your query, please contact technical support (FUSERID)';
require_once("footer.php");
exit;
}
// we assign the did number to the userid .. :D
$query = "update dids set assignedtouserid='".$first_userid."' where number='".$prefix_full."'";
$result5 = mysql_query($query);
if (!$result5) {
echo '
Cannot assign the did number, contact technical support';
} else {
echo '
'.$lang[83].': '.$prefix_full.' '.$lang[84].': '.$first_userid;
// we actually retrive the info of the did..
$query = "select * from dids where number='".$prefix_full."'";
$result16 = mysql_query($query);
$row16 = mysql_fetch_array($result16);
$did_max_channels = $row16['didmaxchannels'];
$price = $row16['price'];
$extraprice = $row16['price'];
// we get clientid max did channel..
$query = "select didmaxchannels from billing where clientid='".$_SESSION['username']."'";
$result56 = mysql_query($query);
$row56 = mysql_fetch_array($result56);
$clientid_max_channels = $row56['didmaxchannels'];
$query = "insert into minutespackagesincoming(id,userid,prefix,price,extraprice,monthlyprice,clienttimecharge)
values(0,'".$first_userid."','".$prefix_full."','".$price."','".$extraprice."','".$monthlypricing."','".$clienttimecharge."')";
$result15 = mysql_query($query);
updateuserid($first_userid);
//echo '
This is where we put the dialplan live stuff ..';
// we insert local-dids stuff ..
// retrive the part we need to remove ..
$part_remove = $did_remove['carrier_local'];
if (substr($prefix_full,0,strlen($part_remove)) == $part_remove) {
$indid = substr($prefix_full,strlen($part_remove));
} else {
$indid = $prefix_full;
}
$did = $prefix_full;
$indid2 = check_addition($did);
if ( !empty($indid2))
$indid = $indid2;
$query = "insert into extensions(id,context,exten,priority,app,appdata) values
(0,'local-dids-e164','".$prefix_full."','1','Dial','Local/".$indid."@dids-inbound')";
mysql_query($query);
// we update the did_assignment field ..
$query = "insert into did_assignment(id,clientid,assignedtouserid,number,userid) values
(0,'".$clientid."','".$first_userid."','".$prefix_full."','".$first_userid."')";
$query = "update did_assignment set
clientid='".$clientid."',assignedtouserid='".$first_userid."',userid='".$first_userid."' where number='".$prefix_full."'";
$result13 = mysql_query($query);
if (!$result13) {
echo '
Cannot update your did settings, contact technical support';
echo '
'.mysql_error();
}
// this is where we place the realtime stuff .... YAY! operation based on $userid ..for device ..
// WE GET THE USERID TYPE .. ASSIGNED GATEWAY ETC .. outboundcontext etc ..
// userid type ...
$assigneduserid = $first_userid;
$query = "select userid,switchid,protocol from userid where userid='".$assigneduserid."'";
$result8 = mysql_query($query);
$row8 = mysql_fetch_array($result8);
$switchid = $row8['switchid'];
$userid_proto = $row8['protocol'];
// outbound context retrieval ..
if ($userid_proto =="SIP") {
$query = "select context from sipusers where name='".$assigneduserid."'";
} elseif ($userid_proto =="IAX") {
$query = "select context from iaxusers where name='".$assigneduserid."'";
}
//echo "
Q:".$query;
$result9 = mysql_query($query);
$row9 = mysql_fetch_array($result9);
$outboundcontext = $row9['context'];
if (stristr($outboundcontext,"live-prepaid")) {
$outboundcontext = "from-".$outboundcontext;
}
if ( empty($outboundcontext))
$outboundcontext = $GLOBALS['default_dialing_context'];
$did = $prefix_full;
// we retrive the carrier of the $DID.. for stuff to remove ..
$query = "select telco from dids where number='".$did."'";
//echo "
q2:".$query;
$result10 = mysql_query($query);
$row10 = mysql_fetch_array($result10);
$carrier = $row10['telco'];
// retrive the part we need to remove ..
$part_remove = $did_remove[$carrier];
//echo "PART:".$part_remove;
if (substr($did,0,strlen($part_remove)) == $part_remove) {
$indid = substr($did,strlen($part_remove));
} else {
$indid = $did;
}
$indid2 = check_addition($did);
if ( !empty($indid2))
$indid = $indid2;
require_once("did_templates.inc.php");
// we retrive the template into an array ..
if ($userid_proto=="IAX") {
$userid_array = explode('
',$userid_iax_template);
}
if ($userid_proto=="SIP") {
$userid_array = explode('
',$userid_sip_template);
}
$userid_count = count($userid_array);
$var = 1;
$did = trim($did);
$indid = trim($indid);
// we remove the old content ..
$query = "delete from extensions where exten='".$indid."' and context='dids-inbound'";
$result11 = mysql_query($query);
if (!$result11) {
echo '
Cannot update your did settings, please contact technical support (INDIDMISSING)';
require_once("footer.php");
exit;
}
// we remove the old content ..
$query = "delete from extensions where exten='".$did."' and context='dids-inbound'";
$result11 = mysql_query($query);
if (!$result) {
echo '
Cannot update your did settings, please contact technical support (INDIDMISSING)';
require_once("footer.php");
exit;
}
$query = "delete from extensions where exten='".$did."' and context='transit'";
$result11 = mysql_query($query);
if (!$result11) {
echo '
Cannot update your did settings, please contact technical support (INDIDMISSING)';
require_once("footer.php");
exit;
}
while ($var < $userid_count -1) {
//replace stuff ..
$userid_array[$var] = str_replace("|DID|",$did,$userid_array[$var]);
$userid_array[$var] = str_replace("|INDID|",$indid,$userid_array[$var]);
if ($userid_proto=="IAX")
$userid_array[$var] = str_replace("|PROTO|","IAX2",$userid_array[$var]);
if ($userid_proto=="SIP")
$userid_array[$var] = str_replace("|PROTO|","SIP",$userid_array[$var]);
$userid_array[$var] = str_replace("|ACCOUNT|",$assigneduserid,$userid_array[$var]);
$userid_array[$var] = str_replace("|GATEWAYSTR|",$switchid,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTNUMBER|",$altpnumber,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTSIPURI|",$altsipurl,$userid_array[$var]);
$userid_array[$var] = str_replace("|TERMINALACTION|",$terminalaction,$userid_array[$var]);
$userid_array[$var] = str_replace("|OUTBOUNDCONTEXT|",$outboundcontext,$userid_array[$var]);
if ($price+$extraprice == "0" and $clientid_max_channels < "0") {
$maxchannels = $default_channels_flat;
} else if ($price+$extraprice == "0" and $did_max_channels > "0" ) {
$maxchannels = $did_max_channels;
} elseif ($price + $extraprice =="0" and $did_max_channels < "0" and $clientid_max_channels > "0") {
$maxchannels = $clientid_max_channels;
} else {
$maxchannels = $default_channels_multi;
}
$userid_array[$var] = str_replace("|CHANNELS|",$maxchannels,$userid_array[$var]);
//echo "
UPDATED LINE:".$userid_array[$var];
// we insert into mysql extensions table for dids-inbound
$update_line2 = explode(",",$userid_array[$var]);
$query = "insert into extensions(id,context,exten,priority,app,appdata) values
(0,'dids-inbound','".$indid."',".$update_line2[0].",'".$update_line2[1]."','".$update_line2[2]."')";
//echo "
".$query;
$result12 = mysql_query($query);
if (!$result12) {
echo '
Cannot update your did settings, please contact technical support (INSERTFAIL)';
require_once("footer.php");
exit;
}
$var += 1;
}
// we retrive the template into an array ..
if ($userid_proto=="IAX"){
$userid_array = explode('
',$userid_iax_template_transit);
}
if ($userid_proto=="SIP"){
$userid_array = explode('
',$userid_sip_template_transit);
}
$userid_count = count($userid_array);
$var = 1;
while ($var < $userid_count -1) {
//replace stuff ..
$userid_array[$var] = str_replace("|DID|",$did,$userid_array[$var]);
$userid_array[$var] = str_replace("|INDID|",$indid,$userid_array[$var]);
if ($userid_proto=="IAX")
$userid_array[$var] = str_replace("|PROTO|","IAX2",$userid_array[$var]);
if ($userid_proto=="SIP")
$userid_array[$var] = str_replace("|PROTO|","SIP",$userid_array[$var]);
$userid_array[$var] = str_replace("|ACCOUNT|",$assigneduserid,$userid_array[$var]);
$userid_array[$var] = str_replace("|GATEWAYSTR|",$switchid,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTNUMBER|",$altpnumber,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTSIPURI|",$altsipurl,$userid_array[$var]);
$userid_array[$var] = str_replace("|TERMINALACTION|",$terminalaction,$userid_array[$var]);
$userid_array[$var] = str_replace("|OUTBOUNDCONTEXT|",$outboundcontext,$userid_array[$var]);
//echo "
UPDATED LINE:".$userid_array[$var];
// we insert into mysql extensions table for dids-inbound
$update_line2 = explode(",",$userid_array[$var]);
$query = "insert into extensions(id,context,exten,priority,app,appdata) values
(0,'transit','".$did."',".$update_line2[0].",'".$update_line2[1]."','".$update_line2[2]."')";
//echo "
".$query;
$result11 = mysql_query($query);
if (!$result) {
echo '
Cannot update your did settings, please contact technical support (INSERTFAIL)';
require_once("footer.php");
exit;
}
$var += 1;
}
echo '
'.$lang[81];
}
}
} elseif($flag=="postpaid") {
// we check the credit limit ..
if ( ($setup + $monthlypricing + $row6['balance'] + $row6['currentbalance'] + $row6['monthlypricing'] +
$row6['hardwareprice'] +
$row6['extramonthlypricing'] ) - ($row6['prepaid'] - $row6['prepaidused'] ) > $row6['currentcreditlimit']) {
// Not enough credit ..
echo '
'.$lang[150].'.';
//echo '
CURRENT CREIDT:'.$$row6['currentcreditlimit'];
} else {
// actual code to buy the did finally .....
// echo "
FAKE BUY";
// we update the user balance for setup ..
$query = "update billing set balance=balance+".$setup." where clientid='".$clientid."'";
$result17 = mysql_query($query);
// we actually assign the did to the userid ... number = $prefix_full
// we retrive the first userid of the clientid ..
$query = "select userid from userid where assignedtouserid='".$clientid."' order by id";
$result4 = mysql_query($query);
$row4 = mysql_fetch_array($result4);
$first_userid = $row4['userid'];
if ( empty($first_userid) ) {
echo '
We are sorry, we are not able to process your query, please contact technical support (FUSERID)';
require_once("footer.php");
exit;
}
// we assign the did number to the userid .. :D
$query = "update dids set assignedtouserid='".$first_userid."' where number='".$prefix_full."'";
$result5 = mysql_query($query);
if (!$result5) {
echo '
Cannot assign the did number, contact technical support';
} else {
echo '
'.$lang[83].': '.$prefix_full.' '.$lang[84].': '.$first_userid;
// we actually retrive the info of the did..
$query = "select * from dids where number='".$prefix_full."'";
$result16 = mysql_query($query);
$row16 = mysql_fetch_array($result16);
$did_max_channels = $row16['didmaxchannels'];
$price = $row16['price'];
$extraprice = $row16['price'];
// we get clientid max did channel..
$query = "select didmaxchannels from billing where clientid='".$_SESSION['username']."'";
$result56 = mysql_query($query);
$row56 = mysql_fetch_array($result56);
$clientid_max_channels = $row56['didmaxchannels'];
$query = "insert into minutespackagesincoming(id,userid,prefix,price,extraprice,monthlyprice,clienttimecharge)
values(0,'".$first_userid."','".$prefix_full."','".$price."','".$extraprice."','".$monthlypricing."','".$clienttimecharge."')";
$result15 = mysql_query($query);
updateuserid($first_userid);
//echo '
This is where we put the dialplan live stuff ..';
// we insert local-dids stuff ..
// retrive the part we need to remove ..
$part_remove = $did_remove['carrier_local'];
if (substr($prefix_full,0,strlen($part_remove)) == $part_remove) {
$indid = substr($prefix_full,strlen($part_remove));
} else {
$indid = $prefix_full;
}
$did = $prefix_full;
$indid2 = check_addition($did);
if ( !empty($indid2))
$indid = $indid2;
$query = "insert into extensions(id,context,exten,priority,app,appdata) values
(0,'local-dids-e164','".$prefix_full."','1','Dial','Local/".$indid."@dids-inbound')";
mysql_query($query);
// we update the did_assignment field ..
$query = "insert into did_assignment(id,clientid,assignedtouserid,number,userid) values
(0,'".$clientid."','".$first_userid."','".$prefix_full."','".$first_userid."')";
$query = "update did_assignment set
clientid='".$clientid."',assignedtouserid='".$first_userid."',userid='".$first_userid."' where number='".$prefix_full."'";
$result13 = mysql_query($query);
if (!$result13) {
echo '
Cannot update your did settings, contact technical support';
echo '
'.mysql_error();
}
// this is where we place the realtime stuff .... YAY! operation based on $userid ..for device ..
// WE GET THE USERID TYPE .. ASSIGNED GATEWAY ETC .. outboundcontext etc ..
// userid type ...
$assigneduserid = $first_userid;
$query = "select userid,switchid,protocol from userid where userid='".$assigneduserid."'";
$result8 = mysql_query($query);
$row8 = mysql_fetch_array($result8);
$switchid = $row8['switchid'];
$userid_proto = $row8['protocol'];
// outbound context retrieval ..
if ($userid_proto =="SIP") {
$query = "select context from sipusers where name='".$assigneduserid."'";
} elseif ($userid_proto =="IAX") {
$query = "select context from iaxusers where name='".$assigneduserid."'";
}
//echo "
Q:".$query;
$result9 = mysql_query($query);
$row9 = mysql_fetch_array($result9);
$outboundcontext = $row9['context'];
if (stristr($outboundcontext,"live-prepaid")) {
$outboundcontext = "from-".$outboundcontext;
}
if ( empty($outboundcontext))
$outboundcontext = $GLOBALS['default_dialing_context'];
$did = $prefix_full;
// we retrive the carrier of the $DID.. for stuff to remove ..
$query = "select telco from dids where number='".$did."'";
//echo "
q2:".$query;
$result10 = mysql_query($query);
$row10 = mysql_fetch_array($result10);
$carrier = $row10['telco'];
// retrive the part we need to remove ..
$part_remove = $did_remove[$carrier];
//echo "PART:".$part_remove;
if (substr($did,0,strlen($part_remove)) == $part_remove) {
$indid = substr($did,strlen($part_remove));
} else {
$indid = $did;
}
$indid2 = check_addition($did);
if ( !empty($indid2))
$indid = $indid2;
require_once("did_templates.inc.php");
// we retrive the template into an array ..
if ($userid_proto=="IAX") {
$userid_array = explode('
',$userid_iax_template);
}
if ($userid_proto=="SIP") {
$userid_array = explode('
',$userid_sip_template);
}
$userid_count = count($userid_array);
$var = 1;
$did = trim($did);
$indid = trim($indid);
// we remove the old content ..
$query = "delete from extensions where exten='".$indid."' and context='dids-inbound'";
$result11 = mysql_query($query);
if (!$result11) {
echo '
Cannot update your did settings, please contact technical support (INDIDMISSING)';
require_once("footer.php");
exit;
}
// we remove the old content ..
$query = "delete from extensions where exten='".$did."' and context='dids-inbound'";
$result11 = mysql_query($query);
if (!$result11) {
echo '
Cannot update your did settings, please contact technical support (INDIDMISSING)';
require_once("footer.php");
exit;
}
$query = "delete from extensions where exten='".$did."' and context='transit'";
$result11 = mysql_query($query);
if (!$result11) {
echo '
Cannot update your did settings, please contact technical support (INDIDMISSING)';
require_once("footer.php");
exit;
}
while ($var < $userid_count -1) {
//replace stuff ..
$userid_array[$var] = str_replace("|DID|",$did,$userid_array[$var]);
$userid_array[$var] = str_replace("|INDID|",$indid,$userid_array[$var]);
if ($userid_proto=="IAX")
$userid_array[$var] = str_replace("|PROTO|","IAX2",$userid_array[$var]);
if ($userid_proto=="SIP")
$userid_array[$var] = str_replace("|PROTO|","SIP",$userid_array[$var]);
$userid_array[$var] = str_replace("|ACCOUNT|",$assigneduserid,$userid_array[$var]);
$userid_array[$var] = str_replace("|GATEWAYSTR|",$switchid,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTNUMBER|",$altpnumber,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTSIPURI|",$altsipurl,$userid_array[$var]);
$userid_array[$var] = str_replace("|TERMINALACTION|",$terminalaction,$userid_array[$var]);
$userid_array[$var] = str_replace("|OUTBOUNDCONTEXT|",$outboundcontext,$userid_array[$var]);
if ($price+$extraprice == "0" and $clientid_max_channels < "0") {
$maxchannels = $default_channels_flat;
} else if ($price+$extraprice == "0" and $did_max_channels > "0" ) {
$maxchannels = $did_max_channels;
} elseif ($price + $extraprice =="0" and $did_max_channels < "0" and $clientid_max_channels > "0") {
$maxchannels = $clientid_max_channels;
} else {
$maxchannels = $default_channels_multi;
}
$userid_array[$var] = str_replace("|CHANNELS|",$maxchannels,$userid_array[$var]);
//echo "
UPDATED LINE:".$userid_array[$var];
// we insert into mysql extensions table for dids-inbound
$update_line2 = explode(",",$userid_array[$var]);
$query = "insert into extensions(id,context,exten,priority,app,appdata) values
(0,'dids-inbound','".$indid."',".$update_line2[0].",'".$update_line2[1]."','".$update_line2[2]."')";
//echo "
".$query;
$result12 = mysql_query($query);
if (!$result12) {
echo '
Cannot update your did settings, please contact technical support (INSERTFAIL)';
require_once("footer.php");
exit;
}
$var += 1;
}
// we retrive the template into an array ..
if ($userid_proto=="IAX"){
$userid_array = explode('
',$userid_iax_template_transit);
}
if ($userid_proto=="SIP"){
$userid_array = explode('
',$userid_sip_template_transit);
}
$userid_count = count($userid_array);
$var = 1;
while ($var < $userid_count -1) {
//replace stuff ..
$userid_array[$var] = str_replace("|DID|",$did,$userid_array[$var]);
$userid_array[$var] = str_replace("|INDID|",$indid,$userid_array[$var]);
if ($userid_proto=="IAX")
$userid_array[$var] = str_replace("|PROTO|","IAX2",$userid_array[$var]);
if ($userid_proto=="SIP")
$userid_array[$var] = str_replace("|PROTO|","SIP",$userid_array[$var]);
$userid_array[$var] = str_replace("|ACCOUNT|",$assigneduserid,$userid_array[$var]);
$userid_array[$var] = str_replace("|GATEWAYSTR|",$switchid,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTNUMBER|",$altpnumber,$userid_array[$var]);
$userid_array[$var] = str_replace("|ALTSIPURI|",$altsipurl,$userid_array[$var]);
$userid_array[$var] = str_replace("|TERMINALACTION|",$terminalaction,$userid_array[$var]);
$userid_array[$var] = str_replace("|OUTBOUNDCONTEXT|",$outboundcontext,$userid_array[$var]);
//echo "
UPDATED LINE:".$userid_array[$var];
// we insert into mysql extensions table for dids-inbound
$update_line2 = explode(",",$userid_array[$var]);
$query = "insert into extensions(id,context,exten,priority,app,appdata) values
(0,'transit','".$did."',".$update_line2[0].",'".$update_line2[1]."','".$update_line2[2]."')";
//echo "
".$query;
$result11 = mysql_query($query);
if (!$result11) {
echo '
Cannot update your did settings, please contact technical support (INSERTFAIL)';
require_once("footer.php");
exit;
}
$var += 1;
}