|
...
|
...
|
@@ -13,6 +13,7 @@ use GuzzleHttp\Client; |
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
|
|
define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/');
|
|
...
|
...
|
@@ -28,7 +29,7 @@ define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); |
|
|
|
if (!function_exists('generateRoute')) {
|
|
|
|
function generateRoute($string)
|
|
|
|
{
|
|
|
|
if(is_array($string)){
|
|
|
|
if (is_array($string)) {
|
|
|
|
$string = $string[0];
|
|
|
|
}
|
|
|
|
$sign = str_replace(".", "", trim(strtolower(preg_replace('/[^\w.]+/', '-', trim($string))), '-'));
|
|
...
|
...
|
@@ -61,7 +62,7 @@ if (!function_exists('http_post')) { |
|
|
|
* @param type $url
|
|
|
|
* @param type $post_data
|
|
|
|
*/
|
|
|
|
function http_post($url, $post_data, $header = [],$is_json = true,$timeout = 60)
|
|
|
|
function http_post($url, $post_data, $header = [], $is_json = true, $timeout = 60)
|
|
|
|
{
|
|
|
|
if (empty($header)) {
|
|
|
|
$header = array(
|
|
...
|
...
|
@@ -87,7 +88,7 @@ if (!function_exists('http_post')) { |
|
|
|
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($error_message, true) . PHP_EOL, FILE_APPEND);
|
|
|
|
}
|
|
|
|
curl_close($ch);
|
|
|
|
if($is_json){
|
|
|
|
if ($is_json) {
|
|
|
|
return json_decode($res, true);
|
|
|
|
}
|
|
|
|
return trim($res);
|
|
...
|
...
|
@@ -106,7 +107,7 @@ if (!function_exists('http_get')) { |
|
|
|
if (empty($header)) {
|
|
|
|
$header[] = "content-type: application/json";
|
|
|
|
}
|
|
|
|
$ch1 = curl_init();
|
|
|
|
$ch1 = curl_init();
|
|
|
|
$timeout = 0;
|
|
|
|
curl_setopt($ch1, CURLOPT_URL, $url);
|
|
|
|
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
|
|
...
|
...
|
@@ -130,7 +131,7 @@ if (!function_exists('http_get')) { |
|
|
|
|
|
|
|
|
|
|
|
if (!function_exists('curl_get')) {
|
|
|
|
function curl_get($url,$is_array=true)
|
|
|
|
function curl_get($url, $is_array = true)
|
|
|
|
{
|
|
|
|
$header = array(
|
|
|
|
'Expect:',
|
|
...
|
...
|
@@ -161,7 +162,8 @@ if (!function_exists('curl_get')) { |
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/5 10:38
|
|
|
|
*/
|
|
|
|
function contains_russian($text) {
|
|
|
|
function contains_russian($text)
|
|
|
|
{
|
|
|
|
// 使用正则表达式检查是否包含俄语字符
|
|
|
|
return preg_match('/[\x{0400}-\x{04FF}]/u', $text) > 0;
|
|
|
|
|
|
...
|
...
|
@@ -176,7 +178,8 @@ if (!function_exists('curl_c')) { |
|
|
|
* @author Akun
|
|
|
|
* @date 2023/11/22 11:33
|
|
|
|
*/
|
|
|
|
function curl_c($url,$is_array=true,$replace=[]){
|
|
|
|
function curl_c($url, $is_array = true, $replace = [])
|
|
|
|
{
|
|
|
|
$header = array(
|
|
|
|
'Expect:',
|
|
|
|
'Content-Type: application/json; charset=utf-8'
|
|
...
|
...
|
@@ -195,16 +198,16 @@ if (!function_exists('curl_c')) { |
|
|
|
curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
|
$content = curl_exec($ch);
|
|
|
|
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
|
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
curl_close($ch);
|
|
|
|
if($http_code == 200){
|
|
|
|
if(!empty($replace)){
|
|
|
|
foreach ($replace as $k=>$v){
|
|
|
|
$content = str_replace($k,$v,$content);
|
|
|
|
if ($http_code == 200) {
|
|
|
|
if (!empty($replace)) {
|
|
|
|
foreach ($replace as $k => $v) {
|
|
|
|
$content = str_replace($k, $v, $content);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $is_array ? json_decode($content, true) : $content;
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -218,7 +221,8 @@ if (!function_exists('curl_code')) { |
|
|
|
* @author Akun
|
|
|
|
* @date 2023/11/22 11:33
|
|
|
|
*/
|
|
|
|
function curl_code($url,$is_array=true){
|
|
|
|
function curl_code($url, $is_array = true)
|
|
|
|
{
|
|
|
|
$header = array(
|
|
|
|
'Expect:',
|
|
|
|
'Content-Type: application/json; charset=utf-8'
|
|
...
|
...
|
@@ -237,11 +241,11 @@ if (!function_exists('curl_code')) { |
|
|
|
curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
|
$content = curl_exec($ch);
|
|
|
|
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
|
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
curl_close($ch);
|
|
|
|
if($http_code == 200){
|
|
|
|
if ($http_code == 200) {
|
|
|
|
return $is_array ? json_decode($content, true) : $content;
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
return $http_code;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -260,7 +264,7 @@ if (!function_exists('_get_child')) { |
|
|
|
foreach ($arr as $v) {
|
|
|
|
$v = (array)$v;
|
|
|
|
if ($v['pid'] == $my_id) {
|
|
|
|
$v['sub'] = _get_child($v['id'], $arr);
|
|
|
|
$v['sub'] = _get_child($v['id'], $arr);
|
|
|
|
$new_arr[] = $v;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -274,7 +278,7 @@ if (!function_exists('_get_all_sub')) { |
|
|
|
* @param int
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function _get_all_sub($my_id,$id_Arr)
|
|
|
|
function _get_all_sub($my_id, $id_Arr)
|
|
|
|
{
|
|
|
|
$new_arr[] = $my_id;
|
|
|
|
foreach ($id_Arr as $v) {
|
|
...
|
...
|
@@ -302,7 +306,7 @@ if (!function_exists('checkDomain')) { |
|
|
|
if (empty($urlParts['host'])) {
|
|
|
|
$urlParts = parse_url('https://' . $value);
|
|
|
|
}
|
|
|
|
$host = $urlParts['host'] ?? '';
|
|
|
|
$host = $urlParts['host'] ?? '';
|
|
|
|
$scheme = $urlParts['scheme'] ?? 'https';
|
|
|
|
if (!in_array($scheme, ['http', 'https'])) {
|
|
|
|
return false;
|
|
...
|
...
|
@@ -380,7 +384,7 @@ function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = '_child', $root |
|
|
|
// 如果是数字,则是root
|
|
|
|
if (is_numeric($pk)) {
|
|
|
|
$root = $pk;
|
|
|
|
$pk = 'id';
|
|
|
|
$pk = 'id';
|
|
|
|
}
|
|
|
|
// 创建Tree
|
|
|
|
$tree = array();
|
|
...
|
...
|
@@ -505,7 +509,7 @@ if (!function_exists('getPreviousDaysDate')) { |
|
|
|
$days = [];
|
|
|
|
while ($day > 0) {
|
|
|
|
$days[] = date("Y-m-d", strtotime("-{$day} days"));
|
|
|
|
$day -= 1;
|
|
|
|
$day -= 1;
|
|
|
|
}
|
|
|
|
return $days;
|
|
|
|
}
|
|
...
|
...
|
@@ -522,7 +526,7 @@ if (!function_exists('getPreviousMonthsDate')) { |
|
|
|
$months = [];
|
|
|
|
while ($month > 0) {
|
|
|
|
$months[] = date("Y-m", strtotime("-{$month} months"));
|
|
|
|
$month -= 1;
|
|
|
|
$month -= 1;
|
|
|
|
}
|
|
|
|
return $months;
|
|
|
|
}
|
|
...
|
...
|
@@ -536,17 +540,17 @@ if (!function_exists('getInquiryInformation')) { |
|
|
|
*/
|
|
|
|
function getInquiryInformation($domain, $sta_date)
|
|
|
|
{
|
|
|
|
$token = md5($domain . date("Y-m-d"));
|
|
|
|
$token = md5($domain . date("Y-m-d"));
|
|
|
|
$source = '1,3';
|
|
|
|
$url = "https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?domain={$domain}&token={$token}&source={$source}&sta_date={$sta_date}";
|
|
|
|
$url = "https://www.globalso.site/api/external-interface/country_con/15243d63ed5a5738?domain={$domain}&token={$token}&source={$source}&sta_date={$sta_date}";
|
|
|
|
$client = new Client(['verify' => false]);
|
|
|
|
$http = $client->get($url);
|
|
|
|
$data = [];
|
|
|
|
$http = $client->get($url);
|
|
|
|
$data = [];
|
|
|
|
if ($http->getStatusCode() != 200) {
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
$content = $http->getBody()->getContents();
|
|
|
|
$json = json_decode($content, true);
|
|
|
|
$json = json_decode($content, true);
|
|
|
|
if ($json['status'] != 200) {
|
|
|
|
return $content;
|
|
|
|
}
|
|
...
|
...
|
@@ -597,7 +601,7 @@ if (!function_exists('checkIsMonth')) { |
|
|
|
$now = time();
|
|
|
|
// 获取当月的起始时间戳和结束时间戳
|
|
|
|
$firstDay = strtotime(date('Y-m-01', $now));
|
|
|
|
$lastDay = strtotime(date('Y-m-t', $now));
|
|
|
|
$lastDay = strtotime(date('Y-m-t', $now));
|
|
|
|
// 传入日期的时间戳
|
|
|
|
$timestamp = strtotime($date);
|
|
|
|
// 判断传入日期是否在当月范围内
|
|
...
|
...
|
@@ -621,8 +625,8 @@ if (!function_exists('getDateDays')) { |
|
|
|
if (!is_null($date)) {
|
|
|
|
$dd = explode('-', $date);
|
|
|
|
if (!checkIsGreaterMonth($date) && !checkIsMonth($date)) {
|
|
|
|
$year = $dd[0];
|
|
|
|
$month = $dd[1];
|
|
|
|
$year = $dd[0];
|
|
|
|
$month = $dd[1];
|
|
|
|
$first_day_of_month = "{$year}-{$month}-01";
|
|
|
|
return getDateArray("{$year}-{$month}-" . date("t", strtotime($first_day_of_month)));
|
|
|
|
}
|
|
...
|
...
|
@@ -641,7 +645,7 @@ if (!function_exists('getDateArray')) { |
|
|
|
function getDateArray(string $date)
|
|
|
|
{
|
|
|
|
list($year, $month, $day) = explode('-', date($date));
|
|
|
|
$i = 1;
|
|
|
|
$i = 1;
|
|
|
|
$days = [];
|
|
|
|
while ($i <= $day) {
|
|
|
|
$days[] = "{$year}-{$month}-" . str_pad($i, 2, "0", STR_PAD_LEFT);
|
|
...
|
...
|
@@ -659,34 +663,35 @@ if (!function_exists('getImageUrl')) { |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/20 16:46
|
|
|
|
*/
|
|
|
|
function getImageUrl($path,$storage_type = 0,$location = 0,$image_cdn = 1){
|
|
|
|
if(is_array($path)){
|
|
|
|
$url =[];
|
|
|
|
foreach ($path as $v){
|
|
|
|
$url[] = getImageUrl($v,$storage_type,$location);
|
|
|
|
function getImageUrl($path, $storage_type = 0, $location = 0, $image_cdn = 1)
|
|
|
|
{
|
|
|
|
if (is_array($path)) {
|
|
|
|
$url = [];
|
|
|
|
foreach ($path as $v) {
|
|
|
|
$url[] = getImageUrl($v, $storage_type, $location);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(empty($path)){
|
|
|
|
} else {
|
|
|
|
if (empty($path)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
|
|
|
|
return $path;
|
|
|
|
if ((strpos($path, 'https://') !== false) || (strpos($path, 'http://') !== false)) {
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
if(substr($path,0,2) == '//'){
|
|
|
|
return 'https:'.$path;
|
|
|
|
if (substr($path, 0, 2) == '//') {
|
|
|
|
return 'https:' . $path;
|
|
|
|
}
|
|
|
|
if($location == 0){
|
|
|
|
if ($location == 0) {
|
|
|
|
$cos = config('filesystems.disks.cos');
|
|
|
|
if($image_cdn == 0){//v6链接
|
|
|
|
if ($image_cdn == 0) {//v6链接
|
|
|
|
$cosCdn = $cos['cdn2'];
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
|
|
|
|
}
|
|
|
|
$url = $cosCdn.$path;
|
|
|
|
}else{
|
|
|
|
$url = $cosCdn . $path;
|
|
|
|
} else {
|
|
|
|
$s3 = config('filesystems.disks.s3');
|
|
|
|
$cdn = $s3['cdn'];
|
|
|
|
$url = $cdn.$path;
|
|
|
|
$url = $cdn . $path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $url;
|
|
...
|
...
|
@@ -701,36 +706,37 @@ if (!function_exists('getFileUrl')) { |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/20 16:46
|
|
|
|
*/
|
|
|
|
function getFileUrl($path,$storage_type = 0,$location = 0,$file_cdn = 0){
|
|
|
|
if(is_array($path)){
|
|
|
|
$url =[];
|
|
|
|
foreach ($path as $v){
|
|
|
|
$url[] = getFileUrl($v,$storage_type,$location,$file_cdn);
|
|
|
|
function getFileUrl($path, $storage_type = 0, $location = 0, $file_cdn = 0)
|
|
|
|
{
|
|
|
|
if (is_array($path)) {
|
|
|
|
$url = [];
|
|
|
|
foreach ($path as $v) {
|
|
|
|
$url[] = getFileUrl($v, $storage_type, $location, $file_cdn);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(empty($path)){
|
|
|
|
} else {
|
|
|
|
if (empty($path)) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
if((strpos($path,'https://')!== false) || (strpos($path,'http://') !== false)){
|
|
|
|
return $path;
|
|
|
|
if ((strpos($path, 'https://') !== false) || (strpos($path, 'http://') !== false)) {
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
if(substr($path,0,2) == '//'){
|
|
|
|
return 'https:'.$path;
|
|
|
|
if (substr($path, 0, 2) == '//') {
|
|
|
|
return 'https:' . $path;
|
|
|
|
}
|
|
|
|
$file_type = pathinfo($path, PATHINFO_EXTENSION);
|
|
|
|
$fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
|
|
|
|
if(in_array(strtolower($file_type),$fileTypeArr) && ($file_cdn == 0)){
|
|
|
|
if (in_array(strtolower($file_type), $fileTypeArr) && ($file_cdn == 0)) {
|
|
|
|
$cdn2 = config('filesystems.disks.cos')['cdn2'];
|
|
|
|
return $cdn2.$path;
|
|
|
|
return $cdn2 . $path;
|
|
|
|
}
|
|
|
|
if($location == 0){
|
|
|
|
if ($location == 0) {
|
|
|
|
$cos = config('filesystems.disks.cos');
|
|
|
|
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
|
|
|
|
return $cosCdn.$path;
|
|
|
|
}else{
|
|
|
|
return $cosCdn . $path;
|
|
|
|
} else {
|
|
|
|
$s3 = config('filesystems.disks.s3');
|
|
|
|
$cdn = $s3['cdn'];
|
|
|
|
return $cdn.$path;
|
|
|
|
return $cdn . $path;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $url;
|
|
...
|
...
|
@@ -744,7 +750,8 @@ if (!function_exists('getFileUrl')) { |
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/28 17:39
|
|
|
|
*/
|
|
|
|
function characterTruncation($string,$pattern){
|
|
|
|
function characterTruncation($string, $pattern)
|
|
|
|
{
|
|
|
|
preg_match($pattern, $string, $matches);
|
|
|
|
if (isset($matches[0])) {
|
|
|
|
$result = $matches[0];
|
|
...
|
...
|
@@ -761,7 +768,8 @@ function characterTruncation($string,$pattern){ |
|
|
|
* @method :post
|
|
|
|
* @time :2024/5/14 16:24
|
|
|
|
*/
|
|
|
|
function characterTruncationStr($string,$startStr,$endStr){
|
|
|
|
function characterTruncationStr($string, $startStr, $endStr)
|
|
|
|
{
|
|
|
|
$start = strpos($string, $startStr);
|
|
|
|
$end = strpos($string, $endStr) + strlen($endStr);
|
|
|
|
return substr($string, $start, $end - $start);
|
|
...
|
...
|
@@ -798,7 +806,7 @@ if (!function_exists('str_replace_url')) { |
|
|
|
$cosCdn1 = $cos['cdn1'];
|
|
|
|
$cosCdn2 = $cos['cdn2'];
|
|
|
|
$cosCdn3 = config('filesystems.disks.s3')['cdn'];
|
|
|
|
if($url && ((strpos($url,$cosCdn) !== false) || (strpos($url,$cosCdn1) !== false) || (strpos($url,$cosCdn2) !== false) || (strpos($url,$cosCdn3) !== false))){
|
|
|
|
if ($url && ((strpos($url, $cosCdn) !== false) || (strpos($url, $cosCdn1) !== false) || (strpos($url, $cosCdn2) !== false) || (strpos($url, $cosCdn3) !== false))) {
|
|
|
|
// 外部URL无需解析
|
|
|
|
// 使用 parse_url 函数来解析 URL
|
|
|
|
$urlParts = parse_url($url);
|
|
...
|
...
|
@@ -812,7 +820,7 @@ if (!function_exists('str_replace_url')) { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!function_exists('curlGet')){
|
|
|
|
if (!function_exists('curlGet')) {
|
|
|
|
/**
|
|
|
|
* @remark :忽略证书curl请求
|
|
|
|
* @name :curlGet
|
|
...
|
...
|
@@ -820,8 +828,9 @@ if(!function_exists('curlGet')){ |
|
|
|
* @method :post
|
|
|
|
* @time :2023/9/12 10:10
|
|
|
|
*/
|
|
|
|
function curlGet($url){
|
|
|
|
$ch1 = curl_init();
|
|
|
|
function curlGet($url)
|
|
|
|
{
|
|
|
|
$ch1 = curl_init();
|
|
|
|
$timeout = 60;
|
|
|
|
curl_setopt($ch1, CURLOPT_URL, $url);
|
|
|
|
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
|
|
...
|
...
|
@@ -852,15 +861,15 @@ function ends_with($string, $suffix) |
|
|
|
* @method :post
|
|
|
|
* @time :2025/6/21 9:57
|
|
|
|
*/
|
|
|
|
function getCustomRouteMap($module_route,$route = '',$is_upgrade = 0)
|
|
|
|
function getCustomRouteMap($module_route, $route = '', $is_upgrade = 0)
|
|
|
|
{
|
|
|
|
if($is_upgrade == 0){
|
|
|
|
if ($is_upgrade == 0) {
|
|
|
|
return $route;
|
|
|
|
}
|
|
|
|
if($module_route == $route){
|
|
|
|
if ($module_route == $route) {
|
|
|
|
$resultRoute = $route;
|
|
|
|
}else{
|
|
|
|
$resultRoute = $module_route.'_catalog/'.$route;
|
|
|
|
} else {
|
|
|
|
$resultRoute = $module_route . '_catalog/' . $route;
|
|
|
|
}
|
|
|
|
return $resultRoute;
|
|
|
|
}
|
|
...
|
...
|
@@ -872,48 +881,53 @@ function getCustomRouteMap($module_route,$route = '',$is_upgrade = 0) |
|
|
|
* @method :post
|
|
|
|
* @time :2023/11/10 14:29
|
|
|
|
*/
|
|
|
|
function getRouteMap($source,$source_id,$is_upgrade = 0, $returnModel = false){
|
|
|
|
function getRouteMap($source, $source_id, $is_upgrade = 0, $returnModel = false)
|
|
|
|
{
|
|
|
|
$route = '';
|
|
|
|
$routeMapModel = new RouteMap();
|
|
|
|
$info = $routeMapModel->read(['source'=>$source,'source_id'=>$source_id]);
|
|
|
|
if($info !== false){
|
|
|
|
if($is_upgrade == 1){
|
|
|
|
if($source == $routeMapModel::SOURCE_NEWS_CATE){
|
|
|
|
if($info['route'] != 'news'){
|
|
|
|
return $routeMapModel::PATH_NEWS_CATE.'/'.$info['route'];
|
|
|
|
$info = $routeMapModel->read(['source' => $source, 'source_id' => $source_id]);
|
|
|
|
if ($info !== false) {
|
|
|
|
if ($is_upgrade == 1) {
|
|
|
|
if ($source == $routeMapModel::SOURCE_NEWS_CATE) {
|
|
|
|
if ($info['route'] != 'news') {
|
|
|
|
return $routeMapModel::PATH_NEWS_CATE . '/' . $info['route'];
|
|
|
|
}
|
|
|
|
}elseif ($source == $routeMapModel::SOURCE_BLOG_CATE){
|
|
|
|
if($info['route'] != 'blog'){
|
|
|
|
return $routeMapModel::PATH_BLOG_CATE.'/'.$info['route'];
|
|
|
|
} elseif ($source == $routeMapModel::SOURCE_BLOG_CATE) {
|
|
|
|
if ($info['route'] != 'blog') {
|
|
|
|
return $routeMapModel::PATH_BLOG_CATE . '/' . $info['route'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$route = $info['route'];
|
|
|
|
return $route;
|
|
|
|
}
|
|
|
|
if(!empty($info['path'])){
|
|
|
|
if($info['path'] == 'blog'){
|
|
|
|
$info['path'] = $info['path'].'s';
|
|
|
|
if (!empty($info['path'])) {
|
|
|
|
if ($info['path'] == 'blog') {
|
|
|
|
$info['path'] = $info['path'] . 's';
|
|
|
|
}
|
|
|
|
$route = $info['path'].'/'.$info['route'];
|
|
|
|
}else{
|
|
|
|
$route = $info['path'] . '/' . $info['route'];
|
|
|
|
} else {
|
|
|
|
$route = $info['route'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($returnModel && ($info !== false)){
|
|
|
|
if ($returnModel && ($info !== false)) {
|
|
|
|
return $info;
|
|
|
|
}
|
|
|
|
return $route;
|
|
|
|
}
|
|
|
|
|
|
|
|
function redis_get($key){
|
|
|
|
function redis_get($key)
|
|
|
|
{
|
|
|
|
return Redis::connection()->client()->get($key);
|
|
|
|
}
|
|
|
|
function redis_del(...$key){
|
|
|
|
|
|
|
|
function redis_del(...$key)
|
|
|
|
{
|
|
|
|
return Redis::connection()->client()->del(...$key);
|
|
|
|
}
|
|
|
|
|
|
|
|
function redis_set($key,$val,$ttl=3600){
|
|
|
|
return Redis::connection()->client()->set($key,$val,$ttl);
|
|
|
|
function redis_set($key, $val, $ttl = 3600)
|
|
|
|
{
|
|
|
|
return Redis::connection()->client()->set($key, $val, $ttl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -925,7 +939,8 @@ function redis_set($key,$val,$ttl=3600){ |
|
|
|
* @author:dc
|
|
|
|
* @time 2023/10/25 9:48
|
|
|
|
*/
|
|
|
|
function redis_add($key,$val,$ttl=3600){
|
|
|
|
function redis_add($key, $val, $ttl = 3600)
|
|
|
|
{
|
|
|
|
return Redis::connection()->client()->eval(
|
|
|
|
"return redis.call('exists',KEYS[1])<1 and redis.call('setex',KEYS[1],ARGV[2],ARGV[1])", [$key, $val, $ttl], 1
|
|
|
|
);
|
|
...
|
...
|
@@ -937,11 +952,12 @@ function redis_add($key,$val,$ttl=3600){ |
|
|
|
* @param $project_id
|
|
|
|
* @param $domain
|
|
|
|
* @param $is_complete
|
|
|
|
* @author Akun
|
|
|
|
* @return bool
|
|
|
|
* @date 2023/12/08 14:17
|
|
|
|
* @author Akun
|
|
|
|
*/
|
|
|
|
function check_remote_url_down($url,$project_id,$domain,$is_complete=0){
|
|
|
|
function check_remote_url_down($url, $project_id, $domain, $is_complete = 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!$url) {
|
|
|
|
return '';
|
|
...
|
...
|
@@ -950,24 +966,24 @@ function check_remote_url_down($url,$project_id,$domain,$is_complete=0){ |
|
|
|
$arr = parse_url($url);
|
|
|
|
$scheme = $arr['scheme'] ?? '';
|
|
|
|
$host = $arr['host'] ?? '';
|
|
|
|
$host_arr = explode('.',$host);
|
|
|
|
$host_arr = explode('.', $host);
|
|
|
|
$path = $arr['path'] ?? '';
|
|
|
|
|
|
|
|
if(strpos($host_arr[0], 'cdn') !== false){
|
|
|
|
if (strpos($host_arr[0], 'cdn') !== false) {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
if($host_arr[0] == 'file' && $host_arr[1] == 'globalso'){
|
|
|
|
if ($host_arr[0] == 'file' && $host_arr[1] == 'globalso') {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
//475项目特殊处理
|
|
|
|
if($project_id == 475 && $host == 'www.ebuyplc.com'){
|
|
|
|
if ($project_id == 475 && $host == 'www.ebuyplc.com') {
|
|
|
|
$host = 'g934.goodao.net';
|
|
|
|
}
|
|
|
|
|
|
|
|
if($path && substr($path,0,1) != '/'){
|
|
|
|
$path = '/'.$path;
|
|
|
|
if ($path && substr($path, 0, 1) != '/') {
|
|
|
|
$path = '/' . $path;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
...
|
...
|
@@ -978,13 +994,13 @@ function check_remote_url_down($url,$project_id,$domain,$is_complete=0){ |
|
|
|
) {
|
|
|
|
$url_complete = ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path;
|
|
|
|
|
|
|
|
$new_url = CosService::uploadRemote($project_id,'image_product',$url_complete);
|
|
|
|
if($new_url){
|
|
|
|
$new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete);
|
|
|
|
if ($new_url) {
|
|
|
|
return $is_complete ? getImageUrl($new_url) : $new_url;
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -994,10 +1010,11 @@ function check_remote_url_down($url,$project_id,$domain,$is_complete=0){ |
|
|
|
* @author zbj
|
|
|
|
* @date 2024/3/29
|
|
|
|
*/
|
|
|
|
function textareaToArr($content, $separator = ','){
|
|
|
|
return array_values(array_filter(array_unique(array_map(function ($v){
|
|
|
|
function textareaToArr($content, $separator = ',')
|
|
|
|
{
|
|
|
|
return array_values(array_filter(array_unique(array_map(function ($v) {
|
|
|
|
return trim($v);
|
|
|
|
},explode($separator, $content)))));
|
|
|
|
}, explode($separator, $content)))));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -1007,7 +1024,8 @@ function textareaToArr($content, $separator = ','){ |
|
|
|
* @method :post
|
|
|
|
* @time :2024/6/26 10:46
|
|
|
|
*/
|
|
|
|
function ip_to_unique_string($ip) {
|
|
|
|
function ip_to_unique_string($ip)
|
|
|
|
{
|
|
|
|
// 将IP地址转换为数值表示
|
|
|
|
$ip_number = ip2long($ip);
|
|
|
|
// 使用哈希函数生成唯一数值
|
|
...
|
...
|
@@ -1021,7 +1039,8 @@ function ip_to_unique_string($ip) { |
|
|
|
return strtolower($unique_string);
|
|
|
|
}
|
|
|
|
|
|
|
|
function base62_encode($num) {
|
|
|
|
function base62_encode($num)
|
|
|
|
{
|
|
|
|
$characters = '23456789abcdefghijkmnpqrstuvwxyz';
|
|
|
|
$base = strlen($characters);
|
|
|
|
$result = '';
|
|
...
|
...
|
@@ -1039,8 +1058,9 @@ function base62_encode($num) { |
|
|
|
* @method :post
|
|
|
|
* @time :2024/8/19 14:21
|
|
|
|
*/
|
|
|
|
function urlSafeBase64Encode($data = '') {
|
|
|
|
if(empty($data)){
|
|
|
|
function urlSafeBase64Encode($data = '')
|
|
|
|
{
|
|
|
|
if (empty($data)) {
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
// 1. 使用标准的 BASE64 编码
|
|
...
|
...
|
@@ -1061,7 +1081,8 @@ function urlSafeBase64Encode($data = '') { |
|
|
|
* @method :post
|
|
|
|
* @time :2024/9/14 16:45
|
|
|
|
*/
|
|
|
|
function generateRandomString($length) {
|
|
|
|
function generateRandomString($length)
|
|
|
|
{
|
|
|
|
return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -1080,26 +1101,26 @@ if (!function_exists('check_domain_record')) { |
|
|
|
$is_record = false;
|
|
|
|
|
|
|
|
//获取域名解析记录
|
|
|
|
$records = dns_get_record($domain,DNS_A);
|
|
|
|
if(count($records) == 1 && ($records[0]['host'] == $server_info['domain'] || $records[0]['ip'] == $server_info['ip'])){
|
|
|
|
$records = dns_get_record($domain, DNS_A);
|
|
|
|
if (count($records) == 1 && ($records[0]['host'] == $server_info['domain'] || $records[0]['ip'] == $server_info['ip'])) {
|
|
|
|
$is_record = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!$is_record){
|
|
|
|
if (!$is_record) {
|
|
|
|
//解析不正确,再判断是否开启cnd
|
|
|
|
$top_domain = getTopDomain($domain);
|
|
|
|
$cnd = curlGet('http://sitebak.globalso.com/get_records?domain=' . $top_domain);
|
|
|
|
if (isset($cnd['data']) && $cnd['data']) {
|
|
|
|
if($domain == $top_domain || substr($domain,0,4) == 'www.'){
|
|
|
|
if ($domain == $top_domain || substr($domain, 0, 4) == 'www.') {
|
|
|
|
$check_domain = $domain;
|
|
|
|
}else{
|
|
|
|
$check_domain = '*.'.$top_domain;
|
|
|
|
} else {
|
|
|
|
$check_domain = '*.' . $top_domain;
|
|
|
|
}
|
|
|
|
foreach ($cnd['data'] as $vc) {
|
|
|
|
if ($vc['name'] == $check_domain && $vc['type'] == 'A' && $vc['content'] == $server_info['ip']) {
|
|
|
|
$is_record = true;
|
|
|
|
break;
|
|
|
|
}elseif ($vc['name'] == $check_domain && $vc['type'] == 'CNAME' && $vc['content'] == $server_info['domain']){
|
|
|
|
} elseif ($vc['name'] == $check_domain && $vc['type'] == 'CNAME' && $vc['content'] == $server_info['domain']) {
|
|
|
|
$is_record = true;
|
|
|
|
break;
|
|
|
|
}
|
|
...
|
...
|
@@ -1108,8 +1129,8 @@ if (!function_exists('check_domain_record')) { |
|
|
|
}
|
|
|
|
|
|
|
|
return $is_record;
|
|
|
|
}catch (\Exception $e){
|
|
|
|
errorLog('dns_get_record',['domain'=>$domain],$e);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
errorLog('dns_get_record', ['domain' => $domain], $e);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -1123,7 +1144,8 @@ if (!function_exists('check_curl_status')) { |
|
|
|
* @author Akun
|
|
|
|
* @date 2024/12/12 15:52
|
|
|
|
*/
|
|
|
|
function check_curl_status($url){
|
|
|
|
function check_curl_status($url)
|
|
|
|
{
|
|
|
|
$header = array(
|
|
|
|
'Expect:',
|
|
|
|
'Content-Type: application/json; charset=utf-8'
|
|
...
|
...
|
@@ -1142,7 +1164,7 @@ if (!function_exists('check_curl_status')) { |
|
|
|
curl_setopt($ch, CURLOPT_SSLVERSION, 'all');
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
|
curl_exec($ch);
|
|
|
|
$http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
|
|
|
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
|
|
curl_close($ch);
|
|
|
|
|
|
|
|
return $http_code;
|
|
...
|
...
|
@@ -1154,7 +1176,8 @@ if (!function_exists('check_curl_status')) { |
|
|
|
* @author zbj
|
|
|
|
* @date 2024/10/25
|
|
|
|
*/
|
|
|
|
function email_desensitize($email){
|
|
|
|
function email_desensitize($email)
|
|
|
|
{
|
|
|
|
$parts = explode('@', $email);
|
|
|
|
$username = $parts[0] ?? '';
|
|
|
|
$domain = $parts[1] ?? '';
|
|
...
|
...
|
@@ -1168,7 +1191,8 @@ function email_desensitize($email){ |
|
|
|
* @author zbj
|
|
|
|
* @date 2024/10/25
|
|
|
|
*/
|
|
|
|
function getRandByRatio($proArr){
|
|
|
|
function getRandByRatio($proArr)
|
|
|
|
{
|
|
|
|
$result = '';
|
|
|
|
$proSum = array_sum($proArr);
|
|
|
|
foreach ($proArr as $key => $proCur) {
|
|
...
|
...
|
@@ -1206,7 +1230,7 @@ function getPrefixKeyword($project_id, $type, $num) |
|
|
|
$keyword = array_slice($fix_keyword, 0, $num);
|
|
|
|
$str = implode(", ", $keyword);
|
|
|
|
|
|
|
|
foreach ($keyword as $k=>$v){
|
|
|
|
foreach ($keyword as $k => $v) {
|
|
|
|
$tmp = rtrim($v, 's');
|
|
|
|
if (substr_count($str, $tmp) > 1) {
|
|
|
|
unset($keyword[$k]);
|
|
...
|
...
|
@@ -1224,16 +1248,17 @@ function getPrefixKeyword($project_id, $type, $num) |
|
|
|
* @method :post
|
|
|
|
* @time :2025/2/11 14:58
|
|
|
|
*/
|
|
|
|
function getDeployOptimize($project_id){
|
|
|
|
function getDeployOptimize($project_id)
|
|
|
|
{
|
|
|
|
$cache_key = 'project_deploy_optimize_info_' . $project_id;
|
|
|
|
$info = Cache::get($cache_key);
|
|
|
|
if(!$info){
|
|
|
|
if (!$info) {
|
|
|
|
$projectOptimizeModel = new DeployOptimize();
|
|
|
|
$info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'company_en_name', 'company_en_description', 'keyword_prefix', 'keyword_suffix', 'special']);
|
|
|
|
$projectKeywordModel = new ProjectKeyword();
|
|
|
|
$keywordInfo = $projectKeywordModel->read(['project_id'=>$project_id]);
|
|
|
|
$keywordInfo = $projectKeywordModel->read(['project_id' => $project_id]);
|
|
|
|
$info['main_keyword'] = '';
|
|
|
|
if(!empty($keywordInfo['main_keyword'])){
|
|
|
|
if (!empty($keywordInfo['main_keyword'])) {
|
|
|
|
$info['main_keyword'] = $keywordInfo['main_keyword'];
|
|
|
|
}
|
|
|
|
Cache::put($cache_key, $info, 600);
|
|
...
|
...
|
@@ -1249,7 +1274,8 @@ function getDeployOptimize($project_id){ |
|
|
|
* @method :post
|
|
|
|
* @time :2025/4/1 9:41
|
|
|
|
*/
|
|
|
|
function paginateArray($array, $page = 1, $pageSize = 20) {
|
|
|
|
function paginateArray($array, $page = 1, $pageSize = 20)
|
|
|
|
{
|
|
|
|
$totalItems = count($array);
|
|
|
|
$totalPages = ceil($totalItems / $pageSize);
|
|
|
|
// 确保页码有效
|
|
...
|
...
|
@@ -1272,8 +1298,9 @@ function paginateArray($array, $page = 1, $pageSize = 20) { |
|
|
|
* @method :post
|
|
|
|
* @time :2025/4/3 16:19
|
|
|
|
*/
|
|
|
|
function getDomain($url) {
|
|
|
|
if(empty($url)){
|
|
|
|
function getDomain($url)
|
|
|
|
{
|
|
|
|
if (empty($url)) {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
$parsedUrl = parse_url($url);
|
|
...
|
...
|
@@ -1394,12 +1421,13 @@ function analysisRoute($pathInfo) |
|
|
|
return $router;
|
|
|
|
}
|
|
|
|
|
|
|
|
function getTopDomain ($url) {
|
|
|
|
function getTopDomain($url)
|
|
|
|
{
|
|
|
|
$url = strtolower($url); //首先转成小写
|
|
|
|
$url = mb_ereg_replace('^( | )+', '', trim($url));
|
|
|
|
$url = mb_ereg_replace('( | )+$', '', $url);
|
|
|
|
if (!preg_match('/^(http:\/\/|https)/', $url)) {
|
|
|
|
$url = "https://".$url;
|
|
|
|
$url = "https://" . $url;
|
|
|
|
}
|
|
|
|
$hosts = parse_url($url);
|
|
|
|
$host = $hosts['host'] ?? '';
|
|
...
|
...
|
@@ -1413,10 +1441,10 @@ function getTopDomain ($url) { |
|
|
|
$preg = '/[\w].+\.(com|net|org|gov|edu|co|ne)\.[\w]/';
|
|
|
|
if (($n > 2) && preg_match($preg, $host)) {
|
|
|
|
//双后缀取后3位
|
|
|
|
$host = $data[$n - 3].'.'.$data[$n - 2].'.'.$data[$n - 1];
|
|
|
|
$host = $data[$n - 3] . '.' . $data[$n - 2] . '.' . $data[$n - 1];
|
|
|
|
} else {
|
|
|
|
//非双后缀取后两位
|
|
|
|
$host = $data[$n - 2].'.'.$data[$n - 1];
|
|
|
|
$host = $data[$n - 2] . '.' . $data[$n - 1];
|
|
|
|
}
|
|
|
|
return $host;
|
|
|
|
}
|
|
...
|
...
|
@@ -1440,3 +1468,55 @@ function diffInHours($startTime, $endTime) |
|
|
|
return round($hours, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 通过图片地址压缩图片
|
|
|
|
* @param $url
|
|
|
|
* @param int $width
|
|
|
|
* @return string
|
|
|
|
* @author Akun
|
|
|
|
* @date 2025/09/01 15:18
|
|
|
|
*/
|
|
|
|
function thumbImageByUrl($url, $width = 360)
|
|
|
|
{
|
|
|
|
if (empty($url)) {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strpos($url, '_thumb') !== false) {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
//获取图片完整访问地址
|
|
|
|
$url = getImageUrl($url);
|
|
|
|
|
|
|
|
//获取与原图存储路径相同的压缩路径
|
|
|
|
$path = parse_url($url, PHP_URL_PATH);
|
|
|
|
$path_arr = explode('.', $path);
|
|
|
|
if (count($path_arr) != 2) {
|
|
|
|
return $url;
|
|
|
|
}
|
|
|
|
$path_arr[0] = $path_arr[0] . '_thumbW' . $width;
|
|
|
|
$key = implode('.', $path_arr);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$img = \Intervention\Image\Facades\Image::make($url);
|
|
|
|
|
|
|
|
//宽度按设定,高度自动调整
|
|
|
|
$img->resize($width, null, function ($constraint) {
|
|
|
|
$constraint->aspectRatio();
|
|
|
|
$constraint->upsize();
|
|
|
|
});
|
|
|
|
|
|
|
|
//获取处理后的图片二进制资源
|
|
|
|
$resource = $img->stream()->__toString();
|
|
|
|
|
|
|
|
//上传存储桶
|
|
|
|
$thumb_url = CosService::uploadRemote('', '', '', $key, $resource);
|
|
|
|
|
|
|
|
$url = $thumb_url ? $thumb_url : $url;
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
Log::channel('thumb_img')->error($e->getMessage(), [$url, $width]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $url;
|
|
|
|
} |
...
|
...
|
|