Example #1
0
 function task_area()
 {
     include_once PATH_MODULES . 'voip/voip.inc.php';
     $db =& DB();
     $didArea = new didArea();
     $sql = sqlSelect($db, "voip_pool", "*", "areacode is null or areacode=0");
     $rs = $db->Execute($sql);
     if ($rs && $rs->RecordCount()) {
         while (!$rs->EOF) {
             $n = $rs->fields['npa'] . $rs->fields['nxx'] . $rs->fields['station'];
             if (($area = $didArea->determineArea($rs->fields['country_code'], $n)) !== false) {
                 #echo "DID=".$n." has an area of $area = ".$didArea->getName($rs->fields['country_code'],$area)."<br>";
                 $f = array('areacode' => $db->qstr($area));
                 $sql = sqlUpdate($db, "voip_pool", $f, "id=" . $rs->fields['id']);
                 #echo "plugin_id=".$rs->fields['voip_did_plugin_id']."<br>";
                 #echo $sql."<br>";
                 $db->Execute($sql);
             }
             $rs->MoveNext();
         }
     }
 }
Example #2
0
 function menu_station($VAR)
 {
     header('Pragma: no-cache');
     header('Cache-Control: no-cache, must-revalidate');
     $did_plugins = $this->get_did_plugin_countries($VAR['id'], $plugins);
     #echo "alert(\"".str_replace("\n","\\\n",str_replace("\"","\\\"",print_r($VAR,true)))."\");";return;
     #if(empty($VAR['location']) && empty($VAR['country'])) return false;
     $l = $VAR['location'];
     if (strchr($l, ':')) {
         $cn = explode(':', $l);
         $data['country_code'] = $cn[0];
         if ($cn[0] == '61') {
             $cn = explode('-', $cn[1]);
             $data['npa'] = $cn[0];
             $data['nxx'] = $cn[1];
         } else {
             $data['areacode'] = $cn[1];
         }
     } else {
         $cn = explode('-', $l);
         $data['country_code'] = 1;
         $data['npa'] = $cn[0];
         $data['nxx'] = $cn[1];
     }
     $area = new didArea($data['country_code'], $data);
     #echo "alert(\"".str_replace("\n","\\\n",str_replace("\"","\\\"",print_r($area,true)))."\");"; return;
     $js = 'menuClearOptions("voip_station"); ';
     $js .= "menuAppendOption('voip_station', '', '-- Select A Station --'); ";
     $dids = $area->getStations($plugins);
     #echo "alert(\"".str_replace("\n","\\\n",str_replace("\"","\\\"",print_r($dids,true)))."\");"; return;
     foreach ($dids as $did) {
         #if($data['country_code'] == 1) {
         $js .= "menuAppendOption('voip_station', '" . $did[0] . "', '{$did[1]}'); ";
         #} else {
         #	;
         #}
     }
     echo $js;
     return;
     $db =& DB();
     $p = AGILE_DB_PREFIX;
     if (!empty($VAR['location'])) {
         $l = $VAR['location'];
         if (eregi(':', $l)) {
             $cn = explode(':', $l);
             $ccode = $cn[0];
             $npa = $cn[1];
             $sql = "select distinct left(A.station,4) as npa,B.locName, station from {$p}voip_pool AS A \n\t\t\t\tinner join {$p}voip_npa_nxx AS B on (left(A.station,4)=B.npa AND \n\t\t\t\tA.country_code='{$ccode}' AND B.country_code='{$ccode}' AND B.npa='{$npa}') \n\t\t\t\tWHERE (A.account_id IS NULL OR A.account_id = 0) AND \n\t\t\t\t(A.date_reserved IS NULL OR A.date_reserved = 0) AND \n\t\t\t\tA.voip_did_plugin_id in (" . join(",", $plugins) . ") AND\n\t\t\t\tA.site_id=" . DEFAULT_SITE . " ORDER BY B.locName LIMIT 0,50";
             // loop through results
             $rs = $db->Execute($sql);
             if ($rs && $rs->RecordCount() > 0) {
                 while (!$rs->EOF) {
                     if (!empty($rs->fields["station"])) {
                         $js .= "menuAppendOption('voip_station', '011" . $ccode . $rs->fields["station"] . "', '{$ccode} {$rs->fields["station"]}'); ";
                     }
                     $rs->MoveNext();
                 }
             } else {
                 $js = 'document.write("Sorry, none available at this time. Please check again later.");';
             }
         } else {
             $np = explode('-', $l);
             // passed npa-nxx
             $npa = $np[0];
             $nxx = $np[1];
             $sql = "select distinct A.country_code,A.npa,A.nxx,A.station\n\t\t\t\t\t\tFROM {$p}voip_pool AS A\n\t\t\t\t\t\tleft join {$p}voip_npa_nxx AS B\n\t\t\t\t\t\ton (A.npa=B.npa and A.nxx=B.nxx AND B.country_code='1') \n\t\t\t\t\t\tWHERE (A.account_id IS NULL OR A.account_id = 0)\n\t\t\t\t\t\tAND (A.date_reserved IS NULL OR A.date_reserved = 0)\t\n\t\t\t\t\t\tAND A.npa = " . $db->qstr($npa) . "\n\t\t\t\t\t\tAND A.nxx = " . $db->qstr($nxx) . "\n\t\t\t\t\t\tAND A.voip_did_plugin_id in (" . join(",", $plugins) . ")\n\t\t\t\t\t\tAND A.site_id=" . DEFAULT_SITE . "  \n\t\t\t\t\t\tLIMIT 0,50";
             // loop through results
             $rs = $db->Execute($sql);
             if ($rs && $rs->RecordCount() > 0) {
                 while (!$rs->EOF) {
                     if (!empty($rs->fields["station"])) {
                         $js .= "menuAppendOption('voip_station', '" . $rs->fields["country_code"] . $rs->fields["npa"] . $rs->fields["nxx"] . $rs->fields['station'] . "', '{$rs->fields["npa"]}-{$rs->fields["nxx"]}-{$rs->fields["station"]}'); ";
                     }
                     $rs->MoveNext();
                 }
             } else {
                 $js = 'document.write("Sorry, none available at this time. Please check again later.");';
             }
         }
     } else {
         $country = $VAR['country'];
         $sql = "SELECT DISTINCT B.country_code, B.station from {$p}voip_pool AS B \n\t\t\t\t\tLEFT JOIN {$p}voip_iso_country_code_map AS A  ON (B.country_code=A.country_code) \n\t\t\t\t\tWHERE ( account_id IS NULL or account_id = 0) \n\t\t\t\t\tAND ( B.date_reserved IS NULL or B.date_reserved = 0 )\n\t\t\t\t\tAND A.iso_country_code=" . $db->qstr($country) . "\n\t\t\t\t\tAND B.voip_did_plugin_id in (" . join(",", $plugins) . ")\n\t\t\t\t\tand A.site_id=" . DEFAULT_SITE . " AND B.site_id=" . DEFAULT_SITE . " \n\t\t\t\t\tLIMIT 0,50";
         $rs = $db->Execute($sql);
         if ($rs && $rs->RecordCount() > 0) {
             while (!$rs->EOF) {
                 if (!empty($rs->fields["station"])) {
                     $js .= " menuAppendOption('voip_station', '011" . $rs->fields["country_code"] . $rs->fields["station"] . "', '{$rs->fields["country_code"]}{$rs->fields["station"]}'); ";
                 }
                 $rs->MoveNext();
             }
         } else {
             $js = 'document.write("Sorry, none available at this time. Please check again later.");';
         }
     }
     echo $js;
     ob_end_flush();
     return true;
 }