本文整理汇总了PHP中Input::csrfMsg方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::csrfMsg方法的具体用法?PHP Input::csrfMsg怎么用?PHP Input::csrfMsg使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::csrfMsg方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexSection
/**
* Manages configuration settings for the Session module
*
* @return string
*/
public function indexSection()
{
if (!$this->_acl->check('session_manage')) {
throw new Module_NoPermission();
}
$this->setTitle(t('Session configuration'));
$this->setOutputType(self::_OT_CONFIG);
// Check for input data or display the view file
if ($this->_input->has('post', 'session')) {
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
foreach ($this->_input->post('session') as $key => $val) {
try {
$this->_config_sql->update('session/' . $key, $val);
} catch (Config_KeyNoExist $e) {
$this->_config_sql->add('session/' . $key, $val);
}
}
$this->_event->success(t('Updated session configuration'));
}
return zula_redirect($this->_router->makeUrl('session', 'config'));
} else {
$this->addAsset('js/logindest.js');
$view = $this->loadView('config/config.html');
$view->assign($this->_config->get('session'));
$view->assignHtml(array('CSRF' => $this->_input->createToken(true)));
return $view->getOutput();
}
}
示例2: updateSection
/**
* Updates which theme should be used for the different
* site types.
*
* @return string
*/
public function updateSection()
{
if (!$this->_acl->check('theme_update')) {
throw new Module_NoPermission();
} else {
if ($this->_input->checkToken()) {
try {
$siteType = $this->_input->post('theme_site_type');
if ($this->_router->siteTypeExists($siteType)) {
$theme = $this->_input->post('theme');
if (Theme::exists($theme)) {
$this->_config_sql->update('theme/' . $siteType . '_default', $theme);
$this->_event->success(t('Updated default theme'));
}
} else {
$this->_event->error(t('Selected site type does not exist'));
$siteType = null;
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('Please select a theme to use as the default'));
}
} else {
$this->_event->error(Input::csrfMsg());
}
}
$siteType = isset($siteType) ? $siteType : $this->_router->getDefaultSiteType();
return zula_redirect($this->_router->makeUrl('theme')->queryArgs(array('type' => $siteType)));
}
示例3: delOptSection
/**
* Deletes all selected poll options
*
* @return string
*/
public function delOptSection()
{
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_acl->check('poll_delete')) {
throw new Module_NoPermission();
} else {
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
try {
$poll = $this->_model()->getPoll($this->_router->getArgument('id'));
// Check user has permission
$resource = 'poll-' . $poll['id'];
if ($this->_acl->resourceExists($resource) && $this->_acl->check($resource)) {
$optionIds = $this->_input->post('option_ids');
foreach ((array) $optionIds as $oid) {
try {
$this->_model()->deleteOption($oid);
} catch (Poll_OptionNoExist $e) {
}
}
$this->_event->success(t('Deleted selected options'));
} else {
throw new Module_NoPermission();
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No options selected'));
}
}
}
if (isset($poll['id'])) {
return zula_redirect($this->_router->makeUrl('poll', 'config', 'edit', null, array('id' => $poll['id'])));
} else {
return zula_redirect($this->_router->makeUrl('poll', 'config'));
}
}
示例4: bridgeSection
/**
* Creates a bridge between the Delete Selected and Update Order
* functionaility, as there can only be one form with one action
*
* @return mixed
*/
public function bridgeSection()
{
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
if ($this->_input->has('post', 'menu_delete')) {
// Delete all selected menu items
if (!$this->_acl->check('menu_delete_item')) {
throw new Module_NoPermission();
}
try {
$delCount = 0;
foreach ($this->_input->post('menu_ids') as $item) {
try {
$resource = 'menu-item-' . $item;
if ($this->_acl->resourceExists($resource) && $this->_acl->check($resource)) {
$this->_model()->deleteItem($item);
++$delCount;
}
} catch (Menu_ItemNoExist $e) {
}
}
if ($delCount > 0) {
$this->_event->success(t('Deleted menu items'));
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No menu items selected'));
}
} else {
if ($this->_input->has('post', 'menu_updateorder')) {
// Update order of all of the menu items
if (!$this->_acl->check('menu_edit_item')) {
throw new Module_NoPermission();
}
$execData = array();
$sqlMiddle = null;
foreach ($this->_input->post('menu_order') as $item => $order) {
try {
$item = $this->_model()->getItem($item);
$resource = 'menu-item-' . $item['id'];
if ($this->_acl->resourceExists($resource) && $this->_acl->check($resource)) {
// Clear cache for this menu item!
$this->_cache->delete(array('menu_items_' . $item['cat_id'], 'menu_child_items_' . $item['id']));
$execData[] = $item['id'];
$execData[] = abs($order);
$sqlMiddle .= 'WHEN id = ? THEN ? ';
}
} catch (Menu_ItemNoExist $e) {
}
}
if ($sqlMiddle !== null) {
$pdoSt = $this->_sql->prepare('UPDATE {PREFIX}mod_menu SET `order` = CASE ' . $sqlMiddle . 'ELSE `order` END');
$pdoSt->execute($execData);
}
$this->_event->success(t('Menu order updated'));
}
}
}
try {
$url = $this->_router->makeUrl('menu', 'config', 'editcat', null, array('id' => $this->_input->post('menu/cid')));
} catch (Router_ArgNoExist $e) {
$url = $this->_router->makeUrl('menu', 'config');
}
return zula_redirect($url);
}
示例5: deleteSection
/**
* Attempts to delete all selected users
*
* @return string
*/
public function deleteSection()
{
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_acl->check('users_delete')) {
throw new Module_NoPermission();
} else {
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
try {
$delCount = 0;
foreach ($this->_input->post('user_ids') as $uid) {
try {
$this->_ugmanager->deleteUser($uid);
++$delCount;
} catch (Ugmanager_InvalidUser $e) {
$this->_event->error(t('You can not delete the root or guest user'));
} catch (Ugmanager_UserNoExist $e) {
}
}
if ($delCount > 0) {
$this->_event->success(t('Deleted Selected Users'));
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No users selected'));
}
}
}
return zula_redirect($this->_router->makeUrl('users', 'config'));
}
示例6: __call
/**
* Update the settings based on the post-data provided
*
* @param string $name
* @param array $args
* @return string
*/
public function __call($name, $args)
{
$name = substr($name, 0, -7);
if (!$this->_acl->check('settings_update')) {
throw new Module_NoPermission();
} else {
if (!in_array($name, $this->categories)) {
throw new Module_ControllerNoExist();
} else {
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
return zula_redirect($this->_router->makeUrl('settings', $name));
}
}
}
$this->setTitle(t('Update settings'));
// Update all of the provided settings, or insert if they don't exist
foreach ($this->_input->post('setting') as $key => $val) {
if (strpos($key, 'cache') !== 0) {
if (substr($key, 8, 9) == 'mail/smtp' && !$this->_acl->check('settings_access_smtp')) {
continue;
}
try {
$this->_config_sql->update($key, $val);
} catch (Config_KeyNoExist $e) {
$this->_sql->insert('config', array('name' => $key, 'value' => $val));
}
}
}
/**
* Category specific things to do when updating
* the settings or other things (ACL forms etc).
*/
switch ($name) {
case 'general':
$this->_cache->delete('view_default_tags');
break;
case 'cache':
try {
$this->_config_ini->update('cache/type', $this->_input->post('setting/cache\\/type'));
$this->_config_ini->update('cache/ttl', $this->_input->post('setting/cache\\/ttl'));
$this->_config_ini->update('cache/js_aggregate', $this->_input->post('setting/cache\\/js_aggregate'));
$this->_config_ini->update('cache/google_cdn', $this->_input->post('setting/cache\\/google_cdn'));
$this->_config_ini->writeIni();
// Clear cache if needbe
if ($this->_input->post('cache_purge')) {
$this->_cache->purge();
}
} catch (Exception $e) {
$this->_event->error($e->getMessage());
$this->_log->message($e->getMessage(), Log::L_WARNING);
}
break;
case 'locale':
try {
$this->_config_ini->update('locale/default', $this->_input->post('setting/locale\\/default'));
$this->_config_ini->writeIni();
} catch (Exception $e) {
$this->_event->error($e->getMessage());
$this->_log->message($e->getMessage(), Log::L_WARNING);
}
if (($pkg = $this->_input->post('lang_pkg')) !== 'none') {
// Download and install a new locale
if (!zula_supports('zipExtraction')) {
$this->_event->error(t('Cannot install locale, server does not support zip extraction'));
} else {
if (!preg_match('#^[a-z]{2}_[A-Z]{2}$#', $pkg)) {
$this->_event->error(t('Provided locale is invalid, unable to install'));
} else {
if (!zula_is_writable($this->_zula->getDir('locale'))) {
$this->_event->error(t('Locale directory is not writable, unable to install'));
} else {
$version = str_replace('-', '/', zula_version_map(_PROJECT_VERSION));
$zipDest = $this->_zula->getDir('tmp') . '/i18n-' . $pkg . '.zip';
$copyResult = @copy('http://releases.tangocms.org/' . $version . '/i18n/' . $pkg . '.zip', $zipDest);
if ($copyResult) {
// Extract the archive to the locale dir
$zip = new ZipArchive();
if ($zip->open($zipDest)) {
$zip->extractTo($this->_zula->getDir('locale'));
$zip->close();
$this->_event->success(t('Locale successfully installed'));
} else {
$this->_event->error(t('Could not install locale, zip extraction failed'));
}
unlink($zipDest);
} else {
$this->_event->error(t('Failed to get remote language archive'));
}
}
}
}
}
//.........这里部分代码省略.........
示例7: bridgeSection
/**
* Bridges between deleting a page, or update the order. This is only called
* when deleting or ordering children, not for deleting single pages.
*
* @return mixed
*/
public function bridgeSection()
{
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
if ($this->_input->has('post', 'page_delete')) {
$this->setTitle(t('Delete Page'));
try {
foreach ($this->_input->post('page_ids') as $pid) {
if ($this->_acl->check('page-manage_' . $pid)) {
try {
$this->_model()->delete($pid);
} catch (Page_NoExist $e) {
}
}
}
$this->_event->success(t('Deleted selected pages'));
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No pages selected'));
}
} else {
if ($this->_input->has('post', 'page_update_order')) {
$this->setTitle(t('Update Page Order'));
$execData = array();
$sqlMiddle = null;
foreach ($this->_input->post('page_order') as $pid => $order) {
$pid = abs($pid);
if ($this->_acl->check('page-manage_' . $pid)) {
$execData[] = $pid;
$execData[] = abs($order);
$sqlMiddle .= 'WHEN id = ? THEN ? ';
}
}
if ($sqlMiddle !== null) {
$pdoSt = $this->_sql->prepare('UPDATE {PREFIX}mod_page SET `order` = CASE ' . $sqlMiddle . 'ELSE `order` END');
$pdoSt->execute($execData);
}
$this->_event->success(t('Page order updated'));
}
}
}
try {
$parent = $this->_input->post('page_parent');
$url = $this->_router->makeUrl('page', 'config', 'edit', null, array('id' => $parent));
} catch (Input_KeyNoExist $e) {
$url = $this->_router->makeUrl('page', 'config');
}
return zula_redirect($url);
}
示例8: bridgeSection
/**
* Creates a bridge between the Detaching Selected and Update Order
* functionaility, as there can only be one form with one action
*
* @return mixed
*/
public function bridgeSection()
{
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_acl->check('content_layout_config_module')) {
throw new Module_NoPermission();
}
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
if ($this->_input->has('post', 'content_layout_detach')) {
$this->detachCntrlr();
} else {
if ($this->_input->has('post', 'content_layout_order')) {
$this->updateOrder();
}
}
}
try {
return zula_redirect($this->_router->makeUrl('content_layout', 'manage', $this->_input->post('content_layout_name')));
} catch (Input_KeyNoExist $e) {
return zula_redirect($this->_router->makeUrl('content_layout'));
}
}
示例9: updateSection
/**
* Updates the ACL Rules for the provided ACL Resources and Roles
* from a specified module
*
* @return bool
*/
public function updateSection()
{
$this->setTitle(t('Update module permissions'));
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_acl->check('module_manager_edit_permissions')) {
throw new Module_NoPermission();
} else {
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
/**
* Attempt to get details for the module provided, and then also
* check if the user has global permission to the module he/she
* is updating permission rules for
*/
try {
$name = $this->_input->post('module');
$module = new Module($name);
$moduleDetails = $module->getDetails();
// Check if user has global permission
if (!$this->_acl->check($module->name . '_global')) {
$this->_event->error(sprintf(t('Sorry, you do not have global permission to module "%1$s"'), $module->name));
return zula_redirect($this->_router->makeUrl('module_manager'));
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No module provided, could not get permissions'));
return zula_redirect($this->_router->makeUrl('module_manager'));
} catch (Module_NoExist $e) {
$this->_event->error(sprintf(t('Module "%1$s" does not exist, could not get details'), $name));
return zula_redirect($this->_router->makeUrl('module_manager'));
}
// Gather all of the ACL Resources for this module, check we have all from the POST data
foreach ($this->_acl->getAllResources($module->name) as $resource) {
try {
$roles = $this->_input->post('acl_resources/' . $resource['name']);
$this->_acl->allowOnly($resource['name'], $roles);
} catch (Input_KeyNoExist $e) {
$roles = array('group_root' => 1);
} catch (Acl_InvalidName $e) {
$this->_event->error(sprintf(t('Invalid resource name of "%1$s". Could not update ACL rules'), $resource['name']));
}
}
$this->_event->success(sprintf(t('Updated permissions for module "%1$s"'), $module->title));
}
}
return zula_redirect($this->_router->makeUrl('module_manager'));
}
示例10: deleteSection
/**
* Deletes a media item from a category if it exists
*
* @return string
*/
public function deleteSection()
{
$this->setTitle(t('Delete media item'));
// Attempt to remove the single media item
try {
$itemId = $this->_router->getArgument('id');
$item = $this->_model()->getItem($itemId);
// Check permission to parent category resource
$resource = 'media-cat_moderate_' . $item['cat_id'];
if ($this->_acl->resourceExists($resource) && $this->_acl->check($resource)) {
if ($this->_input->checkToken('get')) {
$this->_model()->deleteItem($item['id']);
zula_full_rmdir($item['path_fs'] . '/' . dirname($item['filename']));
$this->_event->success(t('Deleted media item'));
// Redirect back to the parent media category
try {
$category = $this->_model()->getCategory($item['cat_id']);
return zula_redirect($this->_router->makeUrl('media', 'cat', $category['identifier']));
} catch (Media_CatNoExist $e) {
}
} else {
$this->_event->error(Input::csrfMsg());
}
} else {
throw new Module_NoPermission();
}
} catch (Router_ArgNoExist $e) {
$this->_event->error(t('No media item selected'));
} catch (Media_ItemNoExist $e) {
$this->_event->error(t('Media item does not exist'));
}
return zula_redirect($this->_router->makeUrl('media'));
}
示例11: deleteSection
/**
* Deletes multiple content layouts
*
* @return bool
*/
public function deleteSection()
{
$this->setTitle(t('Delete layouts'));
$this->setOutputType(self::_OT_CONFIG);
if ($this->_input->checkToken()) {
try {
$delCount = 0;
foreach ($this->_input->post('layout_names') as $layoutName) {
$layout = new Layout($layoutName);
if ($layout->delete()) {
$delCount++;
} else {
$this->_event->error(sprintf(t('Unable to delete layout "%1$s"'), $layoutName));
}
}
if ($delCount > 0) {
$this->_event->success(t('Deleted selected layouts'));
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No layouts selected'));
}
} else {
$this->_event->error(Input::csrfMsg());
}
return zula_redirect($this->_router->makeUrl('content_layout'));
}
示例12: bridgeSection
/**
* Creates a bridge between the Delete Selected and Update Order
* functionaility, as there can only be one form with one action
*
* @return mixed
*/
public function bridgeSection()
{
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_input->checkToken()) {
$this->_event->error(Input::csrfMsg());
} else {
if ($this->_input->has('post', 'contact_del_selected')) {
// Remove all selected form fields
if (!$this->_acl->check('contact_delete')) {
throw new Module_NoPermission();
}
try {
$delCount = 0;
foreach ($this->_input->post('contact_field_ids') as $fieldId) {
try {
// Check permission to parent form
$field = $this->_model()->getField($fieldId);
$resource = 'contact-form-' . $field['form_id'];
if ($this->_acl->resourceExists($resource) && $this->_acl->check($resource)) {
$this->_model()->deleteField($field['id']);
++$delCount;
}
} catch (Contact_FieldNoExist $e) {
}
}
if ($delCount) {
$this->_event->success(t('Deleted selected form fields'));
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No fields selected'));
}
} else {
if ($this->_input->has('post', 'contact_update_order')) {
// Update the order of the contact form fields
if (!$this->_acl->check('contact_edit')) {
throw new Module_NoPermission();
}
$sqlQuery = 'UPDATE {PREFIX}mod_contact_fields SET `order` = CASE';
$sqlMiddle = array();
$params = array('');
# Force key 0 since that wont be used with PDO
try {
foreach ($this->_input->post('contact_order') as $fieldId => $order) {
/**
* Check user actually has permission to the contact form
* and that the field exists
*/
try {
$field = $this->_model()->getField($fieldId);
$resource = 'contact-form-' . $field['form_id'];
if ($this->_acl->resourceExists($resource) && $this->_acl->check($resource)) {
// Set the paramaters that will be bound to the query
$params[] = $field['id'];
$params[] = $order;
$sqlMiddle[] = ' WHEN id = ? THEN ? ';
}
} catch (Contact_FieldNoExist $e) {
}
}
if (!empty($sqlMiddle)) {
$query = $sqlQuery . implode('', $sqlMiddle) . 'ELSE `order` END';
$pdoSt = $this->_sql->prepare($query);
foreach ($params as $ident => $val) {
if ($ident !== 0) {
$pdoSt->bindValue($ident, (int) $val, PDO::PARAM_INT);
}
}
$pdoSt->execute();
$this->_event->success(t('Updated field orders'));
}
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No fields to update order for'));
}
}
}
}
try {
$formId = $this->_router->getArgument('fid');
$url = $this->_router->makeUrl('contact', 'config', 'edit', null, array('id' => $formId));
$this->_cache->delete('contact_fields_' . $formId);
} catch (Router_ArgNoExist $e) {
$url = $this->_router->makeUrl('contact', 'config');
}
return zula_redirect($url);
}
示例13: deleteSection
/**
* Deletes an alias by ID if it exists
*
* @return string
*/
public function deleteSection()
{
if (!$this->_acl->check('aliases_delete')) {
throw new Module_NoPermission();
} else {
if ($this->_input->checkToken()) {
$this->setOutputType(self::_OT_CONFIG);
try {
$aliasId = $this->_input->post('alias_ids');
$this->_model()->delete($aliasId);
$this->_event->success(t('Deleted selected aliases'));
} catch (Input_KeyNoExist $e) {
$this->_event->error(t('No URL aliases selected'));
}
} else {
$this->_event->error(Input::csrfMsg());
}
}
return zula_redirect($this->_router->makeUrl('aliases'));
}
示例14: isValid
/**
* Runs all of the validation checks on the elements using the
* validatiors that are stored
*
* @return bool
*/
public function isValid()
{
if ($this->csrfToken === true && !$this->_input->checkToken()) {
// CSRF protection failed!
if ($this->storeErrors === true) {
$this->_event->error(Input::csrfMsg());
}
return false;
}
foreach ($this->elements as $element) {
try {
$value = $this->_input->get($element['input_name'], $element['source']);
} catch (Input_KeyNoExist $e) {
if ($element['required'] === true) {
throw $e;
} else {
continue;
}
}
// Store the input names value correclty as a multi-dimensional array
$tmpVal = $value;
foreach (array_reverse(preg_split('#(?<!\\\\)/#', trim($element['input_name'], '/'))) as $v) {
$tmpVal = array($v => $tmpVal);
}
$this->values = zula_merge_recursive($this->values, $tmpVal);
$count = is_array($value) ? count($value) : strlen($value);
if ($element['required'] === false && $count == 0) {
continue;
}
// Check if it is valid
$validator = new Validator($value, $element['title']);
foreach (array_filter($element['validators']) as $tmpValidator) {
$validator->add($tmpValidator);
}
if ($validator->validate() === false) {
$this->valid = false;
if ($this->storeErrors === true) {
// Store all errors (if any)
foreach ($validator->getErrors() as $error) {
$this->_event->error($error);
}
}
}
}
// Check if the antispam was successful, if enabled
if ($this->valid && $this->antispam === true) {
$antispam = new Antispam();
if (!$antispam->check()) {
$this->valid = false;
if ($this->storeErrors === true) {
$this->_event->error(t('Sorry, incorrect answer to the captcha', I18n::_DTD));
}
}
}
return $this->valid;
}
示例15: settingsSection
/**
* Allows the user to change various settings for the article module.
*
* @return string|bool
*/
public function settingsSection()
{
$this->setTitle(t('Article settings'));
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_acl->check('article_manage_settings')) {
throw new Module_NoPermission();
}
// Check for needed post data
if ($this->_input->has('post', 'article')) {
if ($this->_input->checkToken()) {
foreach ($this->_input->post('article') as $key => $val) {
try {
$this->_config_sql->update('article/' . $key, $val);
} catch (Config_KeyNoExist $e) {
$this->_event->error($e->getMessage());
}
}
$this->_event->success(t('Updated article settings'));
} else {
$this->_event->error(Input::csrfMsg());
}
return zula_redirect($this->_router->getParsedUrl());
}
$view = $this->loadView('config/settings.html');
$view->assign(array('per_page' => $this->_config->get('article/per_page'), 'jump_box_position' => $this->_config->get('article/jump_box_position'), 'show_cat_desc' => $this->_config->get('article/show_cat_desc'), 'meta_format' => $this->_config->get('article/meta_format'), 'max_display_age' => $this->_config->get('article/max_display_age')));
$view->assignHtml(array('csrf' => $this->_input->createToken(true)));
return $view->getOutput();
}