⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page.routing.php

📁 最近在做软交换时研究的一个软交换的东东
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php /* $Id: page.routing.php 1962 2006-05-27 11:55:52Z mheydon1973 $ */// routing.php Copyright (C) 2004 Greg MacLellan (greg@mtechsolutions.ca)// routing.php <trunk & roting priority additions> Copyright (C) 2005 Ron Hartmann (rhartmann@vercomsystems.com)// Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)////This program is free software; you can redistribute it and/or//modify it under the terms of the GNU General Public License//as published by the Free Software Foundation; either version 2//of the License, or (at your option) any later version.////This program is distributed in the hope that it will be useful,//but WITHOUT ANY WARRANTY; without even the implied warranty of//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//GNU General Public License for more details.$display='routing'; $extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:'';$action = isset($_REQUEST['action'])?$_REQUEST['action']:'';$repotrunkdirection = isset($_REQUEST['repotrunkdirection'])?$_REQUEST['repotrunkdirection']:'';$repotrunkkey = isset($_REQUEST['repotrunkkey'])?$_REQUEST['repotrunkkey']:'';$dialpattern = array();if (isset($_REQUEST["dialpattern"])) {	//$dialpattern = $_REQUEST["dialpattern"];	$dialpattern = explode("\n",$_REQUEST["dialpattern"]);	if (!$dialpattern) {		$dialpattern = array();	}		foreach (array_keys($dialpattern) as $key) {		//trim it		$dialpattern[$key] = trim($dialpattern[$key]);				// remove blanks		if ($dialpattern[$key] == "") unset($dialpattern[$key]);				// remove leading underscores (we do that on backend)		if ($dialpattern[$key][0] == "_") $dialpattern[$key] = substr($dialpattern[$key],1);	}		// check for duplicates, and re-sequence	$dialpattern = array_values(array_unique($dialpattern));}	if ( (isset($_REQUEST['reporoutedirection'])) && (isset($_REQUEST['reporoutekey']))) {	$routepriority = core_routing_getroutenames();	$routepriority = core_routing_setroutepriority($routepriority, $_REQUEST['reporoutedirection'], $_REQUEST['reporoutekey']);}$trunkpriority = array();if (isset($_REQUEST["trunkpriority"])) {	$trunkpriority = $_REQUEST["trunkpriority"];	if (!$trunkpriority) {		$trunkpriority = array();	}		// delete blank entries and reorder	foreach (array_keys($trunkpriority) as $key) {		if (empty($trunkpriority[$key])) {			// delete this empty			unset($trunkpriority[$key]);					} else if (($key==($repotrunkkey-1)) && ($repotrunkdirection=="up")) {			// swap this one with the one before (move up)			$temptrunk = $trunkpriority[$key];			$trunkpriority[ $key ] = $trunkpriority[ $key+1 ];			$trunkpriority[ $key+1 ] = $temptrunk;					} else if (($key==($repotrunkkey)) && ($repotrunkdirection=="down")) {			// swap this one with the one after (move down)			$temptrunk = $trunkpriority[ $key+1 ];			$trunkpriority[ $key+1 ] = $trunkpriority[ $key ];			$trunkpriority[ $key ] = $temptrunk;		}	}	unset($temptrunk);	$trunkpriority = array_values($trunkpriority); // resequence our numbers}$routename = isset($_REQUEST["routename"]) ? $_REQUEST["routename"] : "";$routepass = isset($_REQUEST["routepass"]) ? $_REQUEST["routepass"] : "";$emergency = isset($_REQUEST["emergency"]) ? $_REQUEST["emergency"] : "";//if submitting form, update databaseswitch ($action) {	case "addroute":		core_routing_add($routename, $dialpattern, $trunkpriority,"new", $routepass, $emergency);		needreload();		$extdisplay = ''; // resets back to main screen		$routename = ''; // resets back to main screen		$routepass = ''; // resets back to main screen		$dialpattern=array();		$trunkpriority=array();	break;	case "editroute":		core_routing_edit($routename, $dialpattern, $trunkpriority, $routepass, $emergency);		needreload();	break;	case "delroute":		core_routing_del($extdisplay);		// re-order the routes to make sure that there are no skipped numbers.		// example if we have 001-test1, 002-test2, and 003-test3 then delete 002-test2		// we do not want to have our routes as 001-test1, 003-test3 we need to reorder them		// so we are left with 001-test1, 002-test3		$routepriority = core_routing_getroutenames();		$routepriority = core_routing_setroutepriority($routepriority, '','');		needreload();				$extdisplay = ''; // resets back to main screen	break;	case 'renameroute':		if (core_routing_rename($routename, $_REQUEST["newroutename"])) {			needreload();		} else {			echo "<script language=\"javascript\">alert('"._("Error renaming route: duplicate name")."');</script>";		}		$route_prefix=substr($routename,0,4);		$extdisplay=$route_prefix.$_REQUEST["newroutename"];	break;	case 'prioritizeroute':		needreload();	break;	case 'populatenpanxx':		if (preg_match("/^([2-9]\d\d)-?([2-9]\d\d)$/", $_REQUEST["npanxx"], $matches)) {			// first thing we do is grab the exch:			$ch = curl_init();			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);			curl_setopt($ch, CURLOPT_URL, "http://members.dandy.net/~czg/lca_prefix.php?npa=".$matches[1]."&nxx=".$matches[2]."&ocn=&pastdays=0&nextdays=0");			curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; Amportal Local Trunks Configuration)");			$str = curl_exec($ch);			curl_close($ch);						if (preg_match("/exch=(\d+)/",$str, $matches)) {				$ch = curl_init();				curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);				curl_setopt($ch, CURLOPT_URL, "http://members.dandy.net/~czg/lprefix.php?exch=".$matches[1]);				curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; Amportal Local Trunks Configuration)");				$str = curl_exec($ch);				curl_close($ch);								foreach (explode("\n", $str) as $line) {					if (preg_match("/^(\d{3});(\d{3})/", $line, $matches)) {						$dialpattern[] = "1".$matches[1].$matches[2]."XXXX";						//$localprefixes[] = "1".$matches[1].$matches[2];					}				}								// check for duplicates, and re-sequence				$dialpattern = array_values(array_unique($dialpattern));			} else {				$errormsg = _("Error fetching prefix list for: "). $_REQUEST["npanxx"];			}					} else {			// what a horrible error message... :p			$errormsg = _("Invalid format for NPA-NXX code (must be format: NXXNXX)");		}				if (isset($errormsg)) {			echo "<script language=\"javascript\">alert('".addslashes($errormsg)."');</script>";			unset($errormsg);		}	break;}		//get all rows from globals$sql = "SELECT * FROM globals";$globals = $db->getAll($sql);if(DB::IsError($globals)) {die($globals->getMessage());}//create a set of variables that match the items in global[0]foreach ($globals as $global) {	${trim($global[0])} = htmlentities($global[1]);	}?></div><div class="rnav">    <li><a id="<?php  echo ($extdisplay=='' ? 'current':'') ?>" href="config.php?display=<?php echo urlencode($display)?>"><?php echo _("Add Route")?></a></li><?php $reporoutedirection = isset($_REQUEST['reporoutedirection'])?$_REQUEST['reporoutedirection']:'';$reporoutekey = isset($_REQUEST['reporoutekey'])?$_REQUEST['reporoutekey']:'';$key = -1;$routepriority = core_routing_getroutenames();$positions=count($routepriority);foreach ($routepriority as $tresult) {$key++;?>			<?php   // move up    			echo "<li><a id=\"".($extdisplay==$tresult[0] ? 'current':'')."\" href=\"config.php?display=".urlencode($display)."&extdisplay=".urlencode($tresult[0])."\">$key ". substr($tresult[0],4)."</a>";			if ($key > 0) {?>				<img src="images/scrollup.gif" onclick="repositionRoute('<?php echo $key ?>','up')" alt="<?php echo _("Move Up")?>" style="float:none; margin-left:0px; margin-bottom:0px;" width="9" height="11">			<?php  } else { ?>				<img src="images/blank.gif" style="float:none; margin-left:0px; margin-bottom:0px;" width="9" height="11">			<?php  }						// move down						if ($key < ($positions-1)) {?>				<img src="images/scrolldown.gif" onclick="repositionRoute('<?php echo $key ?>','down')" alt="<?php echo _("Move Down")?>"  style="float:none; margin-left:0px; margin-bottom:0px;" width="9" height="11">			<?php  } else { ?>				<img src="images/blank.gif" style="float:none; margin-left:0px; margin-bottom:0px;" width="9" height="11">			<?php  } 			echo "</li>";?>			<?php } // foreach?></div><div class="content"><?php if ($extdisplay) {		// load from db		if (!isset($_REQUEST["dialpattern"])) {		$dialpattern = core_routing_getroutepatterns($extdisplay);	}		if (!isset($_REQUEST["trunkpriority"])) {		$trunkpriority = core_routing_getroutetrunks($extdisplay);	}		if (!isset($_REQUEST["routepass"])) {		$routepass = core_routing_getroutepassword($extdisplay);	}		if (!isset($_REQUEST["emergency"])) {		$emergency = core_routing_getrouteemergency($extdisplay);	}		echo "<h2>"._("Edit Route")."</h2>";} else {		echo "<h2>"._("Add Route")."</h2>";}// build trunks associative arrayforeach (core_trunks_list() as $temp) {	$trunks[$temp[0]] = $temp[1];}if ($extdisplay) { // editing?>	<p><a href="config.php?display=<?php echo urlencode($display) ?>&extdisplay=<?php echo urlencode($extdisplay) ?>&action=delroute"><?php echo _("Delete Route")?> <?php  echo substr($extdisplay,4); ?></a></p><?php  } ?>	<form autocomplete="off" id="routeEdit" name="routeEdit" action="config.php" method="POST" onsubmit="return routeEdit_onsubmit('<?php echo ($extdisplay ? "editroute" : "addroute") ?>');">		<input type="hidden" name="display" value="<?php echo $display?>"/>		<input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>"/>		<input type="hidden" id="action" name="action" value=""/>		<table>		<tr>			<td>				<a href=# class="info"><?php echo _("Route Name")?><span><br><?php echo _("Name of this route. Should be used to describe what type of calls this route matches (for example, 'local' or 'longdistance').")?><br><br></span></a>: 			</td><?php  if ($extdisplay) { // editing?>			<td>				<?php echo substr($extdisplay,4);?>				<input type="hidden" id="routename" name="routename" value="<?php echo $extdisplay;?>"/>				<input type="button" onClick="renameRoute();" value="<?php echo _("Rename")?>" style="font-size:10px;"  />				<input type="hidden" id="newroutename" name="newroutename" value=""/>				<script language="javascript">				function renameRoute() {					do {						var newname = prompt("<?php echo _("Rename route")?> " + document.getElementById('routename').value + " <?php echo _("to:")?>");						if (newname == null) return;					} while (!newname.match('^[a-zA-Z0-9][a-zA-Z0-9]+$') && !alert("<?php echo _("Route name is invalid...please try again")?>"));										document.getElementById('newroutename').value = newname;					document.getElementById('routeEdit').action.value = 'renameroute';					document.getElementById('routeEdit').submit();				}				</script>			</td><?php  } else { // new ?>			<td>				<input type="text" size="20" name="routename" value="<?php echo htmlspecialchars($routename);?>"/>			</td><?php  } ?>		</tr>		<tr>			<td><a href=# class="info"><?php echo _("Route Password")?>:<span><?php echo _("Optional: A route can prompt users for a password before allowing calls to progress.  This is useful for restricting calls to international destinations or 1-900 numbers.<br><br>A numerical password, or the path to an Authenticate password file can be used.<br><br>Leave this field blank to not prompt for password.</span>")?></a></td>			<td><input type="text" size="20" name="routepass" value="<?php echo $routepass;?>"/></td>		</tr><?php

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -