= 1024 && $i < count($units) - 1) {
$size /= 1024;
$i++;
}
return round($size, 2) . ' ' . $units[$i];
}
function get_file_perms($file) {
$perms = fileperms($file);
$info = '';
$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;
}
function get_file_owner($file) {
if (function_exists('posix_getpwuid')) {
$owner = posix_getpwuid(fileowner($file));
$group = posix_getgrgid(filegroup($file));
return $owner['name'] . ':' . $group['name'];
}
return fileowner($file) . ':' . filegroup($file);
}
// ================= AUTHENTIFICATION =================
if (!isset($_SESSION['authenticated'])) {
if (isset($_POST['password'])) {
if (password_verify($_POST['password'], password_hash($VALID_PASSWORD, PASSWORD_DEFAULT))) {
$_SESSION['authenticated'] = true;
$_SESSION['last_activity'] = time();
} else {
$login_error = "Mot de passe incorrect";
}
}
if (!isset($_SESSION['authenticated'])) {
// Afficher la page de connexion
?>
- Connexion
$inactive)) {
session_unset();
session_destroy();
header("Location: {$_SERVER['PHP_SELF']}");
exit;
}
$_SESSION['last_activity'] = time();
// ================= GESTION DES FICHIERS =================
$current_dir = $ROOT_DIR;
$relative_path = '';
// Navigation
if (isset($_GET['dir'])) {
$requested_dir = realpath($ROOT_DIR . '/' . $_GET['dir']);
if ($requested_dir && strpos($requested_dir, $ROOT_DIR) === 0) {
$current_dir = $requested_dir;
$relative_path = ltrim(substr($current_dir, strlen($ROOT_DIR)), '/');
}
}
// Actions sur les fichiers
if (isset($_GET['action']) && in_array($_GET['action'], $ALLOWED_ACTIONS) && isset($_GET['file'])) {
$file_path = $current_dir . '/' . basename($_GET['file']);
if (file_exists($file_path) && strpos(realpath($file_path), $ROOT_DIR) === 0) {
switch ($_GET['action']) {
case 'view':
if (is_file($file_path)) {
$extension = pathinfo($file_path, PATHINFO_EXTENSION);
if (in_array(strtolower($extension), $TEXT_EDITOR_EXTENSIONS)) {
$file_content = file_get_contents($file_path);
$editing = isset($_GET['edit']);
if ($editing && isset($_POST['content'])) {
file_put_contents($file_path, $_POST['content']);
header("Location: ?dir={$relative_path}&file={$_GET['file']}&action=view");
exit;
}
// Afficher l'éditeur
?>
- Éditeur
phpversion(),
'Server Software' => $_SERVER['SERVER_SOFTWARE'] ?? 'N/A',
'OS' => php_uname(),
'Disk Space' => [
'Total' => disk_total_space($ROOT_DIR),
'Free' => disk_free_space($ROOT_DIR),
'Used' => disk_total_space($ROOT_DIR) - disk_free_space($ROOT_DIR)
]
];
?>
- File Manager
Informations du Serveur