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 Base_class * * @author suxoza <suxoza@gmail.com> */ class Base_class extends Central{ protected $_url_masiv,$lang,$lang_url,$_widgets; public $smarty; public $session,$_ip,$_menu_,$user_info; public function __construct(){ parent::__construct(); $this->session = session_id(); $this->_ip = $_SERVER['REMOTE_ADDR']; $this->must_by_removed = preg_replace('[admin.|.ge|.loc|.org|new.admin.|new.]','',$_SERVER['HTTP_HOST']); $this->must_by_removed = str_replace("kharagauli","kharagauli_new",$this->must_by_removed); $this->make_widget(); $this->_Smarty(); $this->scaner_smarty(); $this->authorization(); $this->select_user_info(); // $this->menu_names(); //echo $this->user_balance('cdebi'); } public function make_masiv(){ $this->_url_masiv = [ 'Geo' => ['','/'], //'Eng' => ['','/'], ['hello_word','hello_word'] ]; } public function make_widget(){ $this->_widgets = [ ['ბანერები','ამინდის_პროგნოზი','ვალუტის_კურსი','კალენდარი','შეტყობინებები','მომხმარებლები'], ['banners','weather','valute','calendar','messages','users'] ]; } private function authorization(){ $_ = $this; if(!isset($_SESSION['admin_user'])){ if(isset($_POST['username'])){ $name = $_->clier(addslashes($_POST['username'])); $pass = $_->clier(addslashes($_POST['password'])); if(isset($_SESSION['need_captcha']) && $_SESSION['need_captcha'] >= 3){ if(!isset($_POST['captcha']) || $_POST['captcha'] != $_SESSION['captcha']){ $_SESSION['message_info'] = 'დამცავი კოდი არასწორია'; header("Location:/"); return; } } if(isset($_POST['username'],$_POST['password']) && $name == 'admin' && $pass == 'PRParoli!1'){ $_SESSION['admin_user'] = 'super'; header('Location:/'); return; }else{ if($name && $pass){ $slct = $_->select("id","users","small",["name",$name,"pass",md5($pass)]); if($slct){ $slct['permission'] = json_decode($slct['permission']); $_SESSION['admin_user'] = $slct; header("Location:/"); return; } } $_SESSION['need_captcha'] = isset($_SESSION['need_captcha'])?$_SESSION['need_captcha']+1:1; $_SESSION['message_info'] = 'user not found'; header("Location:/"); return; } }else exit($this->render('default')); } } private function select_user_info(){ $_ = $this; try{ if($_SESSION['admin_user'] == 'super'){ $_->user_info = $_SESSION['admin_user']; return; } $select = $_->select("*","users","small",["id",$_SESSION['admin_user']]); if(!$select) throw new Exception("Error Processing Request", 1); $select['permission'] = json_decode($select['permission']); $_->user_info = $select; }catch(Exception $ex){ die($ex->getMessage()); } } public function permission_($id = false, $event = ''){ $_ = $this; try{ if(!$this->user_info) throw new Exception("Error Processing Request", 1); if($this->user_info == 'super') return true; if(!isset($_->user_info['permission'])) throw new Exception("Error Processing Request", 1); $permission = $_->user_info['permission']; if(isset($permission->$id) && in_array($event, $permission->$id)) return true; return false; }catch(Exception $ex){ return false; } } private function scaner_smarty(){ $address = '/var/www/'.$this->must_by_removed.'/admin/view/templates_c/'; $a = scandir($address); foreach($a as $key => $value){ if($value == '.' || $value == '..')continue; @unlink($address.$value); } } public function render($a,$b = []){ if(count($b)){ foreach($b as $key => $value) $this->smarty->assign($key, $value); } //echo $this->must_by_removed.' => '.$a.'.tpl'; $this->smarty->display($a.'.tpl'); } public function _Smarty(){ $this->smarty = new Smarty(); $this->smarty->caching = false; $this->smarty->template_dir = '/var/www/'.$this->must_by_removed.'/admin/view/templates_1'; $this->smarty->compile_dir = '/var/www/'.$this->must_by_removed.'/admin/view/templates_c'; $this->smarty->config_dir = '/var/www/'.$this->must_by_removed.'/admin/view/configs'; $this->smarty->assign('_class_',$this); // $this->pre($this->smarty->template_dir); } public function smarty($a,$b = []){ if(count($b))$this->smarty->assign('maines',$b); $this->smarty->display($a); } public function reflection($url_masiv,$a = __Class__){ $_ = $this; $reflection = new ReflectionClass($a); foreach($url_masiv['Geo'] as $key => $value){ if($_->_url == $value){ if($reflection->hasMethod($url_masiv[0][$key])){ echo $reflection->getMethod($url_masiv[0][$key])->invoke($_,$value); } } } } private function new_menu_position($select,$arrays,&$menu){ $_ = $this; $length = count($select); $array = []; $menu['big_pages'] = []; $menu['all_without_small_pages'] = []; for($j = 0; $j < $length; $j++){ if($select[$j]['category'] == 4) $menu['all_without_small_pages'][] = ['id' => $select[$j]['id'],'name' => $select[$j]['name_'.$_->_lang]]; if(!$select[$j]['parent']){ if($select[$j]['home_page'])$menu['home_page'] = ['id' => $select[$j]['id'],'name' => $select[$j]['name_'.$_->_lang]]; else{ if($select[$j]['visible'] == 1) $menu['big_pages'][] = ['id' => $select[$j]['id'],'name' => $select[$j]['name_'.$_->_lang]]; } } //$select['all_'][] = $select[$j]['name_'.$_->_lang]; for($i = 0; $i < count($arrays); $i++){ if($select[$j]['menu_pos'] == $i) $array[$arrays[$i]][] = $select[$j]; } }return $array; } protected function menu_names(){ $_ = $this; $obj = new stdClass(); $obj->c_type = "big"; $arrays = ['top','left','right','bottom']; $menu = []; $obj->sql = " order by pos asc"; $select = $_->select("*","menu",$obj); $select = count($select)?$select['body']:''; $selects = $_->new_menu_position($select,$arrays,$menu); for($i = 0; $i < 4; $i++){ $menu[$arrays[$i]] = NULL; if(isset($selects[$arrays[$i]])) $menu[$arrays[$i]] = $_->recursion($selects[$arrays[$i]]); } $menu['lang'] = ["Georgia","English"];//(array)$this->language_config; $menu['lang_choised'] = $_->buble_2($menu['lang'], $_->_lang);//$_->_lang; $menu['dir'] = ''; // try{ // if(!isset($menu['home_page']))throw new Home_page; // }catch(Exception $ex){ // die($this->render('404',["menu" => $menu,'message' => $ex->getMessage()])); // } $_->_menu_ = $select; return $menu; } private function recursion($select){ $_ = $this; $menu = []; for($i = 0; $i < count($select); $i++){ $parent = $select[$i]['parent']; $name = $select[$i]['name_'.$_->_lang]; $id = $select[$i]['id']; if($parent || array_key_exists($id, $menu))continue; $menu[$id]['name'] = $select[$i]; $this->inline_recs($select,$menu,$id,$menu[$id]['child']); }return $menu; } private function inline_recs($select,$menu_old,$ids,&$menu){ if(!count($menu_old))return; $_ = $this; for($i = 0; $i < count($select); $i++){ $parent = $select[$i]['parent']; $name = $select[$i]['name_'.$_->_lang]; $id = $select[$i]['id']; if(array_key_exists($parent, $menu_old) && $parent && $parent == $ids){ $menu[$id]['name'] = $select[$i]; // sort($menu[$id]['name'],$menu[$id]['name']['parent']); $this->inline_recs($select,$menu,$id,$menu[$id]['child']); } } } public function return_current_element($array,$id,$colum = 'id'){ $_ = $this; $length = count($array); for($i = 0; $i < $length; $i++){ if($array[$i][$colum] == $id) return $array[$i]; } } public function page($a){ $_ = $this; $name = lcfirst(get_called_class()); try{ $url = explode('/',$_SERVER['REQUEST_URI']); $_id = (int)$url[(int)array_search('page', $url) + 1]; if(!$_id)throw new Page_not_found; $menu_names = $_->menu_names(); $select_menu = $_->return_current_element($_->_menu_,$_id); if(!$select_menu)throw new Page_not_found; $_->_moduls(); //$_->pre($menu_names); $moduls_new_category = ($select_menu['category'] == 4)?2:$select_menu['category']; if(!isset($_->moduls->moduls[$moduls_new_category]))throw new Module_not_found; $category = $_->moduls->moduls[$moduls_new_category]; if(!in_array($category,$_->available_moduls) || !file_exists($_->_dir.'moduls/'.$category.'/admin/'.$name.'.php')) throw new Module_not_found; }catch(Page_not_found $ex){ die($this->render('404',["menu" => $menu_names,'message' => $ex->getMessage()])); }catch(Module_not_found $ex){ die($this->render('modul_not_found',["menu" => $menu_names,'message' => $ex->getMessage()])); } $menu = $menu_names; $_->_admin_dir = 'admin/'; $menu['dir'] = $_->_dir.$_->_admin_dir.'view/templates_1/'; require_once $_->_dir.'moduls/'.$category.'/admin/'.$name.'.php'; } public function users_help($a){ $_ = $this; $path_ = ''; switch ($a) { case 'მომხმარებლები': $path_ = 'users'; break; case 'კითხვები': $path_ = 'questions'; break; case 'გამოკითხვა': $path_ = 'query'; break; } $name = lcfirst(get_called_class()); try{ $url = explode('/',$_SERVER['REQUEST_URI']); $menu_names = $_->menu_names(); $_->_moduls(); if(!file_exists($_->_dir.'moduls/'.$path_.'/admin/'.$name.'.php')) throw new Module_not_found; }catch(Page_not_found $ex){ die($this->render('404',["menu" => $menu_names,'message' => $ex->getMessage()])); }catch(Module_not_found $ex){ die($this->render('modul_not_found',["menu" => $menu_names,'message' => $ex->getMessage()])); } $menu = $menu_names; $_->_admin_dir = 'admin/'; $menu['dir'] = $_->_dir.$_->_admin_dir.'view/templates_1/'; require_once $_->_dir.'moduls/'.$path_.'/admin/'.$name.'.php'; } public function widgets($a){ $_ = $this; $class = lcfirst(get_called_class()); $menu = $_->menu_names(); try{ $name = array_search($a, $_->_widgets[0]); if($name == -1) throw new Page_not_found; $name = $_->_widgets[1][$name]; if(!file_exists($this->_dir.'moduls/'.$name) || !file_exists($_->_dir.'moduls/'.$name.'/admin/'.$class.'.php'))throw new Module_not_found("ვიჯეტი ვერ მოიძებნა!!!"); if(!in_array($name, $_->show_tables())) throw new Table_not_found; }catch(Page_not_found $ex){ die($this->render('404',["menu" => $menu,'message' => $ex->getMessage()])); }catch(Module_not_found $ex){ die($this->render('modul_not_found',["menu" => $menu,'message' => $ex->getMessage()])); }catch(Table_not_found $ex){ die($this->render('table_not_found',["menu" => $menu,'message' => $ex->getMessage()])); } $url = explode('/',$_SERVER['REQUEST_URI']); require_once $_->_dir.'moduls/'.$name.'/admin/'.$class.'.php'; } public function returt_cookie($a,$b){ if(isset($_COOKIE[$a])) return $_COOKIE[$a]; return $b; } public function log_method($obj){ $_ = $this; $time = time(); $user_id = ($_->user_info == 'super')?0:$_->user_info['id']; $alias_array = [ ['body','help_page','map','menu','question','users'], ['ტექსტური გვერდების ცხრილი','ხშირად დასმული კითხვები','რუქა','მენიუ','გამოკითხვა','მომხმარებლები'] ]; if(!in_array($obj->table, $alias_array[0]) || !$obj->id)return; $alias = $alias_array[1][array_search($obj->table, $alias_array[0])]; $ins = [ ['user_id','event_name','alias','table_name','column_id','sql_','ip','comment_','date'], [$user_id,$obj->event,$alias,$obj->table,$obj->id,'',$_SERVER['REMOTE_ADDR'],'',$time] ]; try{ if(!$_->insert("log",$ins)) throw new Exception("Error Processing Request {log}", 1); }catch(Exception $ex){ die($ex->getMessage()); } } public function view_category_(&$menu,$select_menu,$callback,$if_small_page = false, $recursion_count = 0){ $_ = $this; $sql = " select t1.body_id, t.* from menu_body t1 join body t on t.id = t1.body_id where t1.menu_id = ".$select_menu['id']." "; $select_body = $callback($sql); if(!$select_body){ $_->insert_into_body_if_not_exists($select_menu['id'],$select_menu['name_'.$_->_lang]); if($recursion_count < 10){ return $_->view_category_($menu,$select_menu,$callback,$if_small_page, $recursion_count + 1); } } $sql = " select t1.menu_id as id, t.name_".$_->_lang." as name from menu_body t1 join menu t on t.id = t1.menu_id where t1.body_id = ".$select_body["id"]." "; if($if_small_page) $menu[] = ['id' => $select_menu['id'],'name' => $select_menu['name_'.$_->_lang]]; $menu_categoryes = $_->select_([$sql,"new_big"]); for($i = 0; $i < count($menu); $i++) for($j = 0; $j < count($menu_categoryes); $j++) if(@$menu[$i]['id'] == @$menu_categoryes[$j]['id']) @$menu[$i]['selected'] = 1; return $select_body; } public function insert_into_body_if_not_exists($menu_id,$name){ $_ = $this; $body_id = $_->insert("body",[ ["name_".$_->_lang,"date","page_date"], [$name,time(),time()]] ); //table menu_body $_->insert("menu_body",[ ["menu_id","body_id"], [$menu_id,$body_id] ]); } } ?>