本文整理汇总了PHP中csrf_token函数的典型用法代码示例。如果您正苦于以下问题:PHP csrf_token函数的具体用法?PHP csrf_token怎么用?PHP csrf_token使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了csrf_token函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPrelogin
/**
* 初始化登录,返回加密密钥
*
* @param App\Services\Login\Process $loginProcess 登录核心处理
* @access public
*/
public function getPrelogin(LoginProcess $loginProcess)
{
$publicKey = $loginProcess->getProcess()->setPublicKey();
$callback = Request::input('callback');
$result = ['pKey' => $publicKey, 'a' => csrf_token()];
return response()->json($result)->setCallback($callback);
}
示例2: buildupScript
/**
* Build tree grid scripts.
*
* @return void
*/
protected function buildupScript()
{
$confirm = trans('admin::lang.delete_confirm');
$token = csrf_token();
$this->script = <<<SCRIPT
\$('#{$this->elementId}').nestable({});
\$('._delete').click(function() {
var id = \$(this).data('id');
if(confirm("{$confirm}")) {
\$.post('/{$this->path}/' + id, {_method:'delete','_token':'{$token}'}, function(data){
\$.pjax.reload('#pjax-container');
});
}
});
\$('.{$this->elementId}-save').click(function () {
var serialize = \$('#{$this->elementId}').nestable('serialize');
\$.get('/{$this->path}', {'_tree':JSON.stringify(serialize)}, function(data){
\$.pjax.reload('#pjax-container');
});
});
\$('.{$this->elementId}-refresh').click(function () {
\$.pjax.reload('#pjax-container');
});
SCRIPT;
}
示例3: indexAction
/**
* Returns the initial HTML view for the admin interface.
*
* @param \Illuminate\Http\Request $request Laravel request object
* @return \Illuminate\Contracts\View\View View for rendering the output
*/
public function indexAction(Request $request)
{
if (config('shop.authorize', true)) {
$this->authorize('admin');
}
$site = Route::input('site', 'default');
$lang = Input::get('lang', config('app.locale', 'en'));
$aimeos = app('\\Aimeos\\Shop\\Base\\Aimeos')->get();
$cntlPaths = $aimeos->getCustomPaths('controller/extjs');
$context = app('\\Aimeos\\Shop\\Base\\Context')->get(false);
$context = $this->setLocale($context, $site, $lang);
$controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
$cssFiles = array();
foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths) {
foreach ($paths as $path) {
$jsbAbsPath = $base . '/' . $path;
if (!is_file($jsbAbsPath)) {
throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath));
}
$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path));
$cssFiles = array_merge($cssFiles, $jsb2->getUrls('css'));
}
}
$jqadmUrl = route('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product'));
$jsonUrl = route('aimeos_shop_extadm_json', array('site' => $site, '_token' => csrf_token()));
$adminUrl = route('aimeos_shop_extadm', array('site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>'));
$vars = array('lang' => $lang, 'cssFiles' => $cssFiles, 'languages' => $this->getJsonLanguages($context), 'config' => $this->getJsonClientConfig($context), 'site' => $this->getJsonSiteItem($context, $site), 'i18nContent' => $this->getJsonClientI18n($aimeos->getI18nPaths(), $lang), 'searchSchemas' => $controller->getJsonSearchSchemas(), 'itemSchemas' => $controller->getJsonItemSchemas(), 'smd' => $controller->getJsonSmd($jsonUrl), 'urlTemplate' => str_replace(['<', '>'], ['{', '}'], urldecode($adminUrl)), 'uploaddir' => config('shop::uploaddir'), 'activeTab' => Input::get('tab', 0), 'version' => $this->getVersion(), 'jqadmurl' => $jqadmUrl);
return View::make('shop::admin.extadm-index', $vars);
}
示例4: csrf_inject
function csrf_inject()
{
$name = md5(uniqid(rand(), true));
$token = csrf_token($name);
echo "<input type='hidden' name='csrf_name' value='{$name}'>";
echo "<input type='hidden' name='csrf_token' value='{$token}'>";
}
示例5: testCreate
function testCreate()
{
// Given
$this->startSession();
$userData = ['name' => 'Captain Kirk', 'email' => 'jkirk@enterprise.space', 'password' => 'strongpassword', 'country_code' => '1', 'phone_number' => '5558180101'];
$newUser = new User($userData);
$newUser->save();
$this->be($newUser);
$propertyData = ['description' => 'Some description', 'image_url' => 'http://www.someimage.com'];
$newProperty = new VacationProperty($propertyData);
$newUser->properties()->save($newProperty);
$this->assertCount(0, Reservation::all());
$mockTwilioClient = Mockery::mock(Client::class)->makePartial();
$mockTwilioMessages = Mockery::mock();
$mockTwilioClient->messages = $mockTwilioMessages;
$twilioNumber = config('services.twilio')['number'];
$mockTwilioMessages->shouldReceive('create')->with($newUser->fullNumber(), ['from' => $twilioNumber, 'body' => 'Some reservation message - Reply \'yes\' or \'accept\' to confirm the reservation, or anything else to reject it.'])->once();
$this->app->instance(Client::class, $mockTwilioClient);
// When
$response = $this->call('POST', route('reservation-create', ['id' => $newProperty->id]), ['message' => 'Some reservation message', '_token' => csrf_token()]);
// Then
$this->assertCount(1, Reservation::all());
$reservation = Reservation::first();
$this->assertEquals($reservation->message, 'Some reservation message');
$this->assertRedirectedToRoute('property-show', ['id' => $newProperty->id]);
$this->assertSessionHas('status');
$flashreservation = $this->app['session']->get('status');
$this->assertEquals($flashreservation, "Sending your reservation request now.");
}
示例6: it_deletes_an_role
/** @test */
public function it_deletes_an_role()
{
$this->prepare();
$response = $this->actingAs($this->superAdminUser)->visit('genealabs/laravel-governor/roles/create')->type('TestRole', 'name')->type('This is a description for test users role.', 'description')->press('Add Role')->see('TestRole');
$response = $this->actingAs($this->superAdminUser)->delete('genealabs/laravel-governor/roles/TestRole', ['_token' => csrf_token()]);
$this->assertCount(0, Role::where('name', 'TestRole')->get());
}
示例7: __construct
public function __construct()
{
parent::__construct();
$this->setJavascriptData('csrfToken', csrf_token());
$this->setIconMenu();
$this->setRightMenu();
}
示例8: _exportIssues
/**
* @param FunctionalTester $I
* @param Project $project
* @param array $params
*
* @return void
*/
protected function _exportIssues(FunctionalTester $I, Project $project, array $params)
{
$I->amOnAction('ProjectController@getIndex', ['project' => $project]);
$uri = $I->getApplication()->url->action('ProjectController@postExportIssues', ['project' => $project]);
$I->sendAjaxPostRequest($uri, array_merge(['_token' => csrf_token(), 'keyword' => '', 'assignto' => '', 'tags' => ''], $params));
$I->seeResponseCodeIs(200);
}
示例9: testRequests
public function testRequests()
{
$client = factory(Client::class)->create();
$response = $this->call('GET', '/clients/');
$this->assertEquals(404, $response->status());
$response = $this->call('GET', '/clients/new');
$this->assertEquals(200, $response->status());
$response = $this->call('GET', '/clients/list');
$this->assertEquals(200, $response->status());
$response = $this->call('GET', '/clients/edit/' . $client->id);
$this->assertEquals(200, $response->status());
$response = $this->call('POST', '/clients/store', ['name' => 'Ruiz', 'birth' => '1992-07-08', 'address' => 'bairro centro', 'phone' => '55 42 9916-1669']);
$this->assertEquals(500, $response->status());
$response = $this->call('POST', '/clients/store', ['_token' => csrf_token(), 'name' => 'Ruiz']);
$this->assertEquals(302, $response->status());
$response = $this->call('POST', '/clients/store', ['_token' => csrf_token(), 'name' => 'Ruiz', 'birth' => '1992-07-08', 'address' => 'bairro centro', 'phone' => '55 42 9916-1669']);
$this->assertEquals(200, $response->status());
$response = $this->call('POST', '/clients/update/' . $client->id, ['name' => 'Ruiz', 'birth' => '1992-07-08', 'address' => 'bairro centro', 'phone' => '55 42 9916-1669']);
$this->assertEquals(500, $response->status());
$response = $this->call('POST', '/clients/update/' . $client->id, ['_token' => csrf_token(), 'name' => 'Ruiz']);
$this->assertEquals(302, $response->status());
$response = $this->call('POST', '/clients/update/' . $client->id, ['_token' => csrf_token(), 'name' => 'Brizola', 'birth' => '1992-07-08', 'address' => 'bairro centro', 'phone' => '4230353333']);
$this->assertEquals(200, $response->status());
$response = $this->call('POST', '/clients/delete/');
$this->assertEquals(500, $response->status());
$response = $this->call('POST', '/clients/delete/' . $client->id, ['_token' => csrf_token()]);
$this->assertEquals(200, $response->status());
}
示例10: anyData
public function anyData(Request $req)
{
// $data = Unitkerja::all();
// $count = App\Flight::where('active', 1)->count();
// $data = \DB::table('unit_kerja');
$data = Unitkerja::with('skpd');
// dd($data->get());
if ($req->get('filter_skdp_id')) {
$result = $data->where('skpd_id', '=', $req->get('filter_skdp_id'))->get();
// $['rows']=$result;
// return $result;
$datax['rows'] = $this->show_relasi_kolom($result);
// return $this->show_relasi_kolom($result);
return $datax + ['token' => csrf_token()];
}
if ($req->get('page')) {
// dd($req->get('page')-1);
if ($req->get('page') == 1) {
$offset = $req->get('page') - 1;
} else {
$offset = ($req->get('page') - 1) * $req->get('rows');
}
$data->skip($offset);
}
if ($req->get('rows')) {
$data->take($req->get('rows'));
}
// $datax['rows']=$data->get();
// $datax['rows']=$this->show_relasi_kolom($data->get(),'skpd','nama_skpd','skpd');
$datax['rows'] = $this->show_relasi_kolom($data->get());
$total['total'] = \DB::table('unit_kerja')->count();
// dd($data->get());
return $total + $datax + ['token' => csrf_token()];
//
}
示例11: create_csrf_token
function create_csrf_token($id = "")
{
$token = csrf_token();
$_SESSION['csrf_token' . $id] = $token;
$_SESSION['csrf_token_time' . $id] = time();
return $token;
}
示例12: should_redirect_to_home_page_when_not_found_a_log
/**
* @test
*/
public function should_redirect_to_home_page_when_not_found_a_log()
{
$user = factory(App\User::class)->create();
$this->be($user);
$this->post('comments', ['_token' => csrf_token(), 'log_id' => 1234, 'body' => 'A comment.']);
$this->followRedirects()->seePageIs('/');
}
示例13: getPageWysiwyg
/**
* @param int $id
*
* @return string
*/
public function getPageWysiwyg($id)
{
$frontendPage = $this->getPage($id);
$this->templateScripts['PAGE'] = $frontendPage;
Meta::addMeta(['name' => 'page-id', 'data-id' => $id, 'name' => 'csrf-token', 'content' => csrf_token()])->loadPackage(['page-wysiwyg'], true)->addToGroup('site-url', '<script type="text/javascript">' . $this->getTemplateScriptsAsString() . '</script>');
app()->singleton('frontpage', function () use($frontendPage) {
return $frontendPage;
});
app()->singleton('layout.widgets', function ($app) use($frontendPage) {
return new PageWidgetCollection($app['widget.manager'], $frontendPage->getId());
});
app()->singleton('layout.block', function () use($frontendPage) {
return new BlockWysiwyg(app('layout.widgets'), $frontendPage);
});
if (is_null($layout = $frontendPage->getLayoutView())) {
return trans('pages::core.messages.layout_not_set');
}
$html = $layout->with('page', $frontendPage)->render();
$injectHTML = view('pages::pages.wysiwyg.system_blocks');
$matches = preg_split('/(<\\/body>)/i', $html, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
if (count($matches) > 1) {
$html = $matches[0] . $injectHTML->render() . $matches[1] . $matches[2];
}
return $html;
}
示例14: requestGithubAccess
/**
* Request GitHub access
*
* @param string $scope A comma separated list of scopes
*
* @return \Illuminate\Http\RedirectResponse
*/
public function requestGithubAccess($scope)
{
$clientId = $this->config['client_id'];
$redirectUri = secure_url('/getaccesstoken');
$state = csrf_token();
return Redirect::to('https://github.com/login/oauth/authorize?client_id=' . $clientId . '&redirect_uri=' . $redirectUri . '&scope=' . $scope . '&state=' . $state);
}
示例15: testCsrfToken
public function testCsrfToken()
{
set_app($app = new Application());
$app['session'] = $this->getMock('Illuminate\\Session\\TokenProvider');
$app['session']->expects($this->once())->method('getToken')->will($this->returnValue('foo'));
$this->assertEquals('foo', csrf_token());
}