Subversion Repositories ALCASAR

Rev

Rev 628 | Rev 732 | 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";
360 richard 3
$network_pb = False;
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)
628 richard 13
if (($_SERVER['HTTP_HOST'] == $_SERVER['SERVER_ADDR']) || preg_match ("/^alcasar/", $_SERVER['HTTP_HOST']) || preg_match ("/^$hostname/", $_SERVER['HTTP_POST']))
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
25
	$time[2] = $temp % 60 ;						// seconds
26
	$time[1] = ( $temp - $time[2] ) / 60;		// minutes
27
 
28
	return $time[0]." h ".$time[2]." m ".$time[1]." s";
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
33
if ($user[4] != "0"){
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>";
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&egrave;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&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";
84
	  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Se d&eacute;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&egrave;s &agrave; internet.<br><br>Vous devez avoir un compte internet valide.";
360 richard 87
  $l_back_page = "<a href=\"javascript:history.back()\">Page pr&eacute;c&eacute;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>";
509 richard 105
if ($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 {
566 stephane 109
	  $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";
110
	  $l_logout = "<a href=\"http://$hostname:3990/logoff\">Logoff from internet</a>";}
111
  $l_password_change = "<a href=\"https://$hostname/pass\">Change your password</a>";
509 richard 112
  $l_password_change_explain = "Ridirect you on password change page.<br><br> You should already have an Internet access account.";
360 richard 113
  $l_back_page = "<a href=\"javascript:history.back()\">Previous page</a>";
114
}
369 richard 115
$l_title = ($direct_access ? $l_access_welcome : ($network_pb ? $l_access_unavailable : $l_access_denied));
360 richard 116
$l_explain = ($direct_access ? $l_explain_acc_access : ($network_pb ? $l_explain_net_pb : $l_explain_access_deny));
509 richard 117
 
118
# Attribution des icones / images
119
$img_rep = "images/";
120
$img_organisme = "organisme.png";
121
$img_access = "globe_acces_70.png";
122
$img_connect = "globe_70.png";
123
$img_warning = "globe_warning_70.png";
124
$img_pwd = "cle_ombre.png";
125
$img_certificate = "certificat.png";
126
$img_acc = "logo-alcasar_70.png";
127
$img_false = "interdit.png";
128
$img_internet = $img_connect;
129
 
130
if ($user[4] == "0") {
131
	if (! $network_pb) {
132
		$img_internet = $img_access;
133
		}
134
		else {
135
		$img_internet = $img_warning;
136
	}
137
}
138
else {
139
	$img_internet = $img_connect;
140
}
141
 
452 richard 142
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
360 richard 143
?>
566 stephane 144
	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
145
	<html>
146
	<head>
147
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
148
	<title>ALCASAR - <?php echo $l_title; ?></title>
149
	<meta http-equiv="Cache-control" content="no-cache">
150
	<meta http-equiv="Pragma" content="no-cache">
151
	<link rel="stylesheet" type="text/css" href="css/style_intercept.css">
152
	<script type="text/javascript">
509 richard 153
		function valoriserDiv5(param){
154
			document.getElementById("box_info").innerHTML = param.innerHTML;
155
		}
156
	</script>
360 richard 157
</head>
566 stephane 158
<body onload="valoriserDiv5(text_conn);">
509 richard 159
<?php
360 richard 160
if ($direct_access){
161
	echo "
566 stephane 162
		<div id=\"cadre_titre\" class=\"titre_controle\">
163
			<p id=\"acces_controle\" class=\"titre_controle\">$l_title</p>";
509 richard 164
	if ($network_pb) {
566 stephane 165
		echo "	<span>$l_explain_net_pb</span>";
509 richard 166
		}
360 richard 167
	}
509 richard 168
	else {
169
		echo"
566 stephane 170
			<div id=\"cadre_titre\" class=\"titre_refus\">
171
				<p id=\"acces_controle\" class=\"titre_refus\">$l_title</p>";
363 richard 172
	}
360 richard 173
?>
566 stephane 174
			<div id="boite_logo">
175
				<img src="images/organisme.png">
176
			</div>
177
		</div>
178
		<div id="contenu_acces">
179
			<div id="box_url">
509 richard 180
				<?php if (! $direct_access){echo "$l_required_domain : $_SERVER[HTTP_HOST]";}?>
566 stephane 181
			</div>
509 richard 182
<?php
183
if ($direct_access){
566 stephane 184
	echo "	<div id=\"box_bienvenue\">
360 richard 185
				$l_welcome
566 stephane 186
			</div>
187
			<div class=\"box_menu\" id=\"box_conn\" onmouseover=\"valoriserDiv5(text_conn);\">
188
				<span>$l_logout</span>
189
				<img src=\"$img_rep$img_internet\">
190
			</div>
191
			<div class=\"box_menu\" id=\"box_certif\" onmouseover=\"valoriserDiv5(text_certif);\">
192
				<span>$l_install_certif</span>
193
				<img src=\"$img_rep$img_certificate\">
194
			</div>
195
			<div class=\"box_menu\" id=\"box_mdp\" onmouseover=\"valoriserDiv5(text_mdp);\">
196
				<img src=\"$img_rep$img_pwd\">
197
				<span>$l_password_change</span>
198
			</div>		
199
			<div class=\"box_menu\" id=\"box_acc\" onmouseover=\"valoriserDiv5(text_acc);\">
200
				<span>$l_acc_access</span>
201
				<img src=\"$img_rep$img_acc\">
202
			</div>
203
			<div class=\"div-cache\" id=\"text_conn\">
204
				<h2>$l_logout</h2>
205
				<p>$l_logout_explain</p>
206
				<img src=\"$img_rep$img_internet\">
207
			</div>
208
			<div class=\"div-cache\" id=\"text_certif\">
209
				<h2>$l_install_certif_more</h2>
210
				<p>$l_certif_explain $l_certif_explain_help</p>
211
				<img src=\"$img_rep$img_certificate\">				
212
			</div>
213
			<div class=\"div-cache\" id=\"text_mdp\">
214
				<h2>$l_password_change</h2>
215
				<p>$l_password_change_explain</p>
216
				<img src=\"$img_rep$img_pwd\">
217
			</div>
218
			<div class=\"div-cache\" id=\"text_acc\">
219
				<h2>$l_acc_access</h2>
220
				<p>$l_explain</p>
221
				<img src=\"$img_rep$img_acc\">
222
			</div>
223
			<div id=\"box_info\">
224
			</div>";
509 richard 225
	}
226
	else {
227
		echo "
566 stephane 228
			<div id=\"box_refuse\">
509 richard 229
				<img src=\"$img_rep$img_false\">
566 stephane 230
				<p>$l_explain</p>
231
			</div>
232
			<div id=\"liens_redir\">
233
				<p>$l_back_page</p>
234
			</div>";
509 richard 235
		}
236
	if (($network_pb)&&(! $direct_access)) {
566 stephane 237
	echo "	<span>Diagnostic : $diagnostic</span>";
509 richard 238
	}
363 richard 239
?>
566 stephane 240
		</div>
241
	</body>
360 richard 242
</html>