class.a2billing.php
来自「asterisk用 的voip记费软件」· PHP 代码 · 共 1,467 行 · 第 1/5 页
PHP
1,467 行
if(!isset($this->config['database']['dbname'])) $this->config['database']['dbname'] = 'a2billing'; if(!isset($this->config['database']['dbtype'])) $this->config['database']['dbtype'] = 'postgres'; // Conf for the Callback if(!isset($this->config['callback']['context_callback'])) $this->config['callback']['context_callback'] = 'a2billing-callback'; if(!isset($this->config['callback']['ani_callback_delay'])) $this->config['callback']['ani_callback_delay'] = '10'; if(!isset($this->config['callback']['extension'])) $this->config['callback']['extension'] = '1000'; if(!isset($this->config['callback']['sec_avoid_repeate'])) $this->config['callback']['sec_avoid_repeate'] = '30'; if(!isset($this->config['callback']['timeout'])) $this->config['callback']['timeout'] = '20'; if(!isset($this->config['callback']['answer_call'])) $this->config['callback']['answer_call'] = '1'; if(!isset($this->config['callback']['nb_predictive_call'])) $this->config['callback']['nb_predictive_call'] = '10'; if(!isset($this->config['callback']['nb_day_wait_before_retry'])) $this->config['callback']['nb_day_wait_before_retry'] = '1'; if(!isset($this->config['callback']['context_preditctivedialer'])) $this->config['callback']['context_preditctivedialer'] = 'a2billing-predictivedialer'; if(!isset($this->config['callback']['predictivedialer_maxtime_tocall'])) $this->config['callback']['predictivedialer_maxtime_tocall'] = '5400'; if(!isset($this->config['callback']['sec_wait_before_callback'])) $this->config['callback']['sec_wait_before_callback'] = '10'; // Conf for the signup if(!isset($this->config['signup']['enable_signup']))$this->config['signup']['enable_signup'] = '1'; if(!isset($this->config['signup']['credit'])) $this->config['signup']['credit'] = '0'; if(!isset($this->config['signup']['tariff'])) $this->config['signup']['tariff'] = '8'; if(!isset($this->config['signup']['activated'])) $this->config['signup']['activated'] = 't'; if(!isset($this->config['signup']['simultaccess'])) $this->config['signup']['simultaccess'] = '0'; if(!isset($this->config['signup']['typepaid'])) $this->config['signup']['typepaid'] = '0'; if(!isset($this->config['signup']['creditlimit'])) $this->config['signup']['creditlimit'] = '0'; if(!isset($this->config['signup']['runservice'])) $this->config['signup']['runservice'] = '0'; if(!isset($this->config['signup']['enableexpire'])) $this->config['signup']['enableexpire'] = '0'; if(!isset($this->config['signup']['expiredays'])) $this->config['signup']['expiredays'] = '0'; // Conf for Paypal if(!isset($this->config['paypal']['item_name'])) $this->config['paypal']['item_name'] = 'Credit Purchase'; if(!isset($this->config['paypal']['currency_code'])) $this->config['paypal']['currency_code'] = 'USD'; if(!isset($this->config['paypal']['purchase_amount'])) $this->config['paypal']['purchase_amount'] = '5;10;15'; if(!isset($this->config['paypal']['paypal_fees'])) $this->config['paypal']['paypal_fees'] = '1'; // Conf for Backup if(!isset($this->config['backup']['backup_path'])) $this->config['backup']['backup_path'] ='/tmp'; if(!isset($this->config['backup']['gzip_exe'])) $this->config['backup']['gzip_exe'] ='/bin/gzip'; if(!isset($this->config['backup']['gunzip_exe'])) $this->config['backup']['gunzip_exe'] ='/bin/gunzip'; if(!isset($this->config['backup']['mysqldump'])) $this->config['backup']['mysqldump'] ='/usr/bin/mysqldump'; if(!isset($this->config['backup']['pg_dump'])) $this->config['backup']['pg_dump'] ='/usr/bin/pg_dump'; if(!isset($this->config['backup']['mysql'])) $this->config['backup']['mysql'] ='/usr/bin/mysql'; if(!isset($this->config['backup']['psql'])) $this->config['backup']['psql'] ='/usr/bin/psql'; // Conf for Customer Web UI if(!isset($this->config['webcustomerui']['customerinfo'])) $this->config['webcustomerui']['customerinfo'] = '1'; if(!isset($this->config['webcustomerui']['sipiaxinfo'])) $this->config['webcustomerui']['sipiaxinfo'] = '1'; if(!isset($this->config['webcustomerui']['personalinfo'])) $this->config['webcustomerui']['personalinfo'] = '1'; if(!isset($this->config['webcustomerui']['cdr'])) $this->config['webcustomerui']['cdr'] = '1'; if(!isset($this->config['webcustomerui']['invoice'])) $this->config['webcustomerui']['invoice'] = '1'; if(!isset($this->config['webcustomerui']['voucher'])) $this->config['webcustomerui']['voucher'] = '1'; if(!isset($this->config['webcustomerui']['paypal'])) $this->config['webcustomerui']['paypal'] = '1'; if(!isset($this->config['webcustomerui']['speeddial'])) $this->config['webcustomerui']['speeddial'] = '1'; if(!isset($this->config['webcustomerui']['did'])) $this->config['webcustomerui']['did'] = '1'; if(!isset($this->config['webcustomerui']['ratecard'])) $this->config['webcustomerui']['ratecard'] = '1'; if(!isset($this->config['webcustomerui']['simulator'])) $this->config['webcustomerui']['simulator'] = '1'; if(!isset($this->config['webcustomerui']['callback'])) $this->config['webcustomerui']['callback'] = '1'; if(!isset($this->config['webcustomerui']['predictivedialer'])) $this->config['webcustomerui']['predictivedialer'] = '1'; if(!isset($this->config['webcustomerui']['webphone'])) $this->config['webcustomerui']['webphone'] = '1'; if(!isset($this->config['webcustomerui']['callerid'])) $this->config['webcustomerui']['callerid'] = '1'; if(!isset($this->config['webcustomerui']['limit_callerid'])) $this->config['webcustomerui']['limit_callerid'] = '5'; if(!isset($this->config['webcustomerui']['error_email'])) $this->config['webcustomerui']['error_email'] = 'root@localhost'; // conf for the web ui if(!isset($this->config['webui']['buddy_sip_file'])) $this->config['webui']['buddy_sip_file'] = '/etc/asterisk/additional_a2billing_sip.conf'; if(!isset($this->config['webui']['buddy_iax_file'])) $this->config['webui']['buddy_iax_file'] = '/etc/asterisk/additional_a2billing_iax.conf'; if(!isset($this->config['webui']['api_logfile'])) $this->config['webui']['api_logfile'] = '/tmp/api_ecommerce_request.log'; if(isset($this->config['webui']['api_ip_auth'])) $this->config['webui']['api_ip_auth'] = explode(";", $this->config['webui']['api_ip_auth']); if(!isset($this->config['webui']['dir_store_mohmp3'])) $this->config['webui']['dir_store_mohmp3'] = '/var/lib/asterisk/mohmp3'; if(!isset($this->config['webui']['num_musiconhold_class'])) $this->config['webui']['num_musiconhold_class'] = 10; if(!isset($this->config['webui']['show_help'])) $this->config['webui']['show_help'] = 1; if(!isset($this->config['webui']['my_max_file_size_import'])) $this->config['webui']['my_max_file_size_import'] = 1024000; if(!isset($this->config['webui']['dir_store_audio'])) $this->config['webui']['dir_store_audio'] = '/var/lib/asterisk/sounds/a2billing'; if(!isset($this->config['webui']['my_max_file_size_audio'])) $this->config['webui']['my_max_file_size_audio'] = 3072000; if(isset($this->config['webui']['file_ext_allow'])) $this->config['webui']['file_ext_allow'] = explode(",", $this->config['webui']['file_ext_allow']); else $this->config['webui']['file_ext_allow'] = explode(",", "gsm, mp3, wav"); if(isset($this->config['webui']['file_ext_allow_musiconhold'])) $this->config['webui']['file_ext_allow_musiconhold'] = explode(",", $this->config['webui']['file_ext_allow_musiconhold']); else $this->config['webui']['file_ext_allow_musiconhold'] = explode(",", "mp3"); if(!isset($this->config['webui']['show_top_frame'])) $this->config['webui']['show_top_frame'] = 1; if(!isset($this->config['webui']['currency_choose'])) $this->config['webui']['currency_choose'] = 'all'; if(!isset($this->config['webui']['card_export_field_list'])) $this->config['webui']['card_export_field_list'] = 'creationdate, username, credit, lastname, firstname'; if(!isset($this->config['webui']['voucher_export_field_list'])) $this->config['webui']['voucher_export_field_list'] = 'id, voucher, credit, tag, activated, usedcardnumber, usedate, currency'; if(!isset($this->config['webui']['advanced_mode'])) $this->config['webui']['advanced_mode'] = 0; if(!isset($this->config['webui']['delete_fk_card'])) $this->config['webui']['delete_fk_card'] = 1; // conf for the recurring process if(!isset($this->config["recprocess"]['batch_log_file'])) $this->config["recprocess"]['batch_log_file'] = '/tmp/batch-a2billing.log'; // conf for the peer_friend if(!isset($this->config['peer_friend']['type'])) $this->config['peer_friend']['type'] = 'friend'; if(!isset($this->config['peer_friend']['allow'])) $this->config['peer_friend']['allow'] = 'ulaw, alaw, gsm, g729'; if(!isset($this->config['peer_friend']['context'])) $this->config['peer_friend']['context'] = 'a2billing'; if(!isset($this->config['peer_friend']['nat'])) $this->config['peer_friend']['nat'] = 'yes'; if(!isset($this->config['peer_friend']['amaflags'])) $this->config['peer_friend']['amaflags'] = 'billing'; if(!isset($this->config['peer_friend']['qualify'])) $this->config['peer_friend']['qualify'] = 'yes'; if(!isset($this->config['peer_friend']['host'])) $this->config['peer_friend']['host'] = 'dynamic'; if(!isset($this->config['peer_friend']['dtmfmode'])) $this->config['peer_friend']['dtmfmode'] = 'RFC2833'; // conf for the log-files /* if(!isset($this->config['log-files']['cront_alarm'])) $this->config['log-files']['cront_alarm'] = '/tmp/cront_a2b_alarm.log'; if(!isset($this->config['log-files']['cront_autorefill'])) $this->config['log-files']['cront_autorefill'] = '/tmp/cront_a2b_autorefill.log'; if(!isset($this->config['log-files']['cront_batch_process'])) $this->config['log-files']['cront_batch_process'] = '/tmp/cront_a2b_batch_process.log'; if(!isset($this->config['log-files']['cront_bill_diduse'])) $this->config['log-files']['cront_bill_diduse'] = '/tmp/cront_a2b_bill_diduse.log'; if(!isset($this->config['log-files']['cront_subscriptionfee'])) $this->config['log-files']['cront_subscriptionfee'] = '/tmp/cront_a2b_subscriptionfee.log'; if(!isset($this->config['log-files']['cront_currency_update'])) $this->config['log-files']['cront_currency_update'] = '/tmp/cront_a2b_currency_update.log'; if(!isset($this->config['log-files']['cront_invoice'])) $this->config['log-files']['cront_invoice'] = '/tmp/cront_a2b_invoice.log'; if(!isset($this->config['log-files']['paypal'])) $this->config['log-files']['paypal'] = '/tmp/a2billing_paypal.log'; if(!isset($this->config['log-files']['epayment'])) $this->config['log-files']['epayment'] = '/tmp/a2billing_epayment.log'; if(!isset($this->config['log-files']['ecommerce_api'])) $this->config['log-files']['ecommerce_api'] = '/tmp/api_ecommerce_request.log'; if(!isset($this->config['log-files']['soap_api'])) $this->config['log-files']['soap_api'] = '/tmp/api_soap_request.log'; if(!isset($this->config['log-files']['callback_api'])) $this->config['log-files']['callback_api'] = '/tmp/api_callback_request.log'; if(!isset($this->config['log-files']['agi'])) $this->config['log-files']['agi'] = '/tmp/a2billing_agi.log'; */ if(isset($this->config['log-files']['agi']) && strlen ($this->config['log-files']['agi']) > 1) { $this -> log_file = $this -> config['log-files']['agi']; } define ("LOGFILE_CRONT_ALARM", isset($this->config['log-files']['cront_alarm']) ?$this->config['log-files']['cront_alarm']:null); define ("LOGFILE_CRONT_AUTOREFILL", isset($this->config['log-files']['cront_autorefill']) ?$this->config['log-files']['cront_autorefill']:null); define ("LOGFILE_CRONT_BATCH_PROCESS", isset($this->config['log-files']['cront_batch_process']) ?$this->config['log-files']['cront_batch_process']:null); define ("LOGFILE_CRONT_BILL_DIDUSE", isset($this->config['log-files']['cront_bill_diduse']) ?$this->config['log-files']['cront_bill_diduse']:null); define ("LOGFILE_CRONT_SUBSCRIPTIONFEE",isset($this->config['log-files']['cront_subscriptionfee']) ?$this->config['log-files']['cront_subscriptionfee']:null); define ("LOGFILE_CRONT_CURRENCY_UPDATE",isset($this->config['log-files']['cront_currency_update']) ?$this->config['log-files']['cront_currency_update']:null); define ("LOGFILE_CRONT_INVOICE", isset($this->config['log-files']['cront_invoice']) ?$this->config['log-files']['cront_invoice']:null); define ("LOGFILE_CRONT_CHECKACCOUNT", isset($this->config['log-files']['cront_check_account']) ?$this->config['log-files']['cront_check_account']:null); define ("LOGFILE_API_ECOMMERCE", isset($this->config['log-files']['api_ecommerce']) ?$this->config['log-files']['api_ecommerce']:null); define ("LOGFILE_API_CALLBACK", isset($this->config['log-files']['api_callback']) ?$this->config['log-files']['api_callback']:null); define ("LOGFILE_PAYPAL", isset($this->config['log-files']['paypal']) ?$this->config['log-files']['paypal']:null); define ("LOGFILE_EPAYMENT", isset($this->config['log-files']['epayment']) ?$this->config['log-files']['epayment']:null); // conf for the AGI if(!isset($this->config["agi-conf$idconfig"]['play_audio'])) $this->config["agi-conf$idconfig"]['play_audio'] = 1; define ("PLAY_AUDIO", $this->config["agi-conf$idconfig"]['play_audio']); if(!isset($this->config["agi-conf$idconfig"]['debug'])) $this->config["agi-conf$idconfig"]['debug'] = false; if(!isset($this->config["agi-conf$idconfig"]['logger_enable'])) $this->config["agi-conf$idconfig"]['logger_enable'] = 1; if(!isset($this->config["agi-conf$idconfig"]['log_file'])) $this->config["agi-conf$idconfig"]['log_file'] = '/tmp/a2billing.log'; if(!isset($this->config["agi-conf$idconfig"]['answer_call'])) $this->config["agi-conf$idconfig"]['answer_call'] = 1; if(!isset($this->config["agi-conf$idconfig"]['auto_setcallerid'])) $this->config["agi-conf$idconfig"]['auto_setcallerid'] = 1; if(!isset($this->config["agi-conf$idconfig"]['say_goodbye'])) $this->config["agi-conf$idconfig"]['say_goodbye'] = 0; if(!isset($this->config["agi-conf$idconfig"]['play_menulanguage'])) $this->config["agi-conf$idconfig"]['play_menulanguage'] = 0; if(!isset($this->config["agi-conf$idconfig"]['force_language'])) $this->config["agi-conf$idconfig"]['force_language'] = 'EN'; if(!isset($this->config["agi-conf$idconfig"]['min_credit_2call'])) $this->config["agi-conf$idconfig"]['min_credit_2call'] = 0; if(!isset($this->config["agi-conf$idconfig"]['min_duration_2bill'])) $this->config["agi-conf$idconfig"]['min_duration_2bill'] = 0; if(!isset($this->config["agi-conf$idconfig"]['use_dnid'])) $this->config["agi-conf$idconfig"]['use_dnid'] = 0; // Explode the no_auth_dnid string if(isset($this->config["agi-conf$idconfig"]['no_auth_dnid'])) $this->config["agi-conf$idconfig"]['no_auth_dnid'] = explode(",",$this->config["agi-conf$idconfig"]['no_auth_dnid']); // Explode the extracharge_did and extracharge_fee strings if(isset($this->config["agi-conf$idconfig"]['extracharge_did'])) $this->config["agi-conf$idconfig"]['extracharge_did'] = explode(",",$this->config["agi-conf$idconfig"]['extracharge_did']); if(isset($this->config["agi-conf$idconfig"]['extracharge_fee'])) $this->config["agi-conf$idconfig"]['extracharge_fee'] = explode(",",$this->config["agi-conf$idconfig"]['extracharge_fee']); if(!isset($this->config["agi-conf$idconfig"]['number_try'])) $this->config["agi-conf$idconfig"]['number_try'] = 3; if(!isset($this->config["agi-conf$idconfig"]['say_balance_after_auth'])) $this->config["agi-conf$idconfig"]['say_balance_after_auth'] = 1; if(!isset($this->config["agi-conf$idconfig"]['say_balance_after_call'])) $this->config["agi-conf$idconfig"]['say_balance_after_call'] = 0; if(!isset($this->config["agi-conf$idconfig"]['say_rateinitial'])) $this->config["agi-conf$idconfig"]['say_rateinitial'] = 0; if(!isset($this->config["agi-conf$idconfig"]['say_timetocall'])) $this->config["agi-conf$idconfig"]['say_timetocall'] = 1; if(!isset($this->config["agi-conf$idconfig"]['cid_enable'])) $this->config["agi-conf$idconfig"]['cid_enable'] = 0; if(!isset($this->config["agi-conf$idconfig"]['cid_sanitize'])) $this->config["agi-conf$idconfig"]['cid_sanitize'] = 0; if(!isset($this->config["agi-conf$idconfig"]['cid_askpincode_ifnot_callerid'])) $this->config["agi-conf$idconfig"]['cid_askpincode_ifnot_callerid'] = 1; if(!isset($this->config["agi-conf$idconfig"]['cid_auto_assign_card_to_cid'])) $this->config["agi-conf$idconfig"]['cid_auto_assign_card_to_cid'] = 0; if(!isset($this->config["agi-conf$idconfig"]['notenoughcredit_cardnumber'])) $this->config["agi-conf$idconfig"]['notenoughcredit_cardnumber'] = 0; if(!isset($this->config["agi-conf$idconfig"]['notenoughcredit_assign_newcardnumber_cid'])) $this->config["agi-conf$idconfig"]['notenoughcredit_assign_newcardnumber_cid'] = 0; if(!isset($this->config["agi-conf$idconfig"]['maxtime_tocall_negatif_free_route'])) $this->config["agi-conf$idconfig"]['maxtime_tocall_negatif_free_route'] = 1800; if(!isset($this->config["agi-conf$idconfig"]['callerid_authentication_over_cardnumber'])) $this->config["agi-conf$idconfig"]['callerid_authentication_over_cardnumber'] = 0; if(!isset($this->config["agi-conf$idconfig"]['cid_auto_create_card_len'])) $this->config["agi-conf$idconfig"]['cid_auto_create_card_len'] = 10; if(!isset($this->config["agi-conf$idconfig"]['sip_iax_friends'])) $this->config["agi-conf$idconfig"]['sip_iax_friends'] = 0; if(!isset($this->config["agi-conf$idconfig"]['sip_iax_pstn_direct_call'])) $this->config["agi-conf$idconfig"]['sip_iax_pstn_direct_call'] = 0; if(!isset($this->config["agi-conf$idconfig"]['dialcommand_param'])) $this->config["agi-conf$idconfig"]['dialcommand_param'] = '|30|HL(%timeout%:61000:30000)'; if(!isset($this->config["agi-conf$idconfig"]['dialcommand_param_sipiax_friend'])) $this->config["agi-conf$idconfig"]['dialcommand_param_sipiax_friend'] = '|30|HL(3600000:61000:30000)'; if(!isset($this->config["agi-conf$idconfig"]['switchdialcommand'])) $this->config["agi-conf$idconfig"]['switchdialcommand'] = 0; if(!isset($this->config["agi-conf$idconfig"]['failover_recursive_limit'])) $this->config["agi-conf$idconfig"]['failover_recursive_limit'] = 1; if(!isset($this->config["agi-conf$idconfig"]['record_call'])) $this->config["agi-conf$idconfig"]['record_call'] = 0; if(!isset($this->config["agi-conf$idconfig"]['monitor_formatfile'])) $this->config["agi-conf$idconfig"]['monitor_formatfile'] = 'gsm'; if(!isset($this->config["agi-conf$idconfig"]['currency_association'])) $this->config["agi-conf$idconfig"]['currency_association'] = 'all:credit'; $this->config["agi-conf$idconfig"]['currency_association'] = explode(",",$this->config["agi-conf$idconfig"]['currency_association']); foreach($this->config["agi-conf$idconfig"]['currency_association'] as $cur_val){ $cur_val = explode(":",$cur_val); $this->config["agi-conf$idconfig"]['currency_association_internal'][$cur_val[0]]=$cur_val[1]; } if(!isset($this->config["agi-conf$idconfig"]['file_conf_enter_destination'])) $this->config["agi-conf$idconfig"]['file_conf_enter_destination'] = 'prepaid-enter-number-u-calling-1-or-011'; if(!isset($this->config["agi-conf$idconfig"]['file_conf_enter_menulang'])) $this->config["agi-conf$idconfig"]['file_conf_enter_menulang'] = 'prepaid-menulang'; if(!isset($this->config["agi-conf$idconfig"]['send_reminder'])) $this->config["agi-conf$idconfig"]['send_reminder'] = 0; if(isset($this->config["agi-conf$idconfig"]['debugshell']) && $this->config["agi-conf$idconfig"]['debugshell'] == 1 && isset($agi)) $agi->nlinetoread = 0; if(!isset($this->config["agi-conf$idconfig"]['ivr_voucher'])) $this->config["agi-conf$idconfig"]['ivr_voucher'] = 0; if(!isset($this->config["agi-conf$idconfig"]['ivr_voucher_prefixe'])) $this->config["agi-conf$idconfig"]['ivr_voucher_prefixe'] = 8; if(!isset($this->config["agi-conf$idconfig"]['jump_voucher_if_min_credit'])) $this->config["agi-conf$idconfig"]['jump_voucher_if_min_credit'] = 0; $this->agiconfig = $this->config["agi-conf$idconfig"]; if (!$webui) $this->conlog('A2Billing AGI internal configuration:'); if (!$webui) $this->conlog(print_r($this->agiconfig, true)); } /** * Log to console if debug mode. * * @example examples/ping.php Ping an IP address * * @param string $str * @param integer $vbl verbose level */ function conlog($str, $vbl=1) { static $busy = false; global $agi; if($this->agiconfig['debug'] != false) { if(!$busy) // no conlogs inside conlog!!! { $busy = true; $agi->verbose($str, $vbl); $busy = false; } } } /* * Function to create a menu to select the language */ function play_menulanguage ($agi){ // MENU LANGUAGE if ($this->agiconfig['play_menulanguage']==1){ $prompt_menulang = $this->agiconfig['file_conf_enter_menulang']; $res_dtmf = $agi->get_data($prompt_menulang, 1500, 1); $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "RES Menu Language DTMF : ".$res_dtmf ["result"]); $this -> languageselected = $res_dtmf ["result"]; if ($this->languageselected=="2") $language = 'es'; elseif ($this->languageselected=="3") $language = 'fr'; else $language = 'en'; if($this->agiconfig['asterisk_version'] == "1_1") { $agi -> set_variable('LANGUAGE()', $language); } else { $agi->ChangeLanguage($language); } $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[SET LANGUAGE() $language]"); }elseif (strlen($this->agiconfig['force_language'])==2){ $this -> debug( VERBOSE | WRITELOG, $agi, __FILE__, __LINE__, "FORCE LANGUAGE : ".$this->agiconfig['force_language']); $this->languageselected = 1; $language = strtolower($this->agiconfig['force_language']); if($this->agiconfig['asterisk_version'] == "1_1") { $agi -> set_variable('LANGUAGE()', $language); } else { $agi->ChangeLanguage($language); } $this -> debug( WRITELOG, $agi, __FILE__, __LINE__, "[SET LANGUAGE() $language]"); } } /* * intialize evironement variables from the agi values */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?