Updated through tag hostap_2_5 from git://w1.fi/hostap.git
[mech_eap.git] / libeap / hs20 / server / www / redirect.php
1 <?php
2
3 require('config.php');
4
5 $db = new PDO($osu_db);
6 if (!$db) {
7    die($sqliteerror);
8 }
9
10 if (isset($_GET["id"]))
11         $id = preg_replace("/[^a-fA-F0-9]/", "", $_GET["id"]);
12 else
13         $id = 0;
14
15 $row = $db->query("SELECT rowid,* FROM sessions WHERE id='$id'")->fetch();
16 if ($row == false) {
17    die("Session not found");
18 }
19
20 $uri = $row['redirect_uri'];
21
22 header("Location: $uri", true, 302);
23
24 $user = $row['user'];
25 $realm = $row['realm'];
26
27 $db->exec("INSERT INTO eventlog(user,realm,sessionid,timestamp,notes) " .
28           "VALUES ('$user', '$realm', '$id', " .
29           "strftime('%Y-%m-%d %H:%M:%f','now'), " .
30           "'redirected after user input')");
31
32 ?>