| 1: | <?php | 
| 2: | /** | 
| 3: | * XOOPS securityToken Smarty compiler plug-in | 
| 4: | * | 
| 5: | * @copyright (c) 2016-2022 XOOPS Project (https://xoops.org) | 
| 6: | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) | 
| 7: | * @author Richard Griffith <richard@geekwright.com> | 
| 8: | */ | 
| 9: | |
| 10: | /** | 
| 11: | * Inserts a XOOPS security token | 
| 12: | * | 
| 13: | * Examples: <{securityToken}> | 
| 14: | * <{securityToken name="XOOPS_TOKEN"}> | 
| 15: | * | 
| 16: | * Create and render a XoopsFormHiddenToken element. If no 'name' argument is specified | 
| 17: | * the default value will be used. | 
| 18: | * | 
| 19: | * This is intended to replace token generations done in {php} tags which are removed | 
| 20: | * in Smarty 3 and beyond | 
| 21: | * | 
| 22: | * @param string[] $params optional 'name' parameter for token | 
| 23: | * @param Smarty $smarty | 
| 24: | * | 
| 25: | * @return void | 
| 26: | */ | 
| 27: | function smarty_function_securityToken($params, $smarty) | 
| 28: | { | 
| 29: | if (!empty($params['name'])) { | 
| 30: | $name = $params['name']; | 
| 31: | $name = trim($name, "' \t\n\r\0"); | 
| 32: | echo $GLOBALS['xoopsSecurity']->getTokenHTML($name); | 
| 33: | } else { | 
| 34: | echo $GLOBALS['xoopsSecurity']->getTokenHTML(); | 
| 35: | } | 
| 36: | } | 
| 37: |