452 |
richard |
1 |
<?php
|
498 |
richard |
2 |
$hostname = "alcasar";
|
783 |
richard |
3 |
$network_pb = True;
|
509 |
richard |
4 |
$cert_add = "http://alcasar/certs";
|
360 |
richard |
5 |
$direct_access = False;
|
363 |
richard |
6 |
$diagnostic = "eth0 link down";
|
|
|
7 |
$remote_ip = ($_SERVER['REMOTE_ADDR']);
|
|
|
8 |
$tab = array();$user = array();
|
566 |
stephane |
9 |
$connection_history = "";
|
|
|
10 |
$nb_connection_history = 3;
|
|
|
11 |
|
522 |
richard |
12 |
# on discrimine les accès directs sur Alcasar par rapport aux redirections (blacklist ou pannes rso)
|
783 |
richard |
13 |
if (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname/", $_SERVER['HTTP_HOST']))
|
522 |
richard |
14 |
{
|
|
|
15 |
$direct_access=True;
|
|
|
16 |
exec ("sudo /usr/sbin/chilli_query list|grep $remote_ip" , $tab);
|
|
|
17 |
$user = explode (" ", $tab[0]);
|
|
|
18 |
}
|
566 |
stephane |
19 |
#### Affichage des 3 dernières connexions de $user[5]
|
|
|
20 |
function secondsToDuration($seconds = null){
|
|
|
21 |
if ($seconds == null) return "";
|
509 |
richard |
22 |
|
566 |
stephane |
23 |
$temp = $seconds % 3600;
|
|
|
24 |
$time[0] = ( $seconds - $temp ) / 3600 ; // hours
|
732 |
richard |
25 |
$time[2] = $temp % 60 ; // seconds
|
566 |
stephane |
26 |
$time[1] = ( $temp - $time[2] ) / 60; // minutes
|
|
|
27 |
|
732 |
richard |
28 |
return $time[0]." h ".$time[1]." m ".$time[2]." s";
|
566 |
stephane |
29 |
}
|
509 |
richard |
30 |
|
566 |
stephane |
31 |
$l_connected = "connected"; // a traduire (choix de la langue ci-dessous mais nécessitant de $connection_history)
|
|
|
32 |
// si on a pas d'accès à la bdd, la page s'affiche quand même correctement
|
783 |
richard |
33 |
if ((isset ($user[4])) && ($user[4] != "0")){
|
566 |
stephane |
34 |
if ((is_file("./acc/manager/lib/sql/drivers/mysql/functions.php"))&&(is_file("/etc/freeradius-web/config.php"))){
|
|
|
35 |
include_once("/etc/freeradius-web/config.php");
|
|
|
36 |
include_once("./acc/manager/lib/sql/drivers/mysql/functions.php");
|
|
|
37 |
|
|
|
38 |
$sql = "SELECT UserName, AcctStartTime, AcctStopTime, acctsessiontime FROM radacct WHERE UserName='$user[5]' ORDER BY AcctStartTime DESC LIMIT 0 , $nb_connection_history";
|
|
|
39 |
$link = @da_sql_pconnect($config); // on affiche pas les erreurs
|
|
|
40 |
|
|
|
41 |
if ($link){
|
|
|
42 |
$res = @da_sql_query($link,$config,$sql); // on affiche pas les erreurs
|
|
|
43 |
|
|
|
44 |
if ($res){
|
|
|
45 |
$connection_history.= "<ul>";
|
|
|
46 |
while(($row = @da_sql_fetch_array($res,$config))){
|
|
|
47 |
$connected = "";
|
|
|
48 |
if ($row[acctstoptime] == "") $connected = " ($l_connected)";
|
|
|
49 |
$connection_history.="<li title='$row[username] $row[acctstarttime] $row[acctstoptime] (".secondsToDuration($row[acctsessiontime]).")'>$row[acctstarttime] (".secondsToDuration($row[acctsessiontime]).") $connected</li>";
|
|
|
50 |
}
|
|
|
51 |
$connection_history.="</ul>";
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
}
|
509 |
richard |
56 |
####
|
|
|
57 |
|
360 |
richard |
58 |
# Choice of language
|
|
|
59 |
$Language = 'en';
|
|
|
60 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
61 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
62 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
63 |
if($Language == 'fr'){
|
|
|
64 |
$l_access_denied = "ACCÈS REFUSÉ";
|
399 |
franck |
65 |
$l_access_welcome = "Bienvenue sur ALCASAR";
|
360 |
richard |
66 |
$l_access_unavailable = "ACCÈS INDISPONIBLE";
|
|
|
67 |
$l_required_domain = "Site WEB demandé";
|
536 |
franck |
68 |
$l_explain_acc_access = "Le centre de gestion permet d'administrer le portail. Vous devez posséder un compte d'administration ou de gestion pour y accéder.";
|
360 |
richard |
69 |
$l_explain_access_deny = "Vous tentez d'accéder à une ressource dont le contenu est réputé contenir des informations inappropriées.";
|
|
|
70 |
$l_explain_net_pb = "Votre portail détecte que l'accès à Internet est indisponible.";
|
|
|
71 |
$l_contact_access_deny = "Contactez le responsable de la sécurité (OSSI/RSSI) si vous pensez que ce filtrage est abusif.";
|
509 |
richard |
72 |
$l_contact_net_pb = "Contactez votre responsable informatique ou votre prestataire Internet pour plus d'information.";
|
399 |
franck |
73 |
$l_welcome = "Page principale de votre portail captif";
|
566 |
stephane |
74 |
$l_acc_access = "<a href=\"https://$hostname/acc\">Accès au centre de gestion</a>";
|
|
|
75 |
$l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installer le certificat racine</a>";
|
|
|
76 |
$l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Installation du certificat de l'autorité racine d'ALCASAR</a>";
|
536 |
franck |
77 |
$l_certif_explain = "Permet l'échange de données sécurisées entre votre station de consultation et le portail captif ALCASAR.<BR>Si ce certificat n'est pas enregistré sur votre station de consultation, il est possible que des alertes de sécurités soient émises par votre navigateur.<br><br>";
|
688 |
richard |
78 |
$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide complémentaire</a>";
|
369 |
richard |
79 |
if ($user[4] == "0") {
|
509 |
richard |
80 |
$l_logout_explain = "Aucune session de consultation Internet n'est actuellement ouverte sur votre système.";
|
566 |
stephane |
81 |
$l_logout = "<a href=\"http://www.google.fr\">Ouvrir une session Internet</a>";}
|
369 |
richard |
82 |
else {
|
566 |
stephane |
83 |
$l_logout_explain = "Ferme la session de l'usager actuellement connecté. <br><br>Utilisateur connecté : <a href=\"http://$hostname:3990/logoff\" title=\"Deconnecter l'utilisateur $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history dernières connexions :$connection_history";
|
|
|
84 |
$l_logout = "<a href=\"http://$hostname:3990/logoff\">Se déconnecter d'internet</a>";}
|
|
|
85 |
$l_password_change = "<a href=\"https://$hostname/pass\">Changer votre mot de passe</a>";
|
536 |
franck |
86 |
$l_password_change_explain = "Vous redirige sur la page de changement du mot de passe de votre compte d'accès à internet.<br><br>Vous devez avoir un compte internet valide.";
|
360 |
richard |
87 |
$l_back_page = "<a href=\"javascript:history.back()\">Page précédente</a>";
|
|
|
88 |
}
|
|
|
89 |
else {
|
|
|
90 |
$l_access_denied = "ACCESS DENIED";
|
369 |
richard |
91 |
$l_access_welcome = "Welcome on ALCASAR";
|
360 |
richard |
92 |
$l_access_unavailable = "ACCESS UNAVAILABLE";
|
|
|
93 |
$l_required_domain = "Required WEB site";
|
369 |
richard |
94 |
$l_explain_acc_access = "This center control the portal. You must have an administrative account.";
|
360 |
richard |
95 |
$l_explain_access_deny = "Your portal has just detected that the Internet access is down";
|
|
|
96 |
$l_explain_net_pb = "Your portal has just detected that the Internet access is down";
|
|
|
97 |
$l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
|
|
|
98 |
$l_contact_net_pb = "Contact your network responsive or your Internet provider for more information";
|
369 |
richard |
99 |
$l_welcome = "Your captive portal main page";
|
566 |
stephane |
100 |
$l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Control Center</a>";
|
611 |
franck |
101 |
$l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Install ALCASAR AC Certificate</a>";
|
566 |
stephane |
102 |
$l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Install ALCASAR AC Certificate</a>";
|
688 |
richard |
103 |
$l_certif_explain = "Allow secure data exchange between your computer and ALCASAR portal.<BR>If this certificate isn't incorporated in your computer, some security alerts should appear in your browser.<br><br>";
|
|
|
104 |
$l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Complementary help</a>";
|
783 |
richard |
105 |
if ((isset ($user[4])) && ($user[4] == "0")) {
|
369 |
richard |
106 |
$l_logout_explain = "No Internet consultation session is actualy open on your system";
|
566 |
stephane |
107 |
$l_logout = "<a href=\"http://www.google.fr\">Open an Internet session</a>";}
|
369 |
richard |
108 |
else {
|
783 |
richard |
109 |
if (isset ($user[5])) {
|
|
|
110 |
$l_logout_explain = "Close the session of the user actualy connecterd.<br> User logged-on : <a href=\"http://$hostname:3990/logoff\" title=\"Disconnect user $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history last connections :$connection_history";
|
|
|
111 |
$l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";
|
|
|
112 |
}
|
|
|
113 |
}
|
566 |
stephane |
114 |
$l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
|
509 |
richard |
115 |
$l_password_change_explain = "Ridirect you on password change page.<br><br> You should already have an Internet access account.";
|
360 |
richard |
116 |
$l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
|
|
|
117 |
}
|
369 |
richard |
118 |
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied));
|
360 |
richard |
119 |
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
|
509 |
richard |
120 |
|
|
|
121 |
# Attribution des icones / images
|
|
|
122 |
$img_rep = "images/";
|
|
|
123 |
$img_organisme = "organisme.png";
|
|
|
124 |
$img_access = "globe_acces_70.png";
|
|
|
125 |
$img_connect = "globe_70.png";
|
|
|
126 |
$img_warning = "globe_warning_70.png";
|
|
|
127 |
$img_pwd = "cle_ombre.png";
|
|
|
128 |
$img_certificate = "certificat.png";
|
|
|
129 |
$img_acc = "logo-alcasar_70.png";
|
|
|
130 |
$img_false = "interdit.png";
|
|
|
131 |
$img_internet = $img_connect;
|
|
|
132 |
|
783 |
richard |
133 |
if ((isset ($user[4])) && ($user[4] == "0")) {
|
509 |
richard |
134 |
if (! $network_pb) {
|
|
|
135 |
$img_internet = $img_access;
|
|
|
136 |
}
|
|
|
137 |
else {
|
|
|
138 |
$img_internet = $img_warning;
|
|
|
139 |
}
|
|
|
140 |
}
|
|
|
141 |
else {
|
|
|
142 |
$img_internet = $img_connect;
|
|
|
143 |
}
|
|
|
144 |
|
452 |
richard |
145 |
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
360 |
richard |
146 |
?>
|
566 |
stephane |
147 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
|
148 |
<html>
|
|
|
149 |
<head>
|
|
|
150 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
151 |
<title>ALCASAR - <?php echo $l_title; ?></title>
|
|
|
152 |
<meta http-equiv="Cache-control" content="no-cache">
|
|
|
153 |
<meta http-equiv="Pragma" content="no-cache">
|
|
|
154 |
<link rel="stylesheet" type="text/css" href="css/style_intercept.css">
|
|
|
155 |
<script type="text/javascript">
|
509 |
richard |
156 |
function valoriserDiv5(param){
|
|
|
157 |
document.getElementById("box_info").innerHTML = param.innerHTML;
|
|
|
158 |
}
|
|
|
159 |
</script>
|
360 |
richard |
160 |
</head>
|
566 |
stephane |
161 |
<body onload="valoriserDiv5(text_conn);">
|
509 |
richard |
162 |
<?php
|
360 |
richard |
163 |
if ($direct_access){
|
|
|
164 |
echo "
|
566 |
stephane |
165 |
<div id=\"cadre_titre\" class=\"titre_controle\">
|
|
|
166 |
<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
|
509 |
richard |
167 |
if ($network_pb) {
|
566 |
stephane |
168 |
echo " <span>$l_explain_net_pb</span>";
|
509 |
richard |
169 |
}
|
360 |
richard |
170 |
}
|
509 |
richard |
171 |
else {
|
|
|
172 |
echo"
|
566 |
stephane |
173 |
<div id=\"cadre_titre\" class=\"titre_refus\">
|
|
|
174 |
<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
|
363 |
richard |
175 |
}
|
360 |
richard |
176 |
?>
|
566 |
stephane |
177 |
<div id="boite_logo">
|
|
|
178 |
<img src="images/organisme.png">
|
|
|
179 |
</div>
|
|
|
180 |
</div>
|
|
|
181 |
<div id="contenu_acces">
|
|
|
182 |
<div id="box_url">
|
509 |
richard |
183 |
<?php if (! $direct_access){echo "$l_required_domain : $_SERVER[HTTP_HOST]";}?>
|
566 |
stephane |
184 |
</div>
|
509 |
richard |
185 |
<?php
|
|
|
186 |
if ($direct_access){
|
566 |
stephane |
187 |
echo " <div id=\"box_bienvenue\">
|
360 |
richard |
188 |
$l_welcome
|
566 |
stephane |
189 |
</div>
|
|
|
190 |
<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
|
|
|
191 |
<span>$l_logout</span>
|
|
|
192 |
<img src=\"$img_rep$img_internet\">
|
|
|
193 |
</div>
|
|
|
194 |
<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
|
|
|
195 |
<span>$l_install_certif</span>
|
|
|
196 |
<img src=\"$img_rep$img_certificate\">
|
|
|
197 |
</div>
|
|
|
198 |
<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
|
|
|
199 |
<img src=\"$img_rep$img_pwd\">
|
|
|
200 |
<span>$l_password_change</span>
|
|
|
201 |
</div>
|
|
|
202 |
<div class=\"box_menu\" id=\"box_acc\" onmouseover=\"valoriserDiv5(text_acc);\">
|
|
|
203 |
<span>$l_acc_access</span>
|
|
|
204 |
<img src=\"$img_rep$img_acc\">
|
|
|
205 |
</div>
|
|
|
206 |
<div class=\"div-cache\" id=\"text_conn\">
|
|
|
207 |
<h2>$l_logout</h2>
|
|
|
208 |
<p>$l_logout_explain</p>
|
|
|
209 |
<img src=\"$img_rep$img_internet\">
|
|
|
210 |
</div>
|
|
|
211 |
<div class=\"div-cache\" id=\"text_certif\">
|
|
|
212 |
<h2>$l_install_certif_more</h2>
|
|
|
213 |
<p>$l_certif_explain $l_certif_explain_help</p>
|
|
|
214 |
<img src=\"$img_rep$img_certificate\">
|
|
|
215 |
</div>
|
|
|
216 |
<div class=\"div-cache\" id=\"text_mdp\">
|
|
|
217 |
<h2>$l_password_change</h2>
|
|
|
218 |
<p>$l_password_change_explain</p>
|
|
|
219 |
<img src=\"$img_rep$img_pwd\">
|
|
|
220 |
</div>
|
|
|
221 |
<div class=\"div-cache\" id=\"text_acc\">
|
|
|
222 |
<h2>$l_acc_access</h2>
|
|
|
223 |
<p>$l_explain</p>
|
|
|
224 |
<img src=\"$img_rep$img_acc\">
|
|
|
225 |
</div>
|
|
|
226 |
<div id=\"box_info\">
|
|
|
227 |
</div>";
|
509 |
richard |
228 |
}
|
|
|
229 |
else {
|
|
|
230 |
echo "
|
566 |
stephane |
231 |
<div id=\"box_refuse\">
|
509 |
richard |
232 |
<img src=\"$img_rep$img_false\">
|
566 |
stephane |
233 |
<p>$l_explain</p>
|
|
|
234 |
</div>
|
|
|
235 |
<div id=\"liens_redir\">
|
|
|
236 |
<p>$l_back_page</p>
|
|
|
237 |
</div>";
|
509 |
richard |
238 |
}
|
|
|
239 |
if (($network_pb)&&(! $direct_access)) {
|
566 |
stephane |
240 |
echo " <span>Diagnostic : $diagnostic</span>";
|
509 |
richard |
241 |
}
|
363 |
richard |
242 |
?>
|
566 |
stephane |
243 |
</div>
|
|
|
244 |
</body>
|
360 |
richard |
245 |
</html>
|