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

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