Files
Fuxsto-V3/user/mods/ep1/Main.php
2025-10-18 14:46:52 +08:00

116 lines
2.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
function kanglehost_CreateSign($a, $r)
{
return md5($a . "通信密匙" . $r);
}
function kanglehost_GetUrl($info, $skey, $r)
{
$url = "";
foreach ($info as $k => $v) {
$url .= $k . "=" . $v . "&";
}
return "http://38.55.233.203:3312/api/index.php?" . $url . "r=" . $r . "&s=" . $skey . "&json=1";
}
function open_products($data,$post) {
$a = "add_vh";
$r = rand(100000, 999999);
$user = onlystr(10); // 随机生成用户名
$pass = onlystr(15); // 随机生成密码
$currentDate = date('Y-m-d'); // 获取当前日期
$futureDate = date('Y-m-d', strtotime($currentDate . ' +30 days')); // 计算30天后的日期
$info = [
"c" => "whm",
"a" => $a,
"init" => 1,
"name" => $user,
"passwd" => $pass,
"product_id" => 1
];
$skey = kanglehost_CreateSign($a, $r); // 修正函数名称大小写
$url = kanglehost_GetUrl($info, $skey, $r); // 修正函数名称大小写
$re = @file_get_contents($url);
$re = json_decode($re, true);
if (!isset($re['result'])) {
$code = 100; // 错误处理如果result不存在设为100
} else {
$code = $re['result'];
}
$data['dqtime'] = $futureDate;
$data['username'] = $user;
$data['password'] = $pass;
if ($code == 200) {
$data['mid'] = onlystr(8);
$data['msg'] = $re;
$data['code'] = 200;
$data['status'] = '已激活';
} else {
$data['mid'] = onlystr(8);
$data['msg'] = $re;
$data['code'] = 100;
$data['status'] = '待开通';
}
return $data;
}
function show_product($data) {
$templatePath = './mods/ep1/index.html'; // 模板路径
$variables = $data;
return h_t($templatePath, $variables);
}
function long_product($data) {
$date = new DateTime($data['dqtime']);
$date->modify('+' . $data['Today'] . ' days'); // 假设'Today'是$data数组中的一个键
$data['dqtime'] = $date->format('Y-m-d');
return $data;
}
function stop_product($data) {
$data['status'] = '已到期';
$a = "del_vh";
$r = rand(100000, 999999);
$info = ["c" => "whm", "a" => $a, "name" => $data['username']];
$skey = kanglehost_CreateSign($a, $r); // 修正函数名称大小写
$url = kanglehost_GetUrl($info, $skey, $r); // 修正函数名称大小写
$re = @file_get_contents($url);
$data['msg'] = $re;
$re = json_decode($re, true);
$data['code'] = $re["result"];
return $data;
}
function ready_products($data) {
$templatePath = './mods/ep1/ready.html'; // 模板路径
$variables = $data;
$variables["id"] = $_GET["id"];
return h_t($templatePath, $variables);
}