<?php
// $Id: xoopssecurity.php,v 1.1.2.7 2005/05/17 06:10:16 onokazu Exp $

if (!defined('XOOPS_TOKEN_XOOPSORG')) {
    define('XOOPS_TOKEN_XOOPSORG', 'XOOPS_TOKEN_XOOPSORG');
}

/**
 * Class for xoops.org 2.0.10 compatibility
 *
 * @deprecated
 */
class XoopsSecurity
{

    function check($clearIfValid = true, $tokenValue = false) {
        return $this->validateToken($tokenValue, $clearIfValid);
    }

    function createToken($timeout = XOOPS_TOKEN_TIMEOUT)
    {
        $token =& XoopsMultiTokenHandler::quickCreate(XOOPS_TOKEN_XOOPSORG, $timeout);
        return $token->getTokenValue();
    }

    function validateToken($tokenValue = false, $clearIfValid = true)
    {
        if (false !== $tokenValue) {
            $handler = new XoopsSingleTokenHandler();
            $token =& $handler->fetch(XOOPS_TOKEN_XOOPSORG);
            if($token->validate($tokenValue)) {
                if ($clearIfValid) {
                    $handler->unregister($token);
                }
                return true;
            } else {
                return false;
            }
        }
        return XoopsMultiTokenHandler::quickValidate(XOOPS_TOKEN_XOOPSORG, $clearIfValid);
    }

    function getTokenHTML() {
        $token =& XoopsMultiTokenHandler::quickCreate(XOOPS_TOKEN_XOOPSORG);
        return $token->getHtml();
    }
}
?>