Subversion Repositories ALCASAR

Rev

Rev 1729 | Rev 1820 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 1729 Rev 1818
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: index.php 1729 2015-12-22 08:34:53Z richard $
2
# $Id: index.php 1818 2016-04-07 13:38:05Z 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 52... Line 52...
52
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "";
52
$remote_ip = preg_match('#^([0-9]{1,3}\.){3}[0-9]{1,3}$#', $_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : "";
53
$tab = array();$user = array();
53
$tab = array();$user = array();
54
$connection_history =  "";
54
$connection_history =  "";
55
$nb_connection_history = 3;
55
$nb_connection_history = 3;
56
 
56
 
-
 
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);
-
 
59
$user = explode (" ", $tab[0]);
-
 
60
	
57
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
61
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
58
if (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$organisme$/", $_SERVER['HTTP_HOST']))
62
if (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname$/", $_SERVER['HTTP_HOST']) || preg_match ("/^$organisme$/", $_SERVER['HTTP_HOST']))
59
	{
63
	{
60
	$direct_access=True;
64
	$direct_access=True;
61
	exec ("sudo /usr/sbin/chilli_query list|grep $remote_ip" , $tab);
-
 
62
	$user = explode (" ", $tab[0]);
-
 
-
 
65
 
63
	}
66
	}
64
#### Affichage des 3 dernières connexions de $user[5]
67
#### Affichage des 3 dernières connexions de $user[5]
65
function secondsToDuration($seconds = null){
68
function secondsToDuration($seconds = null){
66
	if ($seconds == null) return "";
69
	if ($seconds == null) return "";
67
 
70
 
Line 96... Line 99...
96
				$connection_history.="</ul>";
99
				$connection_history.="</ul>";
97
			}
100
			}
98
		}
101
		}
99
	}
102
	}
100
}
103
}
-
 
104
else
-
 
105
{
-
 
106
	# cas où l'utilisateur non-loggué décide de joindre une page HTTP ou HTTPS ou alcasar (on va l'intercepter en le redirigeant sur index.php afin qu'il puisse se logguer)
-
 
107
	# on place l'utilisateur dans un ipset user_not_connected pour ne pas boucler
-
 
108
	# si il ne joint pas ALCASAR, on le redirige vers celui ci
-
 
109
	exec("sudo /usr/sbin/ipset add user_not_connected_yet $remote_ip");
-
 
110
	if(!$direct_access)
-
 
111
	{
-
 
112
		header("Location: http://alcasar");
-
 
113
		exit;
-
 
114
	}
-
 
115
 
-
 
116
}
-
 
117
 
101
####
118
####
102
 
119
 
103
# Choice of language
120
# Choice of language
104
$Language = 'en';
121
$Language = 'en';
105
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
122
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){