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

Revision 1817, 2.2 KB checked in by kakinaka, 20 years ago (diff)

* empty log message *

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