2024-06-24 11:52:30 +08:00
|
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Here is your custom functions.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Is Url In Domain With Path
|
|
|
|
|
* @param $urlToCheck
|
|
|
|
|
* @param $baseUrl
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
function isUrlInDomainWithPath($urlToCheck,$baseUrl): bool
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// 解析基础 URL
|
|
|
|
|
$baseUrlParts = parse_url($baseUrl);
|
|
|
|
|
if (!$baseUrlParts) {
|
|
|
|
|
return false; // 解析失败
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$basePath = $baseUrlParts['path'] ?? '';
|
|
|
|
|
|
|
|
|
|
// 去除路径末尾的斜杠(如果有的话)
|
|
|
|
|
$basePath = rtrim($basePath, '/');
|
|
|
|
|
|
|
|
|
|
// 解析要检查的 URL(只提取主机名)
|
|
|
|
|
$urlToCheckParts = parse_url($urlToCheck);
|
|
|
|
|
if (!$urlToCheckParts) {
|
|
|
|
|
return false; // 解析失败
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$checkHost = $urlToCheckParts['host'] ?? '';
|
|
|
|
|
|
|
|
|
|
// 比较主机名是否相同,并且检查路径是否包含要检查的 URL 的主机名(这里其实是检查整个路径)
|
|
|
|
|
if ($basePath === $checkHost && strpos($urlToCheck,$basePath) !== false) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2024-11-25 10:11:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function get_week_days() {
|
|
|
|
|
// 获取当前日期
|
|
|
|
|
$currentDate = new DateTime();
|
|
|
|
|
|
|
|
|
|
// 获取本周的周一(使用ISO-8601标准:一周的开始是周一)
|
|
|
|
|
$currentDate->modify('this week monday');
|
|
|
|
|
|
|
|
|
|
// 存储周一到周日的日期
|
|
|
|
|
$weekDays = [];
|
|
|
|
|
|
|
|
|
|
// 循环获取本周的每一天
|
|
|
|
|
for ($i = 0; $i < 7; $i++) {
|
|
|
|
|
// 获取当前日期并添加到数组
|
|
|
|
|
$weekDays[] = [
|
|
|
|
|
'date' => $currentDate->format('Y-m-d')
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 将日期调整到下一个日期(例如,周二 -> 周三)
|
|
|
|
|
$currentDate->modify('+1 day');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $weekDays;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getNewOrderId($type) {
|
|
|
|
|
list($msec, $sec) = explode(' ', microtime());
|
|
|
|
|
$msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', '');
|
|
|
|
|
$orderId = $type . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369));
|
|
|
|
|
return $orderId;
|
|
|
|
|
}
|