public function getCode() { $phone = \Input::get('phone'); $key = \App\Services\User\UserService::getRedisKeys('smsKey', [date('Ymd'), $phone]); $data = \LRedis::GET($key); $data && ($data = json_decode($data, 1)); $last = end($data); return $this->__json(200, 'ok', $last); }
function getOnlineIp() { $OnlineIp = \LRedis::GET('OnlineIp'); if (!$OnlineIp) { $url = 'http://city.ip138.com/ip2city.asp'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 8); $send_result = curl_exec($ch); if ($send_result === false) { throw new \Exception("REQ[{$url}]" . curl_error($ch), curl_errno($ch) + 60000); } preg_match('/\\[(.*)\\]/', $send_result, $ip); $OnlineIp = $ip[1]; \LRedis::SETEX('OnlineIp', 6000, $OnlineIp); } return $OnlineIp; }