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


PHP Zend_Form_Element_Hash::isValid方法代码示例

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


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

示例1: removeAction

 function removeAction()
 {
     $hash = $this->getRequest()->getParam('csrf');
     $key = X_Env::decode($this->getRequest()->getParam('key', false));
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     if (!$csrf->isValid($hash)) {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_err_invalidhash')));
         $this->_helper->redirector('index', 'acl');
         return;
     }
     $resource = new Application_Model_AclResource();
     Application_Model_AclResourcesMapper::i()->find($key, $resource);
     if ($resource->isNew()) {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_acl_err_invalidkey')));
         $this->_helper->redirector('index', 'acl');
         return;
     }
     Application_Model_AclResourcesMapper::i()->delete($resource);
     $this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('p_auth_acl_resourceremoved', $resource->getKey())));
     $this->_helper->redirector('index', 'acl');
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:21,代码来源:AclController.php

示例2: enableAction

 public function enableAction()
 {
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     $pluginId = $request->getParam('pluginId', false);
     $plugin = new Application_Model_Plugin();
     $csrfValue = $request->getParam('csrf', false);
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     if ($csrf->isValid($csrfValue)) {
         if ($pluginId !== false) {
             Application_Model_PluginsMapper::i()->find($pluginId, $plugin);
             if ($plugin->getId() != null && $plugin->getId() == $pluginId) {
                 if ($plugin->getType() != Application_Model_Plugin::SYSTEM) {
                     try {
                         $plugin->setEnabled(true);
                         Application_Model_PluginsMapper::i()->save($plugin);
                         $this->_helper->flashMessenger(X_Env::_('configs_plugins_pluginenabled'));
                     } catch (Exception $e) {
                         $this->_helper->flashMessenger(X_Env::_('configs_plugins_err_db') . ": {$e->getMessage()}");
                     }
                 } else {
                     $this->_helper->flashMessenger(X_Env::_('configs_plugins_err_pluginId_notenable'));
                 }
             } else {
                 $this->_helper->flashMessenger(X_Env::_('configs_plugins_err_pluginId_unknown'));
             }
         } else {
             $this->_helper->flashMessenger(X_Env::_('configs_plugins_err_pluginId_missing'));
         }
     } else {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('configs_plugins_err_invalidtoken')));
     }
     $this->_helper->redirector('index', 'configs');
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:34,代码来源:ConfigsController.php

示例3: removeAction

 function removeAction()
 {
     $hash = $this->getRequest()->getParam('csrf');
     $accountId = $this->getRequest()->getParam('id');
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     if (!$csrf->isValid($hash)) {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_err_invalidhash')));
         $this->_helper->redirector('accounts', 'auth');
         return;
     }
     $account = new Application_Model_AuthAccount();
     Application_Model_AuthAccountsMapper::i()->find($accountId, $account);
     if (is_null($account->getId())) {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_err_invalidaccount')));
         $this->_helper->redirector('accounts', 'auth');
         return;
     }
     if ($this->plugin->getCurrentUser() == $account->getUsername()) {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_err_currentremovalnotallowed')));
         $this->_helper->redirector('accounts', 'auth');
         return;
     }
     Application_Model_AuthAccountsMapper::i()->delete($account);
     $this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('p_auth_accountremoved', $account->getUsername())));
     $this->_helper->redirector('accounts', 'auth');
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:26,代码来源:AuthController.php

示例4: 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

示例5: batchEditSaveAction

 /**
  * Processes batch edit information. Only accessible via POST.
  * 
  * @return void
  */
 public function batchEditSaveAction()
 {
     $hashParam = $this->_getParam('batch_edit_hash');
     $hash = new Zend_Form_Element_Hash('batch_edit_hash');
     if (!$hash->isValid($hashParam)) {
         throw new Omeka_Controller_Exception_403();
     }
     if ($itemIds = $this->_getParam('items')) {
         $metadata = $this->_getParam('metadata');
         $removeMetadata = $this->_getParam('removeMetadata');
         $delete = $this->_getParam('delete');
         $custom = $this->_getParam('custom');
         // Set metadata values to null for "removed" metadata keys.
         if ($removeMetadata && is_array($removeMetadata)) {
             foreach ($removeMetadata as $key => $value) {
                 if ($value) {
                     $metadata[$key] = null;
                 }
             }
         }
         $errorMessage = null;
         $aclHelper = $this->_helper->acl;
         if ($metadata && array_key_exists('public', $metadata) && !$aclHelper->isAllowed('makePublic')) {
             $errorMessage = __('User is not allowed to modify visibility of items.');
         }
         if ($metadata && array_key_exists('featured', $metadata) && !$aclHelper->isAllowed('makeFeatured')) {
             $errorMessage = __('User is not allowed to modify featured status of items.');
         }
         if (!$errorMessage) {
             foreach ($itemIds as $id) {
                 if ($item = $this->_helper->db->getTable('Item')->find($id)) {
                     if ($delete && !$aclHelper->isAllowed('delete', $item)) {
                         $errorMessage = __('User is not allowed to delete selected items.');
                         break;
                     }
                     // Check to see if anything but 'tag'
                     if ($metadata && array_diff_key($metadata, array('tags' => '')) && !$aclHelper->isAllowed('edit', $item)) {
                         $errorMessage = __('User is not allowed to edit selected items.');
                         break;
                     }
                     if ($metadata && array_key_exists('tags', $metadata) && !$aclHelper->isAllowed('tag', $item)) {
                         $errorMessage = __('User is not allowed to tag selected items.');
                         break;
                     }
                     release_object($item);
                 }
             }
         }
         $errorMessage = apply_filters('items_batch_edit_error', $errorMessage, array('metadata' => $metadata, 'custom' => $custom, 'item_ids' => $itemIds));
         if ($errorMessage) {
             $this->_helper->flashMessenger($errorMessage, 'error');
         } else {
             $dispatcher = Zend_Registry::get('job_dispatcher');
             $dispatcher->send('Job_ItemBatchEdit', array('itemIds' => $itemIds, 'delete' => $delete, 'metadata' => $metadata, 'custom' => $custom));
             if ($delete) {
                 $message = __('The items were successfully deleted!');
             } else {
                 $message = __('The items were successfully changed!');
             }
             $this->_helper->flashMessenger($message, 'success');
         }
     }
     $this->_helper->redirector('browse', 'items');
 }
开发者ID:kyfr59,项目名称:cg35,代码行数:69,代码来源:ItemsController.php

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