Subversion Repositories ALCASAR

Rev

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

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