4 ? 4 : count($row); for ($i=0;$i<$count;$i++) { switch (strtolower($row[$i])) { case 'prepend': case 'prefix': case 'match pattern': case 'callerid': $index[strtolower($row[$i])] = $i; break; default: break; } } // If no headers then assume standard order if (count($index) == 0) { $index['prepend'] = 0; $index['prefix'] = 1; $index['match pattern'] = 2; $index['callerid'] = 3; if ($count == 4) { $csv_file[] = $row; } } break; } } $row_count = count($index); while (($row = fgetcsv($fh, 5000, ",", "\"")) !== false) { if (count($row) == $row_count) { $csv_file[] = $row; } } } } // // Use a hash of the value inserted to get rid of duplicates $dialpattern_insert = array(); $p_idx = 0; $n_idx = 0; // If we have a CSV file it replaces any existing patterns // if (!empty($csv_file)) { foreach ($csv_file as $row) { $this_prepend = isset($index['prepend']) ? htmlspecialchars(trim($row[$index['prepend']])) : ''; $this_prefix = isset($index['prefix']) ? htmlspecialchars(trim($row[$index['prefix']])) : ''; $this_match_pattern = isset($index['match pattern']) ? htmlspecialchars(trim($row[$index['match pattern']])) : ''; $this_callerid = isset($index['callerid']) ? htmlspecialchars(trim($row[$index['callerid']])) : ''; if ($this_prepend != '' || $this_prefix != '' || $this_match_pattern != '' || $this_callerid != '') { $dialpattern_insert[] = array( 'prepend_digits' => $this_prepend, 'match_pattern_prefix' => $this_prefix, 'match_pattern_pass' => $this_match_pattern, 'match_cid' => $this_callerid, ); } } } else if (isset($_POST["prepend_digit"])) { $prepend_digit = $_POST["prepend_digit"]; $pattern_prefix = $_POST["pattern_prefix"]; $pattern_pass = $_POST["pattern_pass"]; $match_cid = $_POST["match_cid"]; foreach (array_keys($prepend_digit) as $key) { if ($prepend_digit[$key]!='' || $pattern_prefix[$key]!='' || $pattern_pass[$key]!='' || $match_cid[$key]!='') { $dialpattern_insert[] = array( 'prepend_digits' => htmlspecialchars(trim($prepend_digit[$key])), 'match_pattern_prefix' => htmlspecialchars(trim($pattern_prefix[$key])), 'match_pattern_pass' => htmlspecialchars(trim($pattern_pass[$key])), 'match_cid' => htmlspecialchars(trim($match_cid[$key])), ); } } } if ( isset($_REQUEST['reporoutedirection']) && $_REQUEST['reporoutedirection'] != '' && isset($_REQUEST['reporoutekey']) && $_REQUEST['reporoutekey'] != '') { $_REQUEST['route_seq'] = core_routing_setrouteorder($_REQUEST['reporoutekey'], $_REQUEST['reporoutedirection']); } $trunkpriority = array(); if (isset($_REQUEST["trunkpriority"])) { $trunkpriority = $_REQUEST["trunkpriority"]; if (!$trunkpriority) { $trunkpriority = array(); } // delete blank entries and reorder if($repotrunkkey=="") $repotrunkkey=0; foreach (array_keys($trunkpriority) as $key) { if ($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_unique(array_values($trunkpriority)); // resequence our numbers if ($action == '') { $action = "updatetrunks"; } } $routename = isset($_REQUEST['routename']) ? $_REQUEST['routename'] : ''; $routepass = isset($_REQUEST['routepass']) ? $_REQUEST['routepass'] : ''; $emergency = isset($_REQUEST['emergency']) ? $_REQUEST['emergency'] : ''; $intracompany = isset($_REQUEST['intracompany']) ? $_REQUEST['intracompany'] : ''; $mohsilence = isset($_REQUEST['mohsilence']) ? $_REQUEST['mohsilence'] : ''; $outcid = isset($_REQUEST['outcid']) ? $_REQUEST['outcid'] : ''; $outcid_mode = isset($_REQUEST['outcid_mode']) ? $_REQUEST['outcid_mode'] : ''; $time_group_id = isset($_REQUEST['time_group_id']) ? $_REQUEST['time_group_id'] : ''; $route_seq = isset($_REQUEST['route_seq']) ? $_REQUEST['route_seq'] : ''; $goto = isset($_REQUEST['goto0'])?$_REQUEST['goto0']:''; $dest = $goto ? $_REQUEST[$goto . '0'] : ''; //if submitting form, update database switch ($action) { case 'ajaxroutepos': core_routing_setrouteorder($repotrunkkey, $repotrunkdirection); needreload(); header("Content-type: application/json"); echo json_encode($json_array); exit; break; case "copyroute": $routename .= "_copy_$extdisplay"; $extdisplay=''; $route_seq++; // Fallthrough to addtrunk now... // case "addroute": $extdisplay = core_routing_addbyid($routename, $outcid, $outcid_mode, $routepass, $emergency, $intracompany, $mohsilence, $time_group_id, $dialpattern_insert, $trunkpriority, $route_seq, $dest); $_REQUEST['extdisplay'] = $extdisplay; //have not idea if this is needed or useful needreload(); $_SESSION['msg']=base64_encode(_dgettext('amp','Item has been added')); $_SESSION['msgtype']='success'; $_SESSION['msgtstamp']=time(); redirect_standard('extdisplay'); break; case "editroute": core_routing_editbyid($extdisplay, $routename, $outcid, $outcid_mode, $routepass, $emergency, $intracompany, $mohsilence, $time_group_id, $dialpattern_insert, $trunkpriority, $route_seq, $dest); needreload(); $_SESSION['msg']=base64_encode(_dgettext('amp','Item has been saved')); $_SESSION['msgtype']='success'; $_SESSION['msgtstamp']=time(); redirect_standard('extdisplay'); break; case "updatetrunks": core_routing_updatetrunks($extdisplay, $trunkpriority, true); needreload(); break; case "delete": core_routing_delbyid($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 needreload(); $_SESSION['msg']=base64_encode(_dgettext('amp','Item has been deleted')); $_SESSION['msgtype']='warning'; $_SESSION['msgtstamp']=time(); redirect_standard(); break; case 'prioritizeroute': needreload(); break; case 'populatenpanxx': $dialpattern_array = $dialpattern_insert; 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://www.localcallingguide.com/xmllocalprefix.php?npa=".$matches[1]."&nxx=".$matches[2]); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; IssabelPBX Local Trunks Configuration)"); $str = curl_exec($ch); curl_close($ch); // quick 'n dirty - nabbed from PEAR require_once($amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Parser.php'); require_once($amp_conf['AMPWEBROOT'] . '/admin/modules/core/XML_Unserializer.php'); $xml = new xml_unserializer; $xml->unserialize($str); $xmldata = $xml->getUnserializedData(); $hash_filter = array(); //avoid duplicates if (isset($xmldata['lca-data']['prefix'])) { // we do the loops separately so patterns are grouped together // match 1+NPA+NXX (dropping 1) foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter['1'.$prefix['npa'].$prefix['nxx']])) { continue; } else { $hash_filter['1'.$prefix['npa'].$prefix['nxx']] = true; } $dialpattern_array[] = array( 'prepend_digits' => '', 'match_pattern_prefix' => '1', 'match_pattern_pass' => htmlspecialchars($prefix['npa'].$prefix['nxx']).'XXXX', 'match_cid' => '', ); } // match NPA+NXX foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter[$prefix['npa'].$prefix['nxx']])) { continue; } else { $hash_filter[$prefix['npa'].$prefix['nxx']] = true; } $dialpattern_array[] = array( 'prepend_digits' => '', 'match_pattern_prefix' => '', 'match_pattern_pass' => htmlspecialchars($prefix['npa'].$prefix['nxx']).'XXXX', 'match_cid' => '', ); } // match 7-digits foreach ($xmldata['lca-data']['prefix'] as $prefix) { if (isset($hash_filter[$prefix['nxx']])) { continue; } else { $hash_filter[$prefix['nxx']] = true; } $dialpattern_array[] = array( 'prepend_digits' => '', 'match_pattern_prefix' => '', 'match_pattern_pass' => htmlspecialchars($prefix['nxx']).'XXXX', 'match_cid' => '', ); } unset($hash_filter); } 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 ""; unset($errormsg); } break; } ?> $tresult) { $rnaventries[] = array($tresult['route_id'],' '.$tresult['name'],'',''); } drawListMenu($rnaventries, $type, $display, $extdisplay); ?>
".__("Edit Outbound Route").""; } else if ($extdisplay != '') { // load from db $route_info = core_routing_get($extdisplay); $dialpattern_array = core_routing_getroutepatternsbyid($extdisplay); $trunkpriority = core_routing_getroutetrunksbyid($extdisplay); $routepass = $route_info['password']; $emergency = $route_info['emergency_route']; $intracompany = $route_info['intracompany_route']; $mohsilence = $route_info['mohclass']; $outcid = $route_info['outcid']; $outcid_mode = $route_info['outcid_mode']; $time_group_id = $route_info['time_group_id']; $route_seq = $route_info['seq']; $routename = $route_info['name']; $dest = $route_info['dest']; echo "

".__("Edit Outbound Route").": ".$routename."

"; } else { $route_seq = $last_seq+1; if (!isset($dialpattern_array)) { $dialpattern_array = array(); } echo "

".__("Add Outbound Route")."

"; } // // build trunks associative array foreach (core_trunks_listbyid() as $temp) { $trunks[$temp['trunkid']] = $temp['name']; $trunkstate[$temp['trunkid']] = $temp['disabled']; } ?>
hookHtml)) { ?> hookHtml,$tabindex); } ?> $trunk) { ?> 3) ? 3 : count($trunks))); for ($i=0; $i < $num_new_boxes; $i++) { ?>

  • extension/device EMERGENCY CIDs if this route is checked as an EMERGENCY Route
  • trunk CID if trunk is set to force it's CID
  • Forwarded call CIDs (CF, Follow Me, Ring Groups, etc)
  • Extension/User CIDs if checked
  • ")?>
    >

    A numerical password, or the path to an Authenticate password file can be used.

    Leave this field blank to not prompt for password.")?>
    '.__("Optional: Selecting Intra-Company will treat this route as an intra-company connection, preserving the internal CallerID information instead of the outbound CID of either the extension or trunk.")?> tabindex=""/> tabindex=""/>



    X   
    Z   
    N   
    [1237-9] 
    .   
       
       
       
       
    $pattern) { $tabindex++; if ($idx == 50) { $dpt_title_class = 'dpt-title dpt-nodisplay'; } $dpt_class = $pattern['prepend_digits'] == '' ? $dpt_title_class : 'dpt-value'; echo <<< END
    () + END; $tabindex++; $dpt_class = $pattern['match_pattern_prefix'] == '' ? $dpt_title_class : 'dpt-value'; echo <<< END | END; $tabindex++; $dpt_class = $pattern['match_pattern_pass'] == '' ? $dpt_title_class : 'dpt-value'; echo <<< END [ / END; $tabindex++; $dpt_class = $pattern['match_cid'] == '' ? $dpt_title_class : 'dpt-value'; echo <<< END ] END; ?>
    () + | [ / ]
    " />


    prepend','prefix','match pattern','callerid')?>
    prepend','prefix','match pattern','callerid')?>

    For Dial Patterns that match long distance numbers, for example, you'd want to pick the cheapest routes for long distance (ie, VoIP trunks first) followed by more expensive routes (POTS lines).")?>
       0) {?> <?php echo __(" style="cursor:pointer; float:none; margin-left:0px; margin-bottom:0px;" width="12px" height="12px"> <?php echo __(" style="cursor:pointer; float:none; margin-left:0px; margin-bottom:0px;" width="12px" height="12px">