本文整理汇总了PHP中EB::checkToken方法的典型用法代码示例。如果您正苦于以下问题:PHP EB::checkToken方法的具体用法?PHP EB::checkToken怎么用?PHP EB::checkToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EB
的用法示例。
在下文中一共展示了EB::checkToken方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: togglePublish
/**
* Toggles the publishing state of a block
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function togglePublish()
{
// Check for request forgeries
EB::checkToken();
// Default redirection url
$redirect = 'index.php?option=com_easyblog&view=blocks';
// Get the items to be published / unpublished
$ids = $this->input->get('cid', array(), 'array');
if (!$ids) {
$this->info->set('COM_EASYBLOG_BLOCKS_INVALID_ID_PROVIDED', 'error');
return $this->app->redirect($redirect);
}
// Get the current task
$task = $this->getTask();
foreach ($ids as $id) {
$block = EB::table('Block');
$block->load((int) $id);
$block->{$task}();
}
$message = 'COM_EASYBLOG_BLOCKS_PUBLISHED_SUCCESSFULLY';
if ($task == 'unpublish') {
$message = 'COM_EASYBLOG_BLOCKS_UNPUBLISHED_SUCCESSFULLY';
}
$this->info->set(JText::_($message));
return $this->app->redirect($redirect);
}
示例2: setDefault
/**
* Make the provided theme a default theme for EasyBlog
*
* @since 4.0
* @access public
*/
public function setDefault()
{
// Check for request forgeries
EB::checkToken();
// Check for acl rules.
$this->checkAccess('theme');
$element = $this->input->get('cid', '', 'array');
$element = $element[0];
if (!$element || !isset($element[0])) {
EB::info()->set(JText::_('COM_EASYBLOG_THEME_INVALID_THEME_PROVIDED'), 'error');
return $this->app->redirect('index.php?option=com_easyblog&view=themes');
}
// Legacy codes and should be removed soon
$this->config->set('layout_theme', $element);
// Get the configuration object
$this->config->set('theme_site', $element);
$table = EB::table('Configs');
$table->load('config');
$table->params = $this->config->toString('INI');
$table->store();
// Clear the component's cache
$cache = JFactory::getCache('com_easyblog');
$cache->clean();
EB::info()->set(JText::sprintf('COM_EASYBLOG_THEME_SET_AS_DEFAULT', $element), 'success');
$this->app->redirect('index.php?option=com_easyblog&view=themes');
}
示例3: reject
public function reject()
{
// Check for request forgeries
EB::checkToken();
// Ensure that user is logged in
EB::requireLogin();
// Get any return url
$return = EB::_('index.php?option=com_easyblog&view=dashboard&layout=moderate');
if ($this->getReturnURL()) {
$return = $this->getReturnURL();
}
// Check if the user is privileged enough
if (!$this->acl->get('add_entry') && !$this->acl->get('manage_pending')) {
return JError::raiseError(500, JText::_('COM_EASYBLOG_NO_PERMISSION_TO_MODERATE_BLOG'));
}
// Get a list of ids
$ids = $this->input->get('ids', array(), 'array');
$message = $this->input->get('message', '', 'default');
foreach ($ids as $id) {
$id = (int) $id;
$post = EB::post($id);
$post->reject($message);
}
$message = JText::_('COM_EASYBLOG_BLOGS_BLOG_SAVE_REJECTED');
$this->info->set($message, 'success');
return $this->app->redirect($return);
}
示例4: blogger
/**
* Search blogger
*
* @since 4.0
* @access public
*/
public function blogger()
{
// Check for request forgeries
EB::checkToken();
// Get the query
$search = $this->input->get('search', '', 'string');
$url = EB::_('index.php?option=com_easyblog&view=blogger&search=' . $search, false);
return $this->app->redirect($url);
}
示例5: save
/**
* Saves an acl
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function save()
{
// Check for request forgeries
EB::checkToken();
// @task: Check for acl rules.
$this->checkAccess('acl');
// get current task name.
$task = $this->getTask();
$id = $this->input->get('id', 0, 'int');
$name = $this->input->get('name', '', 'cmd');
// Ensure that the composite keys are provided.
if (empty($id)) {
$this->info->set('COM_EASYBLOG_ACL_INVALID_ID_ERROR', 'error');
return $this->app->redirect('index.php?option=com_easyblog&view=acls&layout=form&id=' . $id);
}
// Get the data from the post
$data = $this->input->getArray('post');
// Get the text filters first.
$filter = EB::table('ACLFilter');
$state = $filter->load($id);
if (!$state) {
$filter->content_id = $id;
$filter->type = 'group';
}
// Set the disallowed tags
$filter->disallow_tags = $data['disallow_tags'];
$filter->disallow_attributes = $data['disallow_attributes'];
$filter->store();
// Load the acl model
$model = EB::model('ACL');
// Delete all existing rule set
$state = $model->deleteRuleset($id);
// Unset unecessary data form the post
unset($data['task']);
unset($data['option']);
unset($data['c']);
unset($data['id']);
unset($data['name']);
unset($data['disallow_tags']);
unset($data['disallow_attributes']);
// Insert new rules
$state = $model->insertRuleset($id, $data);
if (!$state) {
$this->info->set('COM_EASYBLOG_ACL_ERROR_SAVING_ACL', 'error');
return $this->app->redirect('index.php?option=com_easyblog&view=acls&layout=form&id=' . $id);
}
$url = 'index.php?option=com_easyblog&view=acls';
if ($task == 'apply') {
$url = 'index.php?option=com_easyblog&view=acls&layout=form&id=' . $id;
}
$this->info->set('COM_EASYBLOG_ACL_SAVE_SUCCESS', 'success');
return $this->app->redirect($url);
}
示例6: approve
/**
* Approves a blog post
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function approve()
{
// Check for request forgeries
EB::checkToken();
// Check for acl
$this->checkAccess('pending');
// Get a list of id's to approve
$ids = $this->input->get('cid', array(), 'array');
foreach ($ids as $id) {
$post = EB::post($id);
$post->approve();
}
$message = JText::_('COM_EASYBLOG_BLOGS_BLOG_SAVE_APPROVED');
$this->info->set($message, 'success');
$this->app->redirect('index.php?option=com_easyblog&view=blogs&layout=pending');
}
示例7: install
/**
* Install language file on the site
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function install()
{
// Check for request forgeries here
EB::checkToken();
// Get the language id
$ids = $this->input->get('cid', array(), 'array');
foreach ($ids as $id) {
$table = EB::table('Language');
$table->load($id);
$state = $table->install();
if (!$state) {
EB::info()->set($table->getError(), 'error');
return $this->app->redirect('index.php?option=com_easyblog&view=languages');
}
}
EB::info()->set(JText::_('COM_EASYBLOG_LANGUAGE_INSTALLED_SUCCESSFULLY'), 'success');
$this->app->redirect('index.php?option=com_easyblog&view=languages');
}
示例8: setAsAdmin
public function setAsAdmin($teamId, $userId, $isAdmin)
{
// Check for request forgeries
EB::checkToken();
// @task: Check for acl rules.
$this->checkAccess('easyblog.manage.teamblog');
$db = EB::db();
$query = 'UPDATE `#__easyblog_team_users` SET ';
if ($isAdmin) {
$query .= ' `isadmin` = ' . $db->Quote('1');
} else {
$query .= ' `isadmin` = ' . $db->Quote('0');
}
$query .= ' WHERE `team_id` = ' . $db->Quote($teamId);
$query .= ' AND `user_id` = ' . $db->Quote($userId);
$db->setQuery($query);
$db->query();
return true;
}
示例9: save
/**
* save post templates
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function save()
{
// Check for request forgeries
EB::checkToken();
$id = $this->input->get('id', '', 'int');
$template = EB::table('PostTemplate');
$template->load($id);
$title = $this->input->get('title', '', 'default');
$content = $this->input->get('template_content', '', 'raw');
$data['content'] = $content;
$template->title = $title;
$template->data = json_encode($data);
$template->user_id = $this->my->id;
$template->created = EB::date()->toSql();
$template->store();
$this->info->set('COM_EASYBLOG_DASHBOARD_TEMPLATES_SAVED_SUCCESS', 'success');
$redirect = EB::_('index.php?option=com_easyblog&view=dashboard&layout=templates', false);
return $this->app->redirect($redirect);
}
示例10: remove
/**
* Deletes a mailer item
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function remove()
{
// Check for request forgeries
EB::checkToken();
// @task: Check for acl rules.
$this->checkAccess('mail');
$mails = $this->input->get('cid', array(), 'array');
if (!$mails) {
$message = JText::_('COM_EASYBLOG_NO_MAIL_ID_PROVIDED');
$this->info->set($message, 'error');
return $this->app->redirect('index.php?option=com_easyblog&view=spools');
}
foreach ($mails as $id) {
$table = EB::table('MailQueue');
$table->load((int) $id);
$table->delete();
}
$this->info->set('COM_EASYBLOG_SPOOLS_DELETE_SUCCESS', 'success');
return $this->app->redirect('index.php?option=com_easyblog&view=spools');
}
示例11: submit
/**
* Allows caller to submit a report
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function submit()
{
// Check for request forgeries
EB::checkToken();
// Get the composite keys
$id = $this->input->get('id', 0, 'int');
$type = $this->input->get('type', '', 'cmd');
// Initialize redirection link
$redirect = EB::_('index.php?option=com_easyblog&view=entry&id=' . $id, false);
// Check if guest is allowed to report or not.
if ($this->my->guest && !$this->config->get('main_reporting_guests')) {
$this->info->set('COM_EASYBLOG_CATEGORIES_FOR_REGISTERED_USERS_ONLY', 'error');
return $this->app->redirect($redirect);
}
// Ensure that the report reason is not empty.
$reason = $this->input->get('reason', '', 'default');
if (!$reason) {
EB::info()->set(JText::_('COM_EASYBLOG_REPORT_PLEASE_SPECIFY_REASON'), 'error');
return $this->app->redirect($redirect);
}
$report = EB::table('Report');
$report->obj_id = $id;
$report->obj_type = $type;
$report->reason = $reason;
$report->created = EB::date()->toSql();
$report->created_by = $this->my->id;
$report->ip = @$_SERVER['REMOTE_ADDR'];
$state = $report->store();
if (!$state) {
$this->info->set($report->getError());
return $this->app->redirect($redirect);
}
// Notify the site admin when there's a new report made
$post = EB::post($id);
$report->notify($post);
$message = JText::_('COM_EASYBLOG_THANKS_FOR_REPORTING');
$this->info->set($message, 'success');
return $this->app->redirect($redirect);
}
示例12: saveWebcam
/**
* Saves an uploaded webcam picture
*
* @since 4.0
* @access public
* @param string
* @return
*/
public function saveWebcam()
{
// Check for request forgeries
EB::checkToken();
// Ensure that the user user must be logged into the site
EB::requireLogin();
$image = $this->input->get('image', '', 'default');
$image = imagecreatefrompng($image);
ob_start();
imagepng($image, null, 9);
$contents = ob_get_contents();
ob_end_clean();
// Store this in a temporary location
$file = md5(EB::date()->toSql()) . '.png';
$tmp = JPATH_ROOT . '/tmp/' . $file;
$uri = JURI::root() . 'tmp/' . $file;
JFile::write($tmp, $contents);
$result = new stdClass();
$result->file = $file;
$result->url = $uri;
$this->ajax->resolve($result);
}
示例13: remove
/**
* Deletes a draft from the site
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function remove()
{
// Check for request forgeries
EB::checkToken();
// Check for acl access
$this->checkAccess('blog');
// Get list of blog post id's.
$ids = $this->input->get('cid', array(), 'array');
if (!$ids) {
$this->info->set('COM_EASYBLOG_INVALID_BLOG_ID', 'error');
return $this->app->redirect($return);
}
foreach ($ids as $id) {
$id = (int) $id;
$draft = EB::table('Revision');
$draft->load($id);
$draft->delete();
}
$this->info->set('COM_EASYBLOG_BLOGS_DELETED_SUCCESSFULLY', 'success');
$return = 'index.php?option=com_easyblog&view=blogs&layout=drafts';
return $this->app->redirect($return);
}
示例14: runscript
public function runscript()
{
// Check for request forgeries
EB::checkToken();
// Get the key
$key = $this->input->get('key', '', 'default');
// Get the model
$model = EB::model('Maintenance');
$script = $model->getItemByKey($key);
if (!$script) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_MAINTENANCE_SCRIPT_NOT_FOUND'));
}
$classname = $script->classname;
if (!class_exists($classname)) {
return $this->ajax->reject(JText::_('COM_EASYBLOG_MAINTENANCE_CLASS_NOT_FOUND'));
}
$class = new $classname();
try {
$class->main();
} catch (Exception $e) {
return $this->ajax->reject($e->getMessage());
}
return $this->ajax->resolve();
}
示例15: delete
/**
* Deletes a user from the site
*
* @since 4.0
* @access public
*/
public function delete()
{
// Check for request forgeries
EB::checkToken();
// Check for acl rules.
$this->checkAccess('user');
// Get a list of user id's to delete
$ids = $this->input->get('cid', array(), 'array');
// Default redirection url
$redirect = 'index.php?option=com_easyblog&view=bloggers';
if (!$ids) {
$this->info->set('COM_EASYBLOG_INVALID_BLOGGER_ID');
return $this->app->redirect($redirect);
}
foreach ($ids as $id) {
$id = (int) $id;
$user = JFactory::getUser($id);
if ($user->authorise('core.admin')) {
// Throw error
$this->info->set('COM_EASYBLOG_BLOGGER_NOT_ALLOWED_TO_DELETE_SUPER_ADMIN');
return $this->app->redirect($redirect);
}
if ($user->id == $this->my->id) {
$this->info->set('COM_EASYBLOG_BLOGGER_NOT_ALLOWED_TO_DELETE_SELF');
return $this->app->redirect($redirect);
}
// Try to delete the user
$user->delete();
}
$this->info->set('COM_EASYBLOG_BLOGGER_DELETED_SUCCESSFULLY', 'success');
return $this->app->redirect($redirect);
}