Subversion Repositories ALCASAR

Rev

Rev 801 | Rev 912 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
452 richard 1
<?php
498 richard 2
$hostname = "alcasar";
784 richard 3
$network_pb = False;
509 richard 4
$cert_add = "http://alcasar/certs";
360 richard 5
$direct_access = False;
832 richard 6
$diagnostic = "can't contact the default router";
363 richard 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&Egrave;S REFUS&Eacute;";
399 franck 65
  $l_access_welcome = "Bienvenue sur ALCASAR";
360 richard 66
  $l_access_unavailable = "ACC&Egrave;S INDISPONIBLE";
67
  $l_required_domain = "Site WEB demand&eacute;";
536 franck 68
  $l_explain_acc_access = "Le centre de gestion permet d'administrer le portail. Vous devez poss&eacute;der un compte d'administration ou de gestion pour y acc&eacute;der.";
360 richard 69
  $l_explain_access_deny = "Vous tentez d'acc&eacute;der &agrave; une ressource dont le contenu est r&eacute;put&eacute; contenir des informations inappropri&eacute;es.";
70
  $l_explain_net_pb = "Votre portail d&eacute;tecte que l'acc&egrave;s &agrave; Internet est indisponible.";
71
  $l_contact_access_deny = "Contactez le responsable de la s&eacute;curit&eacute; (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&egrave;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&eacute; racine d'ALCASAR</a>";
536 franck 77
  $l_certif_explain = "Permet l'&eacute;change de donn&eacute;es s&eacute;curis&eacute;es entre votre station de consultation et le portail captif ALCASAR.<BR>Si ce certificat n'est pas enregistr&eacute; sur votre station de consultation, il est possible que des alertes de s&eacute;curit&eacute;s soient &eacute;mises par votre navigateur.<br><br>";
688 richard 78
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Aide complémentaire</a>";
832 richard 79
if ((isset ($user[4])) && ($user[4] == "0")) {
509 richard 80
	  $l_logout_explain = "Aucune session de consultation Internet n'est actuellement ouverte sur votre syst&egrave;me.";
566 stephane 81
	  $l_logout = "<a href=\"http://www.google.fr\">Ouvrir une session Internet</a>";}
369 richard 82
  else {
832 richard 83
	  if ($user[5] != $user[0]) // authentication exception or not
84
	  {
85
	  	$l_logout_explain = "Ferme la session de l'usager actuellement connect&eacute;. <br><br>Utilisateur connect&eacute; : <a href=\"http://$hostname:3990/logoff\" title=\"Deconnecter l'utilisateur $user[5]\"><b>$user[5]</b></a><br><br>$nb_connection_history derni&egrave;res connexions :$connection_history";
86
		$l_logout = "<a href=\"http://$hostname:3990/logoff\">Se d&eacute;connecter d'internet</a>";
87
	  }
88
	  else
89
	  {
90
		  $l_logout_explain = "Votre système ($user[5]) est en exception d'authentication.<br><br>$nb_connection_history last connections :$connection_history";
91
		  $l_logout = "Information des connexions";
92
	  }
93
	}
566 stephane 94
  $l_password_change = "<a href=\"https://$hostname/pass\">Changer votre mot de passe</a>";
536 franck 95
  $l_password_change_explain = "Vous redirige sur la page de changement du mot de passe de votre compte d'acc&egrave;s &agrave; internet.<br><br>Vous devez avoir un compte internet valide.";
360 richard 96
  $l_back_page = "<a href=\"javascript:history.back()\">Page pr&eacute;c&eacute;dente</a>";
97
}
98
else {
99
  $l_access_denied = "ACCESS DENIED";
369 richard 100
  $l_access_welcome = "Welcome on ALCASAR";
360 richard 101
  $l_access_unavailable = "ACCESS UNAVAILABLE";
102
  $l_required_domain = "Required WEB site";
369 richard 103
  $l_explain_acc_access = "This center control the portal. You must have an administrative account.";
801 richard 104
  $l_explain_access_deny = "You try to connect to a resource whose content is deemed to contain inappropriate information.";
360 richard 105
  $l_explain_net_pb = "Your portal has just detected that the Internet access is down";
106
  $l_contact_access_deny = "Contact your security system manager if you think this filtering is abusive.";
107
  $l_contact_net_pb = "Contact your network responsive or your Internet provider for more information";
369 richard 108
  $l_welcome = "Your captive portal main page";
566 stephane 109
  $l_acc_access = "<a href=\"https://$hostname/acc\">ALCASAR Control Center</a>";
611 franck 110
  $l_install_certif = "<a href=\"$cert_add/certificat_alcasar_ca.crt\">Install ALCASAR AC Certificate</a>";
566 stephane 111
  $l_install_certif_more = "<a href=\"$cert_add/certificat_alcasar_ca.cert\">Install ALCASAR AC Certificate</a>";
688 richard 112
  $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>";
113
  $l_certif_explain_help = "<a href=\"alcasar-certificat.pdf\" target=\"_blank\">Complementary help</a>";
783 richard 114
if ((isset ($user[4])) && ($user[4] == "0")) {
369 richard 115
	  $l_logout_explain = "No Internet consultation session is actualy open on your system";
566 stephane 116
	  $l_logout = "<a href=\"http://www.google.fr\">Open an Internet session</a>";}
369 richard 117
  else {
832 richard 118
	  if ($user[5] != $user[0]) // authentication exception or not
119
	  {
783 richard 120
		  $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";
121
		  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";
832 richard 122
	  }
123
	  else
124
	  {
125
		  $l_logout_explain = "Your system ($user[5]) is in exception of authentication.<br><br>$nb_connection_history last connections :$connection_history";
126
		  $l_logout = "Connections information";
127
	  }
783 richard 128
  	}
566 stephane 129
  $l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
799 richard 130
  $l_password_change_explain = "Redirect you on password change page.<br><br> You should already have an Internet access account.";
360 richard 131
  $l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
132
}
369 richard 133
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied));
360 richard 134
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
509 richard 135
 
136
# Attribution des icones / images
137
$img_rep = "images/";
138
$img_organisme = "organisme.png";
139
$img_access = "globe_acces_70.png";
140
$img_connect = "globe_70.png";
141
$img_warning = "globe_warning_70.png";
142
$img_pwd = "cle_ombre.png";
143
$img_certificate = "certificat.png";
144
$img_acc = "logo-alcasar_70.png";
145
$img_false = "interdit.png";
146
$img_internet = $img_connect;
147
 
783 richard 148
if ((isset ($user[4])) && ($user[4] == "0")) {
509 richard 149
	if (! $network_pb) {
150
		$img_internet = $img_access;
151
		}
152
		else {
153
		$img_internet = $img_warning;
154
	}
155
}
156
else {
157
	$img_internet = $img_connect;
158
}
159
 
452 richard 160
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
360 richard 161
?>
566 stephane 162
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
163
	<html>
164
	<head>
165
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
166
	<title>ALCASAR - <?php echo $l_title; ?></title>
167
	<meta http-equiv="Cache-control" content="no-cache">
168
	<meta http-equiv="Pragma" content="no-cache">
169
	<link rel="stylesheet" type="text/css" href="css/style_intercept.css">
170
	<script type="text/javascript">
509 richard 171
		function valoriserDiv5(param){
172
			document.getElementById("box_info").innerHTML = param.innerHTML;
173
		}
174
	</script>
360 richard 175
</head>
566 stephane 176
<body onload="valoriserDiv5(text_conn);">
509 richard 177
<?php
360 richard 178
if ($direct_access){
179
	echo "
566 stephane 180
		<div id=\"cadre_titre\" class=\"titre_controle\">
181
			<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
509 richard 182
	if ($network_pb) {
566 stephane 183
		echo "	<span>$l_explain_net_pb</span>";
509 richard 184
		}
360 richard 185
	}
509 richard 186
	else {
187
		echo"
566 stephane 188
			<div id=\"cadre_titre\" class=\"titre_refus\">
189
				<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
363 richard 190
	}
360 richard 191
?>
566 stephane 192
			<div id="boite_logo">
193
				<img src="images/organisme.png">
194
			</div>
195
		</div>
196
		<div id="contenu_acces">
197
			<div id="box_url">
509 richard 198
				<?php if (! $direct_access){echo "$l_required_domain : $_SERVER[HTTP_HOST]";}?>
566 stephane 199
			</div>
509 richard 200
<?php
201
if ($direct_access){
566 stephane 202
	echo "	<div id=\"box_bienvenue\">
360 richard 203
				$l_welcome
566 stephane 204
			</div>
205
			<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
206
				<span>$l_logout</span>
207
				<img src=\"$img_rep$img_internet\">
208
			</div>
209
			<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
210
				<span>$l_install_certif</span>
211
				<img src=\"$img_rep$img_certificate\">
212
			</div>
213
			<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
214
				<img src=\"$img_rep$img_pwd\">
215
				<span>$l_password_change</span>
216
			</div>
217
			<div class=\"box_menu\" id=\"box_acc\" onmouseover=\"valoriserDiv5(text_acc);\">
218
				<span>$l_acc_access</span>
219
				<img src=\"$img_rep$img_acc\">
220
			</div>
221
			<div class=\"div-cache\" id=\"text_conn\">
222
				<h2>$l_logout</h2>
223
				<p>$l_logout_explain</p>
224
				<img src=\"$img_rep$img_internet\">
225
			</div>
226
			<div class=\"div-cache\" id=\"text_certif\">
227
				<h2>$l_install_certif_more</h2>
228
				<p>$l_certif_explain $l_certif_explain_help</p>
229
				<img src=\"$img_rep$img_certificate\">
230
			</div>
231
			<div class=\"div-cache\" id=\"text_mdp\">
232
				<h2>$l_password_change</h2>
233
				<p>$l_password_change_explain</p>
234
				<img src=\"$img_rep$img_pwd\">
235
			</div>
236
			<div class=\"div-cache\" id=\"text_acc\">
237
				<h2>$l_acc_access</h2>
238
				<p>$l_explain</p>
239
				<img src=\"$img_rep$img_acc\">
240
			</div>
241
			<div id=\"box_info\">
242
			</div>";
509 richard 243
	}
244
	else {
245
		echo "
566 stephane 246
			<div id=\"box_refuse\">
509 richard 247
				<img src=\"$img_rep$img_false\">
566 stephane 248
				<p>$l_explain</p>
249
			</div>
250
			<div id=\"liens_redir\">
251
				<p>$l_back_page</p>
252
			</div>";
509 richard 253
		}
254
	if (($network_pb)&&(! $direct_access)) {
566 stephane 255
	echo "	<span>Diagnostic : $diagnostic</span>";
509 richard 256
	}
363 richard 257
?>
566 stephane 258
		</div>
259
	</body>
360 richard 260
</html>