Subversion Repositories ALCASAR

Rev

Rev 2208 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2208 Rev 2250
1
<?php
1
<?php
2
# $Id: autoregistrationinfo.php 2208 2017-05-06 18:13:26Z tom.houdayer $
2
# $Id: autoregistrationinfo.php 2250 2017-05-22 22:00:03Z tom.houdayer $
3
 
3
 
4
// CHECK IF the SMS service is enable
4
// CHECK IF the SMS service is enable
5
$service_SMS_status=false;
5
$service_SMS_status = false;
6
 
6
 
7
if (!$service_SMS_status) {
7
if (!$service_SMS_status) {
8
	header('Location: /');
8
	header('Location: /');
9
	exit();
9
	exit();
10
}
10
}
11
 
11
 
12
 
12
 
13
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
13
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
14
 
14
 
15
// Read CONF_FILE
15
// Read CONF_FILE
16
$file_conf = fopen(CONF_FILE, 'r');
16
$file_conf = fopen(CONF_FILE, 'r');
17
if (!$file_conf) {
17
if (!$file_conf) {
18
	exit('Error opening the file '.CONF_FILE);
18
	exit('Error opening the file '.CONF_FILE);
19
}
19
}
20
while (!feof($file_conf)) {
20
while (!feof($file_conf)) {
21
	$buffer = fgets($file_conf, 4096);
21
	$buffer = fgets($file_conf, 4096);
22
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
22
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
23
		$tmp = explode('=', $buffer);
23
		$tmp = explode('=', $buffer);
24
		$conf[$tmp[0]] = trim($tmp[1]);
24
		$conf[$tmp[0]] = trim($tmp[1]);
25
	}
25
	}
26
}
26
}
27
fclose($file_conf);
27
fclose($file_conf);
28
 
28
 
29
$organisme = trim($conf["ORGANISM"]);
29
$organisme = trim($conf["ORGANISM"]);
30
$current_num='XXXXXXXXXX';
30
$current_num='XXXXXXXXXX';
31
 
31
 
32
 
32
 
33
// Choice of language
33
// Choice of language
34
$Language = 'en';
34
$Language = 'en';
35
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
35
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
36
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
36
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
37
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
37
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
38
}
38
}
39
if ($Language === 'fr') {	// French
39
if ($Language === 'fr') {	// French
40
	$l_title		= "Page d'auto enregistrement";
40
	$l_title		= "Page d'auto enregistrement";
41
	$l_num_exist		= "Compte actif";
41
	$l_num_exist		= "Compte actif";
42
	$l_num_flood		= "Numéro bloqué: nombre d'essai dépassé.";
42
	$l_num_flood		= "Numéro bloqué: nombre d'essai dépassé.";
43
 
43
 
44
	$l_num_num		= "Numero de téléphone";
44
	$l_num_num		= "Numero de téléphone";
45
	$l_num_raison		= "Etat de votre numéro";
45
	$l_num_raison		= "Etat de votre numéro";
46
	$l_num_expiration	= "Expiration du bloquage";
46
	$l_num_expiration	= "Expiration du bloquage";
47
 
47
 
48
	$l_tuto_1		= "Bienvenue sur la page d'auto enregistrement.";
48
	$l_tuto_1		= "Bienvenue sur la page d'auto enregistrement.";
49
	$l_tuto_2		= "Ce portail d'accès à Internet vous offre la possibilité de vous inscrire en envoyant le mot de passe de votre choix par SMS au numéro suivant (prix d'un SMS, non surtaxé).";
49
	$l_tuto_2		= "Ce portail d'accès à Internet vous offre la possibilité de vous inscrire en envoyant le mot de passe de votre choix par SMS au numéro suivant (prix d'un SMS, non surtaxé).";
50
	$l_tuto_3		= "Votre SMS ne doit contenir qu'un seul mot.";
50
	$l_tuto_3		= "Votre SMS ne doit contenir qu'un seul mot.";
51
	$l_tuto_4		= "Votre inscription sera activée lorsque vous retrouverez votre numéro de téléphone dans le tableau ci-dessous. Ce numéro de téléphone constitue votre identifiant de connexion";
51
	$l_tuto_4		= "Votre inscription sera activée lorsque vous retrouverez votre numéro de téléphone dans le tableau ci-dessous. Ce numéro de téléphone constitue votre identifiant de connexion";
52
	$l_tuto_5		= "Le champ de recherche ci-dessous vous permet de retrouver votre numéro suivant les 5 derniers chiffres.";	
52
	$l_tuto_5		= "Le champ de recherche ci-dessous vous permet de retrouver votre numéro suivant les 5 derniers chiffres.";	
53
 
53
 
54
	$l_tab_first		= "premier";
54
	$l_tab_first		= "premier";
55
	$l_tab_last		= "dernier";
55
	$l_tab_last		= "dernier";
56
	$l_tab_next		= "suivant";
56
	$l_tab_next		= "suivant";
57
	$l_tab_prev		= "précédent";
57
	$l_tab_prev		= "précédent";
58
	$l_tab_search		= "Recherche :";
58
	$l_tab_search		= "Recherche :";
59
	$l_tab_pmenu		= "Affiche la page _PAGE_ sur _PAGES_";
59
	$l_tab_pmenu		= "Affiche la page _PAGE_ sur _PAGES_";
60
	$l_tab_info		= "Montrer _MENU_ résultats par page";
60
	$l_tab_info		= "Montrer _MENU_ résultats par page";
61
	$l_tab_infoempty	= "Aucun résultat";
61
	$l_tab_infoempty	= "Aucun résultat";
62
 
62
 
63
	$l_autorefresh		= "Rafraichissement : 10 sec";
63
	$l_autorefresh		= "Rafraichissement : 10 sec";
64
} else {			// English
64
} else {			// English
65
	$l_title		= "Autoregistration";
65
	$l_title		= "Autoregistration";
66
	$l_num_exist		= "Account enables";
66
	$l_num_exist		= "Account enables";
67
	$l_num_flood		= "Phone number banned: Number of trial exceeded.";
67
	$l_num_flood		= "Phone number banned: Number of trial exceeded.";
68
 
68
 
69
	$l_num_num		= "Phone number";
69
	$l_num_num		= "Phone number";
70
	$l_num_raison		= "Status of your phone number";
70
	$l_num_raison		= "Status of your phone number";
71
	$l_num_expiration	= "Expiration";
71
	$l_num_expiration	= "Expiration";
72
 
72
 
73
	$l_tuto_1		= "Welcome to the auto-enrollment page";
73
	$l_tuto_1		= "Welcome to the auto-enrollment page";
74
	$l_tuto_2		= "This portal allows you to enroll by sending the password of you choice via SMS to the following number (no surcharge) :";
74
	$l_tuto_2		= "This portal allows you to enroll by sending the password of you choice via SMS to the following number (no surcharge) :";
75
	$l_tuto_3		= "Just send 1 word in your SMS.";
75
	$l_tuto_3		= "Just send 1 word in your SMS.";
76
	$l_tuto_4		= "Your registration will be activated when you'll find your phone number in the following table. This phone number is your login name";
76
	$l_tuto_4		= "Your registration will be activated when you'll find your phone number in the following table. This phone number is your login name";
77
	$l_tuto_5		= "You can search your phone number according to the 5 last digits in your phone number.";
77
	$l_tuto_5		= "You can search your phone number according to the 5 last digits in your phone number.";
78
	
78
	
79
	$l_tab_first		= "first";
79
	$l_tab_first		= "first";
80
	$l_tab_last		= "last";
80
	$l_tab_last		= "last";
81
	$l_tab_next		= "next";
81
	$l_tab_next		= "next";
82
	$l_tab_prev		= "previous";
82
	$l_tab_prev		= "previous";
83
	$l_tab_search		= "Search :";
83
	$l_tab_search		= "Search :";
84
	$l_tab_pmenu		= "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
84
	$l_tab_pmenu		= "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
85
	$l_tab_info		= "Show _MENU_ entries";
85
	$l_tab_info		= "Show _MENU_ entries";
86
	$l_tab_infoempty	= "No matching records found";
86
	$l_tab_infoempty	= "No matching records found";
87
 
87
 
88
	$l_autorefresh		= "Refresh: 10 sec";
88
	$l_autorefresh		= "Refresh: 10 sec";
89
}
89
}
90
 
90
 
91
// Get SMS from database
91
// Get SMS from database
92
require('/etc/freeradius-web/config.php');
92
require('/etc/freeradius-web/config.php');
93
 
93
 
94
$con = mysqli_connect($config['sql_server'], $config['sql_username'], $config['sql_password'], 'gammu');
94
$con = mysqli_connect($config['sql_server'], $config['sql_username'], $config['sql_password'], 'gammu');
95
 
95
 
96
if (mysqli_connect_errno()) {
96
if (mysqli_connect_errno()) {
97
	exit('Failed to connect to ' . $config['sql_type']/* . ': ' . mysqli_connect_error()*/);
97
	exit('Failed to connect to ' . $config['sql_type']/* . ': ' . mysqli_connect_error()*/);
98
}
98
}
99
 
99
 
100
$result = mysqli_query($con, 'SELECT * FROM `SMS_ban_perm` ORDER BY date_add DESC;');
100
$result = mysqli_query($con, 'SELECT * FROM `SMS_ban_perm` ORDER BY date_add DESC;');
101
 
101
 
102
$smsBanPerms = [];
102
$smsBanPerms = [];
103
while ($row = mysqli_fetch_array($result)) {
103
while ($row = mysqli_fetch_array($result)) {
104
	$smsBanPerms[] = (object) [
104
	$smsBanPerms[] = (object) [
105
		'numberHidden' => substr($row['SenderNumber'], 0, 3) . '****' . substr($row['SenderNumber'], -5),
105
		'numberHidden' => substr($row['SenderNumber'], 0, 3) . '****' . substr($row['SenderNumber'], -5),
106
		'expiration'   => $row['Expiration'],
106
		'expiration'   => $row['Expiration'],
107
		'perm'         => $row['Perm']
107
		'perm'         => $row['Perm']
108
	];
108
	];
109
}
109
}
110
mysqli_close($con);
110
mysqli_close($con);
111
 
111
 
112
?>
112
?>
113
<!DOCTYPE html>
113
<!DOCTYPE html>
114
<html><!-- written by Rexy -->
114
<html><!-- written by Rexy -->
115
<head>
115
<head>
116
	<meta charset="utf-8">
116
	<meta charset="utf-8">
117
	<title>Auto enregistrement</title>
117
	<title>Auto enregistrement</title>
118
	<link rel="stylesheet" type="text/css" href="/css/style_intercept.css">
118
	<link rel="stylesheet" type="text/css" href="/css/style_intercept.css">
119
	<!-- DataTables CSS -->
119
	<!-- DataTables CSS -->
120
	<link rel="stylesheet" type="text/css" href="../css/jquery.dataTables.css">
120
	<link rel="stylesheet" type="text/css" href="../css/jquery.dataTables.css">
121
	<!-- jQuery -->
121
	<!-- jQuery -->
122
	<script charset="utf8" src="../js/jquery.js"></script>
122
	<script charset="utf8" src="../js/jquery.js"></script>
123
	<!-- DataTables -->
123
	<!-- DataTables -->
124
	<script charset="utf8" src="../js/jquery.dataTables.js"></script>
124
	<script charset="utf8" src="../js/jquery.dataTables.js"></script>
125
	<script>
125
	<script>
126
	function timedRefresh(timeoutPeriod) {
126
	function timedRefresh(timeoutPeriod) {
127
		var interval = setInterval(refreshPage, timeoutPeriod);
127
		var interval = setInterval(refreshPage, timeoutPeriod);
128
	}
128
	}
129
 
129
 
130
	function refreshPage() {
130
	function refreshPage() {
131
		if ($('input[name=autoRefreshCheckboxes]').is(':checked')) {
131
		if ($('input[name=autoRefreshCheckboxes]').is(':checked')) {
132
			location.reload(true);
132
			location.reload(true);
133
		}
133
		}
134
	}
134
	}
135
 
135
 
136
	$(document).ready( function () {
136
	$(document).ready( function () {
137
		$('#table_id').DataTable({
137
		$('#table_id').DataTable({
138
			"language": {
138
			"language": {
139
				"paginate": {
139
				"paginate": {
140
					"sFirst":    "<?= $l_tab_first ?>",
140
					"sFirst":    "<?= $l_tab_first ?>",
141
					"sLast":     "<?= $l_tab_last ?>",
141
					"sLast":     "<?= $l_tab_last ?>",
142
					"sPrevious": "<?= $l_tab_prev ?>",
142
					"sPrevious": "<?= $l_tab_prev ?>",
143
					"sNext":     "<?= $l_tab_next ?>"
143
					"sNext":     "<?= $l_tab_next ?>"
144
				},
144
				},
145
				"lengthMenu":  "<?= $l_tab_info ?>",
145
				"lengthMenu":  "<?= $l_tab_info ?>",
146
				"zeroRecords": "<?= $l_tab_infoempty ?>",
146
				"zeroRecords": "<?= $l_tab_infoempty ?>",
147
				"info":        "<?= $l_tab_pmenu ?>",
147
				"info":        "<?= $l_tab_pmenu ?>",
148
				"infoEmpty":   "<?= $l_tab_infoempty ?>",
148
				"infoEmpty":   "<?= $l_tab_infoempty ?>",
149
				"sSearch":     "<?= $l_tab_search ?>"
149
				"sSearch":     "<?= $l_tab_search ?>"
150
			}
150
			}
151
		});
151
		});
152
	});
152
	});
153
	</script>
153
	</script>
154
</head>
154
</head>
155
<body onload="timedRefresh(10000);">
155
<body onload="timedRefresh(10000);">
156
	<center>
156
	<center>
157
	<div id="logon">
157
	<div id="logon">
158
		<h1><?= $organisme ?></h1>
158
		<h1><?= $organisme ?></h1>
159
		<h2><?= $l_title ?></h2>
159
		<h2><?= $l_title ?></h2>
160
 
160
 
161
		<div>
161
		<div>
162
		<table id="boite-info">
162
		<table id="boite-info">
163
			<tr>
163
			<tr>
164
				<td rowspan="6" width="30%"><img id="logo-organ" src="/images/organisme.png"></td>
164
				<td rowspan="6" width="30%"><img id="logo-organ" src="/images/organisme.png"></td>
165
			</tr>
165
			</tr>
166
			<tr>
166
			<tr>
167
				<td><?= $l_tuto_1 ?></td>
167
				<td><?= $l_tuto_1 ?></td>
168
			</tr>
168
			</tr>
169
			<tr>
169
			<tr>
170
				<td><?= $l_tuto_2 ?></td>
170
				<td><?= $l_tuto_2 ?></td>
171
			</tr>
171
			</tr>
172
			<tr>
172
			<tr>
173
				<td align="center"><h3><?= $current_num ?></h3></td>
173
				<td align="center"><h3><?= $current_num ?></h3></td>
174
			</tr>
174
			</tr>
175
			<tr>
175
			<tr>
176
				<td><?= $l_tuto_3 ?></td>
176
				<td><?= $l_tuto_3 ?></td>
177
			</tr>
177
			</tr>
178
			<tr>
178
			<tr>
179
				<td><?= $l_tuto_4 ?></td>
179
				<td><?= $l_tuto_4 ?></td>
180
			</tr>
180
			</tr>
181
<!--
181
<!--
182
			<tr>
182
			<tr>
183
				<td colspan="2"><?= $l_tuto_5 ?></td>
183
				<td colspan="2"><?= $l_tuto_5 ?></td>
184
			</tr>
184
			</tr>
185
-->
185
-->
186
		</table>
186
		</table>
187
		</div>
187
		</div>
188
 
188
 
189
		<div>
189
		<div>
190
		<label><input type="checkbox" checked="checked" name="autoRefreshCheckboxes"><?= $l_autorefresh ?></label>
190
		<label><input type="checkbox" checked="checked" name="autoRefreshCheckboxes"><?= $l_autorefresh ?></label>
191
		<table id="table_id" class="display">
191
		<table id="table_id" class="display">
192
			<thead>
192
			<thead>
193
				<tr>
193
				<tr>
194
					<th><b><?= $l_num_num ?></b></th>
194
					<th><b><?= $l_num_num ?></b></th>
195
					<th><b><?= $l_num_raison ?></b></th>
195
					<th><b><?= $l_num_raison ?></b></th>
196
					<th><b><?= $l_num_expiration ?></b></th>
196
					<th><b><?= $l_num_expiration ?></b></th>
197
				</tr>
197
				</tr>
198
			</thead>
198
			</thead>
199
			<tbody>
199
			<tbody>
200
				<?php foreach ($smsBanPerms as $smsBanPerm): ?>
200
				<?php foreach ($smsBanPerms as $smsBanPerm): ?>
201
					<tr>
201
					<tr>
202
						<td><?= $smsBanPerm->numberHidden ?></td>
202
						<td><?= $smsBanPerm->numberHidden ?></td>
203
 
203
 
204
						<?php if ($smsBanPerm->perm == '0'): ?>
204
						<?php if ($smsBanPerm->perm == '0'): ?>
205
							<td><?= $l_num_exist ?></td>
205
							<td><?= $l_num_exist ?></td>
206
						<?php elseif ($smsBanPerm->perm == '1'): ?>
206
						<?php elseif ($smsBanPerm->perm == '1'): ?>
207
							<td><?= $l_num_flood ?></td>
207
							<td><?= $l_num_flood ?></td>
208
						<?php endif ?>
208
						<?php endif ?>
209
 
209
 
210
						<td><?= $smsBanPerm->expiration ?></td>
210
						<td><?= $smsBanPerm->expiration ?></td>
211
					</tr>
211
					</tr>
212
				<?php endforeach; ?>
212
				<?php endforeach; ?>
213
			</tbody>
213
			</tbody>
214
		</table>
214
		</table>
215
		</div>
215
		</div>
216
	</div>
216
	</div>
217
	</center>
217
	</center>
218
</body>
218
</body>
219
</html>
219
</html>
220
 
220