📄 a2billingi.php
字号:
global $A2B; //已注册用户修改密码菜单 $agi->verbose("change passwd menu"); $QUERY = "SELECT uipass from cc_card WHERE id=".$user_id; $result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY); $user_old_passwd = $result[0][0]; for ($i=0; $i<3; $i++){ $result = $agi->get_data("callingcard-chge-passwd-old",8000, 20); $old_psswd = $result['result']; if ($user_old_passwd == $old_psswd) { for ($i=0; $i<3; $i++){ $result = $agi->get_data("callingcard-chge-passwd-new",8000, 20); $new_psswd = $result['result']; $result = $agi->get_data("callingcard-chge-passwd-again",8000, 20); $new_psswd_confirm = $result['result']; if ($new_psswd == $new_psswd_confirm) { $QUERY = "UPDATE cc_card SET uipass='".$new_psswd."' WHERE id=".$user_id; $result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY); $agi-> stream_file("callingcard-chge-passwd-ok", '#'); break 2; } $agi-> stream_file("callingcard-chge-passwd-erro1", '#'); continue; } } $agi-> stream_file("callingcard-chge-passwd-erro", '#'); continue; }}// 函数结束########################################################################### // 插入语句// $QUERY = "INSERT INTO cc_callerid (id_cc_card, cid) VALUES ('3', '".$A2B->CallerID."')";// $result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);############################################################################################################判断CID属性################################if (strlen($A2B->CallerID)>1 && is_numeric($A2B->CallerID)){ //查询主叫号码是否在回拨列表中$QUERY = "SELECT id_cc_card from cc_callerid WHERE cid='".$A2B->CallerID."'";$result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);if (is_array($result)) {//找到了有效的卡号$agi->verbose('accout found !');$cid_exists = "yes";$acount_id = $result[0][0];$agi->verbose("id is $acount_id");}else { $agi->verbose('account not exists !');$cid_exists = "no";}$QUERY = "SELECT id, uipass, credit from cc_card WHERE id='".$acount_id."'";$result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);$agi->verbose($result);if (is_array($result)){$user_id = $result[0][0];$agi->verbose($user_id); $user_passwd = $result[0][1];$agi->verbose($user_passwd); $user_balance = $result[0][2];$agi->verbose($user_balance);}else{$agi->verbose("accout not found !");}$agi->verbose($cid_exists); #################################判断结束################################## //判断是否存在,操作 if (isset($user_new)) {$agi-> stream_file("callingcard-welcome", '#'); $result = $agi->get_data("callingcard-reg-ok",8000, 1);$dtmf1 = $result['result'];if ($dtmf1 == "1") {$QUERY = "SELECT id, uipass, credit from cc_card WHERE username='".$user_new."'";$result_card = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);$QUERY = "INSERT INTO cc_callerid (id_cc_card, cid) VALUES ('".$result_card[0][0]."', '".$A2B->CallerID."')"; $result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);$agi-> stream_file("cid-reg-sucsess", '#'); $serch_balance = get_balance();registed_user_ivr($serch_balance,$user_new); }elseif($dtmf1 !== 1 ) {//按键错误再见$agi-> stream_file("cid-reg-goodbye", '#');//$agi->get_data("callingcard-enter-card",8000, 20); } }elseif ($cid_exists == "no"){ //callerid不存在//请输入卡号dtmf $agi-> stream_file("callingcard-welcome", '#'); $agi-> stream_file("callingcard-unreg-user", '#'); $abc = cid_new_reg();//卡号密码输入正确 if (is_array($abc)) {//确认请按1,$result = $agi->get_data("cid-reg-yes",8000, 1);$dtmf1 = $result['result'];if ($dtmf1 == "1") {$QUERY = "INSERT INTO cc_callerid (id_cc_card, cid) VALUES ('".$abc[0][0]."', '".$A2B->CallerID."')";$result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY);$agi-> stream_file("cid-reg-sucsess", '#'); $serch_balance = get_balance();registed_user_ivr($serch_balance,$abc[0][0]); }elseif($dtmf1 !== 1 ) {//按键错误再见$agi-> stream_file("cid-reg-goodbye", '#'); } } }elseif($cid_exists == 'yes'){//callerid存在$agi-> stream_file("callingcard-welcome", '#'); registed_user_ivr($user_balance,$user_id); } } } // ??? $A2B->callingcard_auto_setcallerid($agi); for other modes if($mode == 'callingcard'){if ($A2B->agiconfig['answer_call']==1){ $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, '[ANSWER CALL]'); $agi->answer(); $status_channel=6; }else{ $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, '[NO ANSWER CALL]'); $status_channel=4; } $agi->answer(); $A2B -> play_menulanguage ($agi);$QUERY = "SELECT cc_callerid.cid, cc_callerid.id_cc_card, cc_callerid.activated, cc_card.credit, ". " cc_card.tariff, cc_card.activated, cc_card.inuse, cc_card.simultaccess, ". " cc_card.typepaid, cc_card.creditlimit, cc_card.language, cc_card.username, removeinterprefix, cc_card.redial, "; $QUERY .= " enableexpire, UNIX_TIMESTAMP(expirationdate), expiredays, nbused, UNIX_TIMESTAMP(firstusedate), UNIX_TIMESTAMP(cc_card.creationdate), ";$QUERY .= " cc_card.currency, cc_card.lastname, cc_card.firstname, cc_card.email, cc_card.uipass, cc_card.id_campaign, cc_card.id, useralias ". " FROM cc_callerid ". " LEFT JOIN cc_card ON cc_callerid.id_cc_card=cc_card.id ". " LEFT JOIN cc_tariffgroup ON cc_card.tariff=cc_tariffgroup.id ". " WHERE cc_callerid.cid='".$A2B->CallerID."'"; $result = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY); if (is_array($result)) { $res_dtmf = $agi->get_data("callingcard-enter-callnumber",8000, 20); $callnumber = $res_dtmf["result"]; $fg=substr($callnumber,-1,1); if($fg=='*'){ $agi ->exec_goto("test","201","1"); exit(0); } if ($callnumber == "00" ){ callingcard_register(); exit(0); } $nlen=strlen($callnumber); if($nlen==4){ $uname=$result[0][11]; $ncall="%".$callnumber; $QUERY = "SELECT calledstation FROM `cc_call` WHERE `username` LIKE '".$uname."' AND `calledstation` LIKE '".$ncall."'"; $ghcall = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY); if(empty($ghcall[0][0])){$agi ->exec_goto("test","201","1"); exit(0);} $callnumber=$ghcall[0][0]; } $A2B-> accountcode = $result[0][11]; $A2B-> destination = $callnumber; //$agi->verbose("Found a cardnumber for this Caller ! : $A2B->accountcode "); }else { $card_res = callingcard_ivr(); if (is_array($card_res)) { $res_dtmf = $agi->get_data("callingcard-enter-callnumber",8000, 20); $callnumber = $res_dtmf["result"]; $fg=substr($callnumber,-1,1); if($fg=='*'){ $agi ->exec_goto("test","201","1"); exit(0); } if ($callnumber == "00" ){ callingcard_register($card_res[0][3]); exit(0); } if($nlen==4){ $uname=$card_res[0][3]; $ncall="%".$callnumber; $QUERY = "SELECT calledstation FROM `cc_call` WHERE `username` LIKE '".$uname."' AND `calledstation` LIKE '".$ncall."'"; $ghcall = $A2B -> instance_table -> SQLExec ($A2B->DBHandle, $QUERY); if(empty($ghcall[0][0])){$agi ->exec_goto("test","201","1"); exit(0);} $callnumber=$ghcall[0][0]; } $A2B-> accountcode = $card_res[0][3]; $A2B-> destination = $callnumber; //$agi->verbose("Found a cardnumber for this Caller ! : $A2B->accountcode "); }else { $agi->verbose("Not found cardnumber, this Caller not register, Play Custom IVR!"); $agi->stream_file("input_erro"); $agi->hangup(); exit(); }} /* WE START ;) */ $cia_res = $A2B -> callingcard_ivr_authenticate($agi); $A2B -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[TRY : callingcard_ivr_authenticate]"); // GOOD AUTHENTICATION AND WE HAVE CREDIT TO GO AHEAD if ($cia_res==0){ // RE-SET THE CALLERID $A2B->callingcard_auto_setcallerid($agi); //$A2B->callingcard_acct_start_inuse($agi,1); for ($i=0;$i< $A2B->agiconfig['number_try'] ;$i++){ $RateEngine->Reinit(); $A2B-> Reinit(); // RETRIEVE THE CHANNEL STATUS AND LOG : STATUS - CREIT - MIN_CREDIT_2CALL $stat_channel = $agi->channel_status($A2B-> channel); $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, '[CHANNEL STATUS : '.$stat_channel["result"].' = '.$stat_channel["data"].']'); $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[CREDIT : ".$A2B-> credit."][CREDIT MIN_CREDIT_2CALL : ".$A2B->agiconfig['min_credit_2call']."]"); // CHECK IF THE CHANNEL IS UP //if ($stat_channel["status"]!= "6" && $stat_channel["status"]!= "1"){ if (($A2B->agiconfig['answer_call']==1) && ($stat_channel["result"]!=$status_channel) && ($A2B -> CC_TESTING!=1)){ if ($A2B->set_inuse==1) $A2B->callingcard_acct_start_inuse($agi,0); $A2B -> write_log("[STOP - EXIT]", 0); exit(); } // CREATE A DIFFERENT UNIQUEID FOR EACH TRY if ($i>0){ $A2B-> uniqueid=$A2B-> uniqueid+ 1000000000 ; } if( $A2B->credit < $A2B->agiconfig['min_credit_2call'] && $A2B -> typepaid==0 && $A2B->agiconfig['jump_voucher_if_min_credit']==1) { $A2B -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[NOTENOUGHCREDIT - Refill with vouchert]"); $vou_res = $A2B -> refill_card_with_voucher($agi,2); if ($vou_res==1){ $A2B -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[ADDED CREDIT - refill_card_withvoucher Success] "); } else { $A2B -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[NOTENOUGHCREDIT - refill_card_withvoucher fail] "); } } if( $A2B->credit < $A2B->agiconfig['min_credit_2call'] && $A2B -> typepaid==0) { // SAY TO THE CALLER THAT IT DEOSNT HAVE ENOUGH CREDIT TO MAKE A CALL $prompt = "prepaid-no-enough-credit-stop"; $agi-> stream_file($prompt, '#'); $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[STOP STREAM FILE $prompt]"); if (($A2B->agiconfig['notenoughcredit_cardnumber']==1) && (($i+1)< $A2B->agiconfig['number_try'])){ if ($A2B->set_inuse==1) $A2B->callingcard_acct_start_inuse($agi,0); $A2B->agiconfig['cid_enable']=0; $A2B->agiconfig['use_dnid']=0;// $A2B->agiconfig['say_balance_after_auth']=0; $A2B->agiconfig['cid_auto_assign_card_to_cid']=0; $A2B->accountcode=''; $A2B->username=''; $A2B-> ask_other_cardnumber = 1; $cia_res = $A2B -> callingcard_ivr_authenticate($agi); $A2B -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[NOTENOUGHCREDIT_CARDNUMBER - TRY : callingcard_ivr_authenticate]"); if ($cia_res!=0) break; $A2B -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[NOTENOUGHCREDIT_CARDNUMBER - callingcard_acct_start_inuse]"); $A2B->callingcard_acct_start_inuse($agi,1); continue; }else{ $send_reminder = 1; $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "[SET MAIL REMINDER - NOT ENOUGH CREDIT]"); break; } } if ($agi->request['agi_extension']=='s'){ $A2B->dnid = $agi->request['agi_dnid']; }else{ $A2B->dnid = $agi->request['agi_extension']; } if ($A2B->agiconfig['ivr_voucher']==1){ $res_dtmf = $agi->get_data('prepaid-refill_card_with_voucher', 5000, 1); $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "RES REFILL CARD VOUCHER DTMF : ".$res_dtmf ["result"]); $A2B-> ivr_voucher = $res_dtmf ["result"]; if ((isset($A2B-> ivr_voucher)) && ($A2B-> ivr_voucher == $A2B->agiconfig['ivr_voucher_prefixe'])) { $vou_res = $A2B->refill_card_with_voucher($agi, $i); // if ($vou_res==1)$A2B->fct_say_balance ($agi, $A2B->add_credit, 1); } } if ( isset($A2B-> sip_iax_buddy) && ($A2B-> sip_iax_buddy == $A2B->agiconfig['sip_iax_pstn_direct_call_prefix'])) { $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, 'CALL SIP_IAX_BUDDY'); $cia_res = $A2B-> call_sip_iax_buddy($agi, $RateEngine,$i); }else{ if ($A2B-> my_callingcard_ivr_authorize($agi, $RateEngine, $i,$callnumber)==1){ // PERFORM THE CALL $A2B->agiconfig['use_dnid']=1; $result_callperf = $RateEngine->rate_engine_performcall ($agi, $A2B-> destination, $A2B); if (!$result_callperf) { $prompt="prepaid-dest-unreachable"; //$agi->agi_exec("STREAM FILE $prompt #"); $agi-> stream_file($prompt, '#'); } // INSERT CDR & UPDATE SYSTEM $RateEngine->rate_engine_updatesystem($A2B, $agi, $A2B-> destination); if ($A2B->agiconfig['say_balance_after_call']==1){ $A2B-> fct_say_balance ($agi, $A2B-> credit); } $A2B -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, '[a2billing account stop]'); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -