This commit is contained in:
2026-03-01 21:05:19 +08:00
parent 0a45a8fbb9
commit 92948fa856
39 changed files with 594 additions and 269 deletions
+1 -117
View File
@@ -185,34 +185,6 @@ if (!function_exists('captcha_verfiy')) {
return true;
}
}
if (!function_exists('aesencode')) {
function aesencode($str, $key = '')
{
if (!$key) {
$key = Config('pay.api_token');
}
if (is_array($str) || is_object($str)) {
$str = json_encode($str, JSON_UNESCAPED_UNICODE);
}
$key = hash('sha256', $key, true);
$iv = substr($key, 0, 16);
$encrypted = openssl_encrypt($str, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
return base64_encode($encrypted);
}
}
if (!function_exists('aesdecode')) {
function aesdecode($str, $key = '')
{
if (!$key) {
$key = Config('pay.api_token');
}
$key = hash('sha256', $key, true);
$iv = substr($key, 0, 16);
$encrypted = base64_decode($str);
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
return $decrypted;
}
}
if (!function_exists('cdnurl')) {
function cdnurl($path = '')
{
@@ -233,73 +205,6 @@ if (!function_exists('abort')) {
throw new \support\exception\BusinessException($msg, $code);
}
}
if (!function_exists('idEncode')) {
function idEncode($id = '')
{
if($id<=100234){return $id.'';}
return id_encode($id);
}
}
if (!function_exists('idDecode')) {
function idDecode($id = '')
{
$_id= intval($id);
if($_id == $id){return $id;}
return id_decode($id);
}
}
/**
* 生成可逆的邀请码(8位,含校验位)
* @param int $id 用户ID(需≥1000
* @return string 大写字母+数字组合
*/
if (!function_exists('base62Encode')) {
function base62Encode(int $id,$secret='your_secret_salt'): string {
// 添加校验位(防止篡改)
$hash = crc32($id . $secret) % 1000;
$code_num = $id * 1000 + $hash;
// Base62 编码(0-9A-Za-z
$base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$code = '';
while ($code_num > 0) {
$code = $base62[$code_num % 62] . $code;
$code_num = (int)($code_num / 62);
}
// 补全到8位
return str_pad($code, 8, '0', STR_PAD_LEFT);
}
}
/**
* 从邀请码解析用户ID
* @return int|false 成功返回id,失败返回false
*/
if (!function_exists('base62Decode')) {
function base62Decode(string $code,$secret='your_secret_salt'): int|false {
$base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
$code_num = 0;
// Base62 解码
for ($i = 0; $i < strlen($code); $i++) {
$pos = strpos($base62, $code[$i]);
if ($pos === false) return false;
$code_num = $code_num * 62 + $pos;
}
// 分离校验位
$id = (int)($code_num / 1000);
$hash = $code_num % 1000;
// 校验
if (crc32($id . $secret) % 1000 != $hash) {
return false;
}
return $id;
}
}
if (!function_exists('P')) {
function P()
@@ -614,22 +519,6 @@ if (!function_exists('build_invite_code')) {
}
}
if (!function_exists('layun_auth')) {
function layun_auth($type = "url", $version = 1)
{
if ($type == 'url') {
$key = "";
$sercet = "2RxmtM";
if ($version == 1) {
$time = time();
$hash = md5($time . '_' . md5($time . '_' . $sercet));
} else {
}
}
}
}
if (!function_exists('get_parent_id')) {
function get_parent_id($user_id)
{
@@ -712,12 +601,7 @@ if(!function_exists('enum_dir')){
return $list ;
}
}
if(!function_exists('generateShortUniqueID')){
function generateShortUniqueID($length = 8) {
// 生成指定长度的随机字节,转为 Base64 编码并去除不必要字符
return substr(bin2hex(random_bytes($length / 2)), 0, $length);
}
}
if(!function_exists('get_user_rights')){
function get_user_rights($user_id):array{
$user_id = idDecode($user_id);