| Line 1... |
Line 1... |
| 1 |
<?php
|
1 |
<?php
|
| 2 |
# $Id: index.php 1878 2016-05-09 13:09:13Z raphael.pion $
|
2 |
# $Id: index.php 1978 2016-07-06 09:41:58Z raphael.pion $
|
| 3 |
#
|
3 |
#
|
| 4 |
# index.php for ALCASAR captive portal
|
4 |
# index.php for ALCASAR captive portal
|
| 5 |
# by REXY
|
5 |
# by REXY
|
| 6 |
# UI & css style by stephane ERARD
|
6 |
# UI & css style by stephane ERARD
|
| 7 |
# The contents of this file may be used under the terms of the GNU
|
7 |
# The contents of this file may be used under the terms of the GNU
|
| Line 56... |
Line 56... |
| 56 |
|
56 |
|
| 57 |
# Obtenir l'état de connexion de l'utilisateur. 1 si connecté sinon 0.
|
57 |
# Obtenir l'état de connexion de l'utilisateur. 1 si connecté sinon 0.
|
| 58 |
exec ("sudo /usr/sbin/chilli_query list|grep $remote_ip" , $tab);
|
58 |
exec ("sudo /usr/sbin/chilli_query list|grep $remote_ip" , $tab);
|
| 59 |
$user = explode (" ", $tab[0]);
|
59 |
$user = explode (" ", $tab[0]);
|
| 60 |
|
60 |
|
| - |
|
61 |
#then we clean his cache to redirect him properly
|
| - |
|
62 |
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
|
| - |
|
63 |
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
| - |
|
64 |
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
|
| - |
|
65 |
header("Cache-Control: post-check=0, pre-check=0", false);
|
| - |
|
66 |
header("Pragma: no-cache");
|
| - |
|
67 |
|
| - |
|
68 |
|
| 61 |
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
|
69 |
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
|
| 62 |
if (isset($_SERVER['HTTP_HOST']) && (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$organisme$/", $_SERVER['HTTP_HOST'])))
|
70 |
if (isset($_SERVER['HTTP_HOST']) && (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$organisme$/", $_SERVER['HTTP_HOST'])))
|
| 63 |
{
|
71 |
{
|
| 64 |
$direct_access=True;
|
72 |
$direct_access=True;
|
| 65 |
}
|
73 |
}
|
| Line 101... |
Line 109... |
| 101 |
}
|
109 |
}
|
| 102 |
}
|
110 |
}
|
| 103 |
else
|
111 |
else
|
| 104 |
{
|
112 |
{
|
| 105 |
# cas où l'utilisateur non-loggué décide de joindre une page HTTP/S => redirection http://URL
|
113 |
# cas où l'utilisateur non-loggué décide de joindre une page HTTP/S => redirection http://URL
|
| - |
|
114 |
exec("sudo /usr/sbin/ipset list not_auth_yet | grep $remote_ip | wc -l 2>&1", $ipset_not_auth_yet);
|
| 106 |
# ALCASAR => redirection index.php
|
115 |
# ALCASAR => redirection index.php
|
| 107 |
# on place l'IP de l'utilisateur dans un ipset not_auth_yet pour ne pas boucler
|
116 |
# on place l'IP de l'utilisateur dans un ipset not_auth_yet pour ne pas boucler sur index.php et atteindre la page souhaité qui sera traité par coova-chilli
|
| 108 |
exec("sudo /usr/sbin/ipset add not_auth_yet $remote_ip");
|
117 |
if(!$direct_access && $ipset_not_auth_yet[0] == '0')
|
| 109 |
if(!$direct_access)
|
- |
|
| 110 |
{
|
118 |
{
|
| 111 |
header("Cache-Control: no-cache, must-revalidate");
|
- |
|
| 112 |
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
- |
|
| 113 |
header("Content-Type: application/xml; charset=utf-8");
|
119 |
exec("sudo /usr/sbin/ipset add not_auth_yet $remote_ip");
|
| 114 |
header("Location: http://".$_SERVER['HTTP_HOST']);
|
120 |
header("Location: http://$_SERVER[HTTP_HOST]");
|
| 115 |
exit;
|
121 |
exit;
|
| 116 |
}
|
122 |
}
|
| 117 |
|
123 |
|
| 118 |
}
|
124 |
}
|
| 119 |
####
|
125 |
####
|
| Line 279... |
Line 285... |
| 279 |
}
|
285 |
}
|
| 280 |
else {
|
286 |
else {
|
| 281 |
$img_internet = $img_connect;
|
287 |
$img_internet = $img_connect;
|
| 282 |
}
|
288 |
}
|
| 283 |
|
289 |
|
| 284 |
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
- |
|
| 285 |
?>
|
290 |
?>
|
| 286 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
291 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
| 287 |
<html>
|
292 |
<html>
|
| 288 |
<head>
|
293 |
<head>
|
| 289 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
294 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|