/** * Sets the voicemail path(s) */ function get_vm_path() { if (!SESS_LOGGED) { define("FORCE_REDIRECT", "?_page=account:account"); return false; } require_once PATH_MODULES . 'voip/voip.inc.php'; $voip = new voip(); $dids = $voip->get_voicemail_dids(SESS_ACCOUNT); if (!$dids || !is_array($dids) || count($dids) < 1) { return false; } $db =& DB(); foreach ($dids as $did) { $rs =& $db->Execute($sql = sqlSelect($db, "voip_vm", "context,mailbox", "mailbox = ::{$did}:: AND account_id=" . SESS_ACCOUNT)); if ($rs && $rs->RecordCount() > 0) { $path = "/var/spool/asterisk/voicemail/{$rs->fields["context"]}/{$rs->fields["mailbox"]}/INBOX/"; $this->vm[] = $path; if (!is_dir($path)) { global $C_debug; $C_debug->error('voip_vm', 'get_vm_path', 'The voicemail directory does not have the proper permissions assigned.'); } } } }
function getPluginID() { if ($this->plugin_id) { return $this->plugin_id; } require_once PATH_MODULES . "voip/voip.inc.php"; $v = new voip(); $didtable = $v->get_did_e164($this->data['did']); $this->plugin_id = $didtable['voip_did_plugin_id']; return $this->plugin_id; }
/** Imports an uploaded text file into the voip_pool table. Each line must contain a single valid phone number. +--------------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +--------------------+--------------+------+-----+---------+-------+ | id | mediumint(9) | | PRI | 0 | | | site_id | mediumint(9) | YES | MUL | NULL | | | account_id | mediumint(9) | YES | | NULL | | | npa | varchar(16) | YES | MUL | NULL | | | nxx | varchar(16) | YES | | NULL | | | station | varchar(32) | YES | | NULL | | | country_code | mediumint(9) | YES | | NULL | | | date_reserved | bigint(20) | YES | | NULL | | | voip_did_plugin_id | mediumint(9) | YES | | NULL | | +--------------------+--------------+------+-----+---------+-------+ */ function import($VAR) { # Include the voip class include_once PATH_MODULES . 'voip/voip.inc.php'; $v = new voip(); $db =& DB(); if (is_uploaded_file($_FILES['datafile']['tmp_name'])) { # Got a file to import $fp = fopen($_FILES['datafile']['tmp_name'], "r"); if ($fp) { $counter = 0; $skipped = 0; while (!feof($fp)) { $line = fgets($fp, 128); $line = ereg_replace("[^0-9]", "", $line); $cc = ""; $npa = ""; $nxx = ""; $e164 = ""; if ($v->e164($line, $e164, $cc, $npa, $nxx)) { $fields['voip_did_plugin_id'] = $VAR['voip_did_plugin_id']; /* DEFAULT plugin */ $fields['country_code'] = $cc; $fields['npa'] = $npa; $fields['nxx'] = $nxx; if ($cc == '1') { $fields['station'] = substr($e164, 8); } elseif ($cc == "61") { $fields['station'] = substr($e164, 12); } else { $fields['station'] = substr($e164, 4 + strlen($cc)); } $rs = $db->Execute(sqlSelect($db, "voip_pool", "id", "voip_did_plugin_id=::" . $VAR['voip_did_plugin_id'] . ":: and country_code=::" . $fields['country_code'] . ":: and npa=::" . $fields['npa'] . ":: and nxx=::" . $fields['nxx'] . ":: and station=::" . $fields['station'] . "::")); if ($rs && !$rs->EOF) { $skipped++; } else { $db->Execute(sqlInsert($db, "voip_pool", $fields)); $counter++; } } else { $skipped++; } } global $C_debug; $C_debug->error('voip_pool.inc.php', 'import', "Imported {$counter} new DIDs and skipped {$skipped} DIDs!"); $C_debug->alert("Imported {$counter} new DIDs and skipped {$skipped} DIDs!"); } else { # log error message global $C_debug; $C_debug->error('voip_pool.inc.php', 'import', 'Unable to process file: ' . $_FILES['datafile']['tmp_name']); $C_debug->alert('Unable to fopen the file sent.'); } } else { # log error message global $C_debug; $C_debug->error('voip_pool.inc.php', 'import', 'Possible file upload attack'); $C_debug->alert('Unable to process the uploaded file.'); } }
/** Release the DID back to the pool of available numbers */ function release($voip_did_plugin_id, $did) { # Include the voip class include_once PATH_MODULES . 'voip/voip.inc.php'; $v = new voip(); $db =& DB(); $cc = ""; $npa = ""; $nxx = ""; $e164 = ""; if ($v->e164($did, $e164, $cc, $npa, $nxx)) { if ($cc == '1') { $station = substr($e164, 8); $sql = "UPDATE " . AGILE_DB_PREFIX . "voip_pool SET\n\t\t\t\t\tdate_reserved=NULL, account_id=NULL\n\t\t\t\t\tWHERE voip_did_plugin_id=" . $voip_did_plugin_id . " AND \n\t\t\t\t\tcountry_code=" . $db->qstr($cc) . " AND npa=" . $db->qstr($npa) . " AND nxx=" . $db->qstr($nxx) . " AND station=" . $db->qstr($station) . " AND site_id=" . DEFAULT_SITE; } elseif ($cc == '61') { $station = substr($e164, 12); $sql = "UPDATE " . AGILE_DB_PREFIX . "voip_pool SET\n\t\t\t\t\tdate_reserved=NULL, account_id=NULL\n\t\t\t\t\tWHERE voip_did_plugin_id=" . $voip_did_plugin_id . " AND\n\t\t\t\t\tcountry_code=" . $db->qstr($cc) . " AND npa=" . $db->qstr($npa) . " AND nxx=" . $db->qstr($nxx) . " AND station=" . $db->qstr($station) . " AND site_id=" . DEFAULT_SITE; } else { $station = substr($e164, 4 + strlen($cc)); $sql = "UPDATE " . AGILE_DB_PREFIX . "voip_pool SET\n\t\t\t\t\tdate_reserved=NULL, account_id=NULL\n\t\t\t\t\tWHERE voip_did_plugin_id=" . $voip_did_plugin_id . " AND\n\t\t\t\t\tcountry_code=" . $db->qstr($cc) . " AND station=" . $db->qstr($station) . " AND site_id=" . DEFAULT_SITE; } $db->Execute($sql); #echo $sql; if ($db->Affected_Rows()) { return true; } } return "Could not complete request, the number has already been reserved by another user.<BR>\n\t\t\t\tPlease go back and refresh the order page and make a different selection."; }
print "</div>"; } if (browser_ie()) { $js = "js/window_ie6_interface2.js"; } else { $js = "js/window_interface2.js"; } //display the respondents phone numbers as a drop down list for this call global $db; $db->StartTrans(); $operator_id = get_operator_id(); if (isset($_POST['submit'])) { if (is_voip_enabled($operator_id)) { //prepare common voip functions include "functions/functions.voip.php"; $v = new voip(); $v->connect(VOIP_SERVER); } $btext = "onload='parent.closePopup();'"; // set default, change on conditions if (isset($_POST['contact_phone'])) { $contact_phone_id = bigintval($_POST['contact_phone']); $call_attempt_id = get_call_attempt($operator_id, false); $respondent_id = get_respondent_id($call_attempt_id); $call_id = get_call($operator_id, $respondent_id, $contact_phone_id, true); if ($call_id) { if (is_voip_enabled($operator_id)) { $v->dial(get_extension($operator_id), get_call_number($call_id)); } } else { exit;
function agileco_php_local_call($dst) { global $src; $voip = new voip(); $cc1 = ""; $npa1 = ""; $nxx1 = ""; $cc2 = ""; $npa2 = ""; $nxx2 = ""; $e164 = ""; if ($voip->e164($src, $e164, $cc1, $npa1, $nxx1)) { if ($voip->e164($dst, $e164, $cc2, $npa2, $nxx2)) { $sql = "select t1.grouping as id1, t2.grouping from " . AGILE_DB_PREFIX . "voip_local_lookup as t1 join " . AGILE_DB_PREFIX . "voip_local_lookup as t2 on (t1.npa='{$npa1}' and t1.nxx='{$nxx1}' and t2.npa='{$npa2}' and t2.nxx='{$nxx2}') where t1.grouping=t2.grouping"; echo $sql . "\n"; $rs = $db->Execute($sql); if ($rs->fields[0] > 0) { return 1; } } } return 0; }
/** Task to refresh available dids cart items */ function refresh() { # read configuration $this->config(); #$this->log_message('refresh','Refreshing did pool id: '.$this->id); # include the magrathea/telnet classes include_once PATH_INCLUDES . "telnet/magrathea.inc.php"; $bOk = false; $t = new magrathea(); $ret = $t->login($this->server, $this->user, $this->pass); if ($ret === false) { $this->log_message('refresh', 'Error while refreshing DID pool.'); return false; } # Include the voip class include_once PATH_MODULES . 'voip/voip.inc.php'; $voip = new voip(); $db =& DB(); $entries = explode("\r\n", $this->country_area); foreach ($entries as $entry) { $eparts = explode(":", $entry); $areas = explode(",", $eparts[1]); $bDelete = false; foreach ($areas as $area) { # the request must be padded with underscores to make a valid number $orig_area = $area; while (strlen($area) != 11) { $area .= "_"; } $num_to_get = $this->poolcount; $sql = sqlSelect($db, "voip_pool", "count(id)", "country_code=::" . $eparts[0] . ":: AND voip_did_plugin_id=::" . $this->id . ":: AND station like ::" . $orig_area . "%:: AND (account_id is null or account_id=0)"); $rs = $db->Execute($sql); if ($rs) { $num_to_get -= $rs->fields[0]; } if ($num_to_get < 1) { $num_to_get = 0; } # $this->log_message('refresh',"Acquiring $num_to_get DIDs for area $area: $sql"); for ($didnum = 0; $didnum < $num_to_get; $didnum++) { if (($v = $t->allocate($area)) !== false) { $v = "011" . $eparts[0] . $v; # got a phone number! let's insert it into the pool $cc = ""; $npa = ""; $nxx = ""; $e164 = ""; if ($voip->e164($v, $e164, $cc, $npa, $nxx)) { unset($fields); $fields['country_code'] = $cc; $fields['voip_did_plugin_id'] = $this->id; if ($cc == '1') { $fields['station'] = substr($e164, 8); $fields['npa'] = $npa; $fields['nxx'] = $nxx; } else { $fields['station'] = substr($e164, 4 + strlen($cc)); } $rs = $db->Execute(sqlSelect($db, "voip_pool", "id", "country_code=::" . $cc . ":: AND voip_did_plugin_id=::" . $this->id . ":: AND station=::" . $fields['station'] . "::")); if ($rs->RecordCount() == 0) { $queue[] = sqlInsert($db, "voip_pool", $fields); } } else { $this->log_message('refresh', 'Could not parse the phone number returned: ' . $v[0]); } if (isset($queue) && is_array($queue) && count($queue)) { if ($bDelete) { # kill db entries $sql = "DELETE FROM " . AGILE_DB_PREFIX . "voip_pool WHERE \n\t\t\t\t\t\t\t\tvoip_did_plugin_id=" . $this->id . " AND (account_id IS NULL or account_id=0)\n\t\t\t\t\t\t\t\tAND country_code=" . $eparts[0] . "\n\t\t\t\t\t\t\t\tAND (date_reserved IS NULL or date_reserved=0)"; $db->Execute($sql); $bDelete = false; } foreach ($queue as $q) { #echo $q."\n"; $db->Execute($q); } } } # end valid result check from allocate } # end poolcount looper } # end foreach entries } return $bOk; }
$v = new voip(); $v->connect(VOIP_SERVER); $v->hangup(get_extension($operator_id)); } //disable recording $newtext = T_("Start REC"); $js = "js/window.js"; if (browser_ie()) { $js = "js/window_ie6.js"; } xhtml_head(T_("Call"), true, array("css/call.css"), array($js), "onload='toggleRec(\"{$newtext}\",\"record.php?start=start\",\"offline\"); openParentObject(\"main-content\",\"" . get_respondentselection_url($operator_id) . "\"); parent.closePopup();'", false, false, false, false); } else { //if no outcome selected, just hang up the call if (is_voip_enabled($operator_id)) { include "functions/functions.voip.php"; $v = new voip(); $v->connect(VOIP_SERVER); $v->hangup(get_extension($operator_id)); } //disable recording $newtext = T_("Start REC"); $js = "js/window.js"; if (browser_ie()) { $js = "js/window_ie6.js"; } xhtml_head(T_("Call"), true, array("css/call.css"), array($js), "onload='toggleRec(\"{$newtext}\",\"record.php?start=start\",\"offline\"); openParentObject(\"main-content\",\"" . get_respondentselection_url($operator_id) . "\"); parent.closePopup();'", false, false, false, false); } } print "<p></p>"; //for XHTML xhtml_foot();
/** Task to refresh available dids cart items */ function refresh() { # read configuration $this->config(); # include the soap classes include_once(PATH_INCLUDES."nusoap/lib/nusoap.php"); # Include the voip class include_once(PATH_MODULES.'voip/voip.inc.php'); $voip = new voip; $db =& DB(); $client = new soapclient("http://didx.org/cgi-bin/WebGetListServer.cgi", false); $err = $client->getError(); if ($err) { global $C_debug; $C_debug->error('DIDX.php', 'refresh', 'Could not acquire information from DIDx.org'); } else { $entries = split("\r\n", $this->country_area); foreach ($entries as $entry) { $eparts = split(":", $entry); $areas = split(",", $eparts[1]); $bDelete = true; foreach ($areas as $area) { $params = array( 'UserID' => $this->user, 'Password' => $this->pass, 'CountryCode' => $eparts[0], 'AreaCode' => $area ); $result = $client->call('getAvailableDIDS', $params, 'http://didx.org/GetList'); unset($queue); while (is_array($result) && (list($k,$v)=each($result)) !== false) { if (is_array($v)) { if ($v[0] < 0) { # error occured, let's log it! $this->log_message('refresh', 'SOAP Response: '.$this->codes[$v[0]]); } else { if ($eparts[0] == '1') { ; } else { $v[0] = "011".$v[0]; } # got a phone number! let's insert it into the pool $cc = ""; $npa = ""; $nxx = ""; $e164 = ""; if ($voip->e164($v[0], $e164, $cc, $npa, $nxx)) { unset($fields); $fields['country_code'] = $cc; $fields['voip_did_plugin_id'] = $this->id; if ($cc == '1') { $fields['station'] = substr($e164, 8); $fields['npa'] = $npa; $fields['nxx'] = $nxx; } else { $fields['station'] = substr($e164, 4 + strlen($cc)); } $rs = $db->Execute( sqlSelect($db,"voip_pool","id","country_code=::".$cc.":: AND voip_did_plugin_id=::".$this->id.":: AND station=::".$fields['station']."::")); if ($rs->RecordCount() == 0) { $queue[] = sqlInsert($db,"voip_pool",$fields); } } else { $this->log_message('refresh', 'Could not parse the phone number returned: '.$v[0]); } } } } if (isset($queue) && is_array($queue) && count($queue)) { if ($bDelete) { # kill db entries $sql = "DELETE FROM ".AGILE_DB_PREFIX."voip_pool WHERE voip_did_plugin_id=".$this->id." AND (account_id IS NULL or account_id=0) AND country_code=".$eparts[0]." AND (date_reserved IS NULL or date_reserved=0)"; $db->Execute($sql); $bDelete = false; } foreach ($queue as $q) { $db->Execute($q); } } } # end foreach area } # end foreach entries } }
function search_show($VAR) { if (SESS_LOGGED) { include_once PATH_MODULES . "voip/voip.inc.php"; $db =& DB(); $v = new voip(); $fdids = $v->get_fax_dids(SESS_ACCOUNT); #echo "<pre>".print_r($fdids,true)."</pre>"; if (is_array($fdids)) { foreach ($fdids as $did) { $sql = "UPDATE " . AGILE_DB_PREFIX . "voip_fax SET \n\t\t\t\t\t\taccount_id\t\t= " . $db->qstr(SESS_ACCOUNT) . ", \n\t\t\t\t\t\tsite_id\t\t\t= " . $db->qstr(DEFAULT_SITE) . " \n\t\t\t\t\t\tWHERE dst = " . $db->qstr($did); $db->Execute($sql); #echo "did=$did ".$sql."<br>"; } } unset($db); } $type = "search"; $this->method["{$type}"] = split(",", $this->method["{$type}"]); $db = new CORE_database(); $db->search_show($VAR, $this, $type); }
{ print "<p><a href='?callsupervisor=callsupervisor'>" . T_("Click here to call the supervisor's phone. A conference call will be created with the respondent, yourself and the supervisor. Otherwise close this window") . "</a></p>"; print "<p><a href='?callsupervisor=hangup'>" . T_("Hangup when calling the supervisor") . "</a></p>"; } } else { print "<p>" . T_("Try calling the supervisor") . "</p>"; } */ } else { if ($callstatus == 0 || $callstatus == 4 || $callstatus == 5) { if (is_voip_enabled($operator_id)) { if (isset($_GET['callsupervisor'])) { include "functions/functions.voip.php"; $v = new voip(); $v->connect(VOIP_SERVER); if (strcmp($_GET['callsupervisor'], "hangup") == 0) { $v->hangup(get_extension($operator_id)); print "<p>" . T_("You may now close this window") . "</p>"; } else { $v->dial(get_extension($operator_id), SUPERVISOR_EXTENSION); print "<p>" . T_("Calling the supervisor, you may close this window") . "</p>"; } } else { print "<p><a href='?callsupervisor=callsupervisor'>" . T_("Click here to call the supervisor's phone. Otherwise close this window") . "</a></p>"; print "<p><a href='?callsupervisor=hangup'>" . T_("Hangup when calling the supervisor") . "</a></p>"; } } else { print "<p>" . T_("Try calling the supervisor") . "</p>"; }
function validate_cart($VAR, $product, $did, $ported) { // get E164 so we can determine the country code and did npa/nxx/station $db =& DB(); include_once PATH_MODULES . 'voip/voip.inc.php'; $v = new voip(); $cc = ""; $npa = ""; $nxx = ""; $e164 = ""; if ($v->e164($did, $e164, $cc, $npa, $nxx)) { if ($ported) { return true; } // verify this did is in voip_pool, and is not assigned to an account, and is not reserved if ($cc == '1') { $station = substr($e164, 8); $sql = sqlSelect($db, "voip_pool", "*", "(date_reserved IS NULL OR date_reserved=0) AND (account_id IS NULL OR account_id=0) AND country_code={$cc} AND npa={$npa} AND nxx={$nxx} AND station={$station}"); } elseif ($cc == '61') { $station = substr($e164, 12); $sql = sqlSelect($db, "voip_pool", "*", "(date_reserved IS NULL OR date_reserved=0) AND (account_id IS NULL OR account_id=0) AND country_code={$cc} AND npa={$npa} AND nxx={$nxx} AND station={$station}"); } else { $station = substr($e164, 4 + strlen($cc)); $sql = sqlSelect($db, "voip_pool", "*", "(date_reserved IS NULL OR date_reserved=0) AND (account_id IS NULL OR account_id=0) AND country_code={$cc} AND station={$station}"); } $rs = $db->Execute($sql); if ($rs && $rs->RecordCount() > 0) { $did_id = $rs->fields['id']; $plugin_id = $rs->fields['voip_did_plugin_id']; } else { return "Sorry, the selected number is not available or has been removed from our system, please go back and select another."; } } else { return "The format for the provided number is incorrect."; } // get the id of the current country calling code $country_id = 0; $country = $db->Execute($sql = sqlSelect($db, "voip_iso_country_code_map", "iso_country_code", "country_code = {$cc}")); if ($country && $country->RecordCount() == 1) { $countryc =& $db->Execute($sql = sqlSelect($db, "voip_iso_country_code", "id", "code = ::{$country->fields['iso_country_code']}::")); if ($countryc && $countryc->RecordCount() == 1) { $country_id = $countryc->fields['id']; } else { return "Sorry, the selected number is not available as the country is disallowed for the current product"; } } // validate that the country is available for the selected plugin $country_auth = false; $rs = $db->Execute(sqlSelect($db, "voip_did_plugin", "plugin,avail_countries", "id = {$plugin_id}")); if ($rs && $rs->RecordCount()) { $plugin = $rs->fields['plugin']; $carr = unserialize($rs->fields['avail_countries']); foreach ($carr as $cid) { if ($country_id == $cid) { $country_auth = true; break; } } } if (!$country_auth) { return "Sorry, the selected number is not available as the country is disallowed for the current product"; } // Get the plugin details and load plugin as an object $file = PATH_PLUGINS . 'voip_did/' . $plugin . '.php'; if (is_file($file)) { include_once $file; eval('$plg = new plgn_voip_did_' . $plugin . ';'); if (is_object($plg)) { if (is_callable(array($plg, 'reserve'))) { $plg->id = $plugin_id; $plg->did = $did; $plg->did_id = $did_id; $plg->country = $cc; $result = $plg->reserve(); if ($result === true) { return true; } else { return $result; } } } else { return "VoIP DID object couldn't be created."; } } else { return "VoIP DID plugin not found."; } // something failed... return "An unknown error occurred while attempting to reserve your requested number, please try again later."; }
include "functions/functions.voip.php"; $v = new voip(); $v->connect(VOIP_SERVER); $v->beginRecord(get_extension($operator_id), "{$case_id}-{$call_id}-{$operator_id}-" . get_operator_time($operator_id, $format = "%Y-%m-%d-%H-%i-%S")); print "<p>" . T_("Beginning recording...") . "</p>"; } else { print "<p>" . T_("Not on a call, so not beginning a recording") . "</p>"; } } else { print "<p>" . T_("Begin the manual recording now...") . "</p>"; } } else { if (isset($_GET['stop'])) { $newtext = T_("Start REC"); xhtml_head(T_("Record"), true, array("css/call.css"), array("js/window.js"), "onload='toggleRec(\"{$newtext}\",\"record.php?start=start\",\"offline\")'"); if (is_voip_enabled($operator_id)) { include "functions/functions.voip.php"; $v = new voip(); $v->connect(VOIP_SERVER); $v->endRecord(get_extension($operator_id)); print "<p>" . T_("Stopping recording...") . "</p>"; } else { print "<p>" . T_("Stop the manual recording now...") . "</p>"; } } } } else { xhtml_head(T_("Record"), true, array("css/call.css")); print "<p>" . T_("Not on a call, so not beginning a recording") . "</p>"; } xhtml_foot();