From dc3f8140a0bec68df163520a69098bf3a8f83179 Mon Sep 17 00:00:00 2001 From: knowpia <9812993@qq.com> Date: Fri, 9 Sep 2022 11:20:20 +0800 Subject: [PATCH] NEED_LOGIN code add --- .gitignore | 3 +- app/controller/Down.php | 59 +++++++++++++++++++++++++++++++++++++++ app/controller/Search.php | 11 ++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 app/controller/Down.php diff --git a/.gitignore b/.gitignore index e8f8d09..d465120 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.idea /.vscode /vendor -*.log \ No newline at end of file +*.log +.env \ No newline at end of file diff --git a/app/controller/Down.php b/app/controller/Down.php new file mode 100644 index 0000000..285532f --- /dev/null +++ b/app/controller/Down.php @@ -0,0 +1,59 @@ +where("name","shengyu")->find(); + if(empty($info) || empty($info['value'])){ + return show("倒计时未设置"); + } + $ints = strtotime($info["value"]) - time(); + return show("获取成功",SUCCESS_CODE,[ + "time"=>$ints, + "timeStr"=>$this->secondsToTime($ints) + ]); + } + + + + /** + * 将秒进行格式化 + *@param $inputSeconds 秒数 + *@return array + */ + function secondsToTime($inputSeconds) { + $secondsInAMinute = 60; + $secondsInAnHour = 60 * $secondsInAMinute; + $secondsInADay = 24 * $secondsInAnHour; + + // extract days + $days = floor($inputSeconds / $secondsInADay); + + // extract hours + $hourSeconds = $inputSeconds % $secondsInADay; + $hours = floor($hourSeconds / $secondsInAnHour); + + // extract minutes + $minuteSeconds = $hourSeconds % $secondsInAnHour; + $minutes = floor($minuteSeconds / $secondsInAMinute); + + // extract the remaining seconds + $remainingSeconds = $minuteSeconds % $secondsInAMinute; + $seconds = ceil($remainingSeconds); + + // return the final array + $obj = array( + 'd' => (int) $days, + 'h' => (int) $hours, + 'm' => (int) $minutes, + 's' => (int) $seconds, + ); + return $obj; + } + + +} \ No newline at end of file diff --git a/app/controller/Search.php b/app/controller/Search.php index 971bdbc..9854ace 100644 --- a/app/controller/Search.php +++ b/app/controller/Search.php @@ -17,6 +17,17 @@ class Search }else{ $where = "id < ".$lastIndex; } + $types = [1,2,3,4]; + if(!empty($GLOBALS['data']['data']["type"])){ + $type = $GLOBALS['data']['data']["type"]; + if(!in_array($type, $types)){ + return show("上传的类型不正确"); + } + + if($type == 1) $where .= " and type = 1"; + if($type == 2) $where .= " and type = 2"; + if($type == 3) $where .= " and disabled = 1"; + } $KEY = $post['keywords'];