|
|
@@ -90,7 +90,7 @@ if (!function_exists('array2xml')) {
|
|
|
*/
|
|
|
function array2xml($arr, $ignore = true, $level = 1)
|
|
|
{
|
|
|
- $s = $level == 1 ? "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<root>\r\n" : '';
|
|
|
+ $s = $level == 1 ? "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<root>\r\n" : '';
|
|
|
$space = str_repeat("\t", $level);
|
|
|
foreach ($arr as $k => $v) {
|
|
|
if (!is_array($v)) {
|
|
|
@@ -118,9 +118,10 @@ if (!function_exists('array_merge_multiple')) {
|
|
|
function array_merge_multiple($array1, $array2)
|
|
|
{
|
|
|
$merge = $array1 + $array2;
|
|
|
- $data = [];
|
|
|
+ $data = [];
|
|
|
foreach ($merge as $key => $val) {
|
|
|
- if (isset($array1[$key])
|
|
|
+ if (
|
|
|
+ isset($array1[$key])
|
|
|
&& is_array($array1[$key])
|
|
|
&& isset($array2[$key])
|
|
|
&& is_array($array2[$key])
|
|
|
@@ -315,7 +316,7 @@ if (!function_exists('datetime')) {
|
|
|
*/
|
|
|
function datetime($time, $format = 'Y-m-d H:i:s')
|
|
|
{
|
|
|
- if($time == '0000-00-00 00:00:00'){
|
|
|
+ if ($time == '0000-00-00 00:00:00') {
|
|
|
return '';
|
|
|
}
|
|
|
$time = is_numeric($time) ? $time : strtotime($time);
|
|
|
@@ -332,10 +333,10 @@ if (!function_exists('dateForWeek')) {
|
|
|
*/
|
|
|
function dateForWeek($time)
|
|
|
{
|
|
|
- if(empty($time)){
|
|
|
+ if (empty($time)) {
|
|
|
return false;
|
|
|
}
|
|
|
- $time = !is_int($time)? strtotime($time) : $time;
|
|
|
+ $time = !is_int($time) ? strtotime($time) : $time;
|
|
|
$weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
|
|
$week = date("w", $time);
|
|
|
$cweek = date("w");
|
|
|
@@ -353,12 +354,12 @@ if (!function_exists('dateFormat')) {
|
|
|
* @param $time 时间戳
|
|
|
* @return false|string
|
|
|
*/
|
|
|
- function dateFormat($time, $format='m月d日')
|
|
|
+ function dateFormat($time, $format = 'm月d日')
|
|
|
{
|
|
|
- if(empty($time)){
|
|
|
+ if (empty($time)) {
|
|
|
return false;
|
|
|
}
|
|
|
- $time = !is_int($time)? strtotime($time) : $time;
|
|
|
+ $time = !is_int($time) ? strtotime($time) : $time;
|
|
|
$weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
|
|
|
$week = date("w", $time);
|
|
|
$cweek = date("w");
|
|
|
@@ -385,15 +386,15 @@ if (!function_exists('formatHour')) {
|
|
|
*/
|
|
|
function formatHour($time)
|
|
|
{
|
|
|
- if(empty($time)){
|
|
|
+ if (empty($time)) {
|
|
|
return '00:00';
|
|
|
}
|
|
|
|
|
|
- $hour = intval($time/3600);
|
|
|
- $hour = $hour<10?'0'.$hour : $hour;
|
|
|
- $minute = intval($time%3600/60);
|
|
|
- $minute = $minute<10?'0'.$minute : $minute;
|
|
|
- return $hour.':'.$minute;
|
|
|
+ $hour = intval($time / 3600);
|
|
|
+ $hour = $hour < 10 ? '0' . $hour : $hour;
|
|
|
+ $minute = intval($time % 3600 / 60);
|
|
|
+ $minute = $minute < 10 ? '0' . $minute : $minute;
|
|
|
+ return $hour . ':' . $minute;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -410,7 +411,7 @@ if (!function_exists('data_auth_sign')) {
|
|
|
{
|
|
|
// 数据类型检测
|
|
|
if (!is_array($data)) {
|
|
|
- $data = (array)$data;
|
|
|
+ $data = (array) $data;
|
|
|
}
|
|
|
// 排序
|
|
|
ksort($data);
|
|
|
@@ -555,7 +556,7 @@ if (!function_exists('format_time')) {
|
|
|
'1' => '秒',
|
|
|
);
|
|
|
foreach ($format as $key => $val) {
|
|
|
- $match = floor($interval / (int)$key);
|
|
|
+ $match = floor($interval / (int) $key);
|
|
|
if (0 != $match) {
|
|
|
return $match . $val . '前';
|
|
|
}
|
|
|
@@ -615,7 +616,7 @@ if (!function_exists('format_cent')) {
|
|
|
*/
|
|
|
function format_cent($money)
|
|
|
{
|
|
|
- return (string)($money * 100);
|
|
|
+ return (string) ($money * 100);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -630,11 +631,11 @@ if (!function_exists('format_bank_card')) {
|
|
|
* @author laravel开发员
|
|
|
* @date 2019/5/23
|
|
|
*/
|
|
|
- function format_bank_card($card_no, $is_format = true, $hidden=true)
|
|
|
+ function format_bank_card($card_no, $is_format = true, $hidden = true)
|
|
|
{
|
|
|
- if($hidden){
|
|
|
- $format_card_no = '****'.substr($card_no, -4, 4);
|
|
|
- }else if ($is_format) {
|
|
|
+ if ($hidden) {
|
|
|
+ $format_card_no = '****' . substr($card_no, -4, 4);
|
|
|
+ } else if ($is_format) {
|
|
|
// 截取银行卡号前4位
|
|
|
$prefix = substr($card_no, 0, 4);
|
|
|
// 截取银行卡号后4位
|
|
|
@@ -643,7 +644,7 @@ if (!function_exists('format_bank_card')) {
|
|
|
$format_card_no = $prefix . " **** **** **** " . $suffix;
|
|
|
} else {
|
|
|
// 4的意思就是每4个为一组
|
|
|
- $arr = str_split($card_no, 4);
|
|
|
+ $arr = str_split($card_no, 4);
|
|
|
$format_card_no = implode(' ', $arr);
|
|
|
}
|
|
|
return $format_card_no;
|
|
|
@@ -789,7 +790,7 @@ if (!function_exists('get_zodiac_sign')) {
|
|
|
array("22" => "射手座"),
|
|
|
array("22" => "摩羯座")
|
|
|
);
|
|
|
- list($sign_start, $sign_name) = each($signs[(int)$month - 1]);
|
|
|
+ list($sign_start, $sign_name) = each($signs[(int) $month - 1]);
|
|
|
if ($day < $sign_start) {
|
|
|
list($sign_start, $sign_name) = each($signs[($month - 2 < 0) ? $month = 11 : $month -= 2]);
|
|
|
}
|
|
|
@@ -813,9 +814,9 @@ if (!function_exists('get_image_url')) {
|
|
|
return '';
|
|
|
}
|
|
|
|
|
|
- if($domain){
|
|
|
- $host = $domain.'/uploads';
|
|
|
- }else{
|
|
|
+ if ($domain) {
|
|
|
+ $host = $domain . '/uploads';
|
|
|
+ } else {
|
|
|
$host = request()->header('HOST');
|
|
|
$https = request()->secure();
|
|
|
$host = ($https ? 'https://' : 'http://') . $host . '/uploads';
|
|
|
@@ -862,9 +863,9 @@ if (!function_exists('get_format_images')) {
|
|
|
|
|
|
$datas = [];
|
|
|
foreach ($images as $v) {
|
|
|
- $url = $key? (isset($v[$key])? $v[$key] : ''):$v;
|
|
|
+ $url = $key ? (isset($v[$key]) ? $v[$key] : '') : $v;
|
|
|
if ($url) {
|
|
|
- $datas[] = $key?[$key=>get_image_path($url)]:['url'=>get_image_path($url)];
|
|
|
+ $datas[] = $key ? [$key => get_image_path($url)] : ['url' => get_image_path($url)];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -889,13 +890,13 @@ if (!function_exists('get_images_preview')) {
|
|
|
return [];
|
|
|
}
|
|
|
|
|
|
- $urls = is_array($urls)? $urls : json_decode($urls, true);
|
|
|
+ $urls = is_array($urls) ? $urls : json_decode($urls, true);
|
|
|
foreach ($urls as &$item) {
|
|
|
- if ($keyName && $level==2) {
|
|
|
+ if ($keyName && $level == 2) {
|
|
|
$item[$keyName] = get_image_url($item[$keyName]);
|
|
|
- } else if($keyName && $level==1){
|
|
|
+ } else if ($keyName && $level == 1) {
|
|
|
$item = get_image_url($item[$keyName]);
|
|
|
- } else if($level==1){
|
|
|
+ } else if ($level == 1) {
|
|
|
$item = get_image_url($item);
|
|
|
}
|
|
|
}
|
|
|
@@ -936,19 +937,19 @@ if (!function_exists('set_format_content')) {
|
|
|
}
|
|
|
|
|
|
$domain = request()->header('HOST');
|
|
|
- if(preg_match("/127/", $domain)){
|
|
|
- $host = env('IMG_URL','');
|
|
|
- if(empty($host)){
|
|
|
+ if (preg_match("/127/", $domain)) {
|
|
|
+ $host = env('IMG_URL', '');
|
|
|
+ if (empty($host)) {
|
|
|
$https = request()->secure();
|
|
|
$host = ($https ? 'https://' : 'http://') . $host . '/uploads';
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$https = request()->secure();
|
|
|
$host = ($https ? 'https://' : 'http://') . $domain . '/uploads';
|
|
|
}
|
|
|
|
|
|
- $content = str_replace("{$host}",'/uploads', htmlspecialchars_decode($content));
|
|
|
- return $content;
|
|
|
+ $content = str_replace("{$host}", '/uploads', htmlspecialchars_decode($content));
|
|
|
+ return $content;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -966,19 +967,19 @@ if (!function_exists('get_format_content')) {
|
|
|
}
|
|
|
|
|
|
$domain = request()->header('HOST');
|
|
|
- if(preg_match("/127/", $domain)){
|
|
|
- $host = env('IMG_URL','');
|
|
|
- if(empty($host)){
|
|
|
+ if (preg_match("/127/", $domain)) {
|
|
|
+ $host = env('IMG_URL', '');
|
|
|
+ if (empty($host)) {
|
|
|
$https = request()->secure();
|
|
|
$host = ($https ? 'https://' : 'http://') . $host . '/uploads';
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
$https = request()->secure();
|
|
|
$host = ($https ? 'https://' : 'http://') . $domain . '/uploads';
|
|
|
}
|
|
|
|
|
|
- $content = str_replace(["\"/uploads","'/uploads"],["\"{$host}","'{$host}"], htmlspecialchars_decode($content));
|
|
|
- return $content;
|
|
|
+ $content = str_replace(["\"/uploads", "'/uploads"], ["\"{$host}", "'{$host}"], htmlspecialchars_decode($content));
|
|
|
+ return $content;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -995,8 +996,8 @@ if (!function_exists('format_content')) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $content = str_replace(["\n"],["<br/>"], htmlspecialchars_decode($content));
|
|
|
- return get_format_content($content);
|
|
|
+ $content = str_replace(["\n"], ["<br/>"], htmlspecialchars_decode($content));
|
|
|
+ return get_format_content($content);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1010,8 +1011,8 @@ if (!function_exists('get_hash')) {
|
|
|
*/
|
|
|
function get_hash()
|
|
|
{
|
|
|
- $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()+-';
|
|
|
- $random = $chars[mt_rand(0, 73)] . $chars[mt_rand(0, 73)] . $chars[mt_rand(0, 73)]
|
|
|
+ $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()+-';
|
|
|
+ $random = $chars[mt_rand(0, 73)] . $chars[mt_rand(0, 73)] . $chars[mt_rand(0, 73)]
|
|
|
. $chars[mt_rand(0, 73)] . $chars[mt_rand(0, 73)];
|
|
|
$content = uniqid() . $random;
|
|
|
return sha1($content);
|
|
|
@@ -1076,7 +1077,7 @@ if (!function_exists('get_client_ip')) {
|
|
|
}
|
|
|
// IP地址合法验证
|
|
|
$long = sprintf("%u", ip2long($ip));
|
|
|
- $ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
|
|
|
+ $ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
|
|
|
return $ip[$type];
|
|
|
}
|
|
|
|
|
|
@@ -1100,13 +1101,13 @@ if (!function_exists('get_guid_v4')) {
|
|
|
}
|
|
|
// OSX/Linux
|
|
|
if (function_exists('openssl_random_pseudo_bytes') === true) {
|
|
|
- $data = openssl_random_pseudo_bytes(16);
|
|
|
+ $data = openssl_random_pseudo_bytes(16);
|
|
|
$data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100
|
|
|
$data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10
|
|
|
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
|
|
}
|
|
|
// Fallback (PHP 4.2+)
|
|
|
- mt_srand((double)microtime() * 10000);
|
|
|
+ mt_srand((double) microtime() * 10000);
|
|
|
$charid = strtolower(md5(uniqid(rand(), true)));
|
|
|
$hyphen = chr(45); // "-"
|
|
|
$lbrace = $trim ? "" : chr(123); // "{"
|
|
|
@@ -1181,8 +1182,8 @@ if (!function_exists('is_idcard')) {
|
|
|
*/
|
|
|
function is_idcard($idno)
|
|
|
{
|
|
|
- $idno = strtoupper($idno);
|
|
|
- $regx = '/(^\d{15}$)|(^\d{17}([0-9]|X)$)/';
|
|
|
+ $idno = strtoupper($idno);
|
|
|
+ $regx = '/(^\d{15}$)|(^\d{17}([0-9]|X)$)/';
|
|
|
$arr_split = array();
|
|
|
if (!preg_match($regx, $idno)) {
|
|
|
return false;
|
|
|
@@ -1209,14 +1210,14 @@ if (!function_exists('is_idcard')) {
|
|
|
// 检验18位身份证的校验码是否正确。
|
|
|
// 校验位按照ISO 7064:1983.MOD 11-2的规定生成,X可以认为是数字10。
|
|
|
$arr_int = array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
|
|
|
- $arr_ch = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
|
|
|
- $sign = 0;
|
|
|
+ $arr_ch = array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
|
|
|
+ $sign = 0;
|
|
|
for ($i = 0; $i < 17; $i++) {
|
|
|
- $b = (int)$idno[$i];
|
|
|
- $w = $arr_int[$i];
|
|
|
+ $b = (int) $idno[$i];
|
|
|
+ $w = $arr_int[$i];
|
|
|
$sign += $b * $w;
|
|
|
}
|
|
|
- $n = $sign % 11;
|
|
|
+ $n = $sign % 11;
|
|
|
$val_num = $arr_ch[$n];
|
|
|
if ($val_num != substr($idno, 17, 1)) {
|
|
|
return false;
|
|
|
@@ -1376,7 +1377,7 @@ if (!function_exists('message')) {
|
|
|
*/
|
|
|
function message($msg = "操作成功", $success = true, $data = [], $code = 0, $type = 'json')
|
|
|
{
|
|
|
- $result = ['success' => $success, 'msg' => lang($msg), 'data' => $data,'stime'=>time()];
|
|
|
+ $result = ['success' => $success, 'msg' => lang($msg), 'data' => $data, 'stime' => time()];
|
|
|
if ($success) {
|
|
|
$result['code'] = 0;
|
|
|
} else {
|
|
|
@@ -1400,13 +1401,13 @@ if (!function_exists('showJson')) {
|
|
|
*/
|
|
|
function showJson($msg = "操作成功", $success = true, $data = [], $code = 0, $type = 'json')
|
|
|
{
|
|
|
- $result = ['success' => $success, 'msg' => lang($msg), 'data' => $data,'stime'=>time()];
|
|
|
+ $result = ['success' => $success, 'msg' => lang($msg), 'data' => $data, 'stime' => time()];
|
|
|
if ($success) {
|
|
|
$result['code'] = 0;
|
|
|
} else {
|
|
|
$result['code'] = $code ? $code : -1;
|
|
|
}
|
|
|
- return $type=='json'?response()->json($result, 200, [])->setEncodingOptions(256):$result;
|
|
|
+ return $type == 'json' ? response()->json($result, 200, [])->setEncodingOptions(256) : $result;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1421,8 +1422,8 @@ if (!function_exists('num2rmb')) {
|
|
|
*/
|
|
|
function num2rmb($num)
|
|
|
{
|
|
|
- $c1 = "零壹贰叁肆伍陆柒捌玖";
|
|
|
- $c2 = "分角元拾佰仟万拾佰仟亿";
|
|
|
+ $c1 = "零壹贰叁肆伍陆柒捌玖";
|
|
|
+ $c2 = "分角元拾佰仟万拾佰仟亿";
|
|
|
$num = round($num, 2);
|
|
|
$num = $num * 100;
|
|
|
if (strlen($num) > 10) {
|
|
|
@@ -1443,23 +1444,23 @@ if (!function_exists('num2rmb')) {
|
|
|
} else {
|
|
|
$c = $p1 . $c;
|
|
|
}
|
|
|
- $i = $i + 1;
|
|
|
+ $i = $i + 1;
|
|
|
$num = $num / 10;
|
|
|
- $num = (int)$num;
|
|
|
+ $num = (int) $num;
|
|
|
if ($num == 0) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- $j = 0;
|
|
|
+ $j = 0;
|
|
|
$slen = strlen($c);
|
|
|
while ($j < $slen) {
|
|
|
$m = substr($c, $j, 6);
|
|
|
if ($m == '零元' || $m == '零万' || $m == '零亿' || $m == '零零') {
|
|
|
- $left = substr($c, 0, $j);
|
|
|
+ $left = substr($c, 0, $j);
|
|
|
$right = substr($c, $j + 3);
|
|
|
- $c = $left . $right;
|
|
|
- $j = $j - 3;
|
|
|
- $slen = $slen - 3;
|
|
|
+ $c = $left . $right;
|
|
|
+ $j = $j - 3;
|
|
|
+ $slen = $slen - 3;
|
|
|
}
|
|
|
$j = $j + 3;
|
|
|
}
|
|
|
@@ -1531,8 +1532,8 @@ if (!function_exists('strip_html_tags')) {
|
|
|
// 将空格替换成空
|
|
|
$str = str_replace(" ", "", $str);
|
|
|
// 函数剥去字符串中的 HTML、XML 以及 PHP 的标签,获取纯文本内容
|
|
|
- $str = strip_tags($str);
|
|
|
- $str = str_replace(array("\n", "\r\n", "\r"), ' ', $str);
|
|
|
+ $str = strip_tags($str);
|
|
|
+ $str = str_replace(array("\n", "\r\n", "\r"), ' ', $str);
|
|
|
$preg = '/<script[\s\S]*?<\/script>/i';
|
|
|
// 剥离JS代码
|
|
|
$str = preg_replace($preg, "", $str, -1);
|
|
|
@@ -1565,10 +1566,10 @@ if (!function_exists('sub_str')) {
|
|
|
} elseif (function_exists('iconv_substr')) {
|
|
|
$slice = iconv_substr($str, $start, $length, $charset);
|
|
|
} else {
|
|
|
- $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
|
|
|
+ $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
|
|
|
$re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
|
|
|
- $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
|
|
|
- $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
|
|
|
+ $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
|
|
|
+ $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
|
|
|
preg_match_all($re[$charset], $str, $match);
|
|
|
$slice = join("", array_slice($match[0], $start, $length));
|
|
|
}
|
|
|
@@ -1594,7 +1595,7 @@ if (!function_exists('save_image')) {
|
|
|
return false;
|
|
|
}
|
|
|
$save_dir = trim($save_dir, "/");
|
|
|
- $imgExt = pathinfo($img_url, PATHINFO_EXTENSION);
|
|
|
+ $imgExt = pathinfo($img_url, PATHINFO_EXTENSION);
|
|
|
|
|
|
|
|
|
// 是否是本站图片
|
|
|
@@ -1785,8 +1786,8 @@ if (!function_exists('upload_image')) {
|
|
|
}
|
|
|
|
|
|
// 文件名称
|
|
|
- $file_name = ($userId? $userId.'_'.str_replace('=','',base64_encode($userId.$original_name)): str_replace('=','',base64_encode($original_name)));
|
|
|
- $file_name = $file_name. '.' . $ext;
|
|
|
+ $file_name = ($userId ? $userId . '_' . str_replace('=', '', base64_encode($userId . $original_name)) : str_replace('=', '', base64_encode($original_name)));
|
|
|
+ $file_name = $file_name . '.' . $ext;
|
|
|
|
|
|
// 重命名保存
|
|
|
$path = $file->move($file_dir, $file_name);
|
|
|
@@ -1797,12 +1798,12 @@ if (!function_exists('upload_image')) {
|
|
|
// 返回结果
|
|
|
$result = [
|
|
|
'img_original_name' => $original_name,
|
|
|
- 'img_ext' => $ext,
|
|
|
- 'img_real_path' => $real_path,
|
|
|
- 'img_type' => $type,
|
|
|
- 'img_size' => $size,
|
|
|
- 'img_name' => $file_name,
|
|
|
- 'img_path' => $file_path,
|
|
|
+ 'img_ext' => $ext,
|
|
|
+ 'img_real_path' => $real_path,
|
|
|
+ 'img_type' => $type,
|
|
|
+ 'img_size' => $size,
|
|
|
+ 'img_name' => $file_name,
|
|
|
+ 'img_path' => $file_path,
|
|
|
];
|
|
|
return message(MESSAGE_OK, true, $result);
|
|
|
}
|
|
|
@@ -1874,12 +1875,12 @@ if (!function_exists('upload_file')) {
|
|
|
// 返回结果
|
|
|
$result = [
|
|
|
'file_original_name' => $original_name,
|
|
|
- 'file_ext' => $ext,
|
|
|
- 'file_real_path' => $real_path,
|
|
|
- 'file_type' => $type,
|
|
|
- 'file_size' => $size,
|
|
|
- 'file_name' => $file_name,
|
|
|
- 'file_path' => $file_path,
|
|
|
+ 'file_ext' => $ext,
|
|
|
+ 'file_real_path' => $real_path,
|
|
|
+ 'file_type' => $type,
|
|
|
+ 'file_size' => $size,
|
|
|
+ 'file_name' => $file_name,
|
|
|
+ 'file_path' => $file_path,
|
|
|
];
|
|
|
return message(MESSAGE_OK, true, $result);
|
|
|
}
|
|
|
@@ -1950,12 +1951,12 @@ if (!function_exists('upload_video')) {
|
|
|
// 返回结果
|
|
|
$result = [
|
|
|
'file_original_name' => $original_name,
|
|
|
- 'file_ext' => $ext,
|
|
|
- 'file_real_path' => $real_path,
|
|
|
- 'file_type' => $type,
|
|
|
- 'file_size' => $size,
|
|
|
- 'file_name' => $file_name,
|
|
|
- 'file_path' => $file_path,
|
|
|
+ 'file_ext' => $ext,
|
|
|
+ 'file_real_path' => $real_path,
|
|
|
+ 'file_type' => $type,
|
|
|
+ 'file_size' => $size,
|
|
|
+ 'file_name' => $file_name,
|
|
|
+ 'file_path' => $file_path,
|
|
|
];
|
|
|
return message(MESSAGE_OK, true, $result);
|
|
|
}
|
|
|
@@ -2011,7 +2012,7 @@ if (!function_exists('get_tree')) {
|
|
|
$tempArr[] = $data;
|
|
|
} else if ($currentPid == 0 && $pid == 0) {
|
|
|
$data['children'] = get_tree($datas, $v['id'], []);
|
|
|
- $tempArr[$id] = $data;
|
|
|
+ $tempArr[$id] = $data;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2030,7 +2031,7 @@ if (!function_exists('getSign')) {
|
|
|
$str .= '&key=' . ($key ? $key : env('APP_SIGN_KEY', 'app&688'));
|
|
|
$str = md5($str);
|
|
|
// MD5 运算
|
|
|
- $sign = md5($str.substr($str,0,6));
|
|
|
+ $sign = md5($str . substr($str, 0, 6));
|
|
|
$sign .= substr($str, 2, 4);
|
|
|
$sign = strtoupper($sign);
|
|
|
|
|
|
@@ -2048,10 +2049,10 @@ if (!function_exists('arrayToStr')) {
|
|
|
$array = array();
|
|
|
|
|
|
foreach ($params as $key => &$value) {
|
|
|
- if($key != 'sign'){
|
|
|
+ if ($key != 'sign') {
|
|
|
// 过滤无法匹配校验的参数类型
|
|
|
- if (!is_array($value) && $value !== 'undefined' && strtolower($value) != 'null' && !empty($value) && !preg_match("/^[0-9]{1,9}\.[0-9]{8,}$/", $value)) {
|
|
|
- $array[] = $key . '=' .trim($value);
|
|
|
+ if (!is_array($value) && $value !== 'undefined' && strtolower($value) != 'null' && !empty($value) && !preg_match("/^[0-9]{1,9}\.[0-9]{8,}$/", $value)) {
|
|
|
+ $array[] = $key . '=' . trim($value);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2070,7 +2071,7 @@ if (!function_exists('arrayToUrl')) {
|
|
|
$array = array();
|
|
|
foreach ($params as $key => $value) {
|
|
|
if ($value != 'undefined') {
|
|
|
- $array[] = $key . '=' . (is_array($value) ? json_encode($value,JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE) : $value);
|
|
|
+ $array[] = $key . '=' . (is_array($value) ? json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $value);
|
|
|
}
|
|
|
}
|
|
|
$string = implode("&", $array);
|
|
|
@@ -2090,13 +2091,13 @@ if (!function_exists('httpRequest')) {
|
|
|
* @return mixed
|
|
|
* @author wesmiler
|
|
|
*/
|
|
|
- function httpRequest($url, $data = '', $type = 'post', $cookie = '', $timeout = 60, $header=[])
|
|
|
+ function httpRequest($url, $data = '', $type = 'post', $cookie = '', $timeout = 60, $header = [])
|
|
|
{
|
|
|
try {
|
|
|
set_time_limit($timeout);
|
|
|
$data = $data && is_array($data) ? http_build_query($data) : $data;
|
|
|
- $url = strtolower($type) == 'get' ? $url . (strpos($url, '?') === false ? '?' : '&') . $data : $url;
|
|
|
- $ch = curl_init($url);
|
|
|
+ $url = strtolower($type) == 'get' ? $url . (strpos($url, '?') === false ? '?' : '&') . $data : $url;
|
|
|
+ $ch = curl_init($url);
|
|
|
if (!empty($cookie)) {
|
|
|
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
|
|
|
}
|
|
|
@@ -2193,7 +2194,7 @@ if (!function_exists('moneyFormat')) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if(!function_exists('getChatKey')){
|
|
|
+if (!function_exists('getChatKey')) {
|
|
|
/**
|
|
|
* 获取聊天窗口KEY
|
|
|
* @param $fromUserId
|
|
|
@@ -2202,7 +2203,7 @@ if(!function_exists('getChatKey')){
|
|
|
*/
|
|
|
function getChatKey($fromUserId, $toUserId)
|
|
|
{
|
|
|
- if(empty($fromUserId) || empty($toUserId)){
|
|
|
+ if (empty($fromUserId) || empty($toUserId)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -2212,7 +2213,7 @@ if(!function_exists('getChatKey')){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if(!function_exists('getDistance')) {
|
|
|
+if (!function_exists('getDistance')) {
|
|
|
/**
|
|
|
* 计算地图坐标距离/米
|
|
|
* @param $lat
|
|
|
@@ -2224,32 +2225,37 @@ if(!function_exists('getDistance')) {
|
|
|
function getDistance($lat, $lng, $toLat, $toLng)
|
|
|
{
|
|
|
return ROUND(6378.138 * 2 * ASIN(
|
|
|
- SQRT(
|
|
|
- POW(
|
|
|
- SIN(
|
|
|
- ($lat * PI() / 180 - $toLat * PI() / 180
|
|
|
- ) / 2
|
|
|
- ),
|
|
|
- 2
|
|
|
- ) + COS($lat * PI() / 180) * COS($toLat * PI() / 180) * POW(
|
|
|
- SIN(
|
|
|
- ($lng * PI() / 180 - $toLng * PI() / 180
|
|
|
- ) / 2
|
|
|
- ), 2))) * 1000);
|
|
|
+ SQRT(
|
|
|
+ POW(
|
|
|
+ SIN(
|
|
|
+ ($lat * PI() / 180 - $toLat * PI() / 180
|
|
|
+ ) / 2
|
|
|
+ ),
|
|
|
+ 2
|
|
|
+ ) + COS($lat * PI() / 180) * COS($toLat * PI() / 180) * POW(
|
|
|
+ SIN(
|
|
|
+ ($lng * PI() / 180 - $toLng * PI() / 180
|
|
|
+ ) / 2
|
|
|
+ ),
|
|
|
+ 2
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ) * 1000);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if(!function_exists('getParents')){
|
|
|
+if (!function_exists('getParents')) {
|
|
|
/**
|
|
|
* 获取分销上级用户ID
|
|
|
* @param $parents
|
|
|
* @return array|false
|
|
|
*/
|
|
|
- function getParents($parents, $level=3){
|
|
|
- $parents = $parents? explode(',', $parents) : [];
|
|
|
+ function getParents($parents, $level = 3)
|
|
|
+ {
|
|
|
+ $parents = $parents ? explode(',', $parents) : [];
|
|
|
$parents = array_filter($parents);
|
|
|
- if(empty($parents)){
|
|
|
+ if (empty($parents)) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
@@ -2258,35 +2264,37 @@ if(!function_exists('getParents')){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if(!function_exists('getMillSecondTime')){
|
|
|
+if (!function_exists('getMillSecondTime')) {
|
|
|
/**
|
|
|
* 获取毫秒时间戳
|
|
|
* @return float
|
|
|
*/
|
|
|
- function getMillSecondTime() {
|
|
|
+ function getMillSecondTime()
|
|
|
+ {
|
|
|
list($msec, $sec) = explode(' ', microtime());
|
|
|
- return (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
|
|
|
+ return (float) sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-if(!function_exists('getPriceData')){
|
|
|
+if (!function_exists('getPriceData')) {
|
|
|
/**
|
|
|
* 格式化价格数据
|
|
|
* @param $prices
|
|
|
* @return array|false|string[]
|
|
|
*/
|
|
|
- function getPriceData($prices) {
|
|
|
+ function getPriceData($prices)
|
|
|
+ {
|
|
|
$datas = [];
|
|
|
- $prices = $prices? explode('|', $prices) : [];
|
|
|
- if($prices){
|
|
|
- foreach ($prices as $item){
|
|
|
- $data = $item? explode(':',$item) : [];
|
|
|
- $num = isset($data[0]) && $data[0]? $data[0] : '';
|
|
|
- $price = isset($data[1])? $data[1] : 0;
|
|
|
- if($num && $price){
|
|
|
+ $prices = $prices ? explode('|', $prices) : [];
|
|
|
+ if ($prices) {
|
|
|
+ foreach ($prices as $item) {
|
|
|
+ $data = $item ? explode(':', $item) : [];
|
|
|
+ $num = isset($data[0]) && $data[0] ? $data[0] : '';
|
|
|
+ $price = isset($data[1]) ? $data[1] : 0;
|
|
|
+ if ($num && $price) {
|
|
|
$datas[] = [
|
|
|
- 'distance'=> $num,
|
|
|
- 'price'=> $price,
|
|
|
+ 'distance' => $num,
|
|
|
+ 'price' => $price,
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
@@ -2310,20 +2318,67 @@ if (!function_exists('api_decrypt')) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-if (!function_exists('format_message')){
|
|
|
+if (!function_exists('format_message')) {
|
|
|
/**
|
|
|
* 格式化消息内容
|
|
|
* @param $message
|
|
|
* @return false|string|string[]|null
|
|
|
*/
|
|
|
- function format_message($message){
|
|
|
- if(empty($message)){
|
|
|
+ function format_message($message)
|
|
|
+ {
|
|
|
+ if (empty($message)) {
|
|
|
return false;
|
|
|
}
|
|
|
$pattern = "/((https|http|ftp):\/\/((\w+(\-)?\w+(\.)){0,2}\w+\.[a-z]{2,3}(\/[a-zA-Z0-9\_\.]{1,50}(\.php|\.html|\.js|\.htm|\.apk)?){0,5})([\?&]\w+=\w*){0,5}(\s?))/u";
|
|
|
- $message = preg_replace($pattern,'<a href="$1" target="_blank">$1</a>', $message);
|
|
|
+ $message = preg_replace($pattern, '<a href="$1" target="_blank">$1</a>', $message);
|
|
|
return format_content($message);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+if (!function_exists('format_image_field')) {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 格式化图片字段(支持单图、多图)
|
|
|
+ * @param string|array $images 数据库存储的图片(可能是字符串或数组)
|
|
|
+ * @param string $domain 域名,可选
|
|
|
+ * @return string|array
|
|
|
+ */
|
|
|
+ function format_image_field($images, $domain = '')
|
|
|
+ {
|
|
|
+ if (empty($images)) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果是 JSON 格式存储(多图)
|
|
|
+ if (is_string($images) && (strpos($images, '[') === 0 || strpos($images, '{') === 0)) {
|
|
|
+ $arr = json_decode($images, true);
|
|
|
+ if (is_array($arr)) {
|
|
|
+ $arr = array_map(function ($img) use ($domain) {
|
|
|
+ return get_image_url($img, $domain);
|
|
|
+ }, $arr);
|
|
|
+ return json_encode($arr, JSON_UNESCAPED_UNICODE);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果是用逗号分隔的字符串(多图)
|
|
|
+ if (is_string($images) && strpos($images, ',') !== false) {
|
|
|
+ $arr = explode(',', $images);
|
|
|
+ $arr = array_map(function ($img) use ($domain) {
|
|
|
+ return get_image_url($img, $domain);
|
|
|
+ }, $arr);
|
|
|
+ return implode(',', $arr);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果是数组
|
|
|
+ if (is_array($images)) {
|
|
|
+ return array_map(function ($img) use ($domain) {
|
|
|
+ return get_image_url($img, $domain);
|
|
|
+ }, $images);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 单图字符串
|
|
|
+ return get_image_url($images, $domain);
|
|
|
+ }
|
|
|
+}
|