📄 class.formhandler.inc.php
字号:
break; case "edit": $this -> perform_edit($form_action); break; case "delete": $this -> perform_delete($form_action); break; } $processed = $this->getProcessed(); //$processed['firstname'] if ( $form_action == "list" || $form_action == "edit" || $form_action == "ask-delete" || $form_action == "ask-edit" || $form_action == "add-content" || $form_action == "del-content" || $form_action == "ask-del-confirm"){ include_once (FSROOT."lib/Class.Table.php"); $this->FG_ORDER = $processed['order']; $this->FG_SENS = $processed['sens']; $this -> CV_CURRENT_PAGE = $processed['current_page']; if (isset($processed['mydisplaylimit']) && (is_numeric($processed['mydisplaylimit']) || ($processed['mydisplaylimit']=='ALL'))){ if ($processed['mydisplaylimit']=='ALL'){ $this -> FG_LIMITE_DISPLAY = 5000; }else{ $this -> FG_LIMITE_DISPLAY = $processed['mydisplaylimit']; } } if ( $this->FG_ORDER == "" || $this->FG_SENS == "" ){ $this->FG_ORDER = $this -> FG_TABLE_DEFAULT_ORDER; $this->FG_SENS = $this -> FG_TABLE_DEFAULT_SENS; } if ( $form_action == "list" ){ $instance_table = new Table($this -> FG_TABLE_NAME, $this -> FG_COL_QUERY); $this->prepare_list_subselection($form_action); // Code here to call the Delete Selected items Fucntion if (isset($processed['deleteselected'])) { $this -> Delete_Selected(); } if ($this->FG_DEBUG >= 2) { echo "FG_CLAUSE:$this->FG_CLAUSE"; echo "FG_ORDER = ".$this->FG_ORDER."<br>"; echo "FG_SENS = ".$this->FG_SENS."<br>"; echo "FG_LIMITE_DISPLAY = ".$this -> FG_LIMITE_DISPLAY."<br>"; echo "CV_CURRENT_PAGE = ".$this -> CV_CURRENT_PAGE."<br>"; } $list = $instance_table -> Get_list ($this -> DBHandle, $this -> FG_TABLE_CLAUSE, $this->FG_ORDER, $this->FG_SENS, null, null, $this -> FG_LIMITE_DISPLAY, $this -> CV_CURRENT_PAGE * $this -> FG_LIMITE_DISPLAY, $this -> SQL_GROUP); if ($this->FG_DEBUG == 3) echo "<br>Clause : ".$this -> FG_TABLE_CLAUSE; $this -> FG_NB_RECORD = $instance_table -> Table_count ($this -> DBHandle, $this -> FG_TABLE_CLAUSE); if ($this->FG_DEBUG >= 1) var_dump ($list); if ($this -> FG_NB_RECORD <=$this -> FG_LIMITE_DISPLAY){ $this -> FG_NB_RECORD_MAX = 1; }else{ $this -> FG_NB_RECORD_MAX = ceil($this -> FG_NB_RECORD / $this -> FG_LIMITE_DISPLAY); } if ($this->FG_DEBUG == 3) echo "<br>Nb_record : ".$this -> FG_NB_RECORD ; if ($this->FG_DEBUG == 3) echo "<br>Nb_record_max : ".$this -> FG_NB_RECORD_MAX ; }else{ $instance_table = new Table($this->FG_TABLE_NAME, $this->FG_QUERY_EDITION); $list = $instance_table -> Get_list ($this->DBHandle, $this->FG_EDITION_CLAUSE, null, null, null, null, 1, 0); } if ($this->FG_DEBUG >= 2) { echo "<br>"; print_r ($list);} } return $list; } /** * Function to prepare the clause from the session filter * @public */ function prepare_list_subselection($form_action){ $processed = $this->getProcessed(); //$processed['firstname'] if ( $form_action == "list" && $this->FG_FILTER_SEARCH_FORM){ if (isset($processed['cancelsearch']) && ($processed['cancelsearch'] == true)){ $_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME] = ''; } // RETRIEVE THE CONTENT OF THE SEARCH SESSION AND if (strlen($_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME])>5 && ($processed['posted_search'] != 1 )){ $element_arr = split("\|", $_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME]); foreach ($element_arr as $val_element_arr){ $pos = strpos($val_element_arr, '='); if ($pos !== false) { $entity_name = substr($val_element_arr,0,$pos); $entity_value = substr($val_element_arr,$pos+1); //echo "entity_name=$entity_name :: entity_value=$entity_value <br>"; $this->_processed[$entity_name]=$entity_value; //$_POST[$entity_name]=$entity_value; } } } if (($processed['posted_search'] != 1 && isset($_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME]) && strlen($_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME])>10 )){ $arr_session_var = split("\|", $_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME]); foreach ($arr_session_var as $arr_val){ list($namevar,$valuevar) = split("=", $arr_val); $this->_processed[$namevar]=$valuevar; $processed[$namevar]=$valuevar; $_POST[$namevar]=$valuevar; } $processed['posted_search'] = 1; } // Search Form On if (($processed['posted_search'] == 1 )){ $SQLcmd = ''; $search_parameters = "Period=$processed[Period]|frommonth=$processed[frommonth]|fromstatsmonth=$processed[fromstatsmonth]|tomonth=$processed[tomonth]"; $search_parameters .= "|tostatsmonth=$processed[tostatsmonth]|fromday=$processed[fromday]|fromstatsday_sday=$processed[fromstatsday_sday]"; $search_parameters .= "|fromstatsmonth_sday=$processed[fromstatsmonth_sday]|today=$processed[today]|tostatsday_sday=$processed[tostatsday_sday]"; $search_parameters .= "|tostatsmonth_sday=$processed[tostatsmonth_sday]"; foreach ($this->FG_FILTER_SEARCH_FORM_1C as $r){ $search_parameters .= "|$r[1]=".$processed[$r[1]]."|$r[2]=".$processed[$r[2]]; $SQLcmd = $this->do_field($SQLcmd, $r[1]); } foreach ($this->FG_FILTER_SEARCH_FORM_2C as $r){ $search_parameters .= "|$r[1]=".$processed[$r[1]]."|$r[2]=".$processed[$r[2]]; $search_parameters .= "|$r[3]=".$processed[$r[3]]."|$r[4]=".$processed[$r[4]]; $SQLcmd = $this->do_field_duration($SQLcmd,$r[1],$r[5]); $SQLcmd = $this->do_field_duration($SQLcmd,$r[3],$r[5]); } foreach ($this->FG_FILTER_SEARCH_FORM_SELECT as $r){ $search_parameters .= "|$r[2]=".$processed[$r[2]]; $SQLcmd = $this->do_field($SQLcmd, $r[2], 1); } $_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME] = $search_parameters; //echo "DEBUG search on<br>"; //print_r($_SESSION[$this->FG_FILTER_SEARCH_SESSION_NAME]); //echo "<br>"; $date_clause=''; if (DB_TYPE == "postgres") $UNIX_TIMESTAMP = ""; else $UNIX_TIMESTAMP = "UNIX_TIMESTAMP"; if ($processed[Period]=="Month"){ if ($processed[frommonth] && isset($processed[fromstatsmonth])) $date_clause.=" AND $UNIX_TIMESTAMP(".$this->FG_FILTER_SEARCH_2_TIME_FIELD.") >= $UNIX_TIMESTAMP('$processed[fromstatsmonth]-01')"; if ($processed[tomonth] && isset($processed[tostatsmonth])) $date_clause.=" AND $UNIX_TIMESTAMP(".$this->FG_FILTER_SEARCH_2_TIME_FIELD.") <= $UNIX_TIMESTAMP('$processed[tostatsmonth]-31 23:59:59')"; }else{ if ($processed[fromday] && isset($processed[fromstatsday_sday]) && isset($processed[fromstatsmonth_sday])) $date_clause.=" AND $UNIX_TIMESTAMP(".$this->FG_FILTER_SEARCH_2_TIME_FIELD.") >= $UNIX_TIMESTAMP('$processed[fromstatsmonth_sday]-$processed[fromstatsday_sday]')"; if ($processed[today] && isset($processed[tostatsday_sday]) && isset($processed[tostatsmonth_sday])) $date_clause.=" AND $UNIX_TIMESTAMP(".$this->FG_FILTER_SEARCH_2_TIME_FIELD.") <= $UNIX_TIMESTAMP('$processed[tostatsmonth_sday]-".sprintf("%02d",intval($processed[tostatsday_sday])/*+1*/)." 23:59:59')"; } if ($processed[Period]=="month_older_rad"){ $from_month = $processed[month_earlier]; if(DB_TYPE == "postgres"){ $date_clause .= " AND CURRENT_TIMESTAMP - interval '$from_month months' > ".$this->FG_FILTER_SEARCH_3_TIME_FIELD.""; }else{ $date_clause .= " AND DATE_SUB(NOW(),INTERVAL $from_month MONTH) > ".$this->FG_FILTER_SEARCH_3_TIME_FIELD.""; } } if (strpos($SQLcmd, 'WHERE') > 0) { if (strlen($this->FG_TABLE_CLAUSE)>0) $this->FG_TABLE_CLAUSE .=" AND "; $this -> FG_TABLE_CLAUSE .= substr($SQLcmd,6).$date_clause; }elseif (strpos($date_clause, 'AND') > 0){ if (strlen($this->FG_TABLE_CLAUSE)>0) $this->FG_TABLE_CLAUSE .=" AND "; $this -> FG_TABLE_CLAUSE .= substr($date_clause,5); } //echo "SQL Search form [".$SQLcmd."] [".$date_clause."]<br>"; } } } /**************************************** Function to delete all pre selected records, This Function Gets the selected records and delete them from DB ******************************************/ function Delete_Selected() { //if ( $form_action == "list" && $this->FG_FILTER_SEARCH_FORM) { $instance_table = new Table($this -> FG_TABLE_NAME, $this -> FG_COL_QUERY); $result = $instance_table -> Delete_Selected ($this -> DBHandle, $this -> FG_TABLE_CLAUSE, $this->FG_ORDER, $this->FG_SENS, null, null, $this -> FG_LIMITE_DISPLAY, $this -> CV_CURRENT_PAGE * $this -> FG_LIMITE_DISPLAY, $this -> SQL_GROUP); } } /** * Function to perform the add action after inserting all data in required fields * @public */ function perform_add (&$form_action){ include_once (FSROOT."lib/Class.Table.php"); $processed = $this->getProcessed(); //$processed['firstname'] $this->VALID_SQL_REG_EXP = true; for($i=0; $i < $this->FG_NB_TABLE_ADITION; $i++){ $pos = strpos($this->FG_TABLE_ADITION[$i][14], ":"); // SQL CUSTOM QUERY $pos_mul = strpos($this->FG_TABLE_ADITION[$i][4], "multiple"); if (!$pos){ $fields_name = $this->FG_TABLE_ADITION[$i][1]; $regexp = $this->FG_TABLE_ADITION[$i][5]; // FIND THE MULTIPLE SELECT 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_add_fields .= ", "; $param_add_fields .= $sp . "$fields_name". $sp; if ($i>0) $param_add_value .= ", "; $param_add_value .= "'".addslashes(trim($total_mult_select))."'"; }else{ // NO MULTIPLE SELECT // CHECK ACCORDING TO THE REGULAR EXPRESSION DEFINED 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>-> $fields_name => ".$this->FG_regular[$regexp][0]." , ".$processed[$fields_name]; if (!$this-> FG_fit_expression[$i]){ $this->VALID_SQL_REG_EXP = false; $form_action="ask-add"; } }elseif ($regexp == "check_select"){ // FOR SELECT FIELD WE HAVE THE check_select THAT WILL ENSURE WE DEFINE A VALUE FOR THE SELECTABLE FIELD if ($processed[$fields_name]==-1){ $this-> FG_fit_expression[$i] = false; $this->VALID_SQL_REG_EXP = false; $form_action="ask-add"; } } // CHECK IF THIS IS A SPLITABLE FIELD :D like 12-14 or 15;16;17 if ($fields_name == $this -> FG_SPLITABLE_FIELD){ $splitable_value = $processed[$fields_name]; $arr_splitable_value = explode(",", $splitable_value); foreach ($arr_splitable_value as $arr_value){ $arr_value = trim ($arr_value); $arr_value_explode = explode("-", $arr_value,2); if (count($arr_value_explode)>1){ if (is_numeric($arr_value_explode[0]) && is_numeric($arr_value_explode[1]) && $arr_value_explode[0] < $arr_value_explode[1] ){ for ($kk=$arr_value_explode[0];$kk<=$arr_value_explode[1];$kk++){ $arr_value_to_import[] = $kk; } }elseif (is_numeric($arr_value_explode[0])){ $arr_value_to_import[] = $arr_value_explode[0]; }elseif (is_numeric($arr_value_explode[1])){ $arr_value_to_import[] = $arr_value_explode[1]; } }else{ $arr_value_to_import[] = $arr_value_explode[0]; } } if (!is_null($processed[$fields_name]) && ($processed[$fields_name]!="") && ($this->FG_TABLE_ADITION[$i][4]!="disabled") ){ if ($i>0) $param_add_fields .= ", "; $param_add_fields .= str_replace('myfrom_', '', $fields_name); if ($i>0) $param_add_value .= ", "; $param_add_value .= "'%TAGPREFIX%'"; } }else{ if ($this->FG_DEBUG == 1) echo "<br>$fields_name : ".$processed[$fields_name]; if (!is_null($processed[$fields_name]) && ($processed[$fields_name]!="") && ($this->FG_TABLE_ADITION[$i][4]!="disabled") ){ if (strtoupper ($this->FG_TABLE_ADITION[$i][3]) != strtoupper("CAPTCHAIMAGE")) { if ($i>0) $param_add_fields .= ", "; $param_add_fields .= str_replace('myfrom_', '', $fields_name); if ($i>0) $param_add_value .= ", "; $param_add_value .= "'".addslashes(trim($processed[$fields_name]))."'"; } } } } } } if (!is_null($this->FG_QUERY_ADITION_HIDDEN_FIELDS) && $this->FG_QUERY_ADITION_HIDDEN_FIELDS!=""){ if ($i>0) $param_add_fields .= ", "; $param_add_fields .= $this->FG_QUERY_ADITION_HIDDEN_FIELDS; if ($i>0) $param_add_value .= ", "; $param_add_value .= $this->FG_QUERY_ADITION_HIDDEN_VALUE; } if ($this->FG_DEBUG == 1) echo "<br><hr> $param_add_fields"; if ($this->FG_DEBUG == 1) echo "<br><hr> $param_add_value"; $instance_table = new Table($this->FG_TABLE_NAME, $param_add_fields); // CHECK IF WE HAD FOUND A SPLITABLE FIELD THEN WE MIGHT HAVE %TAGPREFIX% if (strpos($param_add_value, '%TAGPREFIX%')){ foreach ($arr_value_to_import as $current_value){ $param_add_value_replaced = str_replace("%TAGPREFIX%", $current_value, $param_add_value); if ($this->VALID_SQL_REG_EXP) $this -> RESULT_QUERY = $instance_table -> Add_table ($this->DBHandle, $param_add_value_replaced, null, null, $this->FG_TABLE_ID); } }else{ if ($this->VALID_SQL_REG_EXP) $this -> RESULT_QUERY = $instance_table -> Add_table ($this->DBHandle, $param_add_value, null, null, $this->FG_TABLE_ID); } if($this -> FG_ENABLE_LOG == 1) { $this -> logger -> insertLog_Add($_SESSION["admin_id"], 2, "NEW ".strtoupper($this->FG_INSTANCE_NAME)." CREATED" , "User added a new record in database", $this->FG_TABLE_NAME, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_URI'], $param_add_fields, $param_add_value); } if (!$this -> RESULT_QUERY ){ $findme = 'duplicate'; $pos_find = strpos($instance_sub_table -> errstr, $findme); if ($pos_find !== false) { $alarm_db_error_duplication = true; exit; } }else{ // CALL DEFINED FUNCTION AFTER THE ACTION ADDITION if (strlen($this->FG_ADDITIONAL_FUNCTION_AFTER_ADD)>0) $res_funct = call_user_func(array(&$this, $this->FG_ADDITIONAL_FUNCTION_AFTER_ADD)); if ($this->FG_ADITION_GO_EDITION == "yes"){ $form_action="ask-edit"; $this->FG_ADITION_GO_EDITION = "yes-done"; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -