2018-04-30 10:58:34 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require('config.php');
|
|
|
|
|
2019-02-14 05:09:09 -05:00
|
|
|
function print_header()
|
|
|
|
{
|
|
|
|
echo "<html>\n";
|
|
|
|
echo "<head><title>HS 2.0 Terms and Conditions</title></head>\n";
|
|
|
|
echo "<body>\n";
|
|
|
|
}
|
|
|
|
|
2018-04-30 10:58:34 -04:00
|
|
|
$db = new PDO($osu_db);
|
|
|
|
if (!$db) {
|
|
|
|
die($sqliteerror);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($_GET["addr"])) {
|
|
|
|
die("Missing addr parameter");
|
|
|
|
}
|
|
|
|
$addr = $_GET["addr"];
|
|
|
|
|
|
|
|
$accept = isset($_GET["accept"]) && $_GET["accept"] == "yes";
|
|
|
|
|
|
|
|
$res = $db->prepare("SELECT identity FROM pending_tc WHERE mac_addr=?");
|
|
|
|
$res->execute(array($addr));
|
|
|
|
$row = $res->fetch();
|
|
|
|
if (!$row) {
|
|
|
|
die("No pending session for the specified MAC address");
|
|
|
|
}
|
|
|
|
$identity = $row[0];
|
|
|
|
|
|
|
|
if (!$accept) {
|
2019-02-14 05:09:09 -05:00
|
|
|
print_header();
|
|
|
|
|
2018-04-30 10:58:34 -04:00
|
|
|
echo "<p>Accept the following terms and conditions by clicking here: <a href=\"terms.php?addr=$addr&accept=yes\">Accept</a></p>\n<hr>\n";
|
|
|
|
readfile($t_c_file);
|
|
|
|
} else {
|
|
|
|
$res = $db->prepare("UPDATE users SET t_c_timestamp=? WHERE identity=?");
|
|
|
|
if (!$res->execute(array($t_c_timestamp, $identity))) {
|
2019-02-14 05:09:09 -05:00
|
|
|
die("Failed to update user account.");
|
2018-04-30 10:58:34 -04:00
|
|
|
}
|
2018-06-22 13:22:40 -04:00
|
|
|
|
2019-02-14 05:09:09 -05:00
|
|
|
$res = $db->prepare("DELETE FROM pending_tc WHERE mac_addr=?");
|
|
|
|
$res->execute(array($addr));
|
|
|
|
|
2018-06-22 13:22:40 -04:00
|
|
|
$fp = fsockopen($hostapd_ctrl);
|
|
|
|
if (!$fp) {
|
|
|
|
die("Could not connect to hostapd(AS)");
|
|
|
|
}
|
|
|
|
|
|
|
|
fwrite($fp, "DAC_REQUEST coa $addr t_c_clear");
|
|
|
|
fclose($fp);
|
|
|
|
|
|
|
|
$waiting = true;
|
|
|
|
$ack = false;
|
|
|
|
for ($i = 1; $i <= 10; $i++) {
|
|
|
|
$res = $db->prepare("SELECT waiting_coa_ack,coa_ack_received FROM current_sessions WHERE mac_addr=?");
|
|
|
|
$res->execute(array($addr));
|
|
|
|
$row = $res->fetch();
|
|
|
|
if (!$row) {
|
|
|
|
die("No current session for the specified MAC address");
|
|
|
|
}
|
2018-09-12 18:04:40 -04:00
|
|
|
if (strlen($row[0]) > 0)
|
|
|
|
$waiting = $row[0] == 1;
|
|
|
|
if (strlen($row[1]) > 0)
|
|
|
|
$ack = $row[1] == 1;
|
2018-06-22 13:22:40 -04:00
|
|
|
$res->closeCursor();
|
|
|
|
if (!$waiting)
|
|
|
|
break;
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
if ($ack) {
|
2019-02-14 05:09:09 -05:00
|
|
|
header('X-WFA-Hotspot20-Filtering: removed');
|
|
|
|
print_header();
|
|
|
|
echo "<p>Terms and conditions were accepted.</p>\n";
|
|
|
|
|
2018-06-22 13:22:40 -04:00
|
|
|
echo "<P>Filtering disabled.</P>\n";
|
|
|
|
} else {
|
2019-02-14 05:09:09 -05:00
|
|
|
print_header();
|
2018-06-22 13:22:40 -04:00
|
|
|
echo "<P>Failed to disable filtering.</P>\n";
|
|
|
|
}
|
2018-04-30 10:58:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|