403Webshell
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/admin/clases/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/kharagauli1/admin/clases/_files.php
<?php

/**
 * Created by PhpStorm.
 * User: suxoza
 * author:suxoza <suxoza@gmail.com>
 * Date: 10/30/14
 * Time: 1:03 AM
 */

final class _files{

    private static $IMAGE_PATHS = [70,180,420,600,620];
    private static $HTTP_HOST;
    protected static $_instance;
    private function __construct(){}
    private function __clone(){}
    private function __wakeup(){}
    public static function Coll(){
        if(null === self::$_instance){


            self::$_instance = new _files;
        }return self::$_instance;
    }

    /**
     * @param $image
     * @param $width
     * @param $height
     * @param $scale
     * @return mixed
     */
    public static final function resizeImage($image,$width,$height,$scale){
        $newImageWidth = ceil($width * $scale);
        $newImageHeight = ceil($height * $scale);
        $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
        if(preg_match('/[.](jpg)|(JPG)|(jpeg)|(JPEG)$/',$image))
            $source = imagecreatefromjpeg($image);
        elseif(preg_match('/[.](gif)|(GIF)$/',$image))
            $source = imagecreatefromgif($image);
        elseif(preg_match('/[.](png)|(PNG)$/',$image))
            $source = imagecreatefrompng($image);
        imagecopyresampled($newImage,$source,0,0,0,0,$newImageWidth,$newImageHeight,$width,$height);
        if(preg_match('/[.](jpg)|(JPG)|(jpeg)|(JPEG)$/',$image))
            imagejpeg($newImage,$image,90);
        elseif(preg_match('/[.](gif)|(GIF)$/',$image))
            imagegif($newImage,$image,90);
        elseif(preg_match('/[.](png)|(PNG)$/',$image)){
            $q = 9/100;
            $quality = 90;
            $quality *=$q;
            imagepng($newImage,$image,$quality);
        }
        chmod($image, 0777);
        return $image;
     }

    /**
     * @param $thumb_image_name
     * @param $image
     * @param $width
     * @param $height
     * @param $start_width
     * @param $start_height
     * @param $scale
     * @return mixed
     */
    public static final function resizeThumbnailImage($thumb_image_name, $image, $width, $height, $start_width, $start_height, $scale){
        $newImageWidth = ceil($width * $scale);
        $newImageHeight = ceil($height * $scale);
        $newImage = imagecreatetruecolor($newImageWidth,$newImageHeight);
        if(preg_match('/[.](jpg)|(JPG)|(jpeg)|(JPEG)$/',$image))
            $source = imagecreatefromjpeg($image);
        elseif(preg_match('/[.](gif)|(GIF)$/',$image))
            $source = imagecreatefromgif($image);
        elseif(preg_match('/[.](png)|(PNG)$/',$image))
            $source = imagecreatefrompng($image);
        imagecopyresampled($newImage,$source,0,0,$start_width,$start_height,$newImageWidth,$newImageHeight,$width,$height);
        if(preg_match('/[.](jpg)|(JPG)|(jpeg)|(JPEG)$/',$image))
            imagejpeg($newImage,$thumb_image_name,90);
        elseif(preg_match('/[.](gif)|(GIF)$/',$image))
            imagegif($newImage,$thumb_image_name,90);
        elseif(preg_match('/[.](png)|(PNG)$/',$image)){
            $q = 9/100;
            $quality = 90;
            $quality *=$q;
            imagepng($newImage,$thumb_image_name,$quality);
        }
        chmod($thumb_image_name, 0777);
        return $thumb_image_name;
    }


    /**
     * @param $image
     * @return mixed
     */
    public static final function getHeight($image) {
        $sizes = getimagesize($image);
        $height = $sizes[1];
        return $height;
    }

    /**
     * @param $image
     * @return mixed
     */
    public static final function getWidth($image) {
        $sizes = getimagesize($image);
        $width = $sizes[0];
        return $width;
    }

    /**
     * @param $arg
     * @return string
     */
    public static final function __file($arg){
        $file_name = '';
        if($_FILES[$arg]['name'] && preg_match('/[.](jpg)|(gif)|(png)|(jpeg)|(JPG)|(GIF)|(PNG)|(JPG)|(swf)|(SWF)$/',$_FILES[$arg]['name'])){
            $end = str_replace('jpeg','jpg',explode('.',$_FILES[$arg]['name'])[count(explode('.',$_FILES[$arg]['name'])) - 1]);

            $file_name = _files::_image_name($end);
            $host = self::$HTTP_HOST = str_replace('admin.','',str_replace('.ge','',str_replace('.loc','',$_SERVER['HTTP_HOST'])));
            //echo $_SERVER['HTTP_HOST'].$host."<br/>";
            $path = '/var/www/'.$host.'/image/';
            if(move_uploaded_file($_FILES[$arg]['tmp_name'],$path.$file_name)){
                if(preg_match('/[.](swf)|(SWF)$/',$_FILES[$arg]['name']))return $file_name;
                self::save_image_from_all_size($file_name,$path);
            }
        }return $file_name;
    }


    public static final function save_image_from_all_size($file_name,$path){
        $array = self::$IMAGE_PATHS;
        for($i = 0; $i < count($array); $i++){
            $new_dir = $path.'img_'.$array[$i].'/';
            copy($path.$file_name,$new_dir.$file_name);

            $max_width = $array[$i];
            $width  = self::getWidth($new_dir.$file_name);
            $height = self::getHeight($new_dir.$file_name);
            if($width > $max_width){
                $scale = $max_width/$width;
                self::resizeImage($new_dir.$file_name,$width,$height,$scale);
            }else{
                $scale = 1;
                self::resizeImage($new_dir.$file_name,$width,$height,$scale);
            }
        }
    }



    /**
     * @param $file
     */
    public static final function delete_image($file){
        if(!$file)return;
        $array = self::$IMAGE_PATHS;
        $dir = str_replace('/admin','',$_SERVER['DOCUMENT_ROOT']).'/image/';
        //die($dir.$file)
        @unlink($dir.$file);
        if(preg_match('/[.](swf)|(SWF)$/',$file))return;
        for($i = 0; $i < count($array); $i++)
            @unlink($dir.'img_'.$array[$i].'/'.$file);
    }

    /**
     * @param $file
     * @return string
     */
    public static final function _copy_image($file){
        $new_file = "";
        if(!$file)return $new_file;
        $array = self::$IMAGE_PATHS;
        self::$HTTP_HOST = str_replace('admin.','',str_replace('.ge','',str_replace('.loc','',$_SERVER['HTTP_HOST'])));
        $dir = '/var/www/'.self::$HTTP_HOST.'/image/';
        $end = str_replace('jpeg','jpg',explode('.',$file)[count(explode('.',$file)) - 1]);
        $new_file = _files::_image_name($end);
        @copy($dir.$file,$dir.$new_file);
        if(preg_match('/[.](swf)|(SWF)$/',$file))return;
        for($i = 0; $i < count($array); $i++)
            @copy($dir.'img_'.$array[$i].'/'.$file,$dir.'img_'.$array[$i].'/'.$new_file);
        return $new_file;
    }

    /**
     * @param $filename
     * @param int $size
     */
    public static final 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);
    }

    /**
     * @param $filename
     * @param $a
     * @param $b
     * @param $c
     * @param int $size
     * @param int $d
     * @return bool
     */
    public static final function main_images($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;

    }

    /**
     * @param $filename
     */
    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');
    }

    /**
     * @param $filename
     */
    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);
    }

    /**
     * @param $end
     * @return string
     */
    public static final function _image_name($end){
        return str_replace('.','_',$_SERVER['REMOTE_ADDR']).'_'.microtime(time()).'_'.rand(0,30).'_'.rand(5, 10).'.'.$end;
    }


    /**
     * @param $filename
     * @return bool|string
     */
    public static final 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;
    }

    /**
     * @param string $url
     * @param string $data
     * @return string
     */
    public static final function get_binnary($image,$boolean = true){
        $mime_ = explode('/',mime_content_type($image))[1];
        $mime = $mime_ == 'jpg'?'jpeg':$mime_;
        $function = 'image'.$mime;
        $path = $_SERVER['DOCUMENT_ROOT'].'/image/';
        $file_name = _any::return_random_file_name().'.'.$mime_;
        $function(imagecreatefromstring(file_get_contents($image)),$path.$file_name);
        if($boolean)
            self::save_image_from_all_size($file_name,$path);
        return $file_name;
    }

    /**
     * @param $haystack
     * @param $needle
     * @return bool
     */
    public static final function startsWith($haystack,$needle){
        return (substr($haystack, 0, strlen($needle)) === $needle);
    }

    /**
     * @param $haystack
     * @param $needle
     * @return bool
     */
    public static final function endsWith($haystack, $needle){
        $length = strlen($needle);
        if($length == 0)
            return true;
        return (substr($haystack, -$length) === $needle);
    }

    public static final function pre($a){
        echo "<pre>";
            print_r($a);
        echo "</pre>";
    }

    public static final function custom_copy_image($logo){
        $old_path = '/var/www/kharagauli/img/banners/';
        $new_path = '/var/www/kharagauli/image/';
        if(!file_exists($new_path.$logo) && file_exists($old_path.$logo)){
            copy($old_path.$logo,$new_path.$logo);
            self::save_image_from_all_size($logo,$new_path);
            @unlink($old_path.$logo);
            @unlink($old_path.'small/'.$logo);
        }

    }

    public static final function custom_get_images($body){
        if(!$body)return '';

        $html = str_get_html($body);
        $old_path = '/var/www/kharagauli/admin/img/banners/';
        $new_path = '/var/www/kharagauli/image/';
        foreach($html->find('img') as $value){
            $src = $value->src;
            //echo $src."<br/>";
            $width = $value->width;
            if(strpos($src,'img/banners/') !== false) {
                $src = explode('img/banners/',$src)[1];
                $full_src = $src;

                if(!file_exists($old_path.$src))continue;
                if(copy($old_path.$src,$new_path.$src))
                    self::save_image_from_all_size($src,$new_path);

                if($width && in_array($width,self::$IMAGE_PATHS))
                    $src = 'image/img_'.$width.'/'.$src;
                else
                    $src = 'image/'.$src;
                $src = 'http://'.str_replace('admin.','',$_SERVER['HTTP_HOST']).'/'.$src;
                $value->src = $src;

                $value->height = '';
                unlink($old_path.$full_src);
            }
        }
        return $html;
    }

    public static final function custom_delete_images_from_body($old_body,$new_body){
        if(!$old_body)return;
        if(strpos($old_body,'<img') === false)return;
        $new_image = [];
        $old_image = [];
        $old_body = str_get_html($old_body);
        $old_image = $old_body->find('img');
        if(!$old_image)return;

        $old_img = [];
        $new_img = [];
        foreach($old_image as $value)
            $old_img[] = explode('/',$value->src)[count(explode('/',$value->src)) - 1];
        if(!$old_img)return;

        $new_body = str_get_html($new_body);
        if(strpos($new_body,'<img') !== false)
            $new_image = $new_body->find('img');

        if($new_image)
            foreach($new_image as $value)
                $new_img[] = explode('/',$value->src)[count(explode('/',$value->src)) - 1];

        foreach($old_img as $value)
            if(!in_array($value,$new_img))
                self::delete_image($value);

    }

    public static final function custom_delete_images($body){
        if(!$body)return [];
        if(strpos($body,'<img') === false)return [];
        $images = [];
        $body = str_get_html($body);
        $image = $body->find('img');
        foreach($image as $value)
            $images[] = explode('/',$value->src)[count(explode('/',$value->src)) - 1];
        return $images;
    }



} 

Youez - 2016 - github.com/yon3zu
LinuXploit