ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
Session Class Reference

"Manueller" Session-Fallback mit PHP4 More...

+ Collaboration diagram for Session:

Public Member Functions

 __construct ($sessionName="SESSID")
 Konstruktor - nimmt, wenn gewuenscht einen neuen Session-Namen entgegen. More...
 
 sendNoCacheHeader ()
 Cacheing unterbinden. More...
 
 redirectTo ($pathInfo)
 HTTP-Redirect ausführen (header("Location: ...") More...
 
 removeTrail ($pathInfo)
 Entfernt mögliche abschließende "&" und "?". More...
 
 url ($pathInfo)
 Fallback via GET - wenn Cookies ausgeschaltet sind. More...
 

Data Fields

 $version = 106
 
 $usesCookies = false
 
 $transSID = false
 

Detailed Description

"Manueller" Session-Fallback mit PHP4

Author
Daniel T. Gorski danie.nosp@m.l.go.nosp@m.rski@.nosp@m.blue.nosp@m.mars..nosp@m.de

Definition at line 33 of file class.Session.php.

Constructor & Destructor Documentation

◆ __construct()

Session::__construct (   $sessionName = "SESSID")

Konstruktor - nimmt, wenn gewuenscht einen neuen Session-Namen entgegen.

Definition at line 45 of file class.Session.php.

45 {
46 $this->sendNoCacheHeader();
47
48 ini_set("session.cookie_httponly", 1);
49 if(version_compare(PHP_VERSION, '7.1.0', '>=')) {
50 ini_set("session.sid_length", "32");
51 } else {
52 // force 4 hash bits per character for session_id // Sascha Hofmann (2005-10-19)
53 ini_set("session.hash_bits_per_character", "4");
54 }
55
56 // Session-Namen setzen, Session initialisieren
57 session_name(isset($sessionName)
58 ? $sessionName
59 : session_name());
60
61 @session_start();
62
63 // Prüen ob die Session-ID die Standardlänge
64 // von 32 Zeichen hat,
65 // ansonsten Session-ID neu setzen
66 if (strlen(session_id()) < 32)
67 {
68 mt_srand ((double)microtime()*1000000);
69 session_id(md5(uniqid(mt_rand())));
70 }
71
72 // Prüfen, ob eine Session-ID übergeben wurde
73 // (über Cookie, POST oder GET)
74 $IDpassed = false;
75 if ( isset($_COOKIE[session_name()]) &&
76 @strlen($_COOKIE[session_name()]) >= 32
77 ) $IDpassed = true;
78
79 if (!$IDpassed)
80 {
81 // Es wurde keine (gültige) Session-ID übergeben.
82 // Script-Parameter der URL zufügen
83
84 $query = @$_SERVER["QUERY_STRING"] != "" ? "?".$_SERVER["QUERY_STRING"] : "";
85
86 header("Status: 302 Found");
87
88 // Script terminiert
89 $this->redirectTo($_SERVER["PHP_SELF"].$query);
90 }
91
92 // Wenn die Session-ID übergeben wurde, muss sie
93 // nicht unbedingt gültig sein!
94
95 // Für weiteren Gebrauch merken
96 $this->usesCookies =
97 (isset($_COOKIE[session_name()]) &&
98 @strlen($_COOKIE[session_name()])
99 >= 32);
100 }
$_COOKIE['ilClientId']
Definition: BPMN2Parser.php:15
redirectTo($pathInfo)
HTTP-Redirect ausführen (header("Location: ...")
sendNoCacheHeader()
Cacheing unterbinden.
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']

References $_COOKIE, $_SERVER, $query, redirectTo(), and sendNoCacheHeader().

+ Here is the call graph for this function:

Member Function Documentation

◆ redirectTo()

Session::redirectTo (   $pathInfo)

HTTP-Redirect ausführen (header("Location: ...")

Diese Methode berücksichtigt auch nicht-standard Ports und SSL. Ein GET-Parameter beim wird bei Bedarf (Session-ID-Fallback) an die URI drangehängt. Nach dem Aufruf dieser Methode wird das aktive Script beendet und die Kontrolle wird an das Ziel-Script übergeben.

Parameters
stringZiel-Datei (z.B. "index.php")
Returns
void

Definition at line 133 of file class.Session.php.

133 {
134
135 // Relativer Pfad?
136 if ($pathInfo[0] != "/")
137 { $pathInfo = substr(getenv("PATH_INFO"),
138 0,
139 strrpos(getenv("PATH_INFO"),"/")+1
140 )
141 .$pathInfo;
142 }
143
144 // Läuft dieses Script auf einem non-standard Port?
145 $port = !preg_match( "/^(80|443)$/",
146 getenv("SERVER_PORT"),
147 $portMatch)
148 ? ":".getenv("SERVER_PORT")
149 : "";
150
151 // Redirect
152 header("Location: "
153 .(($portMatch[1] == 443) ? "https://" : "http://")
154 .$_SERVER["HTTP_HOST"].$port.$this->url($pathInfo));
155 exit;
156 }

References $_SERVER, and exit.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ removeTrail()

Session::removeTrail (   $pathInfo)

Entfernt mögliche abschließende "&" und "?".

Parameters
stringString
Returns
string String ohne abschließende "&" und "?"

Definition at line 165 of file class.Session.php.

165 {
166 $dummy = preg_match("/(.*)(?<!&|\?)/",$pathInfo,$match);
167 return $match[0];
168 }

Referenced by url().

+ Here is the caller graph for this function:

◆ sendNoCacheHeader()

Session::sendNoCacheHeader ( )

Cacheing unterbinden.

Ergänze/Override "session.cache_limiter = nocache"

Parameters
void
Returns
void

Definition at line 111 of file class.Session.php.

111 {
112 header("Expires: Sat, 05 Aug 2000 22:27:00 GMT");
113 header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
114 header("Cache-Control: no-cache, must-revalidate");
115 header("Pragma: no-cache");
116 header("Cache-Control: post-check=0, pre-check=0");
117 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ url()

Session::url (   $pathInfo)

Fallback via GET - wenn Cookies ausgeschaltet sind.

Parameters
stringZiel-Datei
Returns
string Ziel-Datei mit - bei Bedarf - angehängter Session-ID

Definition at line 177 of file class.Session.php.

177 {
178 if ($this->usesCookies || $this->transSID) return $pathInfo;
179
180 // Anchor-Fragment extrahieren
181 $dummyArray = explode("#", $pathInfo);
182 $pathInfo = $dummyArray[0];
183
184 // evtl. (kaputte) Session-ID(s) aus dem Querystring entfernen
185 $pathInfo = preg_replace( "/[?|&]".session_name()."=[^&]*/",
186 "",
187 $pathInfo);
188
189 // evtl. Query-Delimiter korrigieren
190 if (preg_match("/&/",$pathInfo) && !preg_match("/\?/",$pathInfo))
191 {
192 // 4ter Parameter für "preg_replace()" erst ab 4.0.1pl2
193 $pathInfo = preg_replace("/&/","?",$pathInfo,1);
194 }
195
196 // Restmüll entsorgen
197 $pathInfo = $this->removeTrail($pathInfo);
198
199 // Session-Name und Session-ID frisch hinzufügen
200 $pathInfo .= preg_match("/\?/",$pathInfo) ? "&" : "?";
201
202 // Anchor-Fragment wieder anfügen
203 $pathInfo .= isset($dummyArray[1]) ? "#".$dummyArray[1] : "";
204
205 return $pathInfo;
206 }
removeTrail($pathInfo)
Entfernt mögliche abschließende "&" und "?".

References removeTrail().

+ Here is the call graph for this function:

Field Documentation

◆ $transSID

Session::$transSID = false

Definition at line 36 of file class.Session.php.

◆ $usesCookies

Session::$usesCookies = false

Definition at line 35 of file class.Session.php.

◆ $version

Session::$version = 106

Definition at line 34 of file class.Session.php.


The documentation for this class was generated from the following file: