本文整理汇总了PHP中FD::checkToken方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::checkToken方法的具体用法?PHP FD::checkToken怎么用?PHP FD::checkToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::checkToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearCache
/**
* Purges the less cache files on the site
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function clearCache()
{
// Check for request forgeries
FD::checkToken();
// Determines if we should purge all javascripts.
$purgeScripts = $this->input->get('script-cache', false, 'bool');
// Clear javascript files
if ($purgeScripts) {
FD::purgeJavascriptResources();
}
// Determines if we should purge the cached less stylesheets
$purgeCssCache = $this->input->get('stylesheet-cache', false, 'bool');
if ($purgeCssCache) {
$templates = JFolder::folders(EASYSOCIAL_SITE_THEMES);
foreach ($templates as $template) {
$task = FD::stylesheet('site', $template)->purge();
}
// Compile admin themes
$templates = JFolder::folders(EASYSOCIAL_ADMIN_THEMES);
foreach ($templates as $template) {
$task = FD::stylesheet('admin', $template)->purge();
}
// Compile modules
$modules = FD::stylesheet('module')->modules();
foreach ($modules as $module) {
$task = FD::stylesheet('module', $module)->purge();
}
}
$message = JText::sprintf('COM_EASYSOCIAL_CACHE_PURGED_FROM_SITE');
$this->view->setMessage($message, SOCIAL_MSG_SUCCESS);
return $this->view->call(__FUNCTION__);
}
示例2: store
/**
* Stores the theme parameter
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function store()
{
// Check for request forgeries
FD::checkToken();
// @TODO: Check if the user has privilege to access this section.
// Get the element from the query
$element = JRequest::getWord('element', '');
// Get the current view
$view = $this->getCurrentView();
if (!$element) {
$view->setMessage(JText::_('COM_EASYSOCIAL_THEMES_INVALID_ELEMENT_PROVIDED'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $this->getTask());
}
// Load the model
$model = FD::model('Themes');
// Format through all the properties that we want to save here.
$data = JRequest::get('post');
// Remove unwanted stuffs from the post data.
unset($data[FD::token()]);
unset($data['option']);
unset($data['controller']);
unset($data['task']);
unset($data['element']);
$state = $model->update($element, $data);
if (!$state) {
$view->setMessage($model->getError(), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $this->getTask(), $element);
}
$view->setMessage(JText::sprintf('COM_EASYSOCIAL_THEMES_SETTINGS_SAVED_SUCCESS', $element), SOCIAL_MSG_SUCCESS);
return $view->call(__FUNCTION__, $this->getTask(), $element);
}
示例3: revoke
/**
* Revokes the access for the user that has already authenticated
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function revoke()
{
// Check for request forgeries
FD::checkToken();
// Get the current view.
$view = $this->getCurrentView();
$client = JRequest::getWord('client');
// Get the oauth library for the consumer type.
$oauth = FD::oauth(ucfirst($client));
$uid = JRequest::getVar('uid');
$type = JRequest::getVar('type');
$callback = JRequest::getVar('callback');
// Grab the token.
$table = FD::table('OAuth');
$table->load(array('uid' => $uid, 'type' => $type));
// Set the access token.
$oauth->setAccess($table->token);
$result = $oauth->revoke();
if (!$result) {
$view->setError(JText::_('COM_EASYSOCIAL_OAUTH_THERE_WAS_ERROR_REVOKING_ACCESS'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $callback);
}
// Try to delete the record permanently
$state = $table->delete();
if (!$state) {
$view->setError(JText::_('COM_EASYSOCIAL_OAUTH_THERE_WAS_DELETING_OAUTH_RECORD'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__, $callback);
}
$view->setMessage(JText::_('COM_EASYSOCIAL_OAUTH_REVOKED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS);
return $view->call(__FUNCTION__, $callback);
}
示例4: delete
/**
* Delete's the location from the database.
*
* @since 1.0
* @access public
*/
public function delete()
{
// Check for valid token
FD::checkToken();
// Guest users shouldn't be allowed to delete any location at all.
FD::requireLogin();
$my = FD::user();
$id = JRequest::getInt('id');
$view = FD::getInstance('View', 'Location', false);
$location = FD::table('Location');
$location->load($id);
// If id is invalid throw errors.
if (!$location->id) {
$view->setErrors(JText::_('COM_EASYSOCIAL_LOCATION_INVALID_ID'));
}
// If user do not own item, throw errors.
if ($my->id !== $location->user_id) {
$view->setErrors(JText::_('COM_EASYSOCIAL_LOCATION_ERROR_YOU_ARE_NOT_OWNER'));
}
// Try to delete location.
if (!$location->delete()) {
$view->setErrors($location->getError());
}
return $view->delete();
}
示例5: unfollow
/**
* Unfollows a user
*
* @since 1.0
* @access public
*/
public function unfollow()
{
// Check for valid tokens.
FD::checkToken();
// Check for valid user.
FD::requireLogin();
// Load friends model.
$model = FD::model('Followers');
// Load the view.
$view = $this->getCurrentView();
// Get the user id that we should load for.
$userId = JRequest::getInt('id');
// Get the current logged in user
$my = FD::user();
// Loads the followers record
$follower = FD::table('Subscription');
$follower->load(array('uid' => $userId, 'type' => 'user.user', 'user_id' => $my->id));
if (!$follower->id || !$userId) {
$view->setMessage(JText::_('COM_EASYSOCIAL_FOLLOWERS_INVALID_ID'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__);
}
// Delete the record
$state = $follower->delete();
$view->call(__FUNCTION__);
}
示例6: runscript
public function runscript()
{
// Check for request forgeries
FD::checkToken();
// Get the key
$key = $this->input->get('key', '', 'default');
// Get the model
$model = FD::model('Maintenance');
$script = $model->getItemByKey($key);
if (!$script) {
$this->view->setMessage(JText::_('COM_EASYSOCIAL_MAINTENANCE_SCRIPT_NOT_FOUND'), SOCIAL_MSG_ERROR);
return $this->view->call(__FUNCTION__);
}
$classname = $script->classname;
if (!class_exists($classname)) {
$this->view->setMessage(JText::_('COM_EASYSOCIAL_MAINTENANCE_CLASS_NOT_FOUND'), SOCIAL_MSG_ERROR);
return $this->view->call(__FUNCTION__);
}
$class = new $classname();
try {
$class->main();
} catch (Exception $e) {
$this->view->setMessage($e->getMessage(), SOCIAL_MSG_ERROR);
return $this->view->call(__FUNCTION__);
}
return $this->view->call(__FUNCTION__);
}
示例7: getLanguages
/**
* Retrieves a list of languages from API server
*
* @since 1.0
* @access public
*/
public function getLanguages()
{
// Check for request forgeries here
FD::checkToken();
// Get the stored key
$key = $this->config->get('general.key');
// Start connecting
$connector = FD::connector();
$connector->addUrl(SOCIAL_UPDATER_LANGUAGE);
$connector->setMethod('POST');
$connector->addQuery('key', $key);
$connector->connect();
$result = $connector->getResult(SOCIAL_UPDATER_LANGUAGE);
$obj = json_decode($result);
if (!$obj || !isset($obj->code) || $obj->code != 200) {
return $this->view->call(__FUNCTION__, $obj);
}
// Go through each of the languages now
foreach ($obj->languages as $language) {
// Check if the language was previously installed thorugh our system.
// If it does, load it instead of overwriting it.
$table = FD::table('Language');
$exists = $table->load(array('locale' => $language->locale));
// We do not want to bind the id
unset($language->id);
// Since this is the retrieval, the state should always be disabled
if (!$exists) {
$table->state = SOCIAL_STATE_UNPUBLISHED;
}
// If the language file has been installed, we want to check the last updated time
if ($exists && $table->state == SOCIAL_LANGUAGES_INSTALLED) {
// Then check if the language needs to be updated. If it does, update the ->state to SOCIAL_LANGUAGES_NEEDS_UPDATING
// We need to check if the language updated time is greater than the local updated time
$languageTime = strtotime($language->updated);
$localLanguageTime = strtotime($table->updated);
if ($languageTime > $localLanguageTime && $table->state == SOCIAL_LANGUAGES_INSTALLED) {
$table->state = SOCIAL_LANGUAGES_NEEDS_UPDATING;
}
}
// Set the title
$table->title = $language->title;
// Set the locale
$table->locale = $language->locale;
// Set the translator
$table->translator = $language->translator;
// Set the updated time
$table->updated = $language->updated;
// Update the progress
$table->progress = $language->progress;
// Update the table with the appropriate params
$params = FD::registry();
$params->set('download', $language->download);
$params->set('md5', $language->md5);
$table->params = $params->toString();
$table->store();
}
return $this->view->call(__FUNCTION__, $obj);
}
示例8: loadStoryForm
public function loadStoryForm()
{
FD::checkToken();
FD::requireLogin();
FD::language()->loadAdmin();
$categoryid = FD::input()->getInt('id', 0);
$category = FD::table('EventCategory');
$category->load($categoryid);
$db = FD::db();
$sql = $db->sql();
$sql->select('#__social_fields', 'a');
$sql->column('a.*');
$sql->column('d.element');
$sql->leftjoin('#__social_fields_steps', 'b');
$sql->on('a.step_id', 'b.id');
$sql->leftjoin('#__social_clusters_categories', 'c');
$sql->on('b.uid', 'c.id');
$sql->leftjoin('#__social_apps', 'd');
$sql->on('a.app_id', 'd.id');
$sql->where('b.type', SOCIAL_TYPE_CLUSTERS);
$sql->where('c.id', $category->id);
$sql->where('d.group', SOCIAL_FIELDS_GROUP_EVENT);
$sql->where('d.type', SOCIAL_APPS_TYPE_FIELDS);
$sql->where('d.element', array('startend', 'title', 'description'), 'in');
$db->setQuery($sql);
$result = $db->loadObjectList();
$theme = FD::themes();
foreach ($result as $row) {
$field = FD::table('Field');
$field->bind($row);
$params = $field->getParams();
if ($row->element === 'startend') {
$dateFormat = $params->get('date_format', 'DD-MM-YYYY');
if ($params->get('allow_time', true)) {
$dateFormat .= ' ' . $params->get('time_format', 'hh:mm A');
}
if ($params->get('allow_timezone', true)) {
$theme->set('timezones', $this->getTimezones());
}
$theme->set('dateFormat', $dateFormat);
$theme->set('allowTimezone', $params->get('allow_timezone', 1));
$theme->set('allowTime', $params->get('allow_time', 1));
$theme->set('yearfrom', $params->get('yearfrom'));
$theme->set('yearto', $params->get('yearto'));
$theme->set('disallowPast', $params->get('disallow_past', 0));
$theme->set('minuteStepping', $params->get('minute_stepping', 15));
}
if ($row->element === 'title') {
$theme->set('titlePlaceholder', $field->get('title'));
}
if ($row->element === 'description') {
$theme->set('descriptionPlaceholder', $field->get('description'));
}
}
FD::ajax()->resolve($theme->output('apps/user/events/story/panel.form'));
}
示例9: send
/**
* Sends a new share to a user.
*
* @since 1.0
* @access public
*/
public function send()
{
FD::checkToken();
$token = JRequest::getString('token', '');
$recipients = JRequest::getVar('recipients', array());
$content = JRequest::getVar('content', '');
// Get the current view.
$view = $this->getCurrentView();
// Cleaning
if (is_string($recipients)) {
$recipients = explode(',', FD::string()->escape($recipients));
}
if (is_array($recipients)) {
foreach ($recipients as &$recipient) {
$recipient = FD::string()->escape($recipient);
if (!JMailHelper::isEmailAddress($recipient)) {
return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_RECIPIENT'));
}
}
}
$content = FD::string()->escape($content);
// Check for valid data
if (empty($recipients)) {
return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_NO_RECIPIENTS'));
}
if (empty($token)) {
return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_TOKEN'));
}
$session = JFactory::getSession();
$config = FD::config();
$limit = $config->get('sharing.email.limit', 0);
$now = FD::date()->toUnix();
$time = $session->get('easysocial.sharing.email.time');
$count = $session->get('easysocial.sharing.email.count');
if (is_null($time)) {
$session->set('easysocial.sharing.email.time', $now);
$time = $now;
}
if (is_null($count)) {
$session->set('easysocial.sharing.email.count', 0);
}
$diff = $now - $time;
if ($diff <= 3600) {
if ($limit > 0 && $count >= $limit) {
return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_SHARING_LIMIT_MAXED'));
}
$count++;
$session->set('easysocial.sharing.email.count', $count);
} else {
$session->set('easysocial.sharing.email.time', $now);
$session->set('easysocial.sharing.email.count', 1);
}
$library = FD::get('Sharing');
$library->sendLink($recipients, $token, $content);
$view->call(__FUNCTION__, true);
}
示例10: installFile
public function installFile()
{
FD::checkToken();
$view = $this->getCurrentView();
$file = JRequest::getVar('file', '');
if (empty($file)) {
$view->setError('Invalid file path given to scan.');
return $view->call(__FUNCTION__);
}
$model = FD::model('accessrules');
$obj = (object) array('file' => str_ireplace(JPATH_ROOT, '', $file), 'rules' => $model->install($file));
return $view->call(__FUNCTION__, $obj);
}
示例11: getNews
/**
* Get's the latest news from updater server.
*
* @since 1.0
* @access public
*/
public function getNews()
{
// Check for request forgeries
FD::checkToken();
// Get the current view
$view = $this->getCurrentView();
// Get the current model
$model = FD::model('News');
// Get the manifest data
$obj = $model->getNews();
// Get the news
$news = $obj->news;
// Get app news
$appNews = $obj->apps;
return $view->call(__FUNCTION__, $news, $appNews);
}
示例12: purge
/**
* Allows user to purge indexed items
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function purge()
{
// Check for request forgeries
FD::checkToken();
// Get the current view
$view = $this->getCurrentView();
$model = FD::model('Indexer');
$state = $model->purge();
if ($state !== true) {
$view->setMessage(JText::_('COM_EASYSOCIAL_INDEXER_PURGE_FAILED'), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__);
}
$message = JText::_('COM_EASYSOCIAL_INDEXER_PURGED_SUCCESS');
$view->setMessage($message, SOCIAL_MSG_SUCCESS);
$view->call(__FUNCTION__);
}
示例13: filterGuests
/**
* Filters the output of members
*
* @since 1.3
* @access public
* @return
*/
public function filterGuests()
{
// Check for request forgeriess
FD::checkToken();
// Ensure that the user is logged in.
FD::requireLogin();
// Get the event object
$id = $this->input->get('id', 0, 'int');
$event = FD::event($id);
if (!$event || !$id) {
return $this->ajax->reject();
}
// Check whether the viewer can really view the contents
if (!$event->canViewItem()) {
return $this->ajax->reject();
}
// Get the current filter
$filter = $this->input->get('filter', '', 'word');
$options = array();
if ($filter == 'admin') {
$options['admin'] = true;
}
if ($filter == 'going') {
$options['state'] = SOCIAL_EVENT_GUEST_GOING;
}
if ($filter == 'maybe') {
$options['state'] = SOCIAL_EVENT_GUEST_MAYBE;
}
if ($filter == 'notgoing') {
$options['state'] = SOCIAL_EVENT_GUEST_NOT_GOING;
}
if ($filter == 'pending') {
$options['state'] = SOCIAL_EVENT_GUEST_PENDING;
}
$model = FD::model('Events');
$guests = $model->getGuests($event->id, $options);
$pagination = $model->getPagination();
$myGuest = $event->getGuest();
// Load the contents
$theme = FD::themes();
$theme->set('pagination', $pagination);
$theme->set('event', $event);
$theme->set('guests', $guests);
$theme->set('myGuest', $myGuest);
$contents = $theme->output('apps/event/guests/events/default.list');
return $this->ajax->resolve($contents, count($guests));
}
示例14: suggest
/**
* Suggests a list of hash tags to the user
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function suggest()
{
// Check for valid tokens.
FD::checkToken();
// Only valid registered user has friends.
FD::requireLogin();
// Get current logged in user
$my = FD::user();
// Load the view.
$view = $this->getCurrentView();
// Properties
$search = $this->input->get('search', '', 'default');
// Get the stream model
$model = FD::model('Hashtags');
// Try to get the search result
$result = $model->search($search);
return $view->call(__FUNCTION__, $result);
}
示例15: remove
public function remove()
{
// Check for valid token
FD::checkToken();
// Ensure that the user is logged in
FD::requireLogin();
$sId = JRequest::getVar('id');
if (empty($sId)) {
FD::getInstance('View', 'Subscriptions', false)->setErrors(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID'));
return FD::getInstance('View', 'Subscriptions', false)->remove();
}
$state = FD::get('Subscriptions')->remove($sId);
if (!$state) {
FD::getInstance('View', 'Subscriptions', false)->setErrors(JText::_('COM_EASYSOCIAL_SUBSCRIPTION_FAILED_TO_UNSUBSCRIBE'));
return FD::getInstance('View', 'Subscriptions', false)->remove();
}
return FD::getInstance('View', 'Subscriptions', false)->remove();
}