ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
Session Class Reference

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

+ Collaboration diagram for Session:

Public Member Functions

 Session ($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...
 
 hidden ()
 Fallback via HIDDEN FIELD - 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.

Member Function Documentation

◆ hidden()

Session::hidden ( )

Fallback via HIDDEN FIELD - wenn Cookies ausgeschaltet sind.

Ohne Cookies erfolgt Fallback via HTML-Hidden-Field (für Formulare)

Parameters
void
Returns
string HTML-Hidden-Input-Tag mit der Session-ID

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

222 {
223 if ($this->usesCookies || $this->transSID) return "";
224 return "<INPUT type=\"hidden\"
225 name=\"".session_name()."\"
226 value=\"".session_id()."\">";
227 }

◆ 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 136 of file class.Session.php.

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

References exit.

Referenced by Session().

+ 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 168 of file class.Session.php.

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

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 114 of file class.Session.php.

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

Referenced by Session().

+ Here is the caller graph for this function:

◆ Session()

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

References $_COOKIE, $_GET, $_POST, $query, redirectTo(), and sendNoCacheHeader().

+ Here is the call 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 180 of file class.Session.php.

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