where("userid", $this->userid)->order("id desc")->paginate(["page" => $page, 'list_rows' => 5]); $count = $result->total(); ?> 外部链接合并 - <?php echo IN_NAME; ?> - 免费应用内测托管平台|iOS应用Beta测试分发|Android应用内测分发 static_(); ?> header(); ?>
我的应用 / 应用列表 / 外部链接合并
外部链接合并
设置提示:本功能可将外部的ios链接或安卓链接,来和本站的链接进行合并到一起使用, 以便更好的管理不同平台链接的使用,可生成二维码和短链接。
">
iOS系统
安卓系统
">
0): ?>
ID 安卓地址 IOS地址 短链接 添加时间 操作
暂无记录

暂无任何数据

提示:请您确认您合并的二维码,符合 《审核规范》,如违反规范,APP将做删除处理,屡次合并二维码将被封禁账号。
根据最新审核规范,不接受如下APP在平台进行合并二维码:色情类、直播类、金融类、区块链虚拟币等。如已合并,将做删除处理。
footer(); ?> userlogined ? "已登录" : "未登录")); if (!$this->userlogined) { error_log("用户未登录,返回错误"); $response = [ "qrcode_path" => "", "status" => 0, "msg" => "请先登录后再操作!", "shortUrl" => "" ]; echo json_encode($response); exit; } $_var_3 = SafeRequest("ios_url"); $_var_4 = SafeRequest("android_url"); error_log("接收到的参数 - ios_url: " . $_var_3 . ", android_url: " . $_var_4); if (!$_var_3) { $response = [ "qrcode_path" => "", "status" => 0, "msg" => "请输入iOS地址!", "shortUrl" => "" ]; echo json_encode($response); exit; } if (!$_var_4) { $response = [ "qrcode_path" => "", "status" => 0, "msg" => "请输入Android地址!", "shortUrl" => "" ]; echo json_encode($response); exit; } // 验证URL格式和安全性 if (!$this->isValidUrl($_var_3)) { $response = [ "qrcode_path" => "", "status" => 0, "msg" => "iOS地址格式无效!", "shortUrl" => "" ]; echo json_encode($response); exit; } if (!$this->isValidUrl($_var_4)) { $response = [ "qrcode_path" => "", "status" => 0, "msg" => "Android地址格式无效!", "shortUrl" => "" ]; echo json_encode($response); exit; } // 生成短链接 $_var_5 = $this->generateShortUrl(); error_log("生成的短链接: " . $_var_5); // 生成短链接URL $short_url = "http://" . $_SERVER['HTTP_HOST'] . "/" . $_var_5; error_log("生成的短链接URL: " . $short_url); // 生成二维码图片路径 $qrcode_url = "http://" . $_SERVER['HTTP_HOST'] . "/qrcode?link=" . urlencode($short_url); error_log("生成的二维码URL: " . $qrcode_url); // 保存到数据库 - 按照指定格式 $insert_data = [ "userid" => $this->userid, "username" => $this->username, "android" => $_var_4, // android字段存储android_url "ios" => $_var_3, // ios字段存储ios_url "link" => $short_url, // link字段存储短链接URL "short" => $_var_5, // short字段存储短链接标识符 "ctime" => time() ]; error_log("插入数据: " . json_encode($insert_data)); try { $_var_7 = db("combine")->insertGetId($insert_data); error_log("数据库插入结果: " . $_var_7); } catch (Exception $e) { error_log("数据库错误: " . $e->getMessage()); $response = [ "qrcode_path" => "", "status" => 0, "msg" => "数据库操作失败,请稍后重试!", "shortUrl" => "" ]; echo json_encode($response); exit; } if ($_var_7) { // 使用新的返回格式 $response = [ "qrcode_path" => $qrcode_url, "status" => 1, "msg" => "success", "shortUrl" => $short_url // 返回完整的短链接URL ]; error_log("成功响应: " . json_encode($response)); echo json_encode($response); } else { $response = [ "qrcode_path" => "", "status" => 0, "msg" => "生成失败!", "shortUrl" => "" ]; error_log("失败响应: " . json_encode($response)); echo json_encode($response); } error_log("=== down() 方法执行完成 ==="); exit; } function download() { $_var_8 = SafeRequest("qrcode_path"); if (!$_var_8) { reJSON("参数错误!", 404); } // 修复路径遍历漏洞 $qrcode_path = $_var_8; // 验证路径格式,只允许字母数字和基本符号 if (!preg_match('/^[a-zA-Z0-9\/\-_\.]+$/', $qrcode_path)) { reJSON("无效的文件路径!", 403); } // 确保路径在允许的目录内 $allowed_dirs = ['/uploads/qrcode/', '/qrcode/']; $is_allowed = false; foreach ($allowed_dirs as $dir) { if (strpos($qrcode_path, $dir) === 0) { $is_allowed = true; break; } } if (!$is_allowed) { reJSON("访问被拒绝!", 403); } $file_path = $_SERVER['DOCUMENT_ROOT'] . $qrcode_path; // 防止目录遍历 $real_path = realpath($file_path); $doc_root = realpath($_SERVER['DOCUMENT_ROOT']); if ($real_path === false || strpos($real_path, $doc_root) !== 0) { reJSON("文件不存在!", 404); } if (file_exists($file_path)) { // 验证文件类型 $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime_type = finfo_file($finfo, $file_path); finfo_close($finfo); if ($mime_type !== 'image/png' && $mime_type !== 'image/jpeg' && $mime_type !== 'image/gif') { reJSON("不支持的文件类型!", 403); } header('Content-Type: ' . $mime_type); header('Content-Disposition: attachment; filename="qrcode.png"'); readfile($file_path); exit; } else { reJSON("文件不存在!", 404); } } private function generateShortUrl() { $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; $short_url = ''; // 使用更安全的随机数生成方法 if (function_exists('random_bytes')) { $random_bytes = random_bytes(6); for ($i = 0; $i < 6; $i++) { $short_url .= $chars[ord($random_bytes[$i]) % strlen($chars)]; } } elseif (function_exists('openssl_random_pseudo_bytes')) { $random_bytes = openssl_random_pseudo_bytes(6); for ($i = 0; $i < 6; $i++) { $short_url .= $chars[ord($random_bytes[$i]) % strlen($chars)]; } } else { // 降级到rand(),但增加熵 for ($i = 0; $i < 6; $i++) { $short_url .= $chars[rand(0, strlen($chars) - 1)]; } } return $short_url; // 只返回短链接标识符,不包含域名 } private function generateQrcodeImage($url) { $qrcode_path = '/uploads/qrcode/' . md5($url) . '.png'; return $qrcode_path; } private function isValidUrl($url) { // 基本URL格式验证 if (!filter_var($url, FILTER_VALIDATE_URL)) { return false; } // 解析URL $parsed_url = parse_url($url); if (!$parsed_url || !isset($parsed_url['scheme']) || !isset($parsed_url['host'])) { return false; } // 只允许HTTP和HTTPS协议 if (!in_array($parsed_url['scheme'], ['http', 'https'])) { return false; } // 检查是否为私有IP地址(防止SSRF) $host = $parsed_url['host']; $ip = gethostbyname($host); if ($ip && $ip !== $host) { // 检查是否为私有IP if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) { // 这是公网IP,允许 } else { // 这是私有IP或保留IP,拒绝 return false; } } // 检查URL长度限制 if (strlen($url) > 2048) { return false; } return true; } }