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 2916 2021-02-08 23:08:44Z rexy $
2822 rexy 3
#
4
# SMS Autoregistration
5
# By Rexy
2208 tom.houday 6
 
7
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
8
 
9
// Read CONF_FILE
10
$file_conf = fopen(CONF_FILE, 'r');
11
if (!$file_conf) {
12
	exit('Error opening the file '.CONF_FILE);
1349 richard 13
}
2208 tom.houday 14
while (!feof($file_conf)) {
15
	$buffer = fgets($file_conf, 4096);
16
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 17
		$tmp = explode('=', $buffer, 2);
18
		$conf[trim($tmp[0])] = trim($tmp[1]);
2208 tom.houday 19
	}
20
}
21
fclose($file_conf);
22
 
2600 tom.houday 23
// Check if the SMS service is enable
24
if ($conf['SMS'] !== 'on') {
25
	header('Location: /');
26
	exit();
27
}
28
$organisme   = $conf['ORGANISM'];
29
$current_num = $conf['SMS_NUM'];
2208 tom.houday 30
 
2600 tom.houday 31
 
2208 tom.houday 32
// Choice of language
1400 richard 33
$Language = 'en';
2208 tom.houday 34
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
35
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
36
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
37
}
38
if ($Language === 'fr') {	// French
39
	$l_title		= "Page d'auto enregistrement";
2916 rexy 40
	$l_num_exist	= "Compte actif";
41
	$l_num_flood	= "Numéro bloqué: nombre d'essai dépassé.";
42
	$l_num_num		= "Numéro de GSM / identifiant de compte";
43
	$l_num_raison	= "État de votre numéro de GSM / compte";
44
	$l_num_expiration	= "Expiration";
2208 tom.houday 45
	$l_tuto_1		= "Bienvenue sur la page d'auto enregistrement.";
2916 rexy 46
	$l_tuto_2		= "Ce portail peut créer un compte dont l'identifiant sera votre numéro de GSM. Pour cela, envoyez le mot de passe de votre choix par SMS au numéro suivant : <b>$current_num</b>";
2208 tom.houday 47
	$l_tuto_3		= "Votre SMS ne doit contenir qu'un seul mot.";
2916 rexy 48
	$l_tuto_4		= "Votre inscription sera activée lorsque vous retrouverez votre numéro de GSM dans le tableau ci-dessous.";
2208 tom.houday 49
	$l_tuto_5		= "Le champ de recherche ci-dessous vous permet de retrouver votre numéro suivant les 5 derniers chiffres.";	
2916 rexy 50
	$l_tab_first	= "premier";
2208 tom.houday 51
	$l_tab_last		= "dernier";
52
	$l_tab_next		= "suivant";
53
	$l_tab_prev		= "précédent";
2916 rexy 54
	$l_tab_search	= "Recherche :";
55
	$l_tab_pmenu	= "Affiche la page _PAGE_ sur _PAGES_";
2208 tom.houday 56
	$l_tab_info		= "Montrer _MENU_ résultats par page";
57
	$l_tab_infoempty	= "Aucun résultat";
58
	$l_autorefresh		= "Rafraichissement : 10 sec";
2850 rexy 59
} else if ($Language === 'es') {	// Spanish
60
	$l_title		= "Auto-Registro";
2916 rexy 61
	$l_num_exist	= "Cuenta existente";
62
	$l_num_flood	= "Número de teléfono bloqueado: se superó el número de intentos.";
63
	$l_num_num		= "Número GSM / identificador de cuenta";
64
	$l_num_raison	= "Estado de su número GSM / cuenta";
2850 rexy 65
	$l_num_expiration	= "Vencimiento";
66
	$l_tuto_1		= "Bienvenido a la página de auto-registro";
2916 rexy 67
	$l_tuto_2		= "Este portal puede crear una cuenta cuyo identificador será su número de teléfono móvil. Para ello, envíe la contraseña que elija por SMS al siguiente número: <b>$current_num</b> ";
2850 rexy 68
	$l_tuto_3		= "Simplemente envíe 1 palabra en su SMS.";
2916 rexy 69
	$l_tuto_4		= "Su registro se activará cuando encuentre su número GSM en la siguiente tabla.";
2850 rexy 70
	$l_tuto_5		= "Puede buscar su número de teléfono de acuerdo con los últimos 5 dígitos de su número de teléfono.";
2916 rexy 71
	$l_tab_first	= "primero";
2850 rexy 72
	$l_tab_last		= "último";
73
	$l_tab_next		= "siguiente";
74
	$l_tab_prev		= "anterior";
2916 rexy 75
	$l_tab_search	= "Buscar :";
76
	$l_tab_pmenu	= "Mostrando _PAGE_ a _PAGE_ de _PAGE_ entradas :";
2850 rexy 77
	$l_tab_info		= "Mostrar _MENU_ entradas";
78
	$l_tab_infoempty	= "No se encontraron registros coincidencias";
79
	$l_autorefresh		= "Actualizar: 10 seg";
2916 rexy 80
} else if ($Language === 'de') {	// German
81
	$l_title		= "Seite zur Selbstregistrierung";
82
	$l_num_exist	= "Aktives Konto";
83
	$l_num_flood	= "Blockierte Nummer: Anzahl der Versuche überschritten.";
84
	$l_num_num		= "GSM-Nummer / Konto-Kennung";
85
	$l_num_raison	= "Status Ihrer Handynummer / Ihres Kontos";
86
	$l_num_expiration	= "Ablauf";
87
	$l_tuto_1		= "Willkommen auf der Seite für die Selbstregistrierung.";
88
	$l_tuto_2		= "Dieses Portal kann ein Konto erstellen, dessen Kennung Ihre Mobiltelefonnummer ist. Senden Sie dazu das Passwort Ihrer Wahl per SMS an die folgende Nummer: <b>$current_num</b> ";
89
	$l_tuto_3		= "Ihre Textnachricht darf nur ein Wort enthalten.";
90
	$l_tuto_4		= "Ihre Registrierung wird aktiviert, wenn Sie Ihre Handynummer in der Tabelle unten finden.";
91
	$l_tuto_5		= "Mit dem Suchfeld unten können Sie Ihre Nummer nach den letzten 5 Ziffern suchen.";
92
	$l_tab_first	= "erste";
93
	$l_tab_last		= "aktuellste";
94
	$l_tab_next		= "unter";
95
	$l_tab_prev		= "vorherige";
96
	$l_tab_search	= "Forschung :";
97
	$l_tab_pmenu	= "Zeigt die Seite _PAGE_ auf _PAGES_ an";
98
	$l_tab_info		= "_MENU_ Ergebnisse pro Seite anzeigen";
99
	$l_tab_infoempty	= "Keine Ergebnisse";
100
	$l_autorefresh		= "Kühlung: 10 sec";
2208 tom.houday 101
} else {			// English
102
	$l_title		= "Autoregistration";
2916 rexy 103
	$l_num_exist		= "Account enabled";
2208 tom.houday 104
	$l_num_flood		= "Phone number banned: Number of trial exceeded.";
2916 rexy 105
	$l_num_num		= "Mobile phone number / account identifier";
106
	$l_num_raison		= "Status of your phone number / account";
2208 tom.houday 107
	$l_num_expiration	= "Expiration";
108
	$l_tuto_1		= "Welcome to the auto-enrollment page";
2916 rexy 109
	$l_tuto_2		= "This portal can create an account whose identifier will be your mobile phone number. To do so, send the password of your choice by SMS to the following number: <b>$current_num</b>";
2208 tom.houday 110
	$l_tuto_3		= "Just send 1 word in your SMS.";
2916 rexy 111
	$l_tuto_4		= "Your registration will be activated when you'll find your phone number in the following table.";
2208 tom.houday 112
	$l_tuto_5		= "You can search your phone number according to the 5 last digits in your phone number.";
113
	$l_tab_first		= "first";
114
	$l_tab_last		= "last";
115
	$l_tab_next		= "next";
116
	$l_tab_prev		= "previous";
117
	$l_tab_search		= "Search :";
118
	$l_tab_pmenu		= "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
119
	$l_tab_info		= "Show _MENU_ entries";
120
	$l_tab_infoempty	= "No matching records found";
121
	$l_autorefresh		= "Refresh: 10 sec";
122
}
1400 richard 123
 
2208 tom.houday 124
// Get SMS from database
125
require('/etc/freeradius-web/config.php');
2822 rexy 126
$img_rep         = '/images/';
127
$img_sms         = 'sms.png';
1400 richard 128
 
2208 tom.houday 129
$con = mysqli_connect($config['sql_server'], $config['sql_username'], $config['sql_password'], 'gammu');
130
 
131
if (mysqli_connect_errno()) {
132
	exit('Failed to connect to ' . $config['sql_type']/* . ': ' . mysqli_connect_error()*/);
1400 richard 133
}
2208 tom.houday 134
 
135
$result = mysqli_query($con, 'SELECT * FROM `SMS_ban_perm` ORDER BY date_add DESC;');
136
 
137
$smsBanPerms = [];
138
while ($row = mysqli_fetch_array($result)) {
139
	$smsBanPerms[] = (object) [
140
		'numberHidden' => substr($row['SenderNumber'], 0, 3) . '****' . substr($row['SenderNumber'], -5),
141
		'expiration'   => $row['Expiration'],
142
		'perm'         => $row['Perm']
143
	];
144
}
145
mysqli_close($con);
146
 
1400 richard 147
?>
2208 tom.houday 148
<!DOCTYPE html>
149
<html><!-- written by Rexy -->
1349 richard 150
<head>
2208 tom.houday 151
	<meta charset="utf-8">
2822 rexy 152
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
153
	<title>ALCASAR - <?= $l_title ?></title>
154
	<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
155
	<link rel="stylesheet" type="text/css" href="/css/index.css">
2809 rexy 156
	<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.css">
2823 rexy 157
	<link rel="icon" href="/images/favicon-48.ico" type="image/ico">
2822 rexy 158
	<script src="/js/jquery.min.js"></script>
159
	<script src="/js/jquery.dataTables.js"></script>
2208 tom.houday 160
	<script>
161
	function timedRefresh(timeoutPeriod) {
162
		var interval = setInterval(refreshPage, timeoutPeriod);
163
	}
1452 richard 164
 
2208 tom.houday 165
	function refreshPage() {
166
		if ($('input[name=autoRefreshCheckboxes]').is(':checked')) {
167
			location.reload(true);
168
		}
169
	}
1452 richard 170
 
2208 tom.houday 171
	$(document).ready( function () {
172
		$('#table_id').DataTable({
2916 rexy 173
			"order": [[ 2, "desc" ]],		
2208 tom.houday 174
			"language": {
175
				"paginate": {
176
					"sFirst":    "<?= $l_tab_first ?>",
177
					"sLast":     "<?= $l_tab_last ?>",
178
					"sPrevious": "<?= $l_tab_prev ?>",
179
					"sNext":     "<?= $l_tab_next ?>"
180
				},
181
				"lengthMenu":  "<?= $l_tab_info ?>",
182
				"zeroRecords": "<?= $l_tab_infoempty ?>",
183
				"info":        "<?= $l_tab_pmenu ?>",
184
				"infoEmpty":   "<?= $l_tab_infoempty ?>",
185
				"sSearch":     "<?= $l_tab_search ?>"
2916 rexy 186
				}
2208 tom.houday 187
		});
1387 richard 188
	});
2208 tom.houday 189
	</script>
1349 richard 190
</head>
2208 tom.houday 191
<body onload="timedRefresh(10000);">
2822 rexy 192
	<div class="col-xs-12 col-md-10 col-md-offset-1"> 
193
		<!-- HeaderBox -->
194
		<div class="row banner">
195
			<!-- Logo box -->
196
			<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2"> 
197
				<img class="img-responsive img-organisme" src="images/organisme.png">
198
			</div>
199
			<!-- Title -->
200
			<div id="cadre_titre" class="titre_banner col-xs-12 col-sm-8">
201
					<p id="acces_controle" class="titre_controle"><?= $l_title ?></p>
202
			</div>
203
			<!-- Logo box -->
204
			<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2">
205
				<img class="img-responsive img-organisme" src="images/logo-alcasar_70.png">
206
			</div>
2208 tom.houday 207
		</div>
2822 rexy 208
		<!-- Main content box -->
209
		<div class="row">
210
			<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
211
				<h3><?= $l_tuto_2 ?></h3>
212
				<div class="menu-container container col_xs_12 col-sm-7">
213
					<div class="box_menu_right box_menu">
2916 rexy 214
						<span><?= $l_tuto_3 ?></span>
2822 rexy 215
						<div class="menu-image">						
216
							<img class="img-responsive" src="<?= $img_rep.$img_sms ?>">
217
						</div>
218
					</div>
219
				</div>
220
			</div>
221
		</div>
222
	<p>
223
		<div class="row">
224
			<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
225
				<h4><?= $l_tuto_4 ?></h4>
226
				<h4><?= $l_tuto_5 ?></h4>
227
				<label><input type="checkbox" checked="checked" name="autoRefreshCheckboxes"><?= $l_autorefresh ?></label>
228
				<table id="table_id" class="display">
229
				<thead>
2208 tom.houday 230
					<tr>
2822 rexy 231
						<th><b><?= $l_num_num ?></b></th>
232
						<th><b><?= $l_num_raison ?></b></th>
233
						<th><b><?= $l_num_expiration ?></b></th>
234
					</tr>
235
				</thead>
236
				<tbody>
237
					<?php foreach ($smsBanPerms as $smsBanPerm): ?>
238
						<tr>
239
							<td><?= $smsBanPerm->numberHidden ?></td>
240
							<?php if ($smsBanPerm->perm == '0'): ?>
2208 tom.houday 241
							<td><?= $l_num_exist ?></td>
2822 rexy 242
							<?php elseif ($smsBanPerm->perm == '1'): ?>
2208 tom.houday 243
							<td><?= $l_num_flood ?></td>
2822 rexy 244
							<?php endif ?>
245
							<td><?= $smsBanPerm->expiration ?></td>
246
						</tr>
247
					<?php endforeach; ?>
248
				</tbody>
249
				</table>
250
			</div>
2208 tom.houday 251
		</div>
252
	</div>
1349 richard 253
</body>
254
</html>