|
|
|
xoops token auto change
2
auto create and check token with different xoops versio
// CreateToken
function create_token($token_name='XOOPS')
{
if( substr( XOOPS_VERSION , 6 , 3 ) > 2.0 ) {
// XOOPS 2.1/2.2
$token = $GLOBALS['xoopsSecurity']->getTokenHTML();
} else {
// XOOPS 2.0.x
$token_handler = new XoopsMultiTokenHandler();
$ticket = &$token_handler->create($token_name);
$token = $ticket->getHtml();
}
return $token;
}
// Token {
function token_check($token_name='XOOPS')
{
$token = false;
if( substr( XOOPS_VERSION , 6 , 3 ) > 2.0 ) {
// XOOPS 2.1/2.2
if ($GLOBALS['xoopsSecurity']->check(true, $_REQUEST['XOOPS_TOKEN_REQUEST'])) {
$token = true;
}
} else {
// XOOPS 2.0.x
$token_handler = new XoopsMultiTokenHandler();
if($token_handler->autoValidate($token_name)) {
$token = true;
}
}
return $token;
}




There are currently no comments for this snippet.