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/admin/clases/ |
Upload File : |
<?php /** * Class Ajax * * @author suxoza <suxoza@gmail.com> */ class Ajax extends Base_class{ public $_url_masiv_2; private $URL; public function __construct(){ parent::__construct(); $this->URL = explode('/',urldecode($_SERVER['REQUEST_URI'])); $this->make_url(); //$this->language = } public function make_url(){ $_ = $this; $_->make_masiv(); $lang = 1; $_->_url = $_->URL[$lang]; $_->_url = (!$_->_url || strlen($_->_url) < 2)?'/':$_->_url; try{ if($_->_url && in_array($_->_url,$_->_url_masiv['Geo'])) $_->reflection($_->_url_masiv,__CLASS__); elseif($_->_url && in_array($_->_url,$_->_url_masiv_2['Geo'])) $_->reflection($_->_url_masiv_2,__CLASS__); ///widgets elseif($_->_url && in_array($_->_url,$_->_widgets[0])){ $reflection = new ReflectionClass(__CLASS__); echo $reflection->getMethod('widgets')->invoke($_,$_->_url); } ///end widgets else throw new Page_not_found; }catch(Page_not_found $ex){ die($this->render('404',["menu" => $_->menu_names(),'message' => $ex->getMessage()])); } } public function make_masiv(){ parent::make_masiv(); $this->_url_masiv_2 = [ //'Eng' => [''], 'Geo' => ['menu_index','change_menu_pos','page','statistic','კითხვები','სლაიდი_1','backup_'], ['menu_index','change_menu_pos','page','statistic','users_help','slide_','backup_db_files'] ]; } public function backup_db_files($a){ $_ = $this; $backup_db = isset($_POST['backup_db'])?true:false; $backup_files = isset($_POST['backup_files'])?true:false; $file_name = ''; $file_end = date("d-m-Y_H_i"); $document_root = str_replace('/admin', '', $_SERVER['DOCUMENT_ROOT']); $command = "cd ".$document_root."/img/backup \n"; exec($command." \n rm *"); if($backup_db && $backup_files){ $file_name = "files_with_db"; }elseif($backup_files && !$backup_db){ $file_name = "files_without_db"; }elseif($backup_db && !$backup_files){ $file_name = "db_without_files"; } if($backup_db) $command .= "mysqldump -u".$_->_user." -p".$_->_pass." '".$_->_db."' > db.sql \n"; $if_files = ($backup_files)?$document_root."/ ":""; $if_db = ($backup_db)?" db.sql ":""; $command .= "tar czfv ".$file_name."-".$file_end.".tar.gz ".$if_files." ".$if_db; exec($command); $download_link = "http://".$this->only_for_subdomain.str_replace('admin.', '', $_SERVER['HTTP_HOST'])."/img/backup/".$file_name."-".$file_end.".tar.gz"; echo json_encode(["file_name" => $download_link]); } public function slide_($a){ $_ = $this; $type = ($a == 'სლაიდი_1')?1:2; $id = (int)$_POST['slide_id']; if($_->update("body",[["slide_".$type],[0],["id",$id]])) echo 1; } public function change_menu_pos($a){ $_ = $this; $json = json_decode($_POST['change_menu_pos']); if($_->update("menu",[['menu_pos'],[$json->vals],["id",$json->id]]))echo 1; } public function menu_index($a){ $_ = $this; $json = json_decode($_->clear($_POST[$a])); $_->menu_position($json); } private function menu_position($json){ $_ = $this; $select = $_->select("*","menu","big")['body']; if($json->delete_menu_name_var && count((array)$json->delete_menu_name_var))$_->delete_menu_name_var($json->delete_menu_name_var); if($json->change_home_page_var && count((array)$json->change_home_page_var))$_->update_home_page($json->change_home_page_var); for($i = 0; $i < count($select); $i++){ $page = $select[$i]; if($json->menu_index_variable && count((array)$json->menu_index_variable)){ $json_ = array_filter($json->menu_index_variable); if($json_[$page['id']]->pos != $page['pos'] || $json_[$page['id']]->parent != $page['parent']){ $_->update("menu",[["parent","pos"],[$json_[$page['id']]->parent,$json_[$page['id']]->pos],["id",$page['id']]]); //echo 1; } } if($json->change_menu_checkbox_visible_var){ $json_ = $json->change_menu_checkbox_visible_var; if(isset($json_->{$page['id']}) && $json_->{$page['id']} != $page['visible']){ $_->update("menu",[["visible"],[$json_->{$page['id']}],["id",$page['id']]]); //echo 1; } } if(isset($json->search_with_calendar_var) && $json->search_with_calendar_var){ $json_ = $json->search_with_calendar_var; if(isset($json_->{$page['id']}) && $json_->{$page['id']} != $page['search_with_calendar']){ $_->update("menu",[["search_with_calendar"],[$json_->{$page['id']}],["id",$page['id']]]); //echo 1; } } if(isset($json->search_with_rss_var) && $json->search_with_rss_var){ $json_ = $json->search_with_rss_var; if(isset($json_->{$page['id']}) && $json_->{$page['id']} != $page['search_with_rss']){ $_->update("menu",[["search_with_rss"],[$json_->{$page['id']}],["id",$page['id']]]); //echo 1; } } if($json->change_menu_name_var){ $json_ = $json->change_menu_name_var; if(isset($json_->{$page['id']}) && $json_->{$page['id']} != $page['name_'.$_->_lang]){ $_->update("menu",[['name_'.$_->_lang],[$json_->{$page['id']}],["id",$page['id']]]); } } }echo 1; } private function update_home_page($id){ $_ = $this; $_->update("menu",[["home_page"],[0],["home_page",1]]); $_->update("menu",[["home_page"],[1],["id",$id]]); } private function delete_menu_name_var_inline(&$ids,$colum,$id){ $_ = $this; $obj = new stdClass(); $arr = []; $obj->c_type = "big"; $obj->sql = " and $colum in(".join(",",$id).")"; $sel = $_->select_(["id","menu",$obj]); if($sel){ $arr[] = $sel; $_->delete_menu_name_var_inline($ids,'parent',$sel); } foreach($arr as $key => $value) foreach($value as $v){ $ids[] = $v; $_->delete("menu",["id",$v]); } } private function delete_menu_name_var_inline_body($body_ids){ $_ = $this; for($i = 0; $i < count($body_ids); $i++){ $sql = "select body_id,count(body_id) as cnt from menu_body where body_id in(select body_id from menu_body where menu_id = ".$body_ids[$i].")"; $select = $_->select_([$sql,"small"]); $_->delete("menu_body",["body_id",$select['body_id'],"menu_id",$body_ids[$i]]); if($select['cnt'] == 1) $_->delete("body",["id",$select['body_id']]); } } private function delete_menu_name_var($a){ $_ = $this; $ids = []; $_->delete_menu_name_var_inline($ids,'id',(array)$a); $_->delete_menu_name_var_inline_body($ids); echo 1; die; //new version $obj = new stdClass(); $obj->c_type = "big"; $obj->sql = ""; $select = $_->select("*","menu",$obj)['body']; function delete_files($file,$_){ if($_->startSwith($file,'http') || !$file)return; if($_->endSwith($file,'.mp4')){ $image_name_ = str_replace('.mp4', '.jpg', $file); if(file_exists($_->_dir.'img/banners/video/'.$file))@unlink($_->_dir.'img/banners/video/'.$file); if(file_exists($_->_dir.'img/banners/video/img/'.$image_name_))@unlink($_->_dir.'img/banners/video/img/'.$image_name_); if(file_exists($_->_dir.'img/banners/video/img/small/'.$image_name_))@unlink($_->_dir.'img/banners/video/img/small/'.$image_name_); }else{ if(file_exists($_->_dir.'img/banners/'.$file))@unlink($_->_dir.'img/banners/'.$file); if(file_exists($_->_dir.'img/banners/small/'.$file))@unlink($_->_dir.'img/banners/small/'.$file); } } function delete_from_body($_a,$a,$b,$_){ //$_->delete("menu",["id",$a]); if(!count($b))return; $_->con->exec("delete from $a where id in(".join(",",$b).")"); $obj = new stdClass(); $obj->event = 2; $obj->table = $a; for($i = 0; $i < count($b); $i++){ $obj->id = $b[$i]; $obj->sql = "delete from $a where id = ".$b[$i].""; $_->log_method($obj); } } $ids = []; $ids2 = []; function inline_delete(&$ids,$_,$select,$a,$c = 1){ if(!count($select))return; for($i = 0; $i < count($select); $i++){ if($select[$i]['home_page'] == 1)continue; if(in_array($select[$i]['parent'], (array)$a)){ $ids[] = $select[$i]['id']; inline_delete($ids,$_,$select,[$select[$i]['id']],2); } if($c == 1) if(in_array($select[$i]['id'], (array)$a)){ $ids[] = $select[$i]['id']; } } } function inline_delete_body(&$ids2,$ids,$_){ $obj = new stdClass(); $deleted_id = [0]; for($i = 0; $i < count($ids); $i++){ $obj->c_type = "small"; $obj->sql = " and (select count(menu_id) from menu_body where menu_id = ".$ids[$i].") = 1"; $menu_body = $_->select_(["body_id","menu_body",$obj,["menu_id",$ids[$i]]]); if($menu_body){ $_->delete("menu_body",["menu_id",$ids[$i],"body_id",$menu_body]); $deleted_id[] = $menu_body; } } $obj->c_type = "big"; $obj->sql = " and id in (".join(',',$deleted_id).")"; $select = $_->select("*","body",$obj); $length = isset($select['body'])?count($select['body']):0; if(!$length)return; $maines = []; for($i = 0; $i < $length; $i++){ delete_files($select['body'][$i]['logo'],$_); $ids2[] = $select['body'][$i]['id']; $maines[] = $select['body'][$i]['id']; } inline_delete_body($ids2,$maines,$_); } inline_delete($ids,$_,$select,$a,1); if(!count($ids))return; ///must by deleted from menu delete_from_body($_,'menu',$ids,$_); ///must by deleted from menu //$_->pre($ids); //echo '---------------------'; inline_delete_body($ids2,$ids,$_); delete_from_body($_,'body',$ids2,$_); //$_->pre($ids2); } public function statistic($a){ $_ = $this; if($_POST['statistic'] == 'files'){ $exec = exec("python3 /var/www/".$this->must_by_removed."/find_replace.py /var/www/".$this->must_by_removed."/"); echo $exec; }else if($_POST['statistic'] == 'database'){ $db_name = ($_SERVER['HTTP_HOST'] == 'admin.new_')?'new_':'_700_lari'; $sql = "SELECT t.table_name, t.table_rows, round(t.index_length/1024/1024,2) as index_length, round(t.data_length/1024/1024,2) as data_length, round(((t.data_length + t.index_length) / 1024 / 1024),2) as all_size FROM information_schema.TABLES t WHERE t.table_schema = '".$db_name."' "; $select = $_->join_select($sql,"big"); for($i = 0; $i < count($select); $i++) $select[$i]['table_rows'] = $_->select("count(*)",$select[$i]['table_name'],"small"); echo Central::_json_encode($select); }elseif($_POST['statistic'] == 'users'){ $year = '1 year'; $month = '1 month'; $week = '1 week'; $now = '10 minute'; $array = [ 'all' => "select count(date) as length_ from visitors", 'all_group' => "select date as length_ from visitors group by ip", 'year' => "select count(date) as length_ from visitors where date > unix_timestamp(DATE_SUB(now(), INTERVAL $year))", 'year_group' => "select date as length_ from visitors where date > unix_timestamp(DATE_SUB(now(), INTERVAL $year)) group by ip", 'month' => "select count(date) as length_ from visitors where date > unix_timestamp(DATE_SUB(now(), INTERVAL $month))", 'month_group' => "select date as length_ from visitors where date > unix_timestamp(DATE_SUB(now(), INTERVAL $month)) group by ip", 'week' => "select count(date) as length_ from visitors where date > unix_timestamp(DATE_SUB(now(), INTERVAL $week))", 'week_group' => "select date as length_ from visitors where date > unix_timestamp(DATE_SUB(now(), INTERVAL $week)) group by ip", 'day' => "select count(date) as length_ from visitors where date > unix_timestamp(date(now()))", 'day_group' => "select date as length_ from visitors where date > unix_timestamp(date(now())) group by ip", 'now' => "select count(date) as length_ from visitors_now", 'now_group' => "select count(date) as length_ from visitors_now where ip not in (select ip from visitors group by ip)" ]; foreach($array as $key => $value){ if(in_array($key,['all_group','year_group','month_group','week_group','day_group'])){ $temp = $_->join_select($value,'big'); $array[$key] = ["length_" => ($temp)?count($temp):0]; }else $array[$key] = $_->join_select($value,'small'); } echo Central::_json_encode($array); } } }