本文整理汇总了PHP中JRequest::checkToken方法的典型用法代码示例。如果您正苦于以下问题:PHP JRequest::checkToken方法的具体用法?PHP JRequest::checkToken怎么用?PHP JRequest::checkToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JRequest
的用法示例。
在下文中一共展示了JRequest::checkToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cancel
function cancel()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('css');
$this->setRedirect('index.php?option=com_webmapplus');
}
示例2: generateJsonResponse
public function generateJsonResponse($action, $do, $data)
{
$response = '';
if (JDEBUG == 1 && defined('JFIREPHP')) {
FB::log("Kunena JSON action: " . $action);
}
// Sanitize $data variable
$data = $this->_db->getEscaped($data);
if ($this->_my->id) {
// We only entertain json requests for registered and logged in users
switch ($action) {
case 'autocomplete':
$response = $this->_getAutoComplete($do, $data);
break;
case 'preview':
$body = JRequest::getVar('body', '', 'post', 'string', JREQUEST_ALLOWRAW);
$response = $this->_getPreview($body);
break;
case 'pollcatsallowed':
// TODO: deprecated
$response = $this->_getPollsCatsAllowed();
break;
case 'pollvote':
$vote = JRequest::getInt('kpollradio', '');
$id = JRequest::getInt('kpoll-id', 0);
if (!JRequest::checkToken()) {
return false;
}
$response = $this->_addPollVote($vote, $id, $this->_my->id);
break;
case 'pollchangevote':
$vote = JRequest::getInt('kpollradio', '');
$id = JRequest::getInt('kpoll-id', 0);
if (!JRequest::checkToken()) {
return false;
}
$response = $this->_changePollVote($vote, $id, $this->_my->id);
break;
case 'anynomousallowed':
// TODO: deprecated
$response = $this->_anynomousAllowed();
break;
case 'uploadfile':
$response = $this->_uploadFile($do);
break;
case 'modtopiclist':
$response = $this->_modTopicList($data);
break;
case 'removeattachment':
$response = $this->_removeAttachment($data);
break;
default:
break;
}
} else {
$response = array('status' => '-1', 'error' => JText::_('COM_KUNENA_AJAX_PERMISSION_DENIED'));
}
// Output the JSON data.
return json_encode($response);
}
示例3: save
function save()
{
// Check for request forgeries
JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN');
$cid = JRequest::getInt("cid", 0);
$post = JRequest::get('post');
if ($cid > 0) {
$club =& JTable::getInstance("Club", "Table");
$club->load($cid);
$club->bind($post);
$params =& JComponentHelper::getParams('com_joomleague');
if ($club->store() && $params->get('cfg_edit_club_info_update_notify') == "1") {
$db = JFactory::getDBO();
$user = JFactory::getUser();
$query = "SELECT email\n FROM #__users \n WHERE usertype = 'Super Administrator' \n OR usertype = 'Administrator'";
$db->setQuery($query);
$to = $db->loadResultArray();
$subject = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_SUBJECT"), $club->name));
$message = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_MESSAGE"), $user->name, $club->name));
$message .= $this->_getShowClubInfoLink();
JUtility::sendMail('', '', $to, $subject, $message);
}
}
$this->setRedirect($this->_getShowClubInfoLink());
}
示例4: remove
function remove()
{
if (!$this->isAllowed($this->aclCat, 'delete')) {
return;
}
JRequest::checkToken() or die('Invalid Token');
$mailid = JRequest::getVar('filter_mail', 0, 'post', 'int');
$queueClass = acymailing_get('class.queue');
$search = JRequest::getString('search');
$filters = array();
if (!empty($search)) {
$db = JFactory::getDBO();
$searchVal = '\'%' . acymailing_getEscaped($search, true) . '%\'';
$searchFields = array('b.name', 'b.email', 'c.subject', 'a.mailid', 'a.subid');
$filters[] = implode(" LIKE {$searchVal} OR ", $searchFields) . " LIKE {$searchVal}";
}
if (!empty($mailid)) {
$filters[] = 'a.mailid = ' . intval($mailid);
}
$total = $queueClass->delete($filters);
$app = JFactory::getApplication();
$app->enqueueMessage(JText::sprintf('SUCC_DELETE_ELEMENTS', $total), 'message');
JRequest::setVar('filter_mail', 0, 'post');
JRequest::setVar('search', '', 'post');
return $this->listing();
}
示例5: sendEmail
function sendEmail()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$post = JRequest::get('post');
$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
$model = $this->getModel('location');
$location = $model->getData();
$contact_name = $post['contact_name'];
$contact_email = $post['contact_email'];
$contact_message = $post['contact_message'];
if ($contact_name == null || $contact_message == null) {
echo JText::_('Please enter a name and message to send.');
return false;
} else {
if (false) {
return false;
} else {
JUtility::sendMail($contact_email, $contact_name, $location->email, 'Contact Message for: ' . $location->name, $contact_message, 0, null, null, null, $contact_email, $contact_name);
echo JText::_('Message Sent');
return true;
}
}
return false;
}
示例6: publish
/**
* Method to change the state of a list of records.
*/
public function publish()
{
// Check for request forgeries.
JRequest::checkToken() or jexit(JText::_('JInvalid_Token'));
// Initialise variables.
$user = JFactory::getUser();
$ids = JRequest::getVar('cid', array(), '', 'array');
$values = array('publish' => 1, 'unpublish' => 0, 'trash' => -2);
$task = $this->getTask();
$value = JArrayHelper::getValue($values, $task, 0, 'int');
if (empty($ids)) {
JError::raiseWarning(500, JText::_('JError_No_items_selected'));
} else {
// Get the model.
$model = $this->getModel();
// Change the state of the records.
if (!$model->publish($ids, $value)) {
JError::raiseWarning(500, $model->getError());
} else {
if ($value == 1) {
$text = 'JSuccess_N_Items_published';
} else {
if ($value == 0) {
$text = 'JSuccess_N_Items_unpublished';
} else {
$text = 'JSuccess_N_Items_trashed';
}
}
$this->setMessage(JText::sprintf($text, count($ids)));
}
}
$this->setRedirect('index.php?option=com_messages&view=messages');
}
示例7: save
/**
* Save the configuration
*/
function save()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$component = JRequest::getCmd('component');
$table =& JTable::getInstance('component');
if (!$table->loadByOption($component)) {
JError::raiseWarning(500, 'Not a valid component');
return false;
}
$post = JRequest::get('post');
$post['option'] = $component;
$table->bind($post);
// pre-save checks
if (!$table->check()) {
JError::raiseWarning(500, $table->getError());
return false;
}
// save the changes
if (!$table->store()) {
JError::raiseWarning(500, $table->getError());
return false;
}
//$this->setRedirect( 'index.php?option=com_config', $msg );
$this->edit();
}
示例8: unzip
/**
* unzip the file
* @return bool
*/
public function unzip()
{
JRequest::checkToken() or die('Invalid Token');
$appl = JFactory::getApplication();
// if folder doesn't exist - create it!
if (!JFolder::exists($this->pathUnzipped)) {
JFolder::create($this->pathUnzipped);
} else {
// let us remove all previous unzipped files
$folders = JFolder::folders($this->pathUnzipped);
foreach ($folders as $folder) {
JFolder::delete($this->pathUnzipped . '/' . $folder);
}
}
$file = JFolder::files($this->pathArchive);
$result = JArchive::extract($this->pathArchive . '/' . $file[0], $this->pathUnzipped . '/' . $file[0]);
if ($result) {
// scan unzipped folders if we find zip file -> unzip them as well
$this->unzipAll($this->pathUnzipped . '/' . $file[0]);
$message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
} else {
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
}
$appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
return $result;
}
示例9: install
/**
* Install an extension.
*
* @return void
* @since 1.8
*/
public function install()
{
// Check for request forgeries
JRequest::checkToken() or $this->sendResponse(new Exception(JText::_('JINVALID_TOKEN'), 403));
$app = JFactory::getApplication();
$model = $this->getModel('install');
$r = new JObject();
if ($model->install()) {
$cache = JFactory::getCache('mod_menu');
$cache->clean();
// TODO: Reset the users acl here as well to kill off any missing bits
$r->success = true;
$r->redirect = $app->getUserState('com_installer.redirect_url');
} else {
$r->success = false;
$r->redirect = $app->getUserState('com_installer.redirect_url');
}
if (!$r->redirect) {
$r->message = $app->getUserState('com_installer.message');
$r->extensionmessage = $app->getUserState('com_installer.extension_message');
// wipe out the user state
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
}
// wipe out the redicrect url
$app->setUserState('com_installer.redirect_url', '');
$this->sendJsonResponse($r);
}
示例10: save
/**
* saves the venue in the database
*
* @access public
* @return void
* @since 0.9
*/
function save()
{
// Check for request forgeries
JRequest::checkToken() or die('Invalid Token');
// Sanitize
$task = JRequest::getVar('task');
$post = JRequest::get('post');
//get model
$model = $this->getModel('settings');
if ($model->store($post)) {
$msg = JText::_('SETTINGS SAVE');
} else {
$msg = JText::_('SAVE SETTINGS FAILED');
}
switch ($task) {
case 'apply':
$link = 'index.php?option=com_eventlist&controller=settings&task=edit';
break;
default:
$link = 'index.php?option=com_eventlist&view=eventlist';
break;
}
$model->checkin();
$this->setRedirect($link, $msg);
}
示例11: approve
function approve()
{
// Check for request forgeries
JRequest::checkToken() or die(JText::_('JINVALID_TOKEN'));
// Get items to publish from the request.
$cid = JRequest::getVar('cid', array(), '', 'array');
$data = array('approve' => 1, 'disapprove' => 0);
$task = $this->getTask();
$value = JArrayHelper::getValue($data, $task, 0, 'int');
if (empty($cid)) {
JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED'));
} else {
// Get the model.
$model = $this->getModel();
// Make sure the item ids are integers
JArrayHelper::toInteger($cid);
// Publish the items.
if (!$model->approve($cid, $value)) {
JError::raiseWarning(500, $model->getError());
} else {
if ($value == 1) {
$ntext = $this->text_prefix . '_N_ITEMS_APPROVED';
} else {
if ($value == 0) {
$ntext = $this->text_prefix . '_N_ITEMS_DISAPPROVED';
}
}
$this->setMessage(JText::plural($ntext, count($cid)));
}
}
$this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
}
示例12: saveOrder
public function saveOrder()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$db = JFactory::getDBO();
$cid = $jinput->post->get('cid', array(0), 'array');
//JRequest::getVar( 'cid', array(0), 'post', 'array' );
$order = $jinput->post->get('order', array(0), 'array');
//JRequest::getVar( 'order', array (0), 'post', 'array' );
$total = count($cid);
$conditions = array();
JArrayHelper::toInteger($cid, array(0));
JArrayHelper::toInteger($order, array(0));
$row = JTable::getInstance('MultiProfile', 'CTable');
// Update the ordering for items in the cid array
for ($i = 0; $i < $total; $i++) {
$row->load((int) $cid[$i]);
if ($row->ordering != $order[$i]) {
$row->ordering = $order[$i];
$row->store();
}
}
$mainframe = JFactory::getApplication();
$mainframe->redirect('index.php?option=com_community&view=multiprofile', JText::_('COM_COMMUNITY_MULTIPROFILE_ORDERING_SAVED'), 'message');
}
示例13: cancel
public function cancel()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$vars = '&ja_tbl_g=' . base64_encode($this->_table) . '&ja_qry_g=' . base64_encode($this->_query);
$this->setRedirect('index.php?option=com_mijosql' . $vars, $msg);
}
示例14: bgimagemedium
function bgimagemedium()
{
JRequest::checkToken() or die('Invalid Token');
$post = JRequest::get('post');
$data['image'] = 'shadow1';
$data['iw'] = $post['miw'];
$data['ih'] = $post['mih'];
$data['sbgc'] = $post['msbgc'];
$data['ibgc'] = $post['mibgc'];
$data['ibrdc'] = $post['mibrdc'];
$data['iec'] = $post['miec'];
$data['ie'] = $post['mie'];
phocagalleryimport('phocagallery.image.imagebgimage');
$errorMsg = '';
$bgImage = PhocaGalleryImageBgImage::createBgImage($data, $errorMsg);
if ($bgImage) {
$msg = JText::_('COM_PHOCAGALLERY_SUCCESS_BG_IMAGE');
} else {
$msg = JText::_('COM_PHOCAGALLERY_ERROR_BG_IMAGE');
if ($errorMsg != '') {
$msg .= '<br />' . $errorMsg;
}
}
$linkSuffix = '&miw=' . $post['miw'] . '&mih=' . $post['mih'] . '&msbgc=' . str_replace('#', '', $post['msbgc']) . '&mibgc=' . str_replace('#', '', $post['mibgc']) . '&mibrdc=' . str_replace('#', '', $post['mibrdc']) . '&mie=' . $post['mie'] . '&miec=' . str_replace('#', '', $post['miec']);
$this->setRedirect('index.php?option=com_phocagallery&view=phocagalleryt' . $linkSuffix, $msg);
}
示例15: editTags
/**
* Add keyword
*/
function editTags()
{
JRequest::checkToken() or die('Invalid Token');
//$user =& JFactory::getUser();
//$model =& $this->getModel('akseo');
$id = JRequest::getInt('artid');
$newTag = JRequest::getWord('newTag');
$tagArray = JRequest::getVar('tags', '', 'post', 'array');
$tagEdit = JRequest::getInt('tagEdit');
$row =& JTable::getInstance('content');
$row->load($id);
//if tags selected, remove from keywords
if (isset($tagArray) and !empty($tagArray)) {
$keywordArray = explode(",", $row->metakey);
$newKeys = array_diff($keywordArray, $tagArray);
$row->metakey = implode(",", $newKeys);
}
if (isset($newTag)) {
$row->metakey = $row->metakey . ', ' . $newTag;
}
if (isset($newTag) or isset($newKeys)) {
if (!$row->save($row)) {
return JError::raiseWarning(500, $row->getError());
}
}
//$article = $model->getOptions($user->id);
return plgSystemAddKeywords::tagList($row, $addkeyParams = null, $tagEdit, $ajax = 1);
}