Server IP : 80.241.246.6 / Your IP : 216.73.216.188 Web Server : Apache/2.4.25 (Debian) System : Linux kharagauli 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64 User : www-data ( 33) PHP Version : 7.0.33-0+deb9u12 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/kharagauli_new/moduls/query/admin/ |
Upload File : |
<?php /* @author suxoza <suxoza@gmail.com> */ if(realpath(__FILE__) == realpath($_SERVER['SCRIPT_FILENAME']))die("__main__"); try{ $time = time(); if(in_array('more', $url)){ if(!$_->permission_('query','edit')) throw new Exception("Error Processing Request", 1); if(!isset($url[3])) throw new Exception("Error Processing Request", 1); $ID = (int)$url[3]; $question = []; $question_answers = []; $old = [0]; foreach ($_POST as $key => $value){ $vls = trim(strip_tags(addslashes($value))); if($_->startSwith($key,'question')) $question[$key] = $value; elseif($_->startSwith($key,'answer')){ $len = explode('_', $key); if(count($len) > 2) $old[$len[1]] = ['ind' => $len[2],'value' => $vls]; else $question_answers[$key] = $vls; } } //update question $start_date = $_->format_date($_POST['start_date']); $end_date = $_->format_date($_POST['end_date']); $arr = [ ['question_'.$_->_lang,'start_date','end_date','modify_date'], [$question['question_'.$_->_lang],$start_date,$end_date,$time], ["id",$ID] ]; $_->update("question",$arr,0); //update question //delete $_->select_(["delete from question_answers where id not in(".join(",",array_keys($old)).") and question_id = $ID","call"]); //delete //insert new values $insert_arr = [ ['question_id','answer_'.$_->_lang,'ind','date'], [] ]; if($question_answers){ foreach ($question_answers as $key => $value) { $pos = explode('_',$key)[1]; $insert_arr[1][] = [$ID,$value,$pos,$time]; } if(!$_->insert_array("question_answers",$insert_arr)) throw new Exception("Error Processing Request 1", 1); } //insert new values //update values foreach ($old as $key => $value) { if(!$value)continue; $pos = $value['ind']; $self_id = $key; $val = $value['value']; $update_arr = [ ['answer_'.$_->_lang,'ind','modify_date'], [$val,$pos,$time], ["id",$self_id,"question_id",$ID] ]; $_->update("question_answers",$update_arr); } //update values header("Location:".$_SERVER['REDIRECT_SCRIPT_URL'].'#changed'); }elseif(in_array('new', $url)){ if(!$_->permission_('query','add')) throw new Exception("Error Processing Request", 1); //$_->format_date($post_array[$var]) $question = []; $question_answers = []; foreach ($_POST as $key => $value){ $vls = trim(strip_tags(addslashes($value))); if($_->startSwith($key,'question')) $question[$key] = $value; elseif($_->startSwith($key,'answer')) $question_answers[$key] = $vls; } $start_date = $_->format_date($_POST['start_date']); $end_date = $_->format_date($_POST['end_date']); $arr = [ ['question_Georgia','question_English','start_date','end_date','date'], [$question['question_'.$_->_lang],$question['question_'.$_->_lang],$start_date,$end_date,$time] ]; $ID = $_->insert("question",$arr,'b_clier'); if(!$ID) throw new Exception("Error Processing Request", 1); $arr = [ ['question_id','answer_Georgia','answer_English','ind','date'], [] ]; foreach ($question_answers as $key => $value) { $pos = explode('_',$key)[1]; $arr[1][] = [$ID,$value,$value,$pos,$time]; } if($_->insert_array("question_answers",$arr)) header("Location:/გამოკითხვა"); else die("insert error!!!!!"); } }catch(Exception $exc) { die($exc->getMessage()); } ?>