Invalid user.
'; } else { $users = getUsers(); echo 'Title: ' . htmlspecialchars($users[$user]['title']) . '
'; echo 'Description: ' . htmlspecialchars($users[$user]['description']) . '
'; echo '' . htmlspecialchars($users[$user]['ascii_art']) . ''; echo '
No repositories.
'; } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'fork' && isset($_SESSION['user']) && $_SESSION['user'] != $user) { $project = $_POST['project']; $new_name = $_POST['new_name']; $srcDir = USERS_DIR . $user . '/' . $project; $dstDir = USERS_DIR . $_SESSION['user'] . '/' . $new_name; if (file_exists($srcDir) && !file_exists($dstDir)) { copyDir($srcDir, $dstDir); echo 'Project forked successfully as ' . htmlspecialchars($new_name) . '.
'; } else { echo 'Error forking project: Destination exists or source missing.
'; } } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['action']) && $_POST['action'] == 'edit' && isset($_SESSION['user']) && $_SESSION['user'] == $user) { $file = USERS_DIR . $user . '/' . $_POST['file']; if (strpos(realpath($file), realpath(USERS_DIR . $user)) === 0 && pathinfo($file, PATHINFO_EXTENSION) == 'txt') { $content = $_POST['content']; $language = $_POST['language'] ?? ''; file_put_contents($file, $content); $jsonFile = pathinfo($file, PATHINFO_DIRNAME) . '/' . pathinfo($file, PATHINFO_FILENAME) . '.json'; if ($language) { file_put_contents($jsonFile, json_encode(['language' => $language])); } else if (file_exists($jsonFile)) { unlink($jsonFile); // Remove metadata if language is empty } echo 'File updated successfully.
'; } else { echo 'Invalid file or permission denied.
'; } } if (isset($_GET['file'])) { $file = USERS_DIR . $user . '/' . $_GET['file']; if (strpos(realpath($file), realpath(USERS_DIR . $user)) === 0) { // Security check $content = file_get_contents($file); $ext = pathinfo($file, PATHINFO_EXTENSION); if ($ext == 'txt' || $ext == 'json') { echo '' . htmlspecialchars($content) . ''; echo ' '; echo ''; // Check for language metadata $jsonFile = pathinfo($file, PATHINFO_DIRNAME) . '/' . pathinfo($file, PATHINFO_FILENAME) . '.json'; if (file_exists($jsonFile)) { $meta = json_decode(file_get_contents($jsonFile), true); echo '
Language: ' . htmlspecialchars($meta['language'] ?? 'None') . '
'; } } else { echo '' . htmlspecialchars($content) . ''; } } } } } ?>