a6f2284f51
# Conflicts: # app/common/controller/AuthController.php # app/common/logic/AuthLogic.php # app/common/model/User.php # app/controller/IndexController.php # app/functions.php # app/middleware/AuthCheck.php # app/view/index/qrcode.html # composer.json # composer.lock # config/middleware.php # config/route.php # config/whitelist.php
77 lines
2.0 KiB
PHP
77 lines
2.0 KiB
PHP
<?php
|
|
/**
|
|
* Here is your custom functions.
|
|
*/
|
|
|
|
/**
|
|
* 标准化账号参数
|
|
*
|
|
* @param string $account 用户输入的账号(可能是手机号或邮箱)
|
|
* @return array 返回 ['phone' => $account] 或 ['email' => $account]
|
|
*/
|
|
if (!function_exists('normalizeAccount')) {
|
|
function normalizeAccount(string $account): array
|
|
{
|
|
// 使用FILTER_VALIDATE_EMAIL验证邮箱格式
|
|
if (filter_var($account, FILTER_VALIDATE_EMAIL)) {
|
|
return ['email' => $account];
|
|
}
|
|
|
|
// 清理手机号中的非数字字符
|
|
$cleanPhone = preg_replace('/[^0-9]/', '', $account);
|
|
|
|
// 验证手机号格式(简单版:11位数字)
|
|
if (preg_match('/^1[3-9]\d{9}$/', $cleanPhone)) {
|
|
return ['phone' => $cleanPhone];
|
|
}
|
|
|
|
// 如果既不是邮箱也不是手机号,根据业务需求处理
|
|
// 这里默认按手机号处理(可根据实际需求调整)
|
|
return ['phone' => $cleanPhone];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 公共html页面
|
|
*/
|
|
if (!function_exists('htmlpage')) {
|
|
function htmlpage()
|
|
{
|
|
static $html;
|
|
if (!$html) {
|
|
$html = file_get_contents(public_path('mzl.html'));
|
|
}
|
|
return $html;
|
|
}
|
|
}
|
|
/**
|
|
* 获取配置
|
|
*/
|
|
if (!function_exists('getConfig')) {
|
|
function getConfig($filePath = null)
|
|
{
|
|
// 构建文件路径
|
|
$config_file = app_path($filePath);
|
|
// 检查文件是否存在
|
|
if (!file_exists($config_file)) {
|
|
return [];
|
|
}
|
|
// 包含文件并获取返回的数组
|
|
$config = include $config_file;
|
|
// 验证是否为数组
|
|
if (!is_array($config)) {
|
|
return [];
|
|
}
|
|
return $config;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* 调试用
|
|
*/
|
|
if (!function_exists('dpr')) {
|
|
function dpr(\Throwable $e)
|
|
{
|
|
var_dump("=== === 报错打印 === ===", "文件:".$e->getFile(), "行数:".$e->getLine(), "详情:".$e->getMessage(), "=== === 报错打印 === ===");
|
|
}
|
|
} |