#!/usr/bin/php -q load_conf($agi, NULL, 0, $idconfig); $A2B -> CC_TESTING = isset($A2B->agiconfig['debugshell']) && $A2B->agiconfig['debugshell']; /* GET THE AGI PARAMETER */ $A2B -> get_agi_request_parameter ($agi); if (!$A2B -> DbConnect()){ $agi-> stream_file('prepaid-final', '#'); exit; } $instance_table = new Table(); $A2B -> set_instance_table ($instance_table); // Get the DID $DID = $agi->request ["agi_extension"]; WriteLog ("DID is ${DID}"); $ok = (strlen ($DID) > 2); WriteLog ("ok is ${ok}"); if ($ok) { // Check if there is a card assocsiated with this DID $query = "SELECT id_cc_card,name FROM cc_sip_buddies WHERE (callerid='${DID}');"; WriteLog ("Executing query ${query}"); $result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $query); WriteLog ("Result is ${result}"); $ok = (is_array($result)); WriteLog ("ok is ${ok}"); } if ($ok) { // Found the card, let's see if it has voicemail enabled $cardID = $result[0][0]; WriteLog ("cardID is ${cardID}"); $PhoneNumber = $result [0][1]; WriteLog ("PhoneNumber is ${PhoneNumber}"); $agi->set_variable ("DialNum", "SIP/${PhoneNumber}"); // Check the cc_card table for voicemail definition $query = "SELECT voicemail_active FROM cc_card WHERE (id=${cardID});"; WriteLog ("Executing query ${query}"); $result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $query); WriteLog ("Result is ${result}"); if ($result [0][0] != "0") { $agi->set_variable ("HasVoicemail", "1"); WriteLog ("Card ha voicemail"); } else { $agi->set_variable ("HasVoicemail", "0"); WriteLog ("Card has no voicemail"); } $agi->set_variable ("CardID", $cardID); } else $agi->set_variable ("CardID", "0"); ?>