include 'pclzip.lib.php';
foreach ($require as $function) {
if (!function_exists($function)) {
exit($function . ' not found');
$dir = getenv('SCRIPT_NAME');
$dir = str_replace('\\', '/', $dir);
$dir = strpos($dir, '/') !== false ? dirname($dir) : null;
$dir = str_replace('\\', '/', $dir);
$dir = $dir == '.' || $dir == '/' ? null : $dir;
$_SERVER['DOCUMENT_ROOT'] = realpath('.');
$_SERVER['DOCUMENT_ROOT'] = $dir == null ? $_SERVER['DOCUMENT_ROOT'] : substr($_SERVER['DOCUMENT_ROOT'], 0, strlen($_SERVER['DOCUMENT_ROOT']) - strlen($dir));
$_SERVER['DOCUMENT_ROOT'] = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
define('REALPATH', realpath('./'));
const PATH_CONFIG = __DIR__ . '/config.inc.php';
const LOGIN_USERNAME_DEFAULT = 'Admin';
const LOGIN_PASSWORD_DEFAULT = '12345';
const PAGE_LIST_DEFAULT = 120;
const PAGE_FILE_EDIT_DEFAULT = 120;
const PAGE_FILE_EDIT_LINE_DEFAULT = 120;
const PAGE_URL_DEFAULT = 'default';
const PAGE_URL_START = 'start';
const PAGE_URL_END = 'end';
const DEVELOPMENT = false;
const NAME_SUBSTR_ELLIPSIS = '...';
'image' => array('png', 'ico', 'jpg', 'jpeg', 'gif', 'bmp'),
'text' => array('cpp', 'css', 'csv', 'h', 'htaccess', 'html', 'java', 'js', 'lng', 'pas', 'php', 'pl', 'py', 'rb', 'rss', 'sh', 'svg', 'tpl', 'txt', 'xml', 'ini', 'cnf', 'config', 'conf', 'conv'),
'archive' => array('7z', 'rar', 'tar', 'tarz', 'zip'),
'audio' => array('acc', 'midi', 'mp3', 'mp4', 'swf', 'wav'),
'font' => array('afm', 'bdf', 'otf', 'pcf', 'snf', 'ttf'),
'binary' => array('pak', 'deb', 'dat'),
'document' => array('pdf'),
'source' => array('changelog', 'copyright', 'license', 'readme'),
'zip' => array('zip', 'jar'),
'other' => array('rpm', 'sql')
header('Location:' . $url);
function getPasswordEncode($pass): string
return md5(md5(trim($pass)));
function getFormat($name)
return strrchr($name, '.') !== false ? strtolower(str_replace('.', null, strrchr($name, '.'))) : null;
function isFormatText($name)
$format = getFormat($name);
return in_array($format, $formats['text']) || in_array($format, $formats['other']) || in_array(strtolower(strpos($name, '.') !== false ? substr($name, 0, strpos($name, '.')) : $name), $formats['source']);
function isFormatUnknown($name)
$format = getFormat($name);
foreach ($formats as $array)
if (in_array($format, $array))
return filter_var($url, FILTER_VALIDATE_URL);
function processDirectory($var)
$var = str_replace('\\', '/', $var);
$var = preg_replace('#/\./#', '//', $var);
$var = preg_replace('#/\.\./#', '//', $var);
$var = preg_replace('#/\.{1,2}$#', '//', $var);
$var = preg_replace('|/{2,}|', '/', $var);
$var = preg_replace('|(.+?)/$|', '$1', $var);
function processImport($url)
if (!preg_match('|^http[s]?://(.+?)$|i', $url))
function processPathZip($var)
$var = str_replace('\\', '/', $var);
$var = preg_replace('#/\./#', '//', $var);
$var = preg_replace('#/\.\./#', '//', $var);
$var = preg_replace('#/\.{1,2}$#', '//', $var);
$var = preg_replace('|/{2,}|', '/', $var);
$var = preg_replace('|/?(.+?)/?$|', '$1', $var);
function processName($var)
$var = str_replace('/', null, $var);
$var = str_replace('\\', null, $var);
function isNameError($var): bool
return strpos($var, '\\') !== false || strpos($var, '/') !== false;
$handler = @scandir($path);
if ($handler !== false) {
foreach ($handler as $entry) {
if ($entry != '.' && $entry != '..') {
$pa = $path . '/' . $entry;
} elseif (@is_dir($pa)) {
function rrms($entrys, $dir)
foreach ($entrys as $e) {
} elseif (@is_dir($pa)) {
function copydir($old, $new, $isParent = true)
$handler = @scandir($old);
if ($handler !== false) {
if ($isParent && $old != '/') {
$arr = explode('/', $old);
$end = $new = $new . '/' . end($arr);
if (@is_file($end) || (!@is_dir($end) && !@mkdir($end)))
} elseif (!$isParent && !@is_dir($new) && !@mkdir($new)) {
foreach ($handler as $entry) {
if ($entry != '.' && $entry != '..') {
$paOld = $old . '/' . $entry;
$paNew = $new . '/' . $entry;
if (!@copy($paOld, $paNew))
} elseif (@is_dir($paOld)) {
if (!copydir($paOld, $paNew, false))
function copys($entrys, $dir, $path)
foreach ($entrys as $e) {
if (isPathNotPermission(processDirectory($path . '/' . $e))) {
/* Entry not permission */
} elseif (@is_file($pa)) {
if (!@copy($pa, $path . '/' . $e))
} elseif (@is_dir($pa)) {
if (!copydir($pa, $path))
function movedir($old, $new, $isParent = true)
$handler = @scandir($old);
if ($handler !== false) {
if ($isParent && $old != '/') {
$end = $new = $new . '/' . end($s);
if (@is_file($end) || (!@is_dir($end) && !@mkdir($end)))
} elseif (!$isParent && !@is_dir($new) && !@mkdir($new)) {
foreach ($handler as $entry) {
if ($entry != '.' && $entry != '..') {
$paOld = $old . '/' . $entry;
$paNew = $new . '/' . $entry;
if (!@copy($paOld, $paNew))
} elseif (@is_dir($paOld)) {
if (!movedir($paOld, $paNew, false))
function moves($entrys, $dir, $path)
foreach ($entrys as $e) {
if (isPathNotPermission(processDirectory($path . '/' . $e))) {
/* Entry not permission */
} elseif (@is_file($pa)) {
if (!@copy($pa, $path . '/' . $e))
} elseif (@is_dir($pa)) {
if (!movedir($pa, $path))
function zipdir($path, $file, $isDelete = false)
$zip = new PclZip($file);
if ($zip->add($path, PCLZIP_OPT_REMOVE_PATH, $path)) {
function zips($dir, $entrys, $file, $isDelete = false)
$zip = new PclZip($file);
if (!$zip->add($dir . '/' . $e, PCLZIP_OPT_REMOVE_PATH, $dir))
function chmods($dir, $entrys, $folder, $file)
$folder = intval($folder, 8);
$file = intval($file, 8);
foreach ($entrys as $e) {
if (!@chmod($path, $file))
} elseif (@is_dir($path)) {
if (!@chmod($path, $folder))
$size = round($size / 1024, 2) . 'KB';
elseif ($size < 1073741824)
$size = round($size / 1048576, 2) . 'MB';
$size = round($size / 1073741824, 2) . 'GB';
function grab($url, $ref = '', $cookie = '', $user_agent = '', $header = '')
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$headers[] = 'Accept-Language: en-us,en;q=0.5';
$headers[] = 'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7';
$headers[] = 'Keep-Alive: 300';
$headers[] = 'Connection: Keep-Alive';
$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_USERAGENT, 'Nokia3110c/2.0 (04.91) Profile/MIDP-2.0 Configuration/CLDC-1.1');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_REFERER, $ref);
curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com.vn/search?hl=vi&client=firefox-a&rls=org.mozilla:en-US:official&hs=hKS&q=video+clip&start=20&sa=N');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (strncmp($url, 'https', 6))
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
$mess_error = curl_error($ch);
function import($url, $path)
if (!file_put_contents($path, $binarys)) {
function page($current, $total, $url): string
$html = '<div class="page">';
$center = PAGE_NUMBER - 2;
$link[PAGE_URL_DEFAULT] = $url[PAGE_URL_DEFAULT] ?? null;
$link[PAGE_URL_START] = $url[PAGE_URL_START] ?? null;
$link[PAGE_URL_END] = $url[PAGE_URL_END] ?? null;
if ($total <= PAGE_NUMBER) {
for ($i = 1; $i <= $total; ++$i) {
$html .= '<strong class="current">' . $i . '</strong>';
$html .= '<a href="' . $link[PAGE_URL_DEFAULT] . '" class="other">' . $i . '</a>';
$html .= '<a href="' . $link[PAGE_URL_START] . $i . $link[PAGE_URL_END] . '" class="other">' . $i . '</a>';
$html .= '<strong class="current">1</strong>';
$html .= '<a href="' . $link[PAGE_URL_DEFAULT] . '" class="other">1</a>';