safebox_class.php
824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
 * @copyright Copyright(c) 2011 http://www.Tinyhu.com
 * @file
 * @brief
 * @author Tinyhu
 * @date 2010-03-25
 * @version 0.6
 * @note
 */
class Safebox
{
    private static $box;
    private static $obj;
    private function __construct(){}
    private function __clone(){}
    public static function getInstance($type='session')
    {
        if(!self::$obj instanceof self)
        {
            $type = strtolower($type);
            if($type == 'session')
            {
                self::$box = new Session();
            }
            else
            {
                self::$box = new Cookie();
                self::$box->setSafeCode(Tiny::app()->getSafeCode());
            }
            self::$obj = new self();
        }
        return self::$box;
    }
}
?>