?? class.a2billing.php
字號:
global $currencies_list; if (isset($this->agiconfig['agi_force_currency']) && strlen($this->agiconfig['agi_force_currency'])==3) { $this->currency = $this->agiconfig['agi_force_currency']; } if (!isset($currencies_list[strtoupper($this->currency)][2]) || !is_numeric($currencies_list[strtoupper($this->currency)][2])) $mycur = 1; else $mycur = $currencies_list[strtoupper($this->currency)][2]; $rate_cur = $rate / $mycur; $cents = intval($rate_cur); $units = round(($rate_cur - $cents) * 1E4); while ($units != 0 && $units % 10 == 0) $units /= 10; // say 'the rate is' //$agi->stream_file('the-rate-is'); $agi->say_number($cents); if ($units > 0) { $agi->stream_file('point'); $agi->say_digits($units); } $agi->stream_file('cents-per-minute'); } /** * Function refill_card_with_voucher * * @param object $agi * @param object $RateEngine * @param object $voucher number * @return 1 if Ok ; -1 if error **/ function refill_card_with_voucher ($agi, $try_num){ global $currencies_list; $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[VOUCHER REFILL CARD LOG BEGIN]"); if (isset($this->agiconfig['agi_force_currency']) && strlen($this->agiconfig['agi_force_currency'])==3){ $this -> currency = $this->agiconfig['agi_force_currency']; } if (!isset($currencies_list[strtoupper($this->currency)][2]) || !is_numeric($currencies_list[strtoupper($this->currency)][2])){ $mycur = 1; } else { $mycur = $currencies_list[strtoupper($this->currency)][2]; } $timetowait = ($this->config['global']['len_voucher'] < 6) ? 8000 : 20000; $res_dtmf = $agi->get_data('prepaid-voucher_enter_number', $timetowait, $this->config['global']['len_voucher'], '#'); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "VOUCHERNUMBER RES DTMF : ".$res_dtmf ["result"]); $this -> vouchernumber = $res_dtmf ["result"]; if ($this -> vouchernumber <= 0){ return -1; } $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "VOUCHER NUMBER : ".$this->vouchernumber); $QUERY = "SELECT voucher, credit, activated, tag, currency, expirationdate FROM cc_voucher WHERE expirationdate >= CURRENT_TIMESTAMP AND activated='t' AND voucher='".$this -> vouchernumber."'"; $result = $this -> instance_table -> SQLExec ($this->DBHandle, $QUERY); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[VOUCHER SELECT: $QUERY]\n".print_r($result,true)); if ($result[0][0]==$this->vouchernumber) { if (!isset ($currencies_list[strtoupper($result[0][4])][2])) { $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "System Error : No currency table complete !!!"); $agi-> stream_file('prepaid-unknow_used_currencie', '#'); return -1; } else { // DISABLE THE VOUCHER $this -> add_credit = $result[0][1] * $currencies_list[strtoupper($result[0][4])][2]; $QUERY = "UPDATE cc_voucher SET activated='f', usedcardnumber='".$this->accountcode."', usedate=now() WHERE voucher='".$this->vouchernumber."'"; $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "QUERY UPDATE VOUCHER: $QUERY"); $result = $this -> instance_table -> SQLExec ($this->DBHandle, $QUERY, 0); // UPDATE THE CARD AND THE CREDIT PROPERTY OF THE CLASS $QUERY = "UPDATE cc_card SET credit=credit+'".$this ->add_credit."' WHERE username='".$this->accountcode."'"; $result = $this -> instance_table -> SQLExec ($this->DBHandle, $QUERY, 0); $this -> credit += $this -> add_credit; $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "QUERY UPDATE CARD: $QUERY"); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, ' The Voucher '.$this->vouchernumber.' has been used, We added '.$this ->add_credit/$mycur.' '.strtoupper($this->currency).' of credit on your account!'); $this->fct_say_balance ($agi, $this->add_credit, 1); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[VOUCHER REFILL CARD: $QUERY]"); return 1; } } else { $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[VOUCHER REFILL ERROR: ".$this->vouchernumber." Voucher not avaible or dosn't exist]"); $agi-> stream_file('voucher_does_not_exist'); return -1; } $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[VOUCHER REFILL CARD LOG END]"); return 1; } /* * Function to generate a cardnumber */ function MDP() { $chrs = $this->agiconfig['cid_auto_create_card_len']; $pwd = ""; mt_srand ((double) microtime() * 1000000); while (strlen($pwd)<$chrs) { $chr = chr(mt_rand (0,255)); if (eregi("^[0-9]$", $chr)) $pwd = $pwd.$chr; }; return $pwd; } /* * Function apply_rules to the phonenumber : Remove internation prefix */ function apply_rules ($phonenumber){ // BEGIN if (substr($phonenumber,0,3)=="011"){ $this->myprefix='011'; return substr($phonenumber,3); } if (substr($phonenumber,0,1)=="1"){ $this->myprefix='1'; return $phonenumber; } if (substr($phonenumber,0,2)=="00"){ $this->myprefix='00'; return substr($phonenumber,2); } if (substr($phonenumber,0,2)=="09"){ $this->myprefix='09'; return substr($phonenumber,2); } $this->myprefix=''; return $phonenumber; // END // THIS PART IS DEPRECIATE : IT WAS DONE TO MANAGE THE CANADIAN LOCAL CALL // (NOT USEFUL ANYMORE AS WE CAN MANAGE THIS FROM THE RATECARD PROPERTIES) /* // EUROPE CALL TO THE CANADIAN SYSTEM if (substr($phonenumber,0,2)=="00"){ $this->myprefix='011'; return "011".substr($phonenumber,2); } // CALL TO US / OR US CALL IN CANADA if (substr($phonenumber,0,1)=="1"){ $this->myprefix=''; return "011".$phonenumber; } // LOCAL CALL WITH 1 $canada[]="1403"; $canada[]="1780"; $canada[]="1250"; $canada[]="1604"; $canada[]="1778"; $canada[]="1204"; $canada[]="1506"; $canada[]="1709"; $canada[]="1902"; $canada[]="1289"; $canada[]="1416"; $canada[]="1519"; $canada[]="1613"; $canada[]="1647"; $canada[]="1705"; $canada[]="1807"; $canada[]="1905"; $canada[]="1418"; $canada[]="1450"; $canada[]="1514"; $canada[]="1819"; $canada[]="1306"; $canada[]="1867"; // LOCAL CALL WITHOUT 1 $localcanada[]="403"; $localcanada[]="780"; $localcanada[]="250"; $localcanada[]="604"; $localcanada[]="778"; $localcanada[]="204"; $localcanada[]="506"; $localcanada[]="709"; $localcanada[]="902"; $localcanada[]="289"; $localcanada[]="416"; $localcanada[]="519"; $localcanada[]="613"; $localcanada[]="647"; $localcanada[]="705"; $localcanada[]="807"; $localcanada[]="905"; $localcanada[]="418"; $localcanada[]="450"; $localcanada[]="514"; $localcanada[]="819"; $localcanada[]="306"; $localcanada[]="867"; foreach ($localcanada as $pn){ if ($pn == substr($phonenumber,0,3)){ $this->myprefix=''; return "011"."1".$phonenumber; } } // NO CHANGE $this->myprefix='011'; return $phonenumber;*/ } /* * Function callingcard_cid_sanitize : Ensure the caller is allowed to use their claimed CID. * Returns: clean CID value, possibly empty. */ function callingcard_cid_sanitize($agi){ $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[CID_SANITIZE - CID:".$this->CallerID."]"); if (strlen($this->CallerID)==0) { $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[CID_SANITIZE - CID: NO CID]"); return ''; } $QUERY=""; if($this->agiconfig['cid_sanitize']=="CID" || $this->agiconfig['cid_sanitize']=="BOTH"){ $QUERY .= "SELECT cc_callerid.cid ". " FROM cc_callerid ". " JOIN cc_card ON cc_callerid.id_cc_card=cc_card.id ". " WHERE cc_card.username='".$this->cardnumber."' "; $QUERY .= "ORDER BY 1"; $result1 = $this->instance_table -> SQLExec ($this->DBHandle, $QUERY); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "QUERY = $QUERY\n".print_r($result1,true)); } /*if($this->agiconfig['cid_sanitize']=="BOTH"){ $QUERY .= " UNION "; }*/ $QUERY=""; if($this->agiconfig['cid_sanitize']=="DID" || $this->agiconfig['cid_sanitize']=="BOTH"){ $QUERY .= "SELECT cc_did.did ". " FROM cc_did ". " JOIN cc_did_destination ON cc_did_destination.id_cc_did=cc_did.id ". " JOIN cc_card ON cc_did_destination.id_cc_card=cc_card.id ". " WHERE cc_card.username='".$this->cardnumber."' "; $QUERY .= "ORDER BY 1"; $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "QUERY = $QUERY"); $result2 = $this->instance_table -> SQLExec ($this->DBHandle, $QUERY); } if (count($result1)>0 || count($result2)>0) $result = array_merge($result1, $result2); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "RESULT MERGE -> ".print_r($result,true)); if( !is_array($result)) { $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[CID_SANITIZE - CID: NO DATA]"); return ''; } for ($i=0;$i<count($result);$i++){ $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[CID_SANITIZE - CID COMPARING: ".substr($result[$i][0],strlen($this->CallerID)*-1)." to ".$this->CallerID."]"); if(substr($result[$i][0],strlen($this->CallerID)*-1)==$this->CallerID) { $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[CID_SANITIZE - CID: ".$result[$i][0]."]"); return $result[$i][0]; } } $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[CID_SANITIZE - CID UNIQUE RESULT: ".$result[0][0]."]"); return $result[0][0]; } function callingcard_auto_setcallerid($agi){ // AUTO SetCallerID $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[AUTO SetCallerID]"); if ($this->agiconfig['auto_setcallerid']==1){ if ( strlen($this->agiconfig['force_callerid']) >=1 ){ $agi -> set_callerid($this->agiconfig['force_callerid']); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[EXEC SetCallerID : ".$this->agiconfig['force_callerid']."]"); }elseif ( strlen($this->CallerID) >=1 ){ $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[REQUESTED SetCallerID : ".$this->CallerID."]"); // IF REQUIRED, VERIFY THAT THE CALLERID IS LEGAL $cid_sanitized = $this->CallerID; /*if ($this->agiconfig['cid_sanitize']=='DID' || $this->agiconfig['cid_sanitize']=='CID' || $this->agiconfig['cid_sanitize']=='BOTH') { $cid_sanitized = $this -> callingcard_cid_sanitize($agi); $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[TRY : callingcard_cid_sanitize]"); if ($this->agiconfig['debug']>=1) $agi->verbose('CALLERID SANITIZED: "'.$cid_sanitized.'"'); }*/ if (strlen($cid_sanitized)>0){ $agi->set_callerid($cid_sanitized); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[EXEC SetCallerID : ".$cid_sanitized."]"); }else{ $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[CANNOT SetCallerID : cid_san is empty]"); } } } } function callingcard_ivr_authenticate($agi){ $prompt=''; $res=0; $retries=0; $language = 'en'; $callerID_enable = $this->agiconfig['cid_enable']; // -%-%-%-%-%-%- FIRST TRY WITH THE CALLERID AUTHENTICATION -%-%-%-%-%-%- if ($callerID_enable==1 && is_numeric($this->CallerID) && $this->CallerID>0){ $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[CID_ENABLE - CID_CONTROL - CID:".$this->CallerID."]"); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[CID_ENABLE - CID_CONTROL - CID:".$this->CallerID."]");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -