source: temp/test-xoops.ec-cube.net/html/class/xoopssecurity.php @ 405

Revision 405, 1.7 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: xoopssecurity.php,v 1.1.2.9 2005/06/01 12:47:46 onokazu Exp $
3
4/**
5 * Class for xoops.org 2.0.10 compatibility
6 *
7 * @deprecated
8 */
9class XoopsSecurity
10{
11    var $errors;
12
13    function check($clearIfValid = true, $tokenValue = false) {
14        return $this->validateToken($tokenValue, $clearIfValid);
15    }
16
17    function createToken($timeout = XOOPS_TOKEN_TIMEOUT)
18    {
19        $token =& XoopsMultiTokenHandler::quickCreate(XOOPS_TOKEN_DEFAULT, $timeout);
20        return $token->getTokenValue();
21    }
22
23    function validateToken($tokenValue = false, $clearIfValid = true)
24    {
25        if (false !== $tokenValue) {
26            $handler = new XoopsSingleTokenHandler();
27            $token =& $handler->fetch(XOOPS_TOKEN_DEFAULT);
28            if($token->validate($tokenValue)) {
29                if ($clearIfValid) {
30                    $handler->unregister($token);
31                }
32                return true;
33            } else {
34                $this->setErrors('No token found');
35                return false;
36            }
37        }
38        return XoopsMultiTokenHandler::quickValidate(XOOPS_TOKEN_DEFAULT, $clearIfValid);
39    }
40
41    function getTokenHTML() {
42        $token =& XoopsMultiTokenHandler::quickCreate(XOOPS_TOKEN_DEFAULT);
43        return $token->getHtml();
44    }
45
46    function setErrors($error)
47    {
48        $this->errors[] = trim($error);
49    }
50
51    function &getErrors($ashtml = false)
52    {
53        if (!$ashtml) {
54            return $this->errors;
55        } else {
56            $ret = '';
57            if (count($this->errors) > 0) {
58                foreach ($this->errors as $error) {
59                    $ret .= $error.'<br />';
60                }
61            }
62            return $ret;
63        }
64    }
65}
66?>
Note: See TracBrowser for help on using the repository browser.