123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- if(!function_exists("json_show")){
- function json_show(int $code = 0, string $message = '请求成功', array $data = [])
- {
- return json(['code' => $code, 'message' => $message, 'data' => $data]);
- }
- }
- if(!function_exists("checkMobile")){
- function checkMobile($mobile){
- if (!is_numeric($mobile)) {
- return false;
- }
- return preg_match('#^1[3,4,5,6,7,8,9]{1}[\d]{9}$#', $mobile) ? true : false;
- }
- }
- if(!function_exists("checkEmail")){
- function checkEmail($email){
- if (!$email) {
- return false;
- }
- return preg_match('#[a-z0-9&\-_.]+@[\w\-_]+([\w\-.]+)?\.[\w\-]+#is', $email) ? true : false;
- }
- }
- if(!function_exists("makeSalt")){
- function makeSalt(){
- $salt = rand(10000000,99999999);
- return $salt;
- }
- }
- if(!function_exists("makeToken")){
- function makeToken($account){
- return sha1($account['username'].$account['mobile'].time());
- }
- }
- if(!function_exists("checkToken")){
-
- function checkToken($token,$expire=0){
- $getToken = think\facade\Cache::store("redis")->get("user:info:{$token}");
- if($getToken!=false){
- $cache=think\facade\Cache::store("redis")->set("user:info:{$token}",$getToken,$expire);
- if($cache!=false) return $getToken;
- }
- return false;
- }
- }
|