| 1 |
<?php /* $Id$ */ |
|---|
| 2 |
// routing.php Copyright (C) 2004 Greg MacLellan (greg@mtechsolutions.ca) |
|---|
| 3 |
// Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) |
|---|
| 4 |
// |
|---|
| 5 |
//This program is free software; you can redistribute it and/or |
|---|
| 6 |
//modify it under the terms of the GNU General Public License |
|---|
| 7 |
//as published by the Free Software Foundation; either version 2 |
|---|
| 8 |
//of the License, or (at your option) any later version. |
|---|
| 9 |
// |
|---|
| 10 |
//This program is distributed in the hope that it will be useful, |
|---|
| 11 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 |
//GNU General Public License for more details. |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
$display='trunks'; |
|---|
| 18 |
$extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; |
|---|
| 19 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; |
|---|
| 20 |
$tech = strtolower(isset($_REQUEST['tech'])?htmlentities($_REQUEST['tech']):''); |
|---|
| 21 |
|
|---|
| 22 |
$trunknum = ltrim($extdisplay,'OUT_'); |
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
// populate some global variables from the request string |
|---|
| 26 |
$set_globals = array("outcid","maxchans","dialoutprefix","channelid","peerdetails","usercontext","userconfig","register","keepcid","failtrunk","disabletrunk"); |
|---|
| 27 |
foreach ($set_globals as $var) { |
|---|
| 28 |
if (isset($_REQUEST[$var])) { |
|---|
| 29 |
$$var = stripslashes( $_REQUEST[$var] ); |
|---|
| 30 |
} |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
// ensure that keepcid is set to something: |
|---|
| 34 |
if (!isset($keepcid)) { |
|---|
| 35 |
$keepcid = "off"; |
|---|
| 36 |
} |
|---|
| 37 |
// ensure that failtrunk is set to something: |
|---|
| 38 |
if (!isset($failtrunk)) { |
|---|
| 39 |
$failtrunk = ""; |
|---|
| 40 |
} |
|---|
| 41 |
$failtrunk_enable = ($failtrunk == "")?'':'CHECKED'; |
|---|
| 42 |
|
|---|
| 43 |
if (!isset($disabletrunk)) { |
|---|
| 44 |
$disabletrunk = "off"; |
|---|
| 45 |
} |
|---|
| 46 |
|
|---|
| 47 |
if (isset($_REQUEST["dialrules"])) { |
|---|
| 48 |
//$dialpattern = $_REQUEST["dialpattern"]; |
|---|
| 49 |
$dialrules = explode("\n",$_REQUEST["dialrules"]); |
|---|
| 50 |
|
|---|
| 51 |
if (is_array($dialrules)) |
|---|
| 52 |
foreach (array_keys($dialrules) as $key) { |
|---|
| 53 |
//trim it |
|---|
| 54 |
$dialrules[$key] = trim($dialrules[$key]); |
|---|
| 55 |
|
|---|
| 56 |
// remove blanks |
|---|
| 57 |
if ($dialrules[$key] == "") unset($dialrules[$key]); |
|---|
| 58 |
|
|---|
| 59 |
// remove leading underscores (we do that on backend) |
|---|
| 60 |
if ($dialrules[$key][0] == "_") $dialrules[$key] = substr($dialrules[$key],1); |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
// check for duplicates, and re-sequence |
|---|
| 64 |
$dialrules = array_values(array_unique($dialrules)); |
|---|
| 65 |
} else { |
|---|
| 66 |
$dialrules = array(); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
//if submitting form, update database |
|---|
| 70 |
switch ($action) { |
|---|
| 71 |
case "addtrunk": |
|---|
| 72 |
if (!isset($failtrunk)) |
|---|
| 73 |
$failtrunk=""; |
|---|
| 74 |
$trunknum = core_trunks_add($tech, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk),$disabletrunk); |
|---|
| 75 |
|
|---|
| 76 |
core_trunks_addDialRules($trunknum, $dialrules); |
|---|
| 77 |
needreload(); |
|---|
| 78 |
redirect_standard(); |
|---|
| 79 |
break; |
|---|
| 80 |
case "edittrunk": |
|---|
| 81 |
if (!isset($failtrunk)) |
|---|
| 82 |
$failtrunk=""; |
|---|
| 83 |
core_trunks_edit($trunknum, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk), $disabletrunk); |
|---|
| 84 |
|
|---|
| 85 |
/* //DIALRULES |
|---|
| 86 |
deleteTrunkRules($channelid); |
|---|
| 87 |
addTrunkRules($channelid, $dialrules); |
|---|
| 88 |
*/ |
|---|
| 89 |
|
|---|
| 90 |
// this can rewrite too, so edit is the same |
|---|
| 91 |
core_trunks_addDialRules($trunknum, $dialrules); |
|---|
| 92 |
needreload(); |
|---|
| 93 |
redirect_standard('extdisplay'); |
|---|
| 94 |
break; |
|---|
| 95 |
case "deltrunk": |
|---|
| 96 |
|
|---|
| 97 |
core_trunks_del($trunknum); |
|---|
| 98 |
core_routing_trunk_del($trunknum); |
|---|
| 99 |
|
|---|
| 100 |
/* //DIALRULES |
|---|
| 101 |
deleteTrunkRules($channelid); |
|---|
| 102 |
*/ |
|---|
| 103 |
core_trunks_deleteDialRules($trunknum); |
|---|
| 104 |
needreload(); |
|---|
| 105 |
redirect_standard(); |
|---|
| 106 |
break; |
|---|
| 107 |
case "populatenpanxx7": |
|---|
| 108 |
case "populatenpanxx10": |
|---|
| 109 |
if (preg_match("/^([2-9]\d\d)-?([2-9]\d\d)$/", $_REQUEST["npanxx"], $matches)) { |
|---|
| 110 |
// first thing we do is grab the exch: |
|---|
| 111 |
$ch = curl_init(); |
|---|
| 112 |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|---|
| 113 |
curl_setopt($ch, CURLOPT_URL, "http://www.localcallingguide.com/xmllocalprefix.php?npa=".$matches[1]."&nxx=".$matches[2]); |
|---|
| 114 |
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; FreePBX Local Trunks Configuration)"); |
|---|
| 115 |
$str = curl_exec($ch); |
|---|
| 116 |
curl_close($ch); |
|---|
| 117 |
|
|---|
| 118 |
// quick 'n dirty - nabbed from PEAR |
|---|
| 119 |
require_once($amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Parser.php'); |
|---|
| 120 |
require_once($amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Unserializer.php'); |
|---|
| 121 |
|
|---|
| 122 |
$xml = new xml_unserializer; |
|---|
| 123 |
$xml->unserialize($str); |
|---|
| 124 |
$xmldata = $xml->getUnserializedData(); |
|---|
| 125 |
|
|---|
| 126 |
if (isset($xmldata['lca-data']['prefix'])) { |
|---|
| 127 |
|
|---|
| 128 |
if ($action == 'populatenpanxx10') { |
|---|
| 129 |
// 10 digit dialing |
|---|
| 130 |
// - add area code to 7 digits |
|---|
| 131 |
// - match local 10 digits |
|---|
| 132 |
// - add 1 to anything else |
|---|
| 133 |
$dialrules[] = $matches[1].'NXXXXXX'; |
|---|
| 134 |
// add NPA to 7-digits |
|---|
| 135 |
foreach ($xmldata['lca-data']['prefix'] as $prefix) { |
|---|
| 136 |
$dialrules[] = $prefix['npa'].'+'.$prefix['nxx'].'XXXX'; |
|---|
| 137 |
} |
|---|
| 138 |
foreach ($xmldata['lca-data']['prefix'] as $prefix) { |
|---|
| 139 |
$dialrules[] = $prefix['npa'].$prefix['nxx'].'XXXX'; |
|---|
| 140 |
} |
|---|
| 141 |
// if a number was not matched as local, dial it with '1' prefix |
|---|
| 142 |
$dialrules[] = '1+NXXNXXXXXX'; |
|---|
| 143 |
} else { |
|---|
| 144 |
// 7 digit dialing |
|---|
| 145 |
// - drop area code from local numbers |
|---|
| 146 |
// - match local 7 digit numbers |
|---|
| 147 |
// - add 1 to everything else |
|---|
| 148 |
foreach ($xmldata['lca-data']['prefix'] as $prefix) { |
|---|
| 149 |
$dialrules[] = $prefix['npa'].'|'.$prefix['nxx'].'XXXX'; |
|---|
| 150 |
} |
|---|
| 151 |
foreach ($xmldata['lca-data']['prefix'] as $prefix) { |
|---|
| 152 |
$dialrules[] = $prefix['nxx'].'XXXX'; |
|---|
| 153 |
} |
|---|
| 154 |
$dialrules[] = '1+NXXNXXXXXX'; |
|---|
| 155 |
$dialrules[] = '1'.$matches[1].'+NXXXXXX'; |
|---|
| 156 |
} |
|---|
| 157 |
|
|---|
| 158 |
// check for duplicates, and re-sequence |
|---|
| 159 |
$dialrules = array_values(array_unique($dialrules)); |
|---|
| 160 |
} else { |
|---|
| 161 |
$errormsg = _("Error fetching prefix list for: "). $_REQUEST["npanxx"]; |
|---|
| 162 |
} |
|---|
| 163 |
|
|---|
| 164 |
} else { |
|---|
| 165 |
// what a horrible error message... :p |
|---|
| 166 |
$errormsg = _("Invalid format for NPA-NXX code (must be format: NXXNXX)"); |
|---|
| 167 |
} |
|---|
| 168 |
|
|---|
| 169 |
if (isset($errormsg)) { |
|---|
| 170 |
echo "<script language=\"javascript\">alert('".addslashes($errormsg)."');</script>"; |
|---|
| 171 |
unset($errormsg); |
|---|
| 172 |
} |
|---|
| 173 |
break; |
|---|
| 174 |
} |
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
//get all rows from globals |
|---|
| 179 |
$sql = "SELECT * FROM globals"; |
|---|
| 180 |
$globals = $db->getAll($sql); |
|---|
| 181 |
if(DB::IsError($globals)) { |
|---|
| 182 |
die_freepbx($globals->getMessage()); |
|---|
| 183 |
} |
|---|
| 184 |
|
|---|
| 185 |
//create a set of variables that match the items in global[0] |
|---|
| 186 |
foreach ($globals as $global) { |
|---|
| 187 |
${trim($global[0])} = htmlentities($global[1]); |
|---|
| 188 |
} |
|---|
| 189 |
|
|---|
| 190 |
?> |
|---|
| 191 |
</div> |
|---|
| 192 |
|
|---|
| 193 |
<div class="rnav"> |
|---|
| 194 |
<ul> |
|---|
| 195 |
<li><a <?php echo ($extdisplay=='' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($display)?>"><?php echo _("Add Trunk")?></a></li> |
|---|
| 196 |
<?php |
|---|
| 197 |
//get existing trunk info |
|---|
| 198 |
$tresults = core_trunks_list(); |
|---|
| 199 |
|
|---|
| 200 |
foreach ($tresults as $tresult) { |
|---|
| 201 |
$background = ($tresult[2] == 'on')?'#DDD':''; |
|---|
| 202 |
echo "\t<li><a ".($extdisplay==$tresult[0] ? 'class="current"':'')." href=\"config.php?display=".urlencode($display)."&extdisplay=".urlencode($tresult[0])."\" title=\"".urlencode($tresult[1])."\" style=\"background: $background;\" >"._("Trunk")." ".substr(str_replace('AMP:', '', $tresult[1]),0,15)."</a></li>\n"; |
|---|
| 203 |
} |
|---|
| 204 |
|
|---|
| 205 |
?> |
|---|
| 206 |
</ul> |
|---|
| 207 |
</div> |
|---|
| 208 |
|
|---|
| 209 |
<div class="content"> |
|---|
| 210 |
|
|---|
| 211 |
<?php |
|---|
| 212 |
|
|---|
| 213 |
if (!$tech && !$extdisplay) { |
|---|
| 214 |
?> |
|---|
| 215 |
<h2><?php echo _("Add a Trunk")?></h2> |
|---|
| 216 |
<a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&tech=ZAP"><?php echo _("Add ZAP Trunk")?></a><br><br> |
|---|
| 217 |
<a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&tech=IAX2"><?php echo _("Add IAX2 Trunk")?></a><br><br> |
|---|
| 218 |
<a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&tech=SIP"><?php echo _("Add SIP Trunk")?></a><br><br> |
|---|
| 219 |
<a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&tech=ENUM"><?php echo _("Add ENUM Trunk")?></a><br><br> |
|---|
| 220 |
<a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&tech=CUSTOM"><?php echo _("Add Custom Trunk")?></a><br><br> |
|---|
| 221 |
<?php |
|---|
| 222 |
} else { |
|---|
| 223 |
if ($extdisplay) { |
|---|
| 224 |
//list($trunk_tech, $trunk_name) = explode("/",$tname); |
|---|
| 225 |
//if ($trunk_tech == "IAX2") $trunk_tech = "IAX"; // same thing |
|---|
| 226 |
$tech = core_trunks_getTrunkTech($trunknum); |
|---|
| 227 |
|
|---|
| 228 |
$outcid = ${"OUTCID_".$trunknum}; |
|---|
| 229 |
$maxchans = ${"OUTMAXCHANS_".$trunknum}; |
|---|
| 230 |
$dialoutprefix = ${"OUTPREFIX_".$trunknum}; |
|---|
| 231 |
$keepcid = isset(${"OUTKEEPCID_".$trunknum})?${"OUTKEEPCID_".$trunknum}:''; |
|---|
| 232 |
$failtrunk = isset(${"OUTFAIL_".$trunknum})?${"OUTFAIL_".$trunknum}:''; |
|---|
| 233 |
$failtrunk_enable = ($failtrunk == "")?'':'CHECKED'; |
|---|
| 234 |
$disabletrunk = isset(${"OUTDISABLE_".$trunknum})?${"OUTDISABLE_".$trunknum}:''; |
|---|
| 235 |
|
|---|
| 236 |
if ($tech!="enum") { |
|---|
| 237 |
|
|---|
| 238 |
if (!isset($channelid)) { |
|---|
| 239 |
$channelid = core_trunks_getTrunkTrunkName($trunknum); |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
if ($tech!="custom") { // custom trunks will not have user/peer details in database table |
|---|
| 243 |
// load from db |
|---|
| 244 |
if (!isset($peerdetails)) { |
|---|
| 245 |
$peerdetails = core_trunks_getTrunkPeerDetails($trunknum); |
|---|
| 246 |
} |
|---|
| 247 |
|
|---|
| 248 |
if (!isset($usercontext)) { |
|---|
| 249 |
$usercontext = core_trunks_getTrunkUserContext($trunknum); |
|---|
| 250 |
} |
|---|
| 251 |
|
|---|
| 252 |
if (!isset($userconfig)) { |
|---|
| 253 |
$userconfig = core_trunks_getTrunkUserConfig($trunknum); |
|---|
| 254 |
} |
|---|
| 255 |
|
|---|
| 256 |
if (!isset($register)) { |
|---|
| 257 |
$register = core_trunks_getTrunkRegister($trunknum); |
|---|
| 258 |
} |
|---|
| 259 |
} |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
if (count($dialrules) == 0) { |
|---|
| 263 |
if ($temp = core_trunks_getDialRules($trunknum)) { |
|---|
| 264 |
foreach ($temp as $key=>$val) { |
|---|
| 265 |
// extract all ruleXX keys |
|---|
| 266 |
if (preg_match("/^rule\d+$/",$key)) { |
|---|
| 267 |
$dialrules[] = $val; |
|---|
| 268 |
} |
|---|
| 269 |
} |
|---|
| 270 |
} |
|---|
| 271 |
unset($temp); |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
echo "<h2>".sprintf(_("Edit %s Trunk"),strtoupper($tech))."</h2>"; |
|---|
| 275 |
?> |
|---|
| 276 |
<p><a title="<?php echo $channelid ?>" href="config.php?display=<?php echo urlencode($display) ?>&extdisplay=<?php echo urlencode($extdisplay) ?>&action=deltrunk"><?php echo _("Delete Trunk")?> <?php echo substr($channelid,0,20); ?></a></p> |
|---|
| 277 |
<?php |
|---|
| 278 |
|
|---|
| 279 |
// find which routes use this trunk |
|---|
| 280 |
$routes = core_trunks_gettrunkroutes($trunknum); |
|---|
| 281 |
$num_routes = count($routes); |
|---|
| 282 |
if ($num_routes > 0) { |
|---|
| 283 |
echo "<a href=# class=\"info\">"._("In use by")." ".$num_routes." ".($num_routes == 1 ? _("route") : _("routes"))."<span>"; |
|---|
| 284 |
foreach($routes as $route=>$priority) { |
|---|
| 285 |
echo _("Route")." <b>".$route."</b>: "._("Sequence")." <b>".$priority."</b><br>"; |
|---|
| 286 |
} |
|---|
| 287 |
echo "</span></a>"; |
|---|
| 288 |
} else { |
|---|
| 289 |
echo "<b>"._("WARNING:")."</b> <a href=# class=\"info\">"._("This trunk is not used by any routes!")."<span>"; |
|---|
| 290 |
echo _("This trunk will not be able to be used for outbound calls until a route is setup that uses it. Click on <b>Outbound Routes</b> to setup routing."); |
|---|
| 291 |
echo "</span></a>"; |
|---|
| 292 |
} |
|---|
| 293 |
echo "<br><br>"; |
|---|
| 294 |
|
|---|
| 295 |
} else { |
|---|
| 296 |
// set defaults |
|---|
| 297 |
$outcid = ""; |
|---|
| 298 |
$maxchans = ""; |
|---|
| 299 |
$dialoutprefix = ""; |
|---|
| 300 |
|
|---|
| 301 |
if ($tech == "zap") { |
|---|
| 302 |
$channelid = "g0"; |
|---|
| 303 |
} else { |
|---|
| 304 |
$channelid = ""; |
|---|
| 305 |
} |
|---|
| 306 |
|
|---|
| 307 |
// only for iax2/sip |
|---|
| 308 |
$peerdetails = "host=***provider ip address***\nusername=***userid***\nsecret=***password***\ntype=peer"; |
|---|
| 309 |
$usercontext = ""; |
|---|
| 310 |
$userconfig = "secret=***password***\ntype=user\ncontext=from-trunk"; |
|---|
| 311 |
$register = ""; |
|---|
| 312 |
|
|---|
| 313 |
$localpattern = "NXXXXXX"; |
|---|
| 314 |
$lddialprefix = "1"; |
|---|
| 315 |
$areacode = ""; |
|---|
| 316 |
|
|---|
| 317 |
echo "<h2>".sprintf("Add %s Trunk",strtoupper($tech))."</h2>"; |
|---|
| 318 |
} |
|---|
| 319 |
?> |
|---|
| 320 |
|
|---|
| 321 |
<form name="trunkEdit" action="config.php" method="post" onsubmit="return trunkEdit_onsubmit('<?php echo ($extdisplay ? "edittrunk" : "addtrunk") ?>');"> |
|---|
| 322 |
<input type="hidden" name="display" value="<?php echo $display?>"/> |
|---|
| 323 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>"/> |
|---|
| 324 |
<input type="hidden" name="action" value=""/> |
|---|
| 325 |
<input type="hidden" name="tech" value="<?php echo $tech?>"/> |
|---|
| 326 |
<table> |
|---|
| 327 |
<tr> |
|---|
| 328 |
<td colspan="2"> |
|---|
| 329 |
<h4><?php echo _("General Settings")?></h4> |
|---|
| 330 |
</td> |
|---|
| 331 |
</tr> |
|---|
| 332 |
<tr> |
|---|
| 333 |
<td> |
|---|
| 334 |
<a href=# class="info"><?php echo _("Outbound Caller ID")?><span><br><?php echo _("Caller ID for calls placed out on this trunk<br><br>Format: <b>\"caller name\" <#######></b>. You can also use the magic string 'hidden' to hide the CallerID sent out over Digital lines ONLY (E1/T1/J1/BRI/SIP/IAX)")?><br><br></span></a>: |
|---|
| 335 |
</td><td> |
|---|
| 336 |
<input type="text" size="20" name="outcid" value="<?php echo $outcid;?>"/> |
|---|
| 337 |
</td> |
|---|
| 338 |
</tr> |
|---|
| 339 |
<tr> |
|---|
| 340 |
<td> |
|---|
| 341 |
<a href="#" class="info"><?php echo _("Never Override CallerID")?><span><br><?php echo _("Some VoIP providers will drop the call if you try to send an invalid CallerID (one you don't 'own.' Use this to never send a CallerID that you haven't explicitly specified in this trunk or in the outbound callerid field of an extension/user. You might notice this problem if you discover that Follow-Me or RingGroups with external numbers don't work properly. Checking this box has the effect of disabling 'foreign' callerids from going out this trunk. You must define an Outbound Caller ID on the this trunk when checking this.");?><br /><br /></span></a>: |
|---|
| 342 |
</td><td> |
|---|
| 343 |
<input type="checkbox" name="keepcid" <?php if ($keepcid=="on") {echo "checked";}?>/> |
|---|
| 344 |
</td> |
|---|
| 345 |
<tr> |
|---|
| 346 |
<td> |
|---|
| 347 |
<?php |
|---|
| 348 |
if ($tech == "sip" || substr($tech,0,3) == "iax") { |
|---|
| 349 |
?> |
|---|
| 350 |
<a href=# class="info"><?php echo _("Maximum channels")?><span><?php echo sprintf(_("Controls the maximum number of outbound channels (simultaneous calls) that can be used on this trunk. To count inbound calls against this maximum, use the auto-generated context: %s as the inbound trunk's context. (see extensions_additional.conf) Leave blank to specify no maximum."),((isset($channelid) && trim($channelid)!="")?"from-trunk-$channelid":"from-trunk-[trunkname]"))?></span></a>: |
|---|
| 351 |
<?php |
|---|
| 352 |
} else { |
|---|
| 353 |
?> |
|---|
| 354 |
<a href=# class="info"><?php echo _("Maximum channels")?><span><?php echo _("Controls the maximum number of outbound channels (simultaneous calls) that can be used on this trunk. Inbound calls are not counted against the maximum. Leave blank to specify no maximum.")?></span></a>: |
|---|
| 355 |
<?php |
|---|
| 356 |
} |
|---|
| 357 |
?> |
|---|
| 358 |
</td><td> |
|---|
| 359 |
<input type="text" size="3" name="maxchans" value="<?php echo htmlspecialchars($maxchans); ?>"/> |
|---|
| 360 |
</td> |
|---|
| 361 |
</tr> |
|---|
| 362 |
|
|---|
| 363 |
<tr> |
|---|
| 364 |
<td><a class="info" href="#"><?php echo _("Disable Trunk")?><span><?php echo _("Check this to disable this trunk in all routes where it is used.")?></span></a>: |
|---|
| 365 |
</td> |
|---|
| 366 |
<td> |
|---|
| 367 |
<input type='checkbox' name='disabletrunk' id="disabletrunk" <?php if ($disabletrunk=="on") { echo 'CHECKED'; }?> OnClick='disable_verify(disabletrunk); return true;'><small><?php echo _("Disable")?></small> |
|---|
| 368 |
</td> |
|---|
| 369 |
</tr> |
|---|
| 370 |
|
|---|
| 371 |
<tr> |
|---|
| 372 |
<td><a class="info" href="#"><?php echo _("Monitor Trunk Failures")?><span><?php echo _("If checked, supply the name of a custom AGI Script that will be called to report, log, email or otherwise take some action on trunk failures that are not caused by either NOANSWER or CANCEL.")?></span></a>: |
|---|
| 373 |
</td> |
|---|
| 374 |
<td> |
|---|
| 375 |
<input <?php if (!$failtrunk_enable) echo "disabled style='background: #DDD;'"?> type="text" size="20" name="failtrunk" value="<?php echo htmlspecialchars($failtrunk)?>"/> |
|---|
| 376 |
<input type='checkbox' name='failtrunk_enable' id="failtrunk_enable" value='1' <?php if ($failtrunk_enable) { echo 'CHECKED'; }?> OnClick='disable_field(failtrunk,failtrunk_enable); return true;'><small><?php echo _("Enable")?></small> |
|---|
| 377 |
</td> |
|---|
| 378 |
</tr> |
|---|
| 379 |
|
|---|
| 380 |
<tr> |
|---|
| 381 |
<td colspan="2"> |
|---|
| 382 |
<br><h4><?php echo _("Outgoing Dial Rules")?></h4> |
|---|
| 383 |
</td> |
|---|
| 384 |
</tr> |
|---|
| 385 |
<tr> |
|---|
| 386 |
<td valign="top"> |
|---|
| 387 |
<a href=# class="info"><?php echo _("Dial Rules")?><span><?php echo _("A Dial Rule controls how calls will be dialed on this trunk. It can be used to add or remove prefixes. Numbers that don't match any patterns defined here will be dialed as-is. Note that a pattern without a + or | (to add or remove a prefix) will not make any changes but will create a match. Only the first matched rule will be executed and the remaining rules will not be acted on.")?><br /><br /><b><?php echo _("Rules:")?></b><br /> |
|---|
| 388 |
<strong>X</strong> <?php echo _("matches any digit from 0-9")?><br /> |
|---|
| 389 |
<strong>Z</strong> <?php echo _("matches any digit from 1-9")?><br /> |
|---|
| 390 |
<strong>N</strong> <?php echo _("matches any digit from 2-9")?><br /> |
|---|
| 391 |
<strong>[1237-9]</strong> <?php echo _("matches any digit or letter in the brackets (in this example, 1,2,3,7,8,9)")?><br /> |
|---|
| 392 |
<strong>.</strong> <?php echo _("wildcard, matches one or more characters (not allowed before a | or +)")?><br /> |
|---|
| 393 |
<strong>|</strong> <?php echo _("removes a dialing prefix from the number (for example, 613|NXXXXXX would match when some dialed \"6135551234\" but would only pass \"5551234\" to the trunk)")?> |
|---|
| 394 |
<strong>+</strong> <?php echo _("adds a dialing prefix from the number (for example, 1613+NXXXXXX would match when some dialed \"5551234\" and would pass \"16135551234\" to the trunk)")?><br /><br /> |
|---|
| 395 |
<?php echo _("You can also use both + and |, for example: 01+0|1ZXXXXXXXXX would match \"016065551234\" and dial it as \"0116065551234\" Note that the order does not matter, eg. 0|01+1ZXXXXXXXXX does the same thing."); ?> |
|---|
| 396 |
</span></a>: |
|---|
| 397 |
</td><td valign="top"> |
|---|
| 398 |
<textarea id="dialrules" cols="20" rows="<?php |
|---|
| 399 |
if (is_array($dialrules)) { |
|---|
| 400 |
$rows = count($dialrules)+1; |
|---|
| 401 |
echo (($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows) ); |
|---|
| 402 |
} else { |
|---|
| 403 |
echo "5"; |
|---|
| 404 |
} ?>" name="dialrules"><?php if(is_array($dialrules)) { echo implode("\n",$dialrules); } ?></textarea><br> |
|---|
| 405 |
|
|---|
| 406 |
<input type="submit" style="font-size:10px;" value="<?php echo _("Clean & Remove duplicates")?>" /> |
|---|
| 407 |
</td> |
|---|
| 408 |
</tr> |
|---|
| 409 |
<tr> |
|---|
| 410 |
<td> |
|---|
| 411 |
<a href=# class="info"><?php echo _("Dial rules wizards")?><span> |
|---|
| 412 |
<strong><?php echo _("Always dial with prefix")?></strong> <?php echo _("is useful for VoIP trunks, where if a number is dialed as \"5551234\", it can be converted to \"16135551234\".")?><br> |
|---|
| 413 |
<strong><?php echo _("Remove prefix from local numbers")?></strong> <?php echo _("is useful for ZAP trunks, where if a local number is dialed as \"6135551234\", it can be converted to \"555-1234\".")?><br> |
|---|
| 414 |
<strong><?php echo _("Lookup numbers for local trunk")?></strong> <?php echo _("This looks up your local number on www.localcallingguide.com (NA-only), and sets up so you can dial either 7 or 10 digits (regardless of what your PSTN is) on a local trunk (where you have to dial 1+areacode for long distance, but only 5551234 (7-digit dialing) or 6135551234 (10-digit dialing) for local calls")?><br> |
|---|
| 415 |
</span></a>: |
|---|
| 416 |
</td><td valign="top"> <select id="autopop" name="autopop" onChange="changeAutoPop(); "> |
|---|
| 417 |
<option value="" SELECTED><?php echo _("(pick one)")?></option> |
|---|
| 418 |
<option value="always"><?php echo _("Always dial with prefix")?></option> |
|---|
| 419 |
<option value="remove"><?php echo _("Remove prefix from local numbers")?></option> |
|---|
| 420 |
<option value="lookup7"><?php echo _("Lookup numbers for local trunk (7-digit dialing)")?></option> |
|---|
| 421 |
<option value="lookup10"><?php echo _("Lookup numbers for local trunk (10-digit dialing)")?></option> |
|---|
| 422 |
</select> |
|---|
| 423 |
</td> |
|---|
| 424 |
</tr> |
|---|
| 425 |
<input id="npanxx" name="npanxx" type="hidden" /> |
|---|
| 426 |
<script language="javascript"> |
|---|
| 427 |
|
|---|
| 428 |
function disable_field(field, field_enable) { |
|---|
| 429 |
if (field_enable.checked) { |
|---|
| 430 |
field.style.backgroundColor = '#FFF'; |
|---|
| 431 |
field.disabled = false; |
|---|
| 432 |
} |
|---|
| 433 |
else { |
|---|
| 434 |
field.style.backgroundColor = '#DDD'; |
|---|
| 435 |
field.disabled = true; |
|---|
| 436 |
} |
|---|
| 437 |
} |
|---|
| 438 |
|
|---|
| 439 |
function disable_verify(field) { |
|---|
| 440 |
if (field.checked) { |
|---|
| 441 |
var answer=confirm("Are you sure you want to disable this trunk in all routes it is used?"); |
|---|
| 442 |
if (!answer) { |
|---|
| 443 |
field.checked = false; |
|---|
| 444 |
} |
|---|
| 445 |
} |
|---|
| 446 |
else { |
|---|
| 447 |
alert("You have enabled this trunk in all routes it is used"); |
|---|
| 448 |
} |
|---|
| 449 |
} |
|---|
| 450 |
|
|---|
| 451 |
function populateLookup(digits) { |
|---|
| 452 |
<?php |
|---|
| 453 |
if (function_exists("curl_init")) { // curl is installed |
|---|
| 454 |
?> |
|---|
| 455 |
//var npanxx = prompt("What is your areacode + prefix (NPA-NXX)?", document.getElementById('areacode').value); |
|---|
| 456 |
do { |
|---|
| 457 |
var npanxx = <?php echo 'prompt("'._("What is your areacode + prefix (NPA-NXX)?\\n\\n(Note: this database contains North American numbers only, and is not guaranteed to be 100% accurate. You will still have the option of modifying results.)\\n\\nThis may take a few seconds.".'")')?>; |
|---|
| 458 |
if (npanxx == null) return; |
|---|
| 459 |
} while (!npanxx.match("^[2-9][0-9][0-9][-]?[2-9][0-9][0-9]$") && <?php echo '!alert("'._("Invalid NPA-NXX. Must be of the format \'NXX-NXX\'").'")'?>); |
|---|
| 460 |
|
|---|
| 461 |
document.getElementById('npanxx').value = npanxx; |
|---|
| 462 |
if (digits == 10) { |
|---|
| 463 |
document.trunkEdit.action.value = "populatenpanxx10"; |
|---|
| 464 |
} else { |
|---|
| 465 |
document.trunkEdit.action.value = "populatenpanxx7"; |
|---|
| 466 |
} |
|---|
| 467 |
document.trunkEdit.submit(); |
|---|
| 468 |
<?php |
|---|
| 469 |
} else { // curl is not installed |
|---|
| 470 |
?> |
|---|
| 471 |
<?php echo 'alert("'._("Error: Cannot continue!\\n\\nPrefix lookup requires cURL support in PHP on the server. Please install or enable cURL support in your PHP installation to use this function. See http://www.php.net/curl for more information.").'")'?>; |
|---|
| 472 |
<?php |
|---|
| 473 |
} |
|---|
| 474 |
?> |
|---|
| 475 |
} |
|---|
| 476 |
|
|---|
| 477 |
function populateAlwaysAdd() { |
|---|
| 478 |
do { |
|---|
| 479 |
var localpattern = <?php echo 'prompt("'._("What is the local dialing pattern?\\n\\n(ie. NXXNXXXXXX for US/CAN 10-digit dialing, NXXXXXX for 7-digit)").'"'?>,"NXXXXXX"); |
|---|
| 480 |
if (localpattern == null) return; |
|---|
| 481 |
} while (!localpattern.match('^[0-9#*ZXN\.]+$') && <?php echo '!alert("'._("Invalid pattern. Only 0-9, #, *, Z, N, X and . are allowed.").'")'?>); |
|---|
| 482 |
|
|---|
| 483 |
do { |
|---|
| 484 |
var localprefix = <?php echo 'prompt("'._("What prefix should be added to the dialing pattern?\\n\\n(ie. for US/CAN, 1+areacode, ie, \'1613\')?").'")'?>; |
|---|
| 485 |
if (localprefix == null) return; |
|---|
| 486 |
} while (!localprefix.match('^[0-9#*]+$') && <?php echo '!alert("'._("Invalid prefix. Only dialable characters (0-9, #, and *) are allowed.").'")'?>); |
|---|
| 487 |
|
|---|
| 488 |
dialrules = document.getElementById('dialrules'); |
|---|
| 489 |
if (dialrules.value[dialrules.value.length-1] != '\n') { |
|---|
| 490 |
dialrules.value = dialrules.value + '\n'; |
|---|
| 491 |
} |
|---|
| 492 |
dialrules.value = dialrules.value + localprefix + '+' + localpattern + '\n'; |
|---|
| 493 |
} |
|---|
| 494 |
|
|---|
| 495 |
function populateRemove() { |
|---|
| 496 |
do { |
|---|
| 497 |
var localprefix = <?php echo 'prompt("'._("What prefix should be removed from the number?\\n\\n(ie. for US/CAN, 1+areacode, ie, \'1613\')").'")'?>; |
|---|
| 498 |
if (localprefix == null) return; |
|---|
| 499 |
} while (!localprefix.match('^[0-9#*ZXN\.]+$') && <?php echo '!alert("'._('Invalid prefix. Only 0-9, #, *, Z, N, and X are allowed.').'")'?>); |
|---|
| 500 |
|
|---|
| 501 |
do { |
|---|
| 502 |
var localpattern = <?php echo 'prompt("'._("What is the dialing pattern for local numbers after")?> "+localprefix+"? \n\n<?php echo _("(ie. NXXNXXXXXX for US/CAN 10-digit dialing, NXXXXXX for 7-digit)").'"'?>,"NXXXXXX"); |
|---|
| 503 |
if (localpattern == null) return; |
|---|
| 504 |
} while (!localpattern.match('^[0-9#*ZXN\.]+$') && <?php echo '!alert("'._("Invalid pattern. Only 0-9, #, *, Z, N, X and . are allowed.").'")'?>); |
|---|
| 505 |
|
|---|
| 506 |
dialrules = document.getElementById('dialrules'); |
|---|
| 507 |
if (dialrules.value[dialrules.value.length-1] != '\n') { |
|---|
| 508 |
dialrules.value = dialrules.value + '\n'; |
|---|
| 509 |
} |
|---|
| 510 |
dialrules.value = dialrules.value + localprefix + '|' + localpattern + '\n'; |
|---|
| 511 |
} |
|---|
| 512 |
|
|---|
| 513 |
function changeAutoPop() { |
|---|
| 514 |
switch(document.getElementById('autopop').value) { |
|---|
| 515 |
case "always": |
|---|
| 516 |
populateAlwaysAdd(); |
|---|
| 517 |
break; |
|---|
| 518 |
case "remove": |
|---|
| 519 |
populateRemove(); |
|---|
| 520 |
break; |
|---|
| 521 |
case "lookup7": |
|---|
| 522 |
populateLookup(7); |
|---|
| 523 |
break; |
|---|
| 524 |
case "lookup10": |
|---|
| 525 |
populateLookup(10); |
|---|
| 526 |
break; |
|---|
| 527 |
} |
|---|
| 528 |
document.getElementById('autopop').value = ''; |
|---|
| 529 |
} |
|---|
| 530 |
</script> |
|---|
| 531 |
<?php /* //DIALRULES |
|---|
| 532 |
<tr> |
|---|
| 533 |
<td> |
|---|
| 534 |
<a href=# class="info">Dial rules<span>The area code this trunk is in.</span></a>: |
|---|
| 535 |
</td><td> |
|---|
| 536 |
<select id="dialrulestype" name="dialrulestype" onChange="changeRulesType();"> |
|---|
| 537 |
<?php |
|---|
| 538 |
$rules = array( "asis" => "Don't change number", |
|---|
| 539 |
"always" => "Always dial prefix+areacode", |
|---|
| 540 |
"local" => "Local 7-digit dialing", |
|---|
| 541 |
"local10" => "Local 10-digit dialing"); |
|---|
| 542 |
|
|---|
| 543 |
foreach ($rules as $value=>$display) { |
|---|
| 544 |
echo "<option value=\"".$value."\" ".(($value == $dialrulestype) ? "SELECTED" : "").">".$display."</option>"; |
|---|
| 545 |
} |
|---|
| 546 |
?> |
|---|
| 547 |
</select> |
|---|
| 548 |
|
|---|
| 549 |
</td> |
|---|
| 550 |
</tr> |
|---|
| 551 |
<tr> |
|---|
| 552 |
<td> |
|---|
| 553 |
<a href=# class="info"><?php echo _("Local dialing pattern<span>The dialing pattern to make a 'local' call.</span>")</a>: |
|---|
| 554 |
</td><td> |
|---|
| 555 |
<input id="localpattern" type="text" size="10" maxlength="20" name="localpattern" value="<?php echo $localpattern ?>"/> |
|---|
| 556 |
|
|---|
| 557 |
</td> |
|---|
| 558 |
</tr> |
|---|
| 559 |
<tr> |
|---|
| 560 |
<td> |
|---|
| 561 |
<a href=# class="info"><?php echo _("Long-distance dial prefix<span>The prefix for dialing long-distance numbers. In north america, this should be \"1\".</span>")?></a>: |
|---|
| 562 |
</td><td> |
|---|
| 563 |
<input id="lddialprefix" type="text" size="3" maxlength="6" name="lddialprefix" value="<?php echo $lddialprefix ?>"/> |
|---|
| 564 |
|
|---|
| 565 |
</td> |
|---|
| 566 |
</tr> |
|---|
| 567 |
<tr> |
|---|
| 568 |
<td> |
|---|
| 569 |
<a href=# class="info"><?php echo _("Local LD prefix<span>The area code this trunk is in. Any 7-digit numbers that don't match a number in the below list will have dialprefix+areacode added to them. </span>")?></a>: |
|---|
| 570 |
</td><td> |
|---|
| 571 |
<input id="areacode" type="text" size="3" maxlength="6" name="areacode" value="<?php echo $areacode ?>"/> |
|---|
| 572 |
|
|---|
| 573 |
</td> |
|---|
| 574 |
</tr> |
|---|
| 575 |
<tr> |
|---|
| 576 |
<td valign="top"> |
|---|
| 577 |
<a href=# class="info"><?php echo _("Local prefixes<span>This should be a list of local areacodes + prefixes to use for local dialing.</span>")?></a>: |
|---|
| 578 |
</td><td valign="top"> |
|---|
| 579 |
<textarea id="localprefixes" cols="8" rows="<?php $rows = count($localprefixes)+1; echo (($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows) ); ?>" name="localprefixes"><?php echo implode("\n",$localprefixes);?></textarea><br> |
|---|
| 580 |
|
|---|
| 581 |
<input id="npanxx" name="npanxx" type="hidden" /><br> |
|---|
| 582 |
<a href=# class="info"><?php echo _("Populate with local rules<span>Do a lookup from http://members.dandy.net/~czg/search.html to find all local-reachable area codes and phone numbers.</span>")?></a>: <input type="button" value="Go" onClick="checkPopulate();" /> |
|---|
| 583 |
<br><br> |
|---|
| 584 |
</td> |
|---|
| 585 |
</tr> |
|---|
| 586 |
<script language="javascript"> |
|---|
| 587 |
|
|---|
| 588 |
function checkPopulate() { |
|---|
| 589 |
//var npanxx = prompt("What is your areacode + prefix (NPA-NXX)?", document.getElementById('areacode').value); |
|---|
| 590 |
var npanxx = <?php echo 'prompt("'._("What is your areacode + prefix (NPA-NXX)?").'")'?>; |
|---|
| 591 |
|
|---|
| 592 |
if (npanxx.match("^[2-9][0-9][0-9][-]?[2-9][0-9][0-9]$")) { |
|---|
| 593 |
document.getElementById('npanxx').value = npanxx; |
|---|
| 594 |
trunkEdit.action.value = "populatenpanxx"; |
|---|
| 595 |
trunkEdit.submit(); |
|---|
| 596 |
} else if (npanxx != null) { |
|---|
| 597 |
<?php echo 'alert("'._("Invalid format for NPA-NXX code (must be format: NXXNXX)").'")'?>; |
|---|
| 598 |
} |
|---|
| 599 |
} |
|---|
| 600 |
|
|---|
| 601 |
function changeRulesType() { |
|---|
| 602 |
switch(document.getElementById('dialrulestype').value) { |
|---|
| 603 |
case "always": |
|---|
| 604 |
document.getElementById('lddialprefix').disabled = false; |
|---|
| 605 |
document.getElementById('areacode').disabled = false; |
|---|
| 606 |
document.getElementById('localprefixes').disabled = true; |
|---|
| 607 |
break; |
|---|
| 608 |
case "local": |
|---|
| 609 |
case "local10": |
|---|
| 610 |
document.getElementById('lddialprefix').disabled = false; |
|---|
| 611 |
document.getElementById('areacode').disabled = false; |
|---|
| 612 |
document.getElementById('localprefixes').disabled = false; |
|---|
| 613 |
break; |
|---|
| 614 |
case "asis": |
|---|
| 615 |
default: |
|---|
| 616 |
document.getElementById('lddialprefix').disabled = true; |
|---|
| 617 |
document.getElementById('areacode').disabled = true; |
|---|
| 618 |
document.getElementById('localprefixes').disabled = true; |
|---|
| 619 |
break; |
|---|
| 620 |
} |
|---|
| 621 |
} |
|---|
| 622 |
changeRulesType(); |
|---|
| 623 |
</script> |
|---|
| 624 |
*/?> |
|---|
| 625 |
<tr> |
|---|
| 626 |
<td> |
|---|
| 627 |
<a href=# class="info"><?php echo _("Outbound Dial Prefix")?><span><?php echo _("The outbound dialing prefix is used to prefix a dialing string to all outbound calls placed on this trunk. For example, if this trunk is behind another PBX or is a Centrex line, then you would put 9 here to access an outbound line. Another common use is to prefix calls with 'w' on a POTS line that need time to obtain dialtone to avoid eating digits.<br><br>Most users should leave this option blank.")?></span></a>: |
|---|
| 628 |
</td><td> |
|---|
| 629 |
<input type="text" size="8" name="dialoutprefix" value="<?php echo htmlspecialchars($dialoutprefix) ?>"/> |
|---|
| 630 |
</td> |
|---|
| 631 |
</tr> |
|---|
| 632 |
<?php if ($tech != "enum") { ?> |
|---|
| 633 |
<tr> |
|---|
| 634 |
<td colspan="2"> |
|---|
| 635 |
<br><h4><?php echo _("Outgoing Settings")?></h4> |
|---|
| 636 |
</td> |
|---|
| 637 |
</tr> |
|---|
| 638 |
<?php } ?> |
|---|
| 639 |
|
|---|
| 640 |
<?php |
|---|
| 641 |
switch ($tech) { |
|---|
| 642 |
case "zap": |
|---|
| 643 |
?> |
|---|
| 644 |
<tr> |
|---|
| 645 |
<td> |
|---|
| 646 |
<a href=# class="info"><?php echo _("Zap Identifier (trunk name)")?><span><br><?php echo _("ZAP channels are referenced either by a group number or channel number (which is defined in zapata.conf). <br><br>The default setting is <b>g0</b> (group zero).")?><br><br></span></a>: |
|---|
| 647 |
</td><td> |
|---|
| 648 |
<input type="text" size="8" name="channelid" value="<?php echo htmlspecialchars($channelid) ?>"/> |
|---|
| 649 |
<input type="hidden" size="14" name="usercontext" value="notneeded"/> |
|---|
| 650 |
</td> |
|---|
| 651 |
</tr> |
|---|
| 652 |
<?php |
|---|
| 653 |
break; |
|---|
| 654 |
case "enum": |
|---|
| 655 |
break; |
|---|
| 656 |
case "custom": |
|---|
| 657 |
?> |
|---|
| 658 |
<tr> |
|---|
| 659 |
<td> |
|---|
| 660 |
<a href=# class="info"><?php echo _("Custom Dial String")?><span><?php echo _("Define the custom Dial String. Include the token")?> $OUTNUM$ <?php echo _("wherever the number to dial should go.<br><br><b>examples:</b><br><br>CAPI/XXXXXXXX/")?>$OUTNUM$<?php echo _("/b<br>H323/")?>$OUTNUM$@XX.XX.XX.XX<br>OH323/$OUTNUM$@XX.XX.XX.XX:XXXX<br>vpb/1-1/$OUTNUM$</span></a>: |
|---|
| 661 |
</td><td> |
|---|
| 662 |
<input type="text" size="35" maxlength="46" name="channelid" value="<?php echo htmlspecialchars($channelid) ?>"/> |
|---|
| 663 |
<input type="hidden" size="14" name="usercontext" value="notneeded"/> |
|---|
| 664 |
</td> |
|---|
| 665 |
</tr> |
|---|
| 666 |
<?php |
|---|
| 667 |
break; |
|---|
| 668 |
default: |
|---|
| 669 |
?> |
|---|
| 670 |
<tr> |
|---|
| 671 |
<td> |
|---|
| 672 |
<a href=# class="info"><?php echo _("Trunk Name")?><span><br><?php echo _("Give this trunk a unique name. Example: myiaxtel")?><br><br></span></a>: |
|---|
| 673 |
</td><td> |
|---|
| 674 |
<input type="text" size="14" name="channelid" value="<?php echo htmlspecialchars($channelid) ?>"/> |
|---|
| 675 |
</td> |
|---|
| 676 |
</tr> |
|---|
| 677 |
<tr> |
|---|
| 678 |
<td colspan="2"> |
|---|
| 679 |
<a href=# class="info"><?php echo _("PEER Details")?><span><br><?php echo _("Modify the default PEER connection parameters for your VoIP provider.<br><br>You may need to add to the default lines listed below, depending on your provider.")?><br><br></span></a>: |
|---|
| 680 |
</td> |
|---|
| 681 |
</tr> |
|---|
| 682 |
<tr> |
|---|
| 683 |
<td colspan="2"> |
|---|
| 684 |
<textarea rows="10" cols="40" name="peerdetails"><?php echo htmlspecialchars($peerdetails) ?></textarea> |
|---|
| 685 |
</td> |
|---|
| 686 |
</tr> |
|---|
| 687 |
<tr> |
|---|
| 688 |
<td colspan="2"> |
|---|
| 689 |
<br><h4><?php echo _("Incoming Settings")?></h4> |
|---|
| 690 |
</td> |
|---|
| 691 |
</tr> |
|---|
| 692 |
<tr> |
|---|
| 693 |
<td> |
|---|
| 694 |
<a href=# class="info"><?php echo _("USER Context")?><span><br><?php echo _("This is most often the account name or number your provider expects.<br><br>This USER Context will be used to define the below user details.")?></span></a>: |
|---|
| 695 |
</td><td> |
|---|
| 696 |
<input type="text" size="14" name="usercontext" value="<?php echo htmlspecialchars($usercontext) ?>"/> |
|---|
| 697 |
</td> |
|---|
| 698 |
</tr> |
|---|
| 699 |
<tr> |
|---|
| 700 |
<td colspan="2"> |
|---|
| 701 |
<a href=# class="info"><?php echo _("USER Details")?><span><br><?php echo _("Modify the default USER connection parameters for your VoIP provider.")?><br><br><?php echo _("You may need to add to the default lines listed below, depending on your provider.")?><br><br></span></a>: |
|---|
| 702 |
</td> |
|---|
| 703 |
</tr> |
|---|
| 704 |
<tr> |
|---|
| 705 |
<td colspan="2"> |
|---|
| 706 |
<textarea rows="10" cols="40" name="userconfig"><?php echo htmlspecialchars($userconfig); ?></textarea> |
|---|
| 707 |
</td> |
|---|
| 708 |
</tr> |
|---|
| 709 |
<tr> |
|---|
| 710 |
<td colspan="2"> |
|---|
| 711 |
<br><h4><?php echo _("Registration")?></h4> |
|---|
| 712 |
</td> |
|---|
| 713 |
</tr> |
|---|
| 714 |
<tr> |
|---|
| 715 |
<td colspan="2"> |
|---|
| 716 |
<a href=# class="info"><?php echo _("Register String")?><span><br><?php echo _("Most VoIP providers require your system to REGISTER with theirs. Enter the registration line here.<br><br>example:<br><br>username:password@switch.voipprovider.com.<br><br>Many providers will require you to provide a DID number, ex: username:password@switch.voipprovider.com/didnumber in order for any DID matching to work.")?><br><br></span></a>: |
|---|
| 717 |
</td> |
|---|
| 718 |
</tr> |
|---|
| 719 |
<tr> |
|---|
| 720 |
<td colspan="2"> |
|---|
| 721 |
<input type="text" size="40" name="register" value="<?php echo htmlspecialchars($register) ?>"/> |
|---|
| 722 |
</td> |
|---|
| 723 |
</tr> |
|---|
| 724 |
<?php |
|---|
| 725 |
break; |
|---|
| 726 |
} |
|---|
| 727 |
?> |
|---|
| 728 |
|
|---|
| 729 |
<tr> |
|---|
| 730 |
<td colspan="2"> |
|---|
| 731 |
<h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6> |
|---|
| 732 |
</td> |
|---|
| 733 |
</tr> |
|---|
| 734 |
</table> |
|---|
| 735 |
|
|---|
| 736 |
<script language="javascript"> |
|---|
| 737 |
<!-- |
|---|
| 738 |
|
|---|
| 739 |
var theForm = document.trunkEdit; |
|---|
| 740 |
|
|---|
| 741 |
theForm.outcid.focus(); |
|---|
| 742 |
|
|---|
| 743 |
function trunkEdit_onsubmit(act) { |
|---|
| 744 |
var msgInvalidOutboundCID = "<?php echo _('Invalid Outbound Caller ID'); ?>"; |
|---|
| 745 |
var msgInvalidMaxChans = "<?php echo _('Invalid Maximum Channels'); ?>"; |
|---|
| 746 |
var msgInvalidDialRules = "<?php echo _('Invalid Dial Rules'); ?>"; |
|---|
| 747 |
var msgInvalidOutboundDialPrefix = "<?php echo _('Invalid Outbound Dial Prefix'); ?>"; |
|---|
| 748 |
var msgInvalidTrunkName = "<?php echo _('Invalid Trunk Name entered'); ?>"; |
|---|
| 749 |
var msgInvalidChannelName = "<?php echo _('Invalid Custom Dial String entered'); ?>"; |
|---|
| 750 |
var msgInvalidTrunkAndUserSame = "<?php echo _('Trunk Name and User Context cannot be set to the same value'); ?>"; |
|---|
| 751 |
var msgConfirmBlankContext = "<?php echo _('User Context was left blank and User Details will not be saved!'); ?>"; |
|---|
| 752 |
var msgNeverOverrideCIDValue = "<?php echo _('You must define an Outbound Caller ID when Choosing Never Override CallerID'); ?>"; |
|---|
| 753 |
|
|---|
| 754 |
defaultEmptyOK = true; |
|---|
| 755 |
|
|---|
| 756 |
if (theForm.keepcid.checked && isEmpty($.trim(theForm.outcid.value))) |
|---|
| 757 |
return warnInvalid(theForm.outcid, msgNeverOverrideCIDValue); |
|---|
| 758 |
|
|---|
| 759 |
if (!isCallerID(theForm.outcid.value)) |
|---|
| 760 |
return warnInvalid(theForm.outcid, msgInvalidOutboundCID); |
|---|
| 761 |
|
|---|
| 762 |
if (!isInteger(theForm.maxchans.value)) |
|---|
| 763 |
return warnInvalid(theForm.maxchans, msgInvalidMaxChans); |
|---|
| 764 |
|
|---|
| 765 |
if (!isDialrule(theForm.dialrules.value)) |
|---|
| 766 |
return warnInvalid(theForm.dialrules, msgInvalidDialRules); |
|---|
| 767 |
|
|---|
| 768 |
if (!isDialIdentifierSpecial(theForm.dialoutprefix.value)) |
|---|
| 769 |
return warnInvalid(theForm.dialoutprefix, msgInvalidOutboundDialPrefix); |
|---|
| 770 |
|
|---|
| 771 |
<?php if ($tech != "enum" && $tech != "custom") { ?> |
|---|
| 772 |
defaultEmptyOK = true; |
|---|
| 773 |
if (isEmpty(theForm.channelid.value) || isWhitespace(theForm.channelid.value)) |
|---|
| 774 |
return warnInvalid(theForm.channelid, msgInvalidTrunkName); |
|---|
| 775 |
|
|---|
| 776 |
if (theForm.channelid.value == theForm.usercontext.value) |
|---|
| 777 |
return warnInvalid(theForm.usercontext, msgInvalidTrunkAndUserSame); |
|---|
| 778 |
<?php } else if ($tech == "custom") { ?> |
|---|
| 779 |
if (isEmpty(theForm.channelid.value) || isWhitespace(theForm.channelid.value)) |
|---|
| 780 |
return warnInvalid(theForm.channelid, msgInvalidChannelName); |
|---|
| 781 |
|
|---|
| 782 |
if (theForm.channelid.value == theForm.usercontext.value) |
|---|
| 783 |
return warnInvalid(theForm.usercontext, msgInvalidTrunkAndUserSame); |
|---|
| 784 |
<?php } ?> |
|---|
| 785 |
|
|---|
| 786 |
<?php if ($tech == "sip" || substr($tech,0,3) == "iax") { ?> |
|---|
| 787 |
if ((isEmpty(theForm.usercontext.value) || isWhitespace(theForm.usercontext.value)) && |
|---|
| 788 |
(!isEmpty(theForm.userconfig.value) && !isWhitespace(theForm.userconfig.value)) && |
|---|
| 789 |
(theForm.userconfig.value != "secret=***password***\ntype=user\ncontext=from-trunk")) { |
|---|
| 790 |
if (confirm(msgConfirmBlankContext) == false) |
|---|
| 791 |
return false; |
|---|
| 792 |
} |
|---|
| 793 |
<?php } ?> |
|---|
| 794 |
|
|---|
| 795 |
theForm.action.value = act; |
|---|
| 796 |
return true; |
|---|
| 797 |
} |
|---|
| 798 |
|
|---|
| 799 |
function isDialIdentifierSpecial(s) { // special chars allowed in dial prefix (e.g. fwdOUT) |
|---|
| 800 |
var i; |
|---|
| 801 |
|
|---|
| 802 |
if (isEmpty(s)) |
|---|
| 803 |
if (isDialIdentifierSpecial.arguments.length == 1) return defaultEmptyOK; |
|---|
| 804 |
else return (isDialIdentifierSpecial.arguments[1] == true); |
|---|
| 805 |
|
|---|
| 806 |
for (i = 0; i < s.length; i++) |
|---|
| 807 |
{ |
|---|
| 808 |
var c = s.charAt(i); |
|---|
| 809 |
|
|---|
| 810 |
if ( !isDialDigitChar(c) && (c != "w") && (c != "W") && (c != "q") && (c != "Q") && (c != "+") ) return false; |
|---|
| 811 |
} |
|---|
| 812 |
|
|---|
| 813 |
return true; |
|---|
| 814 |
} |
|---|
| 815 |
//--> |
|---|
| 816 |
</script> |
|---|
| 817 |
|
|---|
| 818 |
</form> |
|---|
| 819 |
<?php |
|---|
| 820 |
} |
|---|
| 821 |
?> |
|---|