source: temp/trunk/data/class/SC_Session.php @ 1656

Revision 1656, 2.3 KB checked in by kakinaka, 20 years ago (diff)

blank

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2/* ¥»¥Ã¥·¥ç¥ó´ÉÍý¥¯¥é¥¹ */
3class SC_Session {
4    var $login_id;      // ¥í¥°¥¤¥ó¥æ¡¼¥¶Ì¾
5    var $authority;     // ¥æ¡¼¥¶¸¢¸Â
6    var $cert;          // ǧ¾Úʸ»úÎó(ǧ¾ÚÀ®¸ù¤ÎȽÄê¤Ë»ÈÍÑ)
7    var $sid;           // ¥»¥Ã¥·¥ç¥óID
8    var $member_id;     // ¥í¥°¥¤¥ó¥æ¡¼¥¶¤Î¼ç¥­¡¼
9   
10    /* ¥³¥ó¥¹¥È¥é¥¯¥¿ */
11    function SC_Session() {
12        // ¥»¥Ã¥·¥ç¥ó³«»Ï
13        //sfDomainSessionStart();
14        // ¥»¥Ã¥·¥ç¥ó¾ðÊó¤ÎÊݸ
15        if(isset($_SESSION['cert'])) {
16            $this->sid = session_id();
17            $this->cert = $_SESSION['cert'];
18            $this->login_id = $_SESSION['login_id'];
19            $this->authority = $_SESSION['authority'];  // ´ÉÍý¼Ô:0, °ìÈÌ:1, ±ÜÍ÷:2
20            $this->member_id = $_SESSION['member_id'];
21            // ¥í¥°¤Ëµ­Ï¿¤¹¤ë
22            gfPrintLog("access : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
23        } else {
24            // ¥í¥°¤Ëµ­Ï¿¤¹¤ë
25            gfPrintLog("access error.");
26        }
27    }
28   
29    /* ǧ¾ÚÀ®¸ù¤ÎȽÄê */
30    function IsSuccess() {
31        global $arrPERMISSION;
32            /* 
33        if($this->cert == CERT_STRING) {
34            if(isset($arrPERMISSION[$_SERVER['PHP_SELF']])) {
35                // ¿ôÃͤ¬¼«Ê¬¤Î¸¢¸Â°Ê¾å¤Î¤â¤Î¤Ç¤Ê¤¤¤È¥¢¥¯¥»¥¹¤Ç¤­¤Ê¤¤¡£
36                if($arrPERMISSION[$_SERVER['PHP_SELF']] < $this->authority) {           
37                    return AUTH_ERROR;
38                }
39            }
40            return SUCCESS;
41        }
42       
43        return ACCESS_ERROR;
44        */
45        return SUCCESS;
46    }
47   
48    /* ¥»¥Ã¥·¥ç¥ó¤Î½ñ¤­¹þ¤ß */
49    function SetSession($key, $val) {
50        $_SESSION[$key] = $val;
51    }
52   
53    /* ¥»¥Ã¥·¥ç¥ó¤ÎÆÉ¤ß¹þ¤ß */
54    function GetSession($key) {
55        return $_SESSION[$key];
56    }
57   
58    /* ¥»¥Ã¥·¥ç¥óID¤Î¼èÆÀ */
59    function GetSID() {
60        return $this->sid;
61    }
62   
63    /* ¥»¥Ã¥·¥ç¥ó¤ÎÇË´þ */
64    function EndSession() {
65        // ¥Ç¥Õ¥©¥ë¥È¤Ï¡¢¡ÖPHPSESSID¡×
66        $sname = session_name();
67        // ¥»¥Ã¥·¥ç¥óÊÑ¿ô¤òÁ´¤Æ²ò½ü¤¹¤ë
68        $_SESSION = array();
69        // ¥»¥Ã¥·¥ç¥ó¤òÀÚÃǤ¹¤ë¤Ë¤Ï¥»¥Ã¥·¥ç¥ó¥¯¥Ã¥­¡¼¤âºï½ü¤¹¤ë¡£
70        // Note: ¥»¥Ã¥·¥ç¥ó¾ðÊó¤À¤±¤Ç¤Ê¤¯¥»¥Ã¥·¥ç¥ó¤òÇ˲õ¤¹¤ë¡£
71        if (isset($_COOKIE[$sname])) {
72            setcookie($sname, '', time()-42000, '/');
73        }
74        // ºÇ½ªÅª¤Ë¡¢¥»¥Ã¥·¥ç¥ó¤òÇ˲õ¤¹¤ë
75        session_destroy();
76        // ¥í¥°¤Ëµ­Ï¿¤¹¤ë
77        gfPrintLog("logout : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
78    }
79   
80    // ´ØÏ¢¥»¥Ã¥·¥ç¥ó¤Î¤ßÇË´þ¤¹¤ë¡£
81    function logout() {
82        unset($_SESSION['cert']);
83        unset($_SESSION['login_id']);
84        unset($_SESSION['authority']);
85        unset($_SESSION['member_id']);
86        // ¥í¥°¤Ëµ­Ï¿¤¹¤ë
87        gfPrintLog("logout : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
88    }
89}
90?>
Note: See TracBrowser for help on using the repository browser.