public function verify() { if (!Request::ajax() || !Request::isJson()) { return Response::make('...', 403); } $arr = Input::all(); $session_token = Session::get('_token'); //$session_token = Session::get('real'); $_token = $arr['_token']; // if( !isset($arr['time']) || $arr['time'] == null) // { // $arr['time'] = 0; // } if ($session_token == $_token) { $data = array('telphone' => trim($arr['phone']), 'score' => $arr['score'], 'time' => $arr['time']); $type = $arr['type']; if ($data['time'] < 0) { $data['time'] = 0; } $telphone = trim($arr['phone']); $partten = "/1\\d{10}/"; if (preg_match($partten, $telphone)) { } else { return Response::make('fuck', 403); } if ($this->save($data, $type)) { $position = $this->getPosition($type, $telphone); return Response::json($position); } else { return Response::make('fuck!', 403); } } else { return Response::make('403!', 403); } }
public function updateQuestioner($id) { if (\Request::isJson()) { $data = Input::all(); Questioner::updateQuestioner($data); } }
App::after(function ($request, $response) { // }); /* |-------------------------------------------------------------------------- | Authentication Filters |-------------------------------------------------------------------------- | | The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (!Request::isJson()) { return Redirect::guest('login'); } return Response::json(null, 403); } }); Route::filter('admin', function () { if (Auth::guest()) { return Redirect::guest('login')->with('message', 'You need to login'); } if (Auth::user()->admin != 1) { return Redirect::guest('login')->with('message', 'You need to login'); } }); Route::filter('auth.basic', function () { return Auth::basic();
public function testFacade() { $json = Request::isJson(); $this->assertEquals(false, $json); }
/** * Asking if the request is a type of AJAX request. * * @param \Illuminate\Http\Request $request * * @return bool */ protected function areYouAnAjax(Request $request) { return $request->ajax() || $request->wantsJson() || $request->acceptsJson() || $request->isJson(); }
/** * Check if request is Ajax * * @return bool */ public static function isAjax() { return \Request::isJson() || Input::has('ajax'); }