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


PHP JSession::checkToken方法代码示例

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


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

示例1: featured

 /**
  * Method to toggle the featured setting of a list of articles.
  *
  * @return	void
  * @since	1.6
  */
 function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     // Initialise variables.
     $user = JFactory::getUser();
     $ids = JRequest::getVar('cid', array(), '', 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Access checks.
     foreach ($ids as $i => $id) {
         if (!$user->authorise('core.edit.state', 'com_content.article.' . (int) $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
     } else {
         // Get the model.
         $model = $this->getModel();
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_content&view=articles');
 }
开发者ID:joomline,项目名称:Joomla2.5.999,代码行数:36,代码来源:articles.php

示例2: switchAdminLanguage

 /**
  * Task to switch the administrator language.
  *
  * @return  void
  */
 public function switchAdminLanguage()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $cid = $this->input->get('cid', '');
     $model = $this->getModel('installed');
     // Fetching the language name from the xx-XX.xml
     $file = JPATH_ADMINISTRATOR . '/language/' . $cid . '/' . $cid . '.xml';
     $info = JInstaller::parseXMLInstallFile($file);
     $languageName = $info['name'];
     if ($model->switchAdminLanguage($cid)) {
         // Switching to the new language for the message
         $language = JFactory::getLanguage();
         $newLang = JLanguage::getInstance($cid);
         JFactory::$language = $newLang;
         JFactory::getApplication()->loadLanguage($language = $newLang);
         $newLang->load('com_languages', JPATH_ADMINISTRATOR);
         $msg = JText::sprintf('COM_LANGUAGES_MSG_SWITCH_ADMIN_LANGUAGE_SUCCESS', $languageName);
         $type = 'message';
     } else {
         $msg = $model->getError();
         $type = 'error';
     }
     $this->setRedirect('index.php?option=com_languages&view=installed', $msg, $type);
 }
开发者ID:Rai-Ka,项目名称:joomla-cms,代码行数:30,代码来源:installed.php

示例3: delete

 public function delete()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // Get items to remove from the request.
     $cid = JFactory::getApplication()->input->get('cid', array(), 'array');
     if (!is_array($cid) || count($cid) < 1) {
         JLog::add(JText::_($this->text_prefix . '_NO_ITEM_SELECTED'), JLog::WARNING, 'jerror');
     } else {
         // Get the model.
         $model = $this->getModel();
         // Make sure the item ids are integers
         jimport('joomla.utilities.arrayhelper');
         JArrayHelper::toInteger($cid);
         // Remove the items.
         if ($model->delete($cid)) {
             $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid)));
         } else {
             $this->setMessage($model->getError());
         }
     }
     $version = new JVersion();
     if ($version->isCompatible('3.0')) {
         // Invoke the postDelete method to allow for the child class to access the model.
         $this->postDeleteHook($model, $cid);
     }
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
 }
开发者ID:AndreKoepke,项目名称:Einsatzkomponente,代码行数:28,代码来源:alarmierungsarten.php

示例4: importData

 public function importData()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // check if import is allowed for this user.
     $user = JFactory::getUser();
     if ($user->authorise('help_document.import', 'com_costbenefitprojection') && $user->authorise('core.import', 'com_costbenefitprojection')) {
         // Get the import model
         $model = $this->getModel('Help_documents');
         // get the headers to import
         $headers = $model->getExImPortHeaders();
         if (CostbenefitprojectionHelper::checkObject($headers)) {
             // Load headers to session.
             $session = JFactory::getSession();
             $headers = json_encode($headers);
             $session->set('help_document_VDM_IMPORTHEADERS', $headers);
             $session->set('backto_VDM_IMPORT', 'help_documents');
             $session->set('dataType_VDM_IMPORTINTO', 'help_document');
             // Redirect to import view.
             $message = JText::_('COM_COSTBENEFITPROJECTION_IMPORT_SELECT_FILE_FOR_HELP_DOCUMENTS');
             $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=import', false), $message);
             return;
         }
     }
     // Redirect to the list screen with error.
     $message = JText::_('COM_COSTBENEFITPROJECTION_IMPORT_FAILED');
     $this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=help_documents', false), $message, 'error');
     return;
 }
开发者ID:namibia,项目名称:CBP-Joomla-3-Component,代码行数:29,代码来源:help_documents.php

示例5: featured

 /**
  * Method to toggle the featured setting of a list of teamids.
  *
  * @return	void
  * 
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $user = JFactory::getUser();
     $ids = $this->input->getVar('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($values, $task, 0, 'int');
     // Get the model.
     $model = $this->getModel();
     // Access checks.
     foreach ($ids as $i => $id) {
         $item = $model->getItem($id);
         if (!$user->authorise('core.edit.state', 'com_knvbapi2.teamid.' . $id)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_KNVBAPI2_TEAMIDS_NO_ITEM_SELECTED'));
     } else {
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
         if ($value == 1) {
             $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_FEATURED', count($ids));
         } else {
             $message = JText::plural('COM_KNVBAPI2_TEAMIDS_N_ITEMS_UNFEATURED', count($ids));
         }
     }
     $this->setRedirect(JRoute::_('index.php?option=com_knvbapi2&view=teamids', false), $message);
 }
开发者ID:esorone,项目名称:efcpw,代码行数:41,代码来源:teamids.php

示例6: enableau

 /**
  * Enable auto-update.
  *
  * @throws  Exception
  * @return  void
  */
 public function enableau()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $redirectOptions = array("view" => "urls");
     $cid = $this->input->post->get("cid", array(), "array");
     $cid = Joomla\Utilities\ArrayHelper::toInteger($cid);
     $data = array('enableau' => 1, 'disableau' => 0);
     $task = $this->getTask();
     $value = JArrayHelper::getValue($data, $task, 0, 'int');
     if (empty($cid)) {
         $this->displayNotice(JText::_($this->text_prefix . '_ERROR_NO_ITEM_SELECTED'), $redirectOptions);
         return;
     }
     try {
         $model = $this->getModel();
         $model->updateAutoupdate($cid, $value);
     } catch (Exception $e) {
         JLog::add($e->getMessage());
         throw new Exception(JText::_('COM_ITPMETA_ERROR_SYSTEM'));
     }
     if ($value == 1) {
         $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_ENABLED';
     } else {
         $msg = $this->text_prefix . '_N_ITEMS_AUTOUPDATE_DISABLED';
     }
     $this->displayMessage(JText::plural($msg, count($cid)), $redirectOptions);
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:34,代码来源:urls.php

示例7: __construct

} else {
    require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_languages' . DS . 'helpers' . DS . 'jsonresponse.php';
}
/**
 * Content controller class.
 */
class J2XMLControllerCategories extends JControllerAbstract
{
    function __construct($default = array())
    {
        parent::__construct();
    }
    public function display($cachable = false, $urlparams = false)
    {
        JRequest::setVar('view', 'categories');
        parent::display($cachable, $urlparams);
    }
    function send()
    {
        if (!JSession::checkToken('request')) {
            // Check for a valid token. If invalid, send a 403 with the error message.
            JError::raiseWarning(403, JText::_('JINVALID_TOKEN'));
            echo version_compare(JPlatform::RELEASE, '12', 'ge') ? new JResponseJson() : new JJsonResponse();
            return;
        }
        $cid = JRequest::getVar('cid', array(0), null, 'array');
        $sid = JRequest::getVar('w_id', null, null, 'int');
开发者ID:jmangarret,项目名称:webtuagencia24,代码行数:27,代码来源:categories.json.php

示例8: execute

 /**
  * Execute the controller.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function execute()
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = $this->getApplication();
     // Check for request forgeries.
     JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
     // Get array of selected languages
     $lids = $this->input->get('cid', array(), 'array');
     JArrayHelper::toInteger($lids, array());
     // Get the languages model.
     $model = new InstallationModelLanguages();
     if (!$lids) {
         // No languages have been selected
         $app->enqueueMessage(JText::_('INSTL_LANGUAGES_NO_LANGUAGE_SELECTED'), 'warning');
     } else {
         // Install selected languages
         $model->install($lids);
         // Publish the Content Languages.
         $model->publishContentLanguages();
         $app->enqueueMessage(JText::_('INSTL_LANGUAGES_MORE_LANGUAGES'), 'notice');
     }
     // Redirect to the page.
     $r = new stdClass();
     $r->view = 'defaultlanguage';
     $app->sendJsonResponse($r);
 }
开发者ID:eshiol,项目名称:joomla-cms,代码行数:34,代码来源:languages.php

示例9: execute

 /**
  * Return AJAX for the requested layout.
  *
  * @return string  String in JSON or RAW.
  *
  * @throws RuntimeException
  * @throws KunenaExceptionAuthorise
  */
 public function execute()
 {
     $format = $this->input->getWord('format', 'html');
     $function = 'display' . ucfirst($format);
     if (!method_exists($this, $function)) {
         // Invalid page request.
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     }
     // Run before executing action.
     $result = $this->before();
     if ($result === false) {
         $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 404);
     } elseif (!JSession::checkToken()) {
         // Invalid access token.
         $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_ERROR_TOKEN'), 403);
     } elseif ($this->config->board_offline && !$this->me->isAdmin()) {
         // Forum is offline.
         $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_FORUM_IS_OFFLINE'), 503);
     } elseif ($this->config->regonly && !$this->me->exists()) {
         // Forum is for registered users only.
         $content = new KunenaExceptionAuthorise(JText::_('COM_KUNENA_LOGIN_NOTIFICATION'), 401);
     } else {
         $display = $this->input->getCmd('display', 'Undefined') . '/Display';
         try {
             $content = KunenaRequest::factory($display, $this->input, $this->options)->setPrimary()->execute()->render();
         } catch (Exception $e) {
             $content = $e;
         }
     }
     return $this->{$function}($content);
 }
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:39,代码来源:display.php

示例10: save

 public function save()
 {
     die('Save in projectposition controller');
     // Check for request forgeries
     JSession::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN');
     echo '<br /><pre>2' . print_r($post, true) . '~</pre><br />';
     $post = JRequest::get('post');
     $cid = JRequest::getVar('cid', array(0), 'post', 'array');
     $post['id'] = (int) $cid[0];
     $model = $this->getModel('projectposition');
     //if ($model->store($post))
     if (1 == 2) {
         $msg = JText::_('COM_JOOMLEAGUE_ADMIN_P_POSITION_CTRL_TEAM_SAVED');
     } else {
         $msg = JText::_('COM_JOOMLEAGUE_ADMIN_P_POSITION_CTRL_ERROR_SAVING_TEAM') . $model->getError();
     }
     // Check the table in so it can be edited.... we are done with it anyway
     $model->checkin();
     $task = $this->getTask();
     if ($task == 'save') {
         $link = 'index.php?option=com_joomleague&view=projectposition&task=projectposition.display';
     } else {
         $link = 'index.php?option=com_joomleague&task=projectposition.edit&cid[]=' . $post['id'];
     }
     //$this->setRedirect($link,$msg);
 }
开发者ID:Heart1010,项目名称:JoomLeague,代码行数:26,代码来源:projectposition.php

示例11: featured

 /**
  * Method to toggle the featured setting of a list of contacts.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function featured()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $ids = $this->input->get('cid', array(), 'array');
     $values = array('featured' => 1, 'unfeatured' => 0);
     $task = $this->getTask();
     $value = ArrayHelper::getValue($values, $task, 0, 'int');
     // Get the model.
     /** @var ContactModelContact $model */
     $model = $this->getModel();
     // Access checks.
     foreach ($ids as $i => $id) {
         $item = $model->getItem($id);
         if (!JFactory::getUser()->authorise('core.edit.state', 'com_contact.category.' . (int) $item->catid)) {
             // Prune items that you can't change.
             unset($ids[$i]);
             JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
         }
     }
     if (empty($ids)) {
         JError::raiseWarning(500, JText::_('COM_CONTACT_NO_ITEM_SELECTED'));
     } else {
         // Publish the items.
         if (!$model->featured($ids, $value)) {
             JError::raiseWarning(500, $model->getError());
         }
     }
     $this->setRedirect('index.php?option=com_contact&view=contacts');
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:37,代码来源:contacts.php

示例12: addFunders

 /**
  * Add funders to Acy Mailing list.
  *
  * @throws Exception
  */
 public function addFunders()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     /** @var $app JApplicationAdministrator */
     $response = new Prism\Response\Json();
     $projectId = $this->input->post->getInt('acy_pid');
     $listId = $this->input->post->getInt('acy_lid');
     $model = $this->getModel();
     $numberOfAdded = 0;
     try {
         $numberOfAdded = $model->addFundersToAcyList($projectId, $listId);
     } catch (Exception $e) {
         JLog::add($e->getMessage(), JLog::ERROR, 'com_crowdfunding');
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'))->failure();
         echo $response;
         $app->close();
     }
     if (!$numberOfAdded) {
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_CANNOT_BE_ADDED_SUBSCRIBERS'))->failure();
     } else {
         $response->setTitle(JText::_('COM_CROWDFUNDING_SUCCESS'))->setText(JText::sprintf('COM_CROWDFUNDING_ADDED_SUBSCRIBERS_D', $numberOfAdded))->success();
     }
     echo $response;
     $app->close();
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:32,代码来源:tools.raw.php

示例13: execute

 /**
  * Execute the controller.
  *
  * @return  void
  *
  * @since   3.1
  */
 public function execute()
 {
     // Get the application
     /* @var InstallationApplicationWeb $app */
     $app = $this->getApplication();
     // Check for request forgeries.
     JSession::checkToken() or $app->sendJsonResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
     // Get the setup model.
     $model = new InstallationModelSetup();
     // Check the form
     $vars = $model->checkForm('database');
     // Determine if the configuration file path is writable.
     $path = JPATH_CONFIGURATION . '/configuration.php';
     $useftp = file_exists($path) ? !is_writable($path) : !is_writable(JPATH_CONFIGURATION . '/');
     $r = new stdClass();
     $r->view = $useftp ? 'ftp' : 'summary';
     // Get the database model.
     $db = new InstallationModelDatabase();
     // Attempt to initialise the database.
     $return = $db->createDatabase($vars);
     // Check if the database was initialised
     if (!$return) {
         $r->view = 'database';
     }
     $app->sendJsonResponse($r);
 }
开发者ID:SysBind,项目名称:joomla-cms,代码行数:33,代码来源:database.php

示例14: getStatistics

 public function getStatistics()
 {
     // Check for request forgeries
     JSession::checkToken() or die(JText::_('JINVALID_TOKEN'));
     // Get component parameters
     $params = JComponentHelper::getParams('com_isbnregistry');
     // Get statistics file format
     $format = $params->get('statistics_format', 'XLS');
     // Get form data
     $data = $this->input->post->get('jform', array(), 'array');
     // Get begin
     $begin = $data['begin'];
     // Get end
     $end = $data['end'];
     // Get type
     $type = $data['type'];
     // Redirect
     if ($this->validateDate($begin) && $this->validateDate($end) && $this->validateType($type)) {
         $this->setRedirect('index.php?option=com_isbnregistry&view=statistic&format=' . strtolower($format) . '&begin=' . $begin . '&end=' . $end . '&type=' . $type);
     } else {
         if (!$this->validateType($type)) {
             $this->setMessage(JText::_('COM_ISBNREGISTRY_STATISTIC_INVALID_TYPE'), 'error');
         } else {
             $this->setMessage(JText::_('COM_ISBNREGISTRY_STATISTIC_INVALID_DATE'), 'error');
         }
         $this->setRedirect('index.php?option=com_isbnregistry&view=statistic&layout=popup&tmpl=component');
     }
     $this->redirect();
 }
开发者ID:petkivim,项目名称:id-registry,代码行数:29,代码来源:statistic.php

示例15: save

 /**
  * save a ad fields 
  */
 function save()
 {
     // Check for request forgeries
     JSession::checkToken() or jexit('Invalid Token');
     $input = JFactory::getApplication()->input;
     $model = $this->getModel('settings');
     $post = JRequest::get('post');
     // allow name only to contain html
     $model->setState('request', $post);
     if ($model->store()) {
         $msg = JText::_('C_SAVE_M_S');
     } else {
         $msg = JText::_('C_SAVE_M_NS');
     }
     $task = $input->get('task', '', 'STRING');
     switch ($task) {
         case 'cancel':
             $cancelmsg = JText::_('FIELD_CANCEL_MSG');
             $this->setRedirect('index.php?option=com_socialads', $msg);
             break;
         case 'save':
             $this->setRedirect(JUri::base() . "index.php?option=com_socialads&view=settings", $msg);
             break;
     }
 }
开发者ID:politik86,项目名称:test2,代码行数:28,代码来源:settings.php


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