Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

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