|
|
@@ -322,7 +322,6 @@ if (!function_exists('datetime')) {
|
|
|
$time = is_numeric($time) ? $time : strtotime($time);
|
|
|
return date($format, $time);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('dateForWeek')) {
|
|
|
@@ -573,17 +572,17 @@ if (!function_exists('format_times')) {
|
|
|
* @author laravel开发员
|
|
|
* @date 2019/5/23
|
|
|
*/
|
|
|
- function format_times($time, $type=0)
|
|
|
+ function format_times($time, $type = 0)
|
|
|
{
|
|
|
- if($type == 1){
|
|
|
- $hour = $time>=3600? intval($time/3600) : 0;
|
|
|
- $minute = $time>=60? intval($time%3600/60) : 0;
|
|
|
- $second = intval($time%60);
|
|
|
- return ($hour<10?'0'.$hour:$hour).':'.($minute<10?'0'.$minute:$minute).':'.($second<10?'0'.$second:$second);
|
|
|
- }else{
|
|
|
- $minute = $time>=60? intval($time/60) : 0;
|
|
|
- $second = intval($time%60);
|
|
|
- return ($minute<10?'0'.$minute:$minute).':'.($second<10?'0'.$second:$second);
|
|
|
+ if ($type == 1) {
|
|
|
+ $hour = $time >= 3600 ? intval($time / 3600) : 0;
|
|
|
+ $minute = $time >= 60 ? intval($time % 3600 / 60) : 0;
|
|
|
+ $second = intval($time % 60);
|
|
|
+ return ($hour < 10 ? '0' . $hour : $hour) . ':' . ($minute < 10 ? '0' . $minute : $minute) . ':' . ($second < 10 ? '0' . $second : $second);
|
|
|
+ } else {
|
|
|
+ $minute = $time >= 60 ? intval($time / 60) : 0;
|
|
|
+ $second = intval($time % 60);
|
|
|
+ return ($minute < 10 ? '0' . $minute : $minute) . ':' . ($second < 10 ? '0' . $second : $second);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -606,7 +605,6 @@ if (!function_exists('format_bytes')) {
|
|
|
}
|
|
|
return round($size, 2) . $delimiter . $units[$i];
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('format_yuan')) {
|
|
|
@@ -625,7 +623,6 @@ if (!function_exists('format_yuan')) {
|
|
|
}
|
|
|
return "0.00";
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('format_cent')) {
|
|
|
@@ -637,9 +634,8 @@ if (!function_exists('format_cent')) {
|
|
|
*/
|
|
|
function format_cent($money)
|
|
|
{
|
|
|
- return ($money * 100).'';
|
|
|
+ return ($money * 100) . '';
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('format_day')) {
|
|
|
@@ -655,13 +651,12 @@ if (!function_exists('format_day')) {
|
|
|
{
|
|
|
if ($day >= 365) {
|
|
|
return '一年';
|
|
|
- }else if($day>=30){
|
|
|
- return intval($day/30).'个月';
|
|
|
- }else{
|
|
|
- return intval($day).'天';
|
|
|
+ } else if ($day >= 30) {
|
|
|
+ return intval($day / 30) . '个月';
|
|
|
+ } else {
|
|
|
+ return intval($day) . '天';
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('format_bank_card')) {
|
|
|
@@ -692,7 +687,6 @@ if (!function_exists('format_bank_card')) {
|
|
|
}
|
|
|
return $format_card_no;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('format_mobile')) {
|
|
|
@@ -760,7 +754,6 @@ if (!function_exists('get_password')) {
|
|
|
{
|
|
|
return md5(md5($password));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('get_order_num')) {
|
|
|
@@ -777,7 +770,6 @@ if (!function_exists('get_order_num')) {
|
|
|
$micro = substr(microtime(), 2, 2);
|
|
|
return $prefix . date("YmdHis") . $micro . rand(1000, 9999);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('getter')) {
|
|
|
@@ -839,7 +831,6 @@ if (!function_exists('get_zodiac_sign')) {
|
|
|
}
|
|
|
return $sign_name;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('get_image_url')) {
|
|
|
@@ -1039,7 +1030,7 @@ if (!function_exists('format_content')) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $content = str_replace(["\n",'\n'], ["<br/>","<br/>"], htmlspecialchars_decode($content));
|
|
|
+ $content = str_replace(["\n", '\n'], ["<br/>", "<br/>"], htmlspecialchars_decode($content));
|
|
|
return get_format_content($content);
|
|
|
}
|
|
|
}
|
|
|
@@ -1123,7 +1114,6 @@ if (!function_exists('get_client_ip')) {
|
|
|
$ip = $long ? array($ip, $long) : array('0.0.0.0', 0);
|
|
|
return $ip[$type];
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('get_guid_v4')) {
|
|
|
@@ -1150,7 +1140,7 @@ if (!function_exists('get_guid_v4')) {
|
|
|
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((float) microtime() * 10000);
|
|
|
$charid = strtolower(md5(uniqid(rand(), true)));
|
|
|
$hyphen = chr(45); // "-"
|
|
|
$lbrace = $trim ? "" : chr(123); // "{"
|
|
|
@@ -1179,7 +1169,6 @@ if (!function_exists('is_email')) {
|
|
|
{
|
|
|
return preg_match('/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/', $str);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('is_mobile')) {
|
|
|
@@ -1195,7 +1184,6 @@ if (!function_exists('is_mobile')) {
|
|
|
{
|
|
|
return preg_match('/^1(3|4|5|7|8)\d{9}$/', $num);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('is_zipcode')) {
|
|
|
@@ -1211,7 +1199,6 @@ if (!function_exists('is_zipcode')) {
|
|
|
{
|
|
|
return preg_match('/^[1-9][0-9]{5}$/', $code);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('is_idcard')) {
|
|
|
@@ -1270,7 +1257,6 @@ if (!function_exists('is_idcard')) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('is_empty')) {
|
|
|
@@ -1420,7 +1406,7 @@ if (!function_exists('message')) {
|
|
|
*/
|
|
|
function message($msg = "操作成功", $success = true, $data = [], $code = 0, $type = 'json')
|
|
|
{
|
|
|
- $result = ['success' => $success, 'msg' => lang($msg), 'data' => $success==true || env('APP_DEBUG')?$data:[], 'stime' => time()];
|
|
|
+ $result = ['success' => $success, 'msg' => lang($msg), 'data' => $success == true || env('APP_DEBUG') ? $data : [], 'stime' => time()];
|
|
|
if ($success) {
|
|
|
$result['code'] = 0;
|
|
|
} else {
|
|
|
@@ -1586,7 +1572,6 @@ if (!function_exists('strip_html_tags')) {
|
|
|
}
|
|
|
return $str;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('sub_str')) {
|
|
|
@@ -1619,7 +1604,6 @@ if (!function_exists('sub_str')) {
|
|
|
$omit = mb_strlen($str) >= $length ? '...' : '';
|
|
|
return $suffix ? $slice . $omit : $slice;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
if (!function_exists('save_image')) {
|
|
|
@@ -1809,13 +1793,13 @@ if (!function_exists('upload_image')) {
|
|
|
$size = $file->getSize();
|
|
|
|
|
|
// 文件大小校验
|
|
|
- if ($size > 5 * 1024 * 1024) {
|
|
|
- return message("文件大小超过了5M", false);
|
|
|
+ if ($size > 10 * 1024 * 1024) {
|
|
|
+ return message("文件大小超过了10M", false);
|
|
|
}
|
|
|
|
|
|
// 文件后缀校验
|
|
|
$ext = strtolower($ext);
|
|
|
- $ext_arr = array('jpg', 'jpeg', 'png', 'gif');
|
|
|
+ $ext_arr = array('jpg', 'jpeg', 'png', 'gif', 'doc', 'docx');
|
|
|
if (!in_array($ext, $ext_arr)) {
|
|
|
return message("文件格式不正确:" . $ext, false);
|
|
|
}
|
|
|
@@ -2176,7 +2160,6 @@ if (!function_exists('httpRequest')) {
|
|
|
$ret = iconv('gb2312', 'utf-8', $ret);
|
|
|
$retArr = json_decode($ret, true);
|
|
|
}
|
|
|
-
|
|
|
} catch (\Exception $exception) {
|
|
|
$retArr = ['code' => 'error', 'msg' => 'request error'];
|
|
|
}
|
|
|
@@ -2199,20 +2182,20 @@ if (!function_exists('aiRequest')) {
|
|
|
function aiRequest($url, $data = '', $timeout = 60, $header = [])
|
|
|
{
|
|
|
|
|
|
- set_time_limit($timeout);
|
|
|
- $ch = curl_init($url);
|
|
|
- if ($header) {
|
|
|
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
- }
|
|
|
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
|
|
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //禁止 cURL 验证对等证书
|
|
|
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //是否检测服务器的域名与证书上的是否一致
|
|
|
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
|
|
- $ret = curl_exec($ch);
|
|
|
- curl_close($ch);
|
|
|
- return $ret;
|
|
|
+ set_time_limit($timeout);
|
|
|
+ $ch = curl_init($url);
|
|
|
+ if ($header) {
|
|
|
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
+ }
|
|
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //禁止 cURL 验证对等证书
|
|
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); //是否检测服务器的域名与证书上的是否一致
|
|
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+ curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
|
|
|
+ $ret = curl_exec($ch);
|
|
|
+ curl_close($ch);
|
|
|
+ return $ret;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2317,7 +2300,6 @@ if (!function_exists('getDistance')) {
|
|
|
)
|
|
|
)
|
|
|
) * 1000);
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2408,7 +2390,7 @@ if (!function_exists('crypt_answer')) {
|
|
|
}
|
|
|
|
|
|
$key = $key ? $key : env('APP_SIGN_KEY', '');
|
|
|
- return md5($id.'-'. $answer.'-'.$key);
|
|
|
+ return md5($id . '-' . $answer . '-' . $key);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -2473,4 +2455,4 @@ if (!function_exists('format_image_field')) {
|
|
|
// 单图字符串
|
|
|
return get_image_url($images, $domain);
|
|
|
}
|
|
|
-}
|
|
|
+}
|