本文整理汇总了PHP中SecurityToken::disable方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityToken::disable方法的具体用法?PHP SecurityToken::disable怎么用?PHP SecurityToken::disable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecurityToken
的用法示例。
在下文中一共展示了SecurityToken::disable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsEnabledStatic
public function testIsEnabledStatic()
{
$this->assertTrue(SecurityToken::is_enabled());
SecurityToken::disable();
$this->assertFalse(SecurityToken::is_enabled());
SecurityToken::enable();
$this->assertTrue(SecurityToken::is_enabled());
}
示例2: testCorruptedOrderItemLinks
/**
* Coverage for a bug where there's an error generating the link when ProductID = 0
*/
public function testCorruptedOrderItemLinks()
{
SecurityToken::disable();
$product = $this->socks;
$item = $product->Item();
$item->ProductID = 0;
$this->assertEquals('', $item->removeLink());
}
示例3: tearDown
public function tearDown()
{
parent::tearDown();
//if the token is turned on reset it before the next test run
if ($this->useToken) {
SecurityToken::enable();
} else {
SecurityToken::disable();
}
}
示例4: testLinks
/**
* Check the links are accurate
*/
public function testLinks()
{
SecurityToken::disable();
$product = $this->socks;
$item = $product->Item();
$this->assertEquals("shoppingcart/add/Product/{$product->ID}", $item->addLink());
$this->assertEquals("shoppingcart/remove/Product/{$product->ID}", $item->removeLink());
$this->assertEquals("shoppingcart/removeall/Product/{$product->ID}", $item->removeallLink());
$this->assertEquals("shoppingcart/setquantity/Product/{$product->ID}", $item->setquantityLink());
}
示例5: tearDown
public function tearDown()
{
if ($this->securityWasEnabled) {
SecurityToken::enable();
} else {
SecurityToken::disable();
}
Injector::unnest();
Config::unnest();
parent::tearDown();
}
示例6: setUp
public function setUp()
{
parent::setUp();
$this->folder = Folder::find_or_make(ASSETS_DIR . '/versionedfiles-test');
$file = $this->folder->getFullPath() . 'test-file.txt';
file_put_contents($file, 'first-version');
$this->file = new File();
$this->file->ParentID = $this->folder->ID;
$this->file->Filename = $this->folder->getFilename() . 'test-file.txt';
$this->file->write();
SecurityToken::disable();
}
示例7: setUp
function setUp()
{
parent::setUp();
$this->mainSession = new TestSession();
// Disable theme, if necessary
if ($this->stat('disable_themes')) {
SSViewer::set_theme(null);
}
// Switch to draft site, if necessary
if ($this->stat('use_draft_site')) {
$this->useDraftSite();
}
// Unprotect the site, tests are running with the assumption it's off. They will enable it on a case-by-case basis.
BasicAuth::protect_entire_site(false);
SecurityToken::disable();
}
示例8: testCommentsForm
public function testCommentsForm()
{
SecurityToken::disable();
$this->autoFollowRedirection = false;
$parent = $this->objFromFixture('CommentableItem', 'first');
// Test posting to base comment
$response = $this->post('CommentingController/CommentsForm', array('Name' => 'Poster', 'Email' => 'guy@test.com', 'Comment' => 'My Comment', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem', 'action_doPostComment' => 'Post'));
$this->assertEquals(302, $response->getStatusCode());
$this->assertStringStartsWith('CommentableItem_Controller#comment-', $response->getHeader('Location'));
$this->assertDOSEquals(array(array('Name' => 'Poster', 'Email' => 'guy@test.com', 'Comment' => 'My Comment', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem')), Comment::get()->filter('Email', 'guy@test.com'));
// Test posting to parent comment
$parentComment = $this->objFromFixture('Comment', 'firstComA');
$this->assertEquals(0, $parentComment->ChildComments()->count());
$response = $this->post('CommentingController/reply/' . $parentComment->ID, array('Name' => 'Test Author', 'Email' => 'test@test.com', 'Comment' => 'Making a reply to firstComA', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem', 'ParentCommentID' => $parentComment->ID, 'action_doPostComment' => 'Post'));
$this->assertEquals(302, $response->getStatusCode());
$this->assertStringStartsWith('CommentableItem_Controller#comment-', $response->getHeader('Location'));
$this->assertDOSEquals(array(array('Name' => 'Test Author', 'Email' => 'test@test.com', 'Comment' => 'Making a reply to firstComA', 'ParentID' => $parent->ID, 'BaseClass' => 'CommentableItem', 'ParentCommentID' => $parentComment->ID)), $parentComment->ChildComments());
}
示例9: AddToWishListForm
public function AddToWishListForm()
{
if (($member = Member::currentUser()) && ($wishlistitems = $member->WishListItems("PageID = " . $this->owner->ID)) && $wishlistitems->exists()) {
$fields = new FieldSet(new HiddenField('PageID', '', $this->owner->ID));
$actions = new FieldSet(new FormAction('removeFromWishList', 'Remove from wish list'));
$validator = new RequiredFields();
SecurityToken::disable();
// have to do this so once logged in the form still works :{
$Form = new Form($this->owner, 'AddToWishListForm', $fields, $actions, $validator);
return $Form;
} else {
$fields = new FieldSet(new HiddenField('PageID', '', $this->owner->ID));
$actions = new FieldSet(new FormAction('addToWishList', 'Add to wish list'));
$validator = new RequiredFields();
SecurityToken::disable();
// have to do this so once logged in the form still works :{
$Form = new Form($this->owner, 'AddToWishListForm', $fields, $actions, $validator);
return $Form;
}
}
示例10: setUp
public function setUp()
{
// Skip calling FunctionalTest directly.
if (get_class($this) == "FunctionalTest") {
$this->skipTest = true;
}
parent::setUp();
$this->mainSession = new TestSession();
// Disable theme, if necessary
if (static::get_disable_themes()) {
Config::inst()->update('SSViewer', 'theme', null);
}
// Switch to draft site, if necessary
if (static::get_use_draft_site()) {
$this->useDraftSite();
}
// Unprotect the site, tests are running with the assumption it's off. They will enable it on a case-by-case
// basis.
BasicAuth::protect_entire_site(false);
SecurityToken::disable();
}
示例11: testDisableSecurityToken
public function testDisableSecurityToken()
{
SecurityToken::enable();
$form = $this->getStubForm();
$this->assertTrue($form->getSecurityToken()->isEnabled());
$form->disableSecurityToken();
$this->assertFalse($form->getSecurityToken()->isEnabled());
SecurityToken::disable();
// restore original
}
示例12: testSecurityToken
public function testSecurityToken()
{
$enabled = SecurityToken::is_enabled();
// enable security tokens
SecurityToken::enable();
$productId = $this->mp3player->ID;
// link should contain the security-token
$link = ShoppingCart_Controller::add_item_link($this->mp3player);
$this->assertRegExp('{^shoppingcart/add/Product/' . $productId . '\\?SecurityID=[a-f0-9]+$}', $link);
// should redirect back to the shop
$response = $this->get($link);
$this->assertEquals($response->getStatusCode(), 302);
// disable security token for cart-links
Config::inst()->update('ShoppingCart_Controller', 'disable_security_token', true);
$link = ShoppingCart_Controller::add_item_link($this->mp3player);
$this->assertEquals('shoppingcart/add/Product/' . $productId, $link);
// should redirect back to the shop
$response = $this->get($link);
$this->assertEquals($response->getStatusCode(), 302);
SecurityToken::disable();
Config::inst()->update('ShoppingCart_Controller', 'disable_security_token', false);
$link = ShoppingCart_Controller::add_item_link($this->mp3player);
$this->assertEquals('shoppingcart/add/Product/' . $productId, $link);
// should redirect back to the shop
$response = $this->get($link);
$this->assertEquals($response->getStatusCode(), 302);
SecurityToken::enable();
// should now return a 400 status
$response = $this->get($link);
$this->assertEquals($response->getStatusCode(), 400);
// restore previous setting
if (!$enabled) {
SecurityToken::disable();
}
}
示例13: disable_all_security_tokens
/**
* Disable security tokens for every form.
* Note that this doesn't apply to {@link SecurityToken}
* instances outside of the Form class, nor applies
* to existing form instances.
*
* See {@link enable_all_security_tokens()}.
*
* @deprecated 2.5 Use SecurityToken::disable()
*/
public static function disable_all_security_tokens() {
Deprecation::notice('2.5', 'Use SecurityToken::disable() instead.');
SecurityToken::disable();
}
示例14: __construct
/**
* creates a form object with a free configurable markup
*
* @param ContentController $controller the calling controller instance
* @param array $params optional parameters
* @param array $preferences optional preferences
* @param bool $barebone defines if a form should only be instanciated or be used too
*
* @return CustomHtmlForm
*
* @author Sebastian Diel <sdiel@pixeltricks.de>,
* Sascha Koehler <skoehler@pixeltricks.de>
* @since 13.01.2015
*/
public function __construct($controller, $params = null, $preferences = null, $barebone = false)
{
$this->extend('onBeforeConstruct', $controller, $params, $preferences, $barebone);
global $project;
$this->barebone = $barebone;
$this->controller = $controller;
if (is_array($params)) {
$this->customParameters = $params;
}
// Hook for setting preferences via a method call
$this->preferences();
if (is_array($preferences)) {
foreach ($preferences as $title => $setting) {
if (!empty($title)) {
$this->basePreferences[$title] = $setting;
}
}
}
$name = $this->getSubmitAction();
if (!$barebone) {
$this->getFormFields();
}
if ($this->securityTokenEnabled) {
SecurityToken::enable();
} else {
SecurityToken::disable();
}
parent::__construct($this->getFormController($controller, $preferences), $name, new FieldList(), new FieldList());
if (!$barebone) {
$this->getFormFields();
$this->fillInFieldValues();
}
// Hook for setting preferences via a method call; we need to do this
// a second time so that the standard Silverstripe mechanism can take
// influence, too (i.e. _config.php files, init methods, etc).
$this->preferences();
if (is_array($preferences)) {
foreach ($preferences as $title => $setting) {
if (!empty($title)) {
$this->basePreferences[$title] = $setting;
}
}
}
// Counter for the form class, init or increment
if (!isset(self::$classInstanceCounter[$this->class])) {
self::$classInstanceCounter[$this->class] = 0;
}
if (!$barebone) {
self::$classInstanceCounter[$this->class]++;
}
// new assignment required, because the controller will be overwritten in the form class
$this->controller = $controller;
// create group structure
if (isset($this->formFields)) {
$this->fieldGroups['formFields'] = $this->getFormFields();
} else {
$this->fieldGroups['formFields'] = array();
}
$this->name = str_replace('/', '', $this->class . '_' . $name . '_' . self::$classInstanceCounter[$this->class]);
$this->jsName = $this->name;
$this->SSformFields = $this->getForm();
$this->SSformFields['fields']->setForm($this);
$this->SSformFields['actions']->setForm($this);
parent::setFields($this->SSformFields['fields']);
parent::setActions($this->SSformFields['actions']);
// define form action
$this->setFormAction($this->buildFormAction());
$this->setHTMLID($this->getName());
/*
* load and init JS validators
* form integration via FormAttributes()
*/
if (!$barebone) {
$javascriptSnippets = $this->getJavascriptValidatorInitialisation();
if (!$this->getLoadShoppingCartModules()) {
SilvercartShoppingCart::setLoadShoppingCartModules(false);
}
if ($this->getCreateShoppingCartForms() && class_exists('SilvercartShoppingCart')) {
SilvercartShoppingCart::setCreateShoppingCartForms(false);
}
$this->controller->addJavascriptSnippet($javascriptSnippets['javascriptSnippets']);
$this->controller->addJavascriptOnloadSnippet($javascriptSnippets['javascriptOnloadSnippets']);
$this->controller->addJavascriptOnloadSnippet($this->getJavascriptFieldInitialisations());
}
// Register the default module directory from mysite/_config.php
self::registerModule($project);
//.........这里部分代码省略.........
示例15: run
/**
* Activate caching on a given url
*
* @param string $url
*/
public function run($url)
{
// Get cache and cache details
$responseHeader = self::config()->responseHeader;
$cache = $this->getCache();
// Start hamaka custom - geef IE zijn eigen cachefiles omdat anders de combined files van IE in Chrome doorkomen als een IE bezoeker de cache aanmaakt
// deze 2 regels kunnen in Page.ss om DynamicCache te debuggen:
// <meta name="gen-date" content="{$Now.Nice}" />
// <meta name="dyn-cache" content="{$UsedDynamicCacheKey}" />
$sCacheKeySeed = $url;
if ($iPosIE = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
$iVersion = substr($_SERVER['HTTP_USER_AGENT'], $iPosIE + 5, 3);
$sCacheKeySeed .= 'IE' . $iVersion;
}
$cacheKey = $this->getCacheKey($sCacheKeySeed);
DynamicCache::$sUsedCacheKey = $sCacheKeySeed;
// End hamaka custom
// Clear cache if flush = cache or all
$this->checkCacheCommands($cache);
// Disable CSRF - It doesn't work with cached security tokens shared across sessions
SecurityToken::disable();
// Check if caching should be short circuted
$enabled = $this->enabled($url);
$this->extend('updateEnabled', $enabled);
if (!$enabled) {
if ($responseHeader) {
header("{$responseHeader}: skipped");
}
$this->yieldControl();
return;
}
// Check if cached value can be returned
$cachedValue = $cache->load($cacheKey);
if ($this->presentCachedResult($cachedValue)) {
return;
}
// Run this page, caching output and capturing data
if ($responseHeader) {
header("{$responseHeader}: miss at " . @date('r'));
}
ob_start();
$this->yieldControl();
$headers = headers_list();
$result = ob_get_flush();
// Skip blank copy
if (empty($result)) {
return;
}
// Check if any headers match the specified rules forbidding caching
if (!$this->headersAllowCaching($headers)) {
return;
}
// Include any "X-Header" sent with this request. This is necessary to
// ensure that additional CSS, JS, and other files are retained
$saveHeaders = $this->getCacheableHeaders($headers);
// Save data along with sent headers
$this->cacheResult($cache, $result, $saveHeaders, $cacheKey);
}