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


PHP Zend_Form_Element_Hash::initCsrfToken方法代码示例

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


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

示例1: testConfigureThemeWithNoLogoFileAndNoPreviousLogoFile

 public function testConfigureThemeWithNoLogoFileAndNoPreviousLogoFile()
 {
     $themeName = self::THEME;
     $this->assertEquals('', (string) get_theme_option('logo', $themeName));
     // specify the files array for the post
     $_FILES = array('logo' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0), 'header_background' => array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0));
     // specify the theme options for the post
     $themeOptions = array('display_featured_item' => '1', 'display_featured_collection' => '1', 'display_featured_exhibit' => '1', 'homepage_recent_items' => '', 'homepage_text' => '', 'footer_text' => '', 'display_footer_copyright' => '0');
     $csrf = new Zend_Form_Element_Hash('theme_config_csrf');
     $csrf->initCsrfToken();
     // specify other post data
     $otherPostData = array('hidden_file_logo' => '', 'hidden_file_header_background' => '', 'MAX_FILE_SIZE' => '33554432', 'submit' => 'Save Changes', 'theme_config_csrf' => $csrf->getHash());
     // set the the post data
     $post = array_merge($themeOptions, $otherPostData);
     $this->getRequest()->setParam('name', $themeName);
     $this->getRequest()->setPost($post);
     $this->getRequest()->setMethod('POST');
     // dispatch the controller action
     $this->dispatch('themes/config');
     $actualOptions = Theme::getOptions(self::THEME);
     $this->assertArrayNotHasKey('theme_config_csrf', $actualOptions);
     foreach ($themeOptions as $name => $value) {
         $this->assertArrayHasKey($name, $actualOptions);
         $this->assertEquals($actualOptions[$name], $value, "Option '{$name}' was not correctly set.");
     }
     // verify that logo is empty
     $this->assertEmpty(get_theme_option('logo', $themeName));
 }
开发者ID:emhoracek,项目名称:Omeka,代码行数:28,代码来源:ThemesControllerTest.php

示例2: getHtmlOutput

 /**
  * Create the snippets content
  *
  * This is a stub function either override getHtmlOutput() or override render()
  *
  * @param \Zend_View_Abstract $view Just in case it is needed here
  * @return \MUtil_Html_HtmlInterface Something that can be rendered
  */
 public function getHtmlOutput(\Zend_View_Abstract $view)
 {
     // Again, just to be sure all changes are set on the form
     $this->populateForm();
     // Hook for subclasses
     $this->beforeDisplay();
     if ($this->_csrf) {
         $this->_csrf->initCsrfToken();
     }
     return $this->_form;
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:19,代码来源:ModelFormSnippetAbstract.php

示例3: beforeDisplay

 /**
  * Perform some actions on the form, right before it is displayed but already populated
  *
  * Here we add the table display to the form.
  *
  * @return \Zend_Form
  */
 public function beforeDisplay()
 {
     if ($this->_csrf) {
         $this->_csrf->initCsrfToken();
     }
     if ($this->layoutAutoWidthFactor || $this->layoutFixedWidth) {
         $div = new \MUtil_Html_DivFormElement();
         if ($this->layoutFixedWidth) {
             $div->setAsFormLayout($this->_form, $this->layoutFixedWidth);
         } else {
             $div->setAutoWidthFormLayout($this->_form, $this->layoutAutoWidthFactor);
         }
     }
 }
开发者ID:GemsTracker,项目名称:MUtil,代码行数:21,代码来源:FormSnippetAbstract.php

示例4: indexAction

 public function indexAction()
 {
     $configs = Application_Model_ConfigsMapper::i()->fetchAll();
     $form = $this->_initConfigsForm($configs);
     $defaultValues = array();
     foreach ($configs as $config) {
         /* @var $config Application_Model_Config */
         $elementName = $config->getSection() . '_' . str_replace('.', '_', $config->getKey());
         $defaultValues[$elementName] = $config->getValue();
     }
     $form->setDefaults($defaultValues);
     $plugins = Application_Model_PluginsMapper::i()->fetchAll();
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     $csrf->initCsrfToken();
     $this->view->csrf = $csrf->getHash();
     $this->view->plugins = $plugins;
     $this->view->form = $form;
     $this->view->messages = array_merge($this->_helper->flashMessenger->getMessages(), $this->_helper->flashMessenger->getCurrentMessages());
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:19,代码来源:ConfigsController.php

示例5: indexAction

 function indexAction()
 {
     $filter = $this->getRequest()->getParam('filter', 'all');
     $plugins = array();
     switch ($filter) {
         case 'installed':
             $plugins = Application_Model_PluginsMapper::i()->fetchByType(Application_Model_Plugin::USER);
             break;
         case 'disabled':
             $plugins = Application_Model_PluginsMapper::i()->fetchAll();
             // filter out disabled
             foreach ($plugins as $key => $value) {
                 /* @var $value Application_Model_Plugin */
                 if ($value->isEnabled()) {
                     unset($plugins[$key]);
                 }
             }
             break;
         case 'enabled':
             $plugins = Application_Model_PluginsMapper::i()->fetchAll();
             // filter out disabled
             foreach ($plugins as $key => $value) {
                 /* @var $value Application_Model_Plugin */
                 if (!$value->isEnabled()) {
                     unset($plugins[$key]);
                 }
             }
             break;
         case 'all':
         default:
             $plugins = Application_Model_PluginsMapper::i()->fetchAll();
             break;
     }
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     $csrf->initCsrfToken();
     $this->view->csrf = $csrf->getHash();
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     $this->view->plugins = $plugins;
     $this->view->filter = $filter;
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:40,代码来源:PluginController.php

示例6: changeAction

 function changeAction()
 {
     $key = $this->getRequest()->getParam('key', false);
     $class = $this->getRequest()->getParam('class', false);
     $csrf = $this->getRequest()->getParam('csrf', false);
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout->disableLayout();
     if (!$key) {
         $this->_helper->json(array('success' => false, 'message' => X_Env::_("p_auth_acl_err_missingkey")), true, false);
         return;
     }
     $key = X_Env::decode($key);
     if (!$class) {
         $this->_helper->json(array('success' => false, 'message' => X_Env::_("p_auth_acl_err_missingclass")), true, false);
         return;
     }
     $hash = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     if (!$hash->isValid($csrf)) {
         $this->_helper->json(array('success' => false, 'message' => X_Env::_("p_auth_acl_err_invalidcsrf")), true, false);
         return;
     }
     $hash->initCsrfToken();
     $resource = X_VlcShares_Plugins::helpers()->acl()->getResourceDescriptor($key);
     if ($resource->isNew()) {
         $this->_helper->json(array('success' => false, 'message' => X_Env::_("p_auth_acl_err_invalidkey")), true, false);
         return;
     }
     $resource->setClass($class);
     try {
         Application_Model_AclResourcesMapper::i()->save($resource);
         $this->_helper->json(array('success' => true, 'csrf' => $hash->getHash()), true, false);
         return;
     } catch (Exception $e) {
         $this->_helper->json(array('success' => false, 'message' => $e->getMessage()), true, false);
         return;
     }
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:37,代码来源:AclController.php

示例7: _getCsrfToken

 private function _getCsrfToken()
 {
     $hash = new Zend_Form_Element_Hash('user_csrf');
     $hash->initCsrfToken();
     return $hash->getHash();
 }
开发者ID:emhoracek,项目名称:Omeka,代码行数:6,代码来源:UsersFormTest.php

示例8: initCsrfToken

 /**
  * Initialize CSRF token in adapter or session if adapter is not set
  *
  * @return void
  */
 public function initCsrfToken()
 {
     if (null !== $this->getAdapter()) {
         $this->_adapter->initCsrfToken();
     } else {
         parent::initCsrfToken();
     }
 }
开发者ID:nstapelbroek,项目名称:Glitch_Lib,代码行数:13,代码来源:Hash.php

示例9: _makePost

 protected function _makePost($post = null)
 {
     $this->request->setMethod('POST');
     if (!$post) {
         $hash = new Zend_Form_Element_Hash('batch_edit_hash');
         $hash->initCsrfToken();
         $itemIds = array();
         foreach ($this->_items as $item) {
             $itemIds[] = $item->id;
         }
         $post = array('items' => $itemIds, 'metadata' => array('public' => 1, 'featured' => 1, 'item_type_id' => 1, 'tags' => 'lorem,ipsum,dolor'), 'batch_edit_hash' => $hash->getHash());
     }
     $this->request->setPost($post);
 }
开发者ID:emhoracek,项目名称:Omeka,代码行数:14,代码来源:BatchEditTest.php

示例10: accountsAction

 function accountsAction()
 {
     $accounts = Application_Model_AuthAccountsMapper::i()->fetchAll();
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     $csrf->initCsrfToken();
     $this->view->ip = '%IP_ADDRESS%';
     $this->view->csrf = $csrf->getHash();
     $this->view->accounts = $accounts;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:10,代码来源:AuthController.php

示例11: testDelete

 public function testDelete()
 {
     $hash = new Zend_Form_Element_Hash('confirm_delete_hash');
     $hash->initCsrfToken();
     $this->_makePost(array('confirm_delete_hash' => $hash->getHash()));
     $this->dispatch('/items/delete/1');
     $this->assertEquals(0, $this->db->getTable('Item')->count());
     $this->assertRedirectTo('/items/browse');
 }
开发者ID:emhoracek,项目名称:Omeka,代码行数:9,代码来源:ItemsControllerTest.php

示例12: bookmarkAction

 public function bookmarkAction()
 {
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     $validCheck = $csrf->isValid($this->getRequest()->getParam('csrf', false));
     $csrf->initCsrfToken();
     $hash = $csrf->getHash();
     $return = array('success' => true, 'api' => array('resolver' => $this->_helper->url->url(array('controller' => 'bookmarklets', 'action' => 'resolver', 'csrf' => $hash)), 'adder' => $this->_helper->url->url(array('controller' => 'bookmarklets', 'action' => 'add', 'csrf' => $hash)), 'bookmark' => $this->_helper->url->url(array('controller' => 'bookmarklets', 'action' => 'bookmark', 'csrf' => $hash))));
     if ($validCheck) {
         $url = $this->getRequest()->getParam("url", false);
         $title = strip_tags($this->getRequest()->getParam("title", false));
         $description = strip_tags($this->getRequest()->getParam("description", false));
         $thumbnail = $this->getRequest()->getParam("thumbnail", false);
         $ua = $this->getRequest()->getParam("ua", false);
         $cookies = $this->getRequest()->getParam("cookies", false);
         if ($url && $title) {
             $model = new Application_Model_Bookmark();
             $model->setUrl($url);
             $model->setTitle($title);
             if ($thumbnail) {
                 $model->setThumbnail($thumbnail);
             }
             if ($description) {
                 $model->setDescription($description);
             }
             if ($ua) {
                 $model->setUa($ua);
             }
             if ($cookies) {
                 $model->setCookies($cookies);
             }
             try {
                 Application_Model_BookmarksMapper::i()->save($model);
             } catch (Exception $e) {
                 X_Debug::e("DB Error: {$e->getMessage()}");
                 $return['success'] = false;
             }
         } else {
             X_Debug::e("Missing data");
             $return['success'] = false;
         }
     } else {
         X_Debug::e("Invalid CSRF");
         $return['success'] = false;
     }
     $this->_helper->json($return, true, false);
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:46,代码来源:BookmarkletsController.php

示例13: _dispatchChangePassword

 private function _dispatchChangePassword(array $form)
 {
     $hash = new Zend_Form_Element_Hash('password_csrf');
     $hash->initCsrfToken();
     $form['password_csrf'] = $hash->getHash();
     $this->getRequest()->setPost($form);
     $this->getRequest()->setMethod('post');
     $this->dispatch(self::FORM_URL);
 }
开发者ID:emhoracek,项目名称:Omeka,代码行数:9,代码来源:ChangePasswordTest.php

示例14: clearAction

 function clearAction()
 {
     $id = $this->getRequest()->getParam('id', false);
     $csrf = $this->getRequest()->getParam('csrf', false);
     if (!$id) {
         throw new Exception("Thread id missing");
     }
     $hash = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     if (!$hash->isValid($csrf)) {
         throw new Exception("Invalid token");
     }
     $hash->initCsrfToken();
     $thread = X_Threads_Manager::instance()->getMonitor()->getThread($id);
     X_Threads_Manager::instance()->getMessenger()->clearQueue($thread);
     $this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('threads_done')));
     $this->_helper->redirector('index', 'tmanager');
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:17,代码来源:TmanagerController.php


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