当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::token方法代码示例

本文整理汇总了PHP中Session::token方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::token方法的具体用法?PHP Session::token怎么用?PHP Session::token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session::token方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testDestroy

 public function testDestroy()
 {
     $server = array('HTTP_X-Requested-With' => 'XMLHttpRequest');
     $params = ['_token' => \Session::token(), 'id' => 1];
     $this->post('/user/destroy', $params, $server)->seeJsonEqualsExt(['status' => '200', 'message' => 'OK']);
     $this->seeInDatabaseExt('users', ['id' => 1], ['created_at' => false, 'updated_at' => true], true);
 }
开发者ID:TakahikoYoshii,项目名称:laravel,代码行数:7,代码来源:destroyTest.php

示例2: testTodosRoutes

 /**
  * TodosControllerのテスト
  *
  * @return void
  */
 public function testTodosRoutes()
 {
     // フィルタを有効にする
     Route::enableFilters();
     // GET /todos
     $response = $this->call('GET', '/todos');
     $this->assertEquals(200, $response->getStatusCode());
     // POST /todos
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos', $input);
     $this->assertEquals(302, $response->getStatusCode());
     $this->assertHasOldInput();
     // POST /todos/1/update
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos/1/update', $input);
     $this->assertEquals(404, $response->getStatusCode());
     // PUT /todos/1/title
     $input = [];
     $response = $this->call('PUT', '/todos/1/title', $input);
     $this->assertEquals(404, $response->getStatusCode());
     // POST /todos/1/delete
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos/1/delete', $input);
     $this->assertEquals(404, $response->getStatusCode());
     // POST /todos/1/restore
     $input = ['_token' => Session::token()];
     $response = $this->call('POST', '/todos/1/restore', $input);
     $this->assertEquals(404, $response->getStatusCode());
 }
开发者ID:r-itakura,项目名称:l4-sample-todo,代码行数:34,代码来源:RouteTest.php

示例3: save

 public function save()
 {
     $id = Input::get('id');
     $ct = $this->category->find($id);
     $token = \Input::get('_token');
     if (\Session::token() === $token) {
         $data = array('ten_vi' => Input::get('ten_vi'), 'hienthi' => Input::has('hienthi'), 'parent' => Input::get('category'), 'slug_vi' => \Str::slug(Input::get('ten_vi'), '-'), 'title_seo_vi' => Input::get('title_seo_vi'), 'desc_seo_vi' => Input::get('desc_seo_vi'), 'keyword_seo_vi' => Input::get('keyword_seo_vi'));
         // var_dump($data);die();
         $ct->hienthi = $data['hienthi'];
         $ct->ten_vi = $data['ten_vi'];
         $ct->slug_vi = $data['slug_vi'];
         $ct->parent = $data['parent'];
         $ct->title_seo_vi = $data['title_seo_vi'];
         $ct->desc_seo_vi = $data['desc_seo_vi'];
         $ct->keyword_seo_vi = $data['keyword_seo_vi'];
         /* avoiding resubmission of same content */
         if (count($ct->getDirty()) > 0) {
             \DB::beginTransaction();
             try {
                 $ct->save();
             } catch (\Exception $e) {
                 \DB::rollBack();
                 return \Redirect::back()->withInput()->with('success', 'ERROR : Update fail');
             }
             \DB::commit();
             return \Redirect::back()->withInput()->with('success', 'Cập nhật thành công');
         } else {
             return \Redirect::back()->withInput()->with('success', 'Không thay đổi gì');
         }
     } else {
         return \Redirect::back()->withInput()->with('success', 'Cập nhật thất bại, Token hết hiệu lực');
     }
 }
开发者ID:anhtuanssp,项目名称:createyourown_vn_inqua,代码行数:33,代码来源:AdminChuyenmucController.php

示例4: crearEncuesta

 public function crearEncuesta($encuesta, $email, $nombre = 'sin dato', $empresa = 'sin dato')
 {
     if (Session::token() != Input::get('_token')) {
         die;
     }
     $respuesta = Input::all();
     //array respuestas form //print_r($respuesta);
     $datosEncuesta = DB::table('encuesta')->where('id', $encuesta)->first();
     $cantidad = DB::table('pregunta')->where('idEncuesta', $encuesta)->count();
     //Inserta usuario por email e ip
     $ip = Request::getClientIp();
     $usuariosEmail = DB::table('users')->where('email', $email)->first();
     //codigo rand
     /*$usuariosEmail = DB::table('users')->where('email', $email)->first();
       $base = 1245;
       $cant= DB::table('users')->count();
       $random = $base + $cant;*/
     if (empty($usuariosEmail)) {
         $x = new User();
         $x->email = $email;
         $x->nombre = $nombre;
         $x->empresa = $empresa;
         $x->ip = $ip;
         $x->codigo = '';
         $x->save();
         //codigo
         $usuarios = DB::table('users')->where('email', $email)->first();
         $usuario = $usuarios->id;
         $codigo = '12' . $usuario;
         DB::table('users')->where('id', $usuario)->update(array('codigo' => $codigo));
     } else {
         $mensaje = 'Usted ya ha completado la encuesta, sólo puede realizar esta acción una vez';
         return View::make('encuesta.completado', array('mensaje' => $mensaje, 'encuesta' => $datosEncuesta));
     }
     $usuarios = DB::table('users')->where('email', $email)->first();
     $usuario = $usuarios->id;
     $codigo = $usuarios->codigo;
     Session::put('codigo', $codigo);
     //Inserta usuario_encuesta
     $x = new UsuarioEncuesta();
     $x->idUsuario = $usuario;
     $x->idEncuesta = $encuesta;
     $x->save();
     $usuarioEnc = DB::table('usuario_encuesta')->where('idUsuario', $usuario)->first();
     $usuarioEncuesta = $usuarioEnc->id;
     //Inserta respuestas
     for ($i = 1; $i <= $cantidad; $i++) {
         $valor = Input::get('pregunta' . $i);
         if ($valor != '') {
             $x = new Respuesta();
             $x->idUsuarioEncuesta = $usuarioEncuesta;
             $x->idEncuestaPregunta = $i;
             $x->valor = $valor;
             $x->save();
         }
     }
     return Redirect::to('/formulario-ok');
     //return View::make('encuesta.completado', array('encuesta' => $datosEncuesta,'email' => $email, 'nombre' => $nombre, 'empresa' => $empresa, 'codigo' => $random));
 }
开发者ID:hramose,项目名称:Nufarm-Encuesta,代码行数:59,代码来源:EncuestasController.php

示例5: routeFilters

 protected function routeFilters()
 {
     Route::filter('csrf', function () {
         if (\Session::token() != \Input::get('_token')) {
             throw new \Illuminate\Session\TokenMismatchException();
         }
     });
 }
开发者ID:stanmay,项目名称:unflare,代码行数:8,代码来源:Start.php

示例6: create

 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create()
 {
     if (Session::token() == Input::get('_token')) {
         $response = array('status' => 'fail', 'msg' => 'unauthorized Action');
     }
     try {
         $month = Input::get('qter');
         if ($month <= 3 && $month >= 1) {
             $q = Leave::whereBetween('date', array('2016-01-01', '2016-03-31'))->where('agent_ID', '=', Input::get('agent'))->count();
         } else {
             if ($month <= 4 && $month >= 6) {
                 $q = Leave::whereBetween('date', array('2016-04-01', '2016-06-30'))->where('agent_ID', '=', Input::get('agent'))->count();
             } else {
                 if ($month <= 7 && $month >= 9) {
                     $q = Leave::whereBetween('date', array('2016-07-01', '2016-09-30'))->where('agent_ID', '=', Input::get('agent'))->count();
                 } else {
                     if ($month <= 10 && $month >= 12) {
                         $q = Leave::whereBetween('date', array('2016-10-01', '2016-12-31'))->where('agent_ID', '=', Input::get('agent'))->count();
                     }
                 }
             }
         }
         $fullyBooked = Leave::where('date', '=', Input::get('date'))->count();
         $agent = Leave::where('date', '=', Input::get('date'))->where('agent_ID', '=', Input::get('agent'))->count();
         $monthMax = Leave::where('date', 'like', Input::get('month') . '%')->where('agent_ID', '=', Input::get('agent'))->count();
         $maxLeave = Leave::where('agent_ID', '=', Input::get('agent'))->count();
         if ($fullyBooked >= 1) {
             $response = array('status' => 'Error', 'msg' => 'Sorry!! This day is fully Booked..Please select another day');
         } else {
             if ($agent >= 1) {
                 $response = array('status' => 'Error', 'msg' => 'You have already booked this day!!');
             } else {
                 if ($q >= 5) {
                     $response = array('status' => 'Error', 'msg' => 'You\'re Not allowed to go for more than 5 days leave in three months.. please see your Team lead in case you want an extra leave for this quota');
                 } else {
                     if ($monthMax >= 5) {
                         $response = array('status' => 'Error', 'msg' => 'Sorry! You can only take 5 leave days in a month!!');
                     } else {
                         if ($maxLeave >= 21) {
                             $response = array('status' => 'Error', 'msg' => 'Sorry! You have exhausted your leave days for this Year(21 max allowed)');
                         } else {
                             $leave = new Leave();
                             $leave->date = Input::get('date');
                             $leave->agent_ID = Input::get('agent');
                             $leave->save();
                             $response = array('status' => 'success', 'msg' => 'leave day successfully booked');
                         }
                     }
                 }
             }
         }
     } catch (\Illuminate\Database\Eloquent\MassAssignmentException $e) {
         $response = array('status' => 'Error', 'msg' => 'mass assignment not allowed!!');
     } catch (Illuminate\Database\QueryException $e) {
         $response = array('status' => 'Error', 'msg' => $e);
     }
     return Response::json($response);
 }
开发者ID:mwenda-eric,项目名称:LeaveApp,代码行数:63,代码来源:LeaveController.php

示例7: testDeleteUser

 /**
  * Удаление пользователя
  * @depends testUpdateUser
  * @param $user_id
  */
 public function testDeleteUser($user_id)
 {
     $this->assertNotEmpty($user_id);
     $url = '/rest/user/' . $user_id;
     \Session::start();
     $this->delete($url, ['_token' => \Session::token()], ['X-Requested-With' => 'XMLHttpRequest'])->see(1);
     $this->assertResponseOk();
     $this->get($url, ['X-Requested-With' => 'XMLHttpRequest'])->seeJson(['User not found']);
 }
开发者ID:serovvitaly,项目名称:new.jp.appros.ru,代码行数:14,代码来源:RestUserTest.php

示例8: testUpdate

 public function testUpdate()
 {
     $server = array('HTTP_X-Requested-With' => 'XMLHttpRequest');
     $params = ['_token' => \Session::token(), 'id' => 1, 'name' => 'test_update', 'email' => 'test_update@test.te', 'password' => 'updatePassword', 'password_confirmation' => 'updatePassword'];
     $this->post('/user/store', $params, $server)->seeJsonEqualsExt(['status' => '200', 'message' => 'OK']);
     $this->seeInDatabaseExt('users', ['id' => 1, 'name' => 'test_update', 'email' => 'test_update@test.te'], ['created_at' => false, 'updated_at' => true], false);
     $user = User::find(1);
     $this->assertTrue(\Hash::check('updatePassword', $user->password));
 }
开发者ID:TakahikoYoshii,项目名称:laravel,代码行数:9,代码来源:storeTest.php

示例9: getForm

 /**
  * 登録フォーム
  * @param null $one
  */
 public function getForm($one = null)
 {
     \Session::put(self::SESSION_KEY, \Session::token());
     $data = ['id' => $one, 'sections' => $this->section->getSectionList('name', 'section_id')];
     if ($one) {
         $data['category'] = $this->category->getCategory($one);
     }
     $this->view('webmaster.category.form', $data);
 }
开发者ID:k-kurikuri,项目名称:Laravel.JpRecipe,代码行数:13,代码来源:CategoryController.php

示例10: postDeleteIncasare

 public function postDeleteIncasare()
 {
     if (Request::ajax()) {
         if (Session::token() === Input::get('_token')) {
             $id = Input::get('id_incasare');
             DB::table('incasare_factura')->where('id_incasare', $id)->update(array('logical_delete' => 1));
             return $id;
         }
     }
 }
开发者ID:binaryk,项目名称:lareab,代码行数:10,代码来源:IncasariFacturaController.php

示例11: testWriteMessage

 /**
  * Test that a user can write a message.
  */
 public function testWriteMessage()
 {
     $admin = $this->createSuperuser();
     $this->be($admin);
     $conversation = $this->createConversation($admin);
     $this->createMessage($conversation);
     $this->call('GET', route('conversation.show', ['conversation' => $conversation->id]));
     $response = $this->call('POST', route('conversation.message.store', ['conversation' => $conversation->id]), ['message' => 'Test', '_token' => \Session::token()]);
     $this->assertRedirectedToRoute('conversation.show', ['conversation' => $conversation->id, '#message-2']);
 }
开发者ID:rafaelvieiras,项目名称:connect,代码行数:13,代码来源:MessageTest.php

示例12: testLoginWrongPassword

 /**
  * Test that the user can't login with a wrong password.
  */
 public function testLoginWrongPassword()
 {
     $password = 'ABC123456';
     $user = $this->createUser($password);
     $this->call('GET', route('account.login'));
     $this->assertResponseOk();
     $this->call('POST', route('account.doLogin'), ['email' => $user->email, 'password' => $password . 'WRONG', '_token' => Session::token()]);
     $this->assertRedirectedToRoute('account.login');
     $this->assertFalse(\Sentry::check());
 }
开发者ID:rafaelvieiras,项目名称:connect,代码行数:13,代码来源:LoginTest.php

示例13: testDeleteProduct

 /**
  * Удаление продукта
  * @depends testUpdateProduct
  * @param $product_id
  */
 public function testDeleteProduct($product_id)
 {
     $this->assertNotEmpty($product_id);
     $url = '/rest/product/' . $product_id;
     \Session::start();
     $user = \App\User::find(8);
     $this->actingAs($user)->delete($url, ['_token' => \Session::token()], ['X-Requested-With' => 'XMLHttpRequest'])->see(1);
     $this->assertResponseOk();
     $this->get($url, ['X-Requested-With' => 'XMLHttpRequest'])->seeJson(['Product not found']);
 }
开发者ID:serovvitaly,项目名称:new.jp.appros.ru,代码行数:15,代码来源:RestProductTest.php

示例14: postAsociazaRole

 public function postAsociazaRole()
 {
     if (Request::ajax()) {
         if (Session::token() === Input::get('_token')) {
             $id = Input::get('id');
             DB::table('aplicatie_role')->insertGetId(array('id_aplicatie' => Input::get('id_aplicatie'), 'id_role' => $id));
             return $id;
         }
     }
 }
开发者ID:binaryk,项目名称:lareab,代码行数:10,代码来源:AplicatieController.php

示例15: postDeleteEtapa

 public function postDeleteEtapa()
 {
     if (Request::ajax()) {
         if (Session::token() !== Input::get('_token')) {
             $id = Input::get('id_etapa');
             DB::table('etape_predare_livrabile')->where('id_etapa', $id)->update(array('logical_delete' => 1));
             return $id;
         }
     }
 }
开发者ID:binaryk,项目名称:lareab,代码行数:10,代码来源:EtapeTermeneController.php


注:本文中的Session::token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。