All pastes #212676 Raw Edit

Untitled

public php v1 · immutable
#212676 ·published 2006-10-21 00:12 UTC
rendered paste body
// DID CARRIER STUFFinclude("mysql.inc.php");// GLOBAL DIDSEEN ARRAY$didseen = array();function check_didseen($prefix,$location) {if (empty($prefix)) {// we do a location check onlyif ( 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 "<meta http-equiv='refresh' content='5;URL=".$GLOBALS['not_auth_url_buyer']."'><br>";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."<br>";//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 '                <h2 class="title">'.$lang[72].' ('.$country.')</h2>                <table class="zebraTable" id="DIDsList" cellpadding="0" cellspacing="0" summary="">                        <tr>                                <th class="sortTable">'.$lang[73].'</th>                                <th class="sortTable">'.$lang[74].'</th>                                <th class="sortTable">'.$lang[75].'</th>                                <th class="sortTable">'.$lang[76].'</th>                                <th class="sortTable">'.$lang[77].'</th>				<th class="sortTable">'.$lang[78].'</th>                                <th>&nbsp;</th></tr>';// 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]."<br>";$var += 1;	}echo '</table><br><a href="manage_did.php">'.$lang[70].'</a> <a href="main.php">'.$lang[55].'</a>                <br/>';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 .. :darray_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 '                                         <tr>                                <td>'.$area.'</td>                                <td>'.$row['city'].'</td>                                <td>'.$setup.'</td>                                <td>'.$monthlypricing.'</td>                                <td>'.$price.'</td>                                <td>'.$extraprice.'</td>                                <td><ahref="manage_did.php?action=buy&location='.$row['number'].'&countrycode='.$countrycode.'&cid=0&ccid='.$clientid.'">'.$lang[149].'</a></td>                     </tr>';}// 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." likeconcat(number,'%') order by length(number) DESC";$result2 = mysql_query($query);$row2= mysql_fetch_array($result2);if ( !empty($row2) ) {// we display the package priceecho '<br>'.$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 '<br>'.$lang[80].'.';		} else { 			// actual code to buy the did finally .....			//echo "<br>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 '<br>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 '<br>Cannot assign the did number, contact technical support';} else {echo '<br>'.$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 '<br>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 setclientid='".$clientid."',assignedtouserid='".$first_userid."',userid='".$first_userid."' where number='".$prefix_full."'";$result13 = mysql_query($query);if (!$result13) {echo '<br>Cannot update your did settings, contact technical support';echo '<br>'.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 "<br>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 "<br>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 '<br>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 '<br>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 '<br>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 "<br>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 "<br>".$query;$result12 = mysql_query($query);if (!$result12) {echo '<br>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 "<br>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 "<br>".$query;$result11 = mysql_query($query);if (!$result) {echo '<br>Cannot update your did settings, please contact technical support (INSERTFAIL)';require_once("footer.php");exit;}$var += 1;}echo '<br>'.$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 '<br>'.$lang[150].'.';//echo '<br>CURRENT CREIDT:'.$$row6['currentcreditlimit'];					} else {					// actual code to buy the did finally .....//                        echo "<br>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 '<br>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 '<br>Cannot assign the did number, contact technical support';} else {echo '<br>'.$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 '<br>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 '<br>Cannot update your did settings, contact technical support';echo '<br>'.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 "<br>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 "<br>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 '<br>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 '<br>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 '<br>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 "<br>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 "<br>".$query;$result12 = mysql_query($query);if (!$result12) {echo '<br>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 "<br>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 "<br>".$query;$result11 = mysql_query($query);if (!$result11) {echo '<br>Cannot update your did settings, please contact technical support (INSERTFAIL)';require_once("footer.php");exit;}$var += 1;}