📄 class.formhandler.inc.php
字号:
$id = $this -> RESULT_QUERY; } if ( ($this->VALID_SQL_REG_EXP) && (isset($this->FG_GO_LINK_AFTER_ACTION_ADD))){ if ($this->FG_DEBUG == 1) echo "<br> GOTO ; ".$this->FG_GO_LINK_AFTER_ACTION_ADD.$id; //echo "<br> GOTO ; ".$this->FG_GO_LINK_AFTER_ACTION_ADD.$id; Header ("Location: ".$this->FG_GO_LINK_AFTER_ACTION_ADD.$id); } } /** * Function to edit the fields * @public */ /** * Function to add/modify cc_did_use and cc_did_destination if records existe * */ function is_did_in_use(){ $processed = $this->getProcessed(); $did_id=$processed['id']; $instance_did_use_table = new Table(); $QUERY_DID="select id_cc_card from cc_did_use where id_did ='".$did_id."' and releasedate IS NULL and activated = 1"; $row= $instance_did_use_table -> SQLexec ($this->DBHandle,$QUERY_DID, 1); if ((isset($row[0][0])) && (strlen($row[0][0]) > 0)) $this -> FG_INTRO_TEXT_ASK_DELETION = gettext ("This did is in use by customer id:".$row[0][0].", If you really want remove this ". $this -> FG_INSTANCE_NAME .", click on the delete button."); } function did_use_delete(){ $processed = $this->getProcessed(); $did_id=$processed['id']; $FG_TABLE_DID_USE_NAME = "cc_did_use"; $FG_TABLE_DID_USE_CLAUSE= "id_did = '".$did_id."' and releasedate IS NULL"; $FG_TABLE_DID_USE_PARAM= "releasedate = now()"; $instance_did_use_table = new Table($FG_TABLE_DID_USE_NAME); $result_query= $instance_did_use_table -> Update_table ($this->DBHandle, $FG_TABLE_DID_USE_PARAM, $FG_TABLE_DID_USE_CLAUSE, null); $FG_TABLE_DID_USE_NAME = "cc_did_destination"; $instance_did_use_table = new Table($FG_TABLE_DID_USE_NAME); $FG_TABLE_DID_USE_CLAUSE= "id_cc_did = '".$did_id."'"; $result_query= $instance_did_use_table -> Delete_table ($this->DBHandle, $FG_TABLE_DID_USE_CLAUSE, null); } function add_did_use(){ $processed = $this->getProcessed(); $did=$processed['did']; $FG_TABLE_DID_USE_NAME = "cc_did_use"; $FG_QUERY_ADITION_DID_USE_FIELDS = 'id_did'; $instance_did_use_table = new Table($FG_TABLE_DID_USE_NAME, $FG_QUERY_ADITION_DID_USE_FIELDS); $id=$this -> RESULT_QUERY; $result_query= $instance_did_use_table -> Add_table ($this->DBHandle, $id, null, null, null); } /* ****End */ function create_sipiax_friends_reload() { $this -> create_sipiax_friends(); // RELOAD SIP & IAX CONF include_once ("../lib/phpagi/phpagi-asmanager.php"); $as = new AGI_AsteriskManager(); // && CONNECTING connect($server=NULL, $username=NULL, $secret=NULL) $res = $as->connect(MANAGER_HOST,MANAGER_USERNAME,MANAGER_SECRET); if ($res){ $res = $as->Command('sip reload'); $res = $as->Command('iax2 reload'); // && DISCONNECTING $as->disconnect(); } } function create_status_log() { $processed = $this->getProcessed(); $status = $processed['status']; if($this -> RESULT_QUERY != '') $id = $this -> RESULT_QUERY; // DEFINED BEFORE FG_ADDITIONAL_FUNCTION_AFTER_ADD else $id = $processed['id']; // DEFINED BEFORE FG_ADDITIONAL_FUNCTION_AFTER_ADD $value = "'$status','$id'"; $func_fields = "status,id_cc_card"; $func_table = 'cc_status_log'; $id_name = ""; $instance_table = new Table(); $inserted_id = $instance_table -> Add_table ($this->DBHandle, $value, $func_fields, $func_table, $id_name); } /** * Function to edit the fields * @public */ function create_sipiax_friends() { global $A2B; $processed = $this->getProcessed(); $id = $this -> RESULT_QUERY; // DEFINED BEFORE FG_ADDITIONAL_FUNCTION_AFTER_ADD $sip_buddy = stripslashes($processed['sip_buddy']); $iax_buddy = stripslashes($processed['iax_buddy']); // $this -> FG_QUERY_EXTRA_HIDDED - username, useralias, uipass, loginkey if (strlen($this -> FG_QUERY_EXTRA_HIDDED[0])>0){ $username = $this -> FG_QUERY_EXTRA_HIDDED[0]; $uipass = $this -> FG_QUERY_EXTRA_HIDDED[2]; $useralias = $this -> FG_QUERY_EXTRA_HIDDED[1]; }else{ $username = $processed['username']; $uipass = $processed['uipass']; $useralias = $processed['useralias']; } $FG_TABLE_SIP_NAME="cc_sip_buddies"; $FG_TABLE_IAX_NAME="cc_iax_buddies"; $FG_QUERY_ADITION_SIP_IAX_FIELDS = "name, accountcode, regexten, amaflags, callerid, context, dtmfmode, host, type, username, allow, secret, id_cc_card, nat, qualify"; $FG_QUERY_ADITION_SIP_IAX='name, type, username, accountcode, regexten, callerid, amaflags, secret, md5secret, nat, dtmfmode, qualify, canreinvite,disallow, allow, host, callgroup, context, defaultip, fromuser, fromdomain, insecure, language, mailbox, permit, deny, mask, pickupgroup, port,restrictcid, rtptimeout, rtpholdtimeout, musiconhold, regseconds, ipaddr, cancallforward'; if (($sip_buddy == 1) || ($iax_buddy == 1)){ $_SESSION["is_sip_iax_change"]=1; $_SESSION["is_sip_changed"]=1; $_SESSION["is_iax_changed"]=1; $list_names = explode(",",$FG_QUERY_ADITION_SIP_IAX); $type = FRIEND_TYPE; $allow = FRIEND_ALLOW; $context = FRIEND_CONTEXT; $nat = FRIEND_NAT; $amaflags = FRIEND_AMAFLAGS; $qualify = FRIEND_QUALIFY; $host = FRIEND_HOST; $dtmfmode = FRIEND_DTMFMODE; $this->FG_QUERY_ADITION_SIP_IAX_VALUE = "'$username', '$username', '$username', '$amaflags', '$useralias', '$context', '$dtmfmode','$host', '$type', '$username', '$allow', '".$uipass."', '$id', '$nat', '$qualify'"; } // Save info in table and in sip file if ($sip_buddy == 1){ $instance_sip_table = new Table($FG_TABLE_SIP_NAME, $FG_QUERY_ADITION_SIP_IAX_FIELDS); $result_query1 = $instance_sip_table -> Add_table ($this->DBHandle, $this->FG_QUERY_ADITION_SIP_IAX_VALUE, null, null, null); $buddyfile = BUDDY_SIP_FILE; $instance_table_friend = new Table($FG_TABLE_SIP_NAME,'id, '.$FG_QUERY_ADITION_SIP_IAX); $list_friend = $instance_table_friend -> Get_list ($this->DBHandle, '', null, null, null, null); if (is_array($list_friend)){ $fd=fopen($buddyfile,"w"); if (!$fd){ $error_msg= "</br><center><b><font color=red>".gettext("Could not open buddy file")." '$buddyfile'</font></b></center>"; }else{ foreach ($list_friend as $data){ $line="\n\n[".$data[1]."]\n"; if (fwrite($fd, $line) === FALSE) { echo "Impossible to write to the file ($buddyfile)"; break; }else{ for ($i=1;$i<count($data)-1;$i++){ if (strlen($data[$i+1])>0){ if (trim($list_names[$i]) == 'allow'){ $codecs = explode(",",$data[$i+1]); $line = ""; foreach ($codecs as $value) $line .= trim($list_names[$i]).'='.$value."\n"; }else $line = (trim($list_names[$i]).'='.$data[$i+1]."\n"); if (fwrite($fd, $line) === FALSE){ echo gettext("Impossible to write to the file")." ($buddyfile)"; break; } } } } } fclose($fd); } } // endif is_array $list_friend } // Save info in table and in iax file if ($iax_buddy == 1){ $instance_iax_table = new Table($FG_TABLE_IAX_NAME, $FG_QUERY_ADITION_SIP_IAX_FIELDS); $result_query1 = $instance_iax_table -> Add_table ($this->DBHandle, $this->FG_QUERY_ADITION_SIP_IAX_VALUE, null, null, null); $buddyfile = BUDDY_IAX_FILE; $instance_table_friend = new Table($FG_TABLE_IAX_NAME,'id, '.$FG_QUERY_ADITION_SIP_IAX); $list_friend = $instance_table_friend -> Get_list ($this->DBHandle, '', null, null, null, null); if (is_array($list_friend)){ $fd=fopen($buddyfile,"w"); if (!$fd){ $error_msg= "</br><center><b><font color=red>".gettext("Could not open buddy file")." '$buddyfile'</font></b></center>"; }else{ foreach ($list_friend as $data){ $line="\n\n[".$data[1]."]\n"; if (fwrite($fd, $line) === FALSE) { echo gettext("Impossible to write to the file")." ($buddyfile)"; break; }else{ for ($i=1;$i<count($data)-1;$i++){ if (strlen($data[$i+1])>0){ if (trim($list_names[$i]) == 'allow'){ $codecs = explode(",",$data[$i+1]); $line = ""; foreach ($codecs as $value) $line .= trim($list_names[$i]).'='.$value."\n"; }else $line = (trim($list_names[$i]).'='.$data[$i+1]."\n"); if (fwrite($fd, $line) === FALSE){ echo gettext("Impossible to write to the file")." ($buddyfile)"; break; } } } } } fclose($fd); } }// end if (is_array($list_friend)) } } /** * Function to edit the fields * @public */ function perform_edit (&$form_action){ include_once (FSROOT."lib/Class.Table.php"); $processed = $this->getProcessed(); //$processed['firstname'] $this->VALID_SQL_REG_EXP = true; $instance_table = new Table($this->FG_TABLE_NAME, $this->FG_QUERY_EDITION); if ($processed['id']!="" || !is_null($processed['id'])){ $this->FG_EDITION_CLAUSE = str_replace("%id", $processed['id'], $this->FG_EDITION_CLAUSE); } for($i=0;$i<$this->FG_NB_TABLE_EDITION;$i++){ $pos = strpos($this->FG_TABLE_EDITION[$i][14], ":"); // SQL CUSTOM QUERY $pos_mul = strpos($this->FG_TABLE_EDITION[$i][4], "multiple"); if (!$pos){ $fields_name = $this->FG_TABLE_EDITION[$i][1]; $regexp = $this->FG_TABLE_EDITION[$i][5]; if ($pos_mul && is_array($processed[$fields_name])){ $total_mult_select=0; foreach ($processed[$fields_name] as $value){ $total_mult_select += $value; } if ($this->FG_DEBUG == 1) echo "<br>$fields_name : ".$total_mult_select; if ($i>0) $param_update .= ", "; $param_update .= $sp . "$fields_name".$sp ." = '".addslashes(trim($total_mult_select))."'"; }else{ if (is_numeric($regexp) && !(strtoupper(substr($this->FG_TABLE_ADITION[$i][13],0,2))=="NO" && $processed[$fields_name]=="") ){ $this-> FG_fit_expression[$i] = ereg( $this->FG_regular[$regexp][0] , $processed[$fields_name]); if ($this->FG_DEBUG == 1) echo "<br>-> ".$this->FG_regular[$regexp][0]." , ".$processed[$fields_name]; if (!$this-> FG_fit_expression[$i]){ $this->VALID_SQL_REG_EXP = false; $form_action="ask-edit"; } } if ($this->FG_DEBUG == 1) echo "<br>$fields_name : ".$processed[$fields_name]; if ($i>0 && $this->FG_TABLE_EDITION[$i][3]!= "SPAN") $param_update .= ", "; if (empty($processed[$fields_name]) && strtoupper(substr($this->FG_TABLE_ADITION[$i][13],3,4))=="NULL"){ $param_update .= $fields_name." = NULL "; }else{ if($this->FG_TABLE_EDITION[$i][3]!= "SPAN") { $param_update .= $fields_name." = '".addslashes(trim($processed[$fields_name]))."' "; } } } }else{ if (strtoupper ($this->FG_TABLE_EDITION[$i][3])==strtoupper ("CHECKBOX")){ $table_split = split(":",$this->FG_TABLE_EDITION[$i][1]); $checkbox_data = $table_split[0]; //doc_tariff $instance_sub_table = new Table($table_split[0], $table_split[1].", ".$table_split[5]); $SPLIT_FG_DELETE_CLAUSE = $table_split[5]."='".trim($processed['id'])."'"; $instance_sub_table -> Delete_table ($this -> DBHandle, $SPLIT_FG_DELETE_CLAUSE, $func_table = null); if (!is_array($processed[$checkbox_data])){ $snum=0; $this -> VALID_SQL_REG_EXP = false; $this-> FG_fit_expression[$i] = false; }else{ $snum = count($processed[$checkbox_data]); } $checkbox_data_tab = $processed[$checkbox_data]; for($j=0;$j<$snum;$j++){ $this -> RESULT_QUERY = $instance_sub_table -> Add_table ($this-> DBHandle, "'".addslashes(trim($checkbox_data_tab[$j]))."', '".addslashes(trim($processed['id']))."'", null, null); if (!$this -> RESULT_QUERY){ //echo "<br><b>OOOOOOOOOO".$instance_sub_table -> errstr."</b><br>"; $findme = 'duplicate'; $pos_find = strpos($instance_sub_table -> errstr, $findme); // Note our use of ===. Simply == would not work as expected // because the position of 'a' was the 0th (first) character. if ($pos_find === false) { echo $instance_sub_table -> errstr; }else{ //echo $FG_TEXT_ERROR_DUPLICATION; $alarm_db_error_duplication = true; } } } } } } if (!is_null($this->FG_QUERY_EDITION_HIDDEN_FIELDS) && $this->FG_QUERY_EDITION_HIDDEN_FIELDS!=""){ $table_split_field = split(",",$this->FG_QUERY_EDITION_HIDDEN_FIELDS); $table_split_value = split(",",$this->FG_QUERY_EDITION_HIDDEN_VALUE); for($k=0;$k<count($table_split_field);$k++){ $param_update .= ", "; $param_update .= "$table_split_field[$k] = '".addslashes(trim($table_split_value[$k]))."'"; } } if ($this->FG_DEBUG == 1) echo "<br><hr> PARAM_UPDATE: $param_update<br>".$this->FG_EDITION_CLAUSE; if ($this->VALID_SQL_REG_EXP) $this -> RESULT_QUERY = $instance_table -> Update_table ($this->DBHandle, $param_update, $this->FG_EDITION_CLAUSE, $func_table = null); if($this -> FG_ENABLE_LOG == 1) { $this -> logger -> insertLog_Update($_SESSION["admin_id"], 3, "A ".strtoupper($this->FG_INSTANCE_NAME)." UPDATED" , "A RECORD IS UPDATED, EDITION CALUSE USED IS ".$this->FG_EDITION_CLAUSE, $thi
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -