url = $value; } elseif ($param == 'me') { $this->method = strtoupper($value); } else { throw new Exception("Unknown parameter $param"); } } // 添加提交数据 public function add($key, $value) { $this->data[$key] = $value; } // 发起提交请求 public function run() { $ch = curl_init(); // 根据请求方法设置URL和数据 if ($this->method == 'POST') { curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($this->data)); } elseif ($this->method == 'GET') { $query = http_build_query($this->data); curl_setopt($ch, CURLOPT_URL, $this->url . '?' . $query); } else { throw new Exception("Invalid method $this->method"); } // 常规设置 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 60); // 新增选项以跳过SSL证书和主机名验证 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过对证书的验证 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 跳过对主机名的验证 // 执行请求并捕获响应 $response = curl_exec($ch); $error = curl_error($ch); curl_close($ch); // 返回结果 if ($error) { $result = ['success' => false, 'error' => $error]; } else { $result = ['success' => true, 'response' => $response]; } return json_encode($result); } } // 默认AES密钥 $key = "12454545454434"; // 定义 v_in 函数(加密函数) function v_in($plaintext) { global $key; // 使用全局变量 $iv = openssl_random_pseudo_bytes(openssl_cipher_iv_length('aes-256-cbc')); $ciphertext = openssl_encrypt($plaintext, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv); return base64_encode($iv . $ciphertext); // 传输 IV 与密文 } // 定义 v_ou 函数(解密函数) function v_ou($ciphertext) { global $key; // 使用全局变量 $data = base64_decode($ciphertext); $ivLength = openssl_cipher_iv_length('aes-256-cbc'); // 提取 IV 和密文 $iv = substr($data, 0, $ivLength); $ciphertextWithoutIV = substr($data, $ivLength); // 解密并返回明文 return openssl_decrypt($ciphertextWithoutIV, 'aes-256-cbc', $key, OPENSSL_RAW_DATA, $iv); } function romstr($length = 10) { // 定义可用字符集合(大写字母和数字) $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $charactersLength = strlen($characters); $randomString = ''; // 随机生成字符串 for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function isValidInteger($value) { // 检查是否是纯数字并且是整数 if (is_numeric($value) && intval($value) == $value) { // 检查是否在1到1000之间 if ($value >= 1 && $value <= 1000) { return true; } } return false; } // 生成唯一的10位数字和小写字母组合,并写入文件 function c_only_user($filePath = './inuse.txt') { // 定义一个生成10位数字加小写字母组合的函数 function generateRandomString($length = 10) { // 可选字符集:小写字母和数字 $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } // 检查文件是否存在,不存在则创建一个空文件 if (!file_exists($filePath)) { file_put_contents($filePath, ''); } // 获取文件内容,并将每一行内容存入数组中 $usedStrings = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); // 初始化生成的字符串变量 $uniqueString = ''; // 不断生成直到生成一个唯一的字符串 do { $uniqueString = generateRandomString(); } while (in_array($uniqueString, $usedStrings)); // 将生成的唯一字符串追加到文件中,并换行 file_put_contents($filePath, $uniqueString . PHP_EOL, FILE_APPEND); // 返回生成的唯一字符串 return $uniqueString; } // 生成包含数字和英文字符的随机字符串 function onlystr($length = 10, $file = 'generated_strings.txt') { // 定义数字和英文字符 $characters = 'abcdefghijklmnopqrstuvwxyz0123456789'; // 将生成过的字符串存储在文件中 $generatedStrings = []; // 读取文件中的已生成字符串 if (file_exists($file)) { $generatedStrings = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); } // 开始生成不重复的字符串 do { $randomString = ''; for ($i = 0; $i < $length; $i++) { // 从字符池中随机选择一个字符 $randomString .= $characters[rand(0, strlen($characters) - 1)]; } } while (in_array($randomString, $generatedStrings)); // 检查是否重复 // 将新生成的字符串追加到文件中 file_put_contents($file, $randomString . PHP_EOL, FILE_APPEND); return $randomString; } function h_t($templatePath, $variables = []) { // 检查模板文件是否存在 if (!file_exists($templatePath)) { throw new Exception("模板文件不存在: " . $templatePath); } // 获取模板文件内容 $templateContent = file_get_contents($templatePath); // 替换模板中的变量(例如 {{user}} 替换为 $user 的值) foreach ($variables as $key => $value) { // 使用正则表达式匹配 {{variable}} 形式的占位符并替换为对应的值 $templateContent = str_replace("{{\$$key}}", htmlspecialchars($value, ENT_QUOTES), $templateContent); } // 返回处理后的内容 return $templateContent; } function log_wt($type, $content, $logName) { // 获取当前时间,格式为 "年 月 日 时:分:秒" $timestamp = date("Y m d H:i:s"); // 获取客户端 IP 地址 $ipAddress = $_SERVER['REMOTE_ADDR'] ?? 'UNKNOWN'; // 构造日志内容 $logEntry = "[$timestamp] - [$type] - [$ipAddress] - $content\n"; $directory = './me/'.$_SESSION['user']; // 替换为你的目录路径 $items = scandir($directory); // 获取目录下的所有文件和文件夹 $firstDir = null; foreach ($items as $item) { if ($item != '.' && $item != '..' && is_dir($directory . '/' . $item)) { $pass = $item; break; // 找到第一个目录后退出循环 } } // 确保日志目录存在(可以根据需要修改日志存放路径) $logDirectory = "./me/" . $_SESSION['user'] . "/" . $pass . "/logs"; if (!is_dir($logDirectory)) { mkdir($logDirectory, 0777, true); } // 设置日志文件路径 $logFilePath = "$logDirectory/$logName.log"; $archiveFilePath = "$logDirectory/{$logName}_archive.log"; // 检查日志文件行数,超过 5000 行则归档 if (file_exists($logFilePath)) { $lineCount = count(file($logFilePath)); if ($lineCount >= 5000) { // 将内容附加到总日志文件 file_put_contents($archiveFilePath, file_get_contents($logFilePath), FILE_APPEND); // 清空当前日志文件 file_put_contents($logFilePath, ""); } } // 将日志内容追加写入日志文件 file_put_contents($logFilePath, $logEntry, FILE_APPEND); }