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

Revision 1795, 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        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 SUCCESS;
43        //return ACCESS_ERROR;
44    }
45   
46    /* ¥»¥Ã¥·¥ç¥ó¤Î½ñ¤­¹þ¤ß */
47    function SetSession($key, $val) {
48        $_SESSION[$key] = $val;
49    }
50   
51    /* ¥»¥Ã¥·¥ç¥ó¤ÎÆÉ¤ß¹þ¤ß */
52    function GetSession($key) {
53        return $_SESSION[$key];
54    }
55   
56    /* ¥»¥Ã¥·¥ç¥óID¤Î¼èÆÀ */
57    function GetSID() {
58        return $this->sid;
59    }
60   
61    /* ¥»¥Ã¥·¥ç¥ó¤ÎÇË´þ */
62    function EndSession() {
63        // ¥Ç¥Õ¥©¥ë¥È¤Ï¡¢¡ÖPHPSESSID¡×
64        $sname = session_name();
65        // ¥»¥Ã¥·¥ç¥óÊÑ¿ô¤òÁ´¤Æ²ò½ü¤¹¤ë
66        $_SESSION = array();
67        // ¥»¥Ã¥·¥ç¥ó¤òÀÚÃǤ¹¤ë¤Ë¤Ï¥»¥Ã¥·¥ç¥ó¥¯¥Ã¥­¡¼¤âºï½ü¤¹¤ë¡£
68        // Note: ¥»¥Ã¥·¥ç¥ó¾ðÊó¤À¤±¤Ç¤Ê¤¯¥»¥Ã¥·¥ç¥ó¤òÇ˲õ¤¹¤ë¡£
69        if (isset($_COOKIE[$sname])) {
70            setcookie($sname, '', time()-42000, '/');
71        }
72        // ºÇ½ªÅª¤Ë¡¢¥»¥Ã¥·¥ç¥ó¤òÇ˲õ¤¹¤ë
73        session_destroy();
74        // ¥í¥°¤Ëµ­Ï¿¤¹¤ë
75        gfPrintLog("logout : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
76    }
77   
78    // ´ØÏ¢¥»¥Ã¥·¥ç¥ó¤Î¤ßÇË´þ¤¹¤ë¡£
79    function logout() {
80        unset($_SESSION['cert']);
81        unset($_SESSION['login_id']);
82        unset($_SESSION['authority']);
83        unset($_SESSION['member_id']);
84        // ¥í¥°¤Ëµ­Ï¿¤¹¤ë
85        gfPrintLog("logout : user=".$this->login_id." auth=".$this->authority." sid=".$this->sid);
86    }
87}
88?>
Note: See TracBrowser for help on using the repository browser.