PHP Classes

File: htdocs/class/smarty3_plugins/function.securityToken.php

Recommend this page to a friend!
  Packages of Michael Beck   Xoops 2.5   htdocs/class/smarty3_plugins/function.securityToken.php   Download  
File: htdocs/class/smarty3_plugins/function.securityToken.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Xoops 2.5
Modular content management publication system
Author: By
Last change:
Date: 3 months ago
Size: 1,053 bytes
 

Contents

Class file image Download
<?php
/**
 * XOOPS securityToken Smarty compiler plug-in
 *
 * @copyright (c) 2000-2025 XOOPS Project (https://xoops.org)
 * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
 * @author Richard Griffith <richard@geekwright.com>
 */

/**
 * Inserts a XOOPS security token
 *
 * Examples: <{securityToken}>
 * <{securityToken name="XOOPS_TOKEN"}>
 *
 * Create and render a XoopsFormHiddenToken element. If no 'name' argument is specified
 * the default value will be used.
 *
 * This is intended to replace token generations done in {php} tags which are removed
 * in Smarty 3 and beyond
 *
 * @param string[] $params optional 'name' parameter for token
 * @param Smarty $smarty
 *
 * @return void
 */
function smarty_function_securityToken($params, $smarty)
{
    if (!empty(
$params['name'])) {
       
$name = $params['name'];
       
$name = trim($name, "' \t\n\r\0");
        echo
$GLOBALS['xoopsSecurity']->getTokenHTML($name);
    } else {
        echo
$GLOBALS['xoopsSecurity']->getTokenHTML();
    }
}