Subversion Repositories ALCASAR

Rev

Rev 2823 | 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 2850 2020-07-15 22:24: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";
40
	$l_num_exist		= "Compte actif";
41
	$l_num_flood		= "Numéro bloqué: nombre d'essai dépassé.";
42
	$l_num_num		= "Numero de téléphone";
43
	$l_num_raison		= "Etat de votre numéro";
44
	$l_num_expiration	= "Expiration du bloquage";
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.";	
50
	$l_tab_first		= "premier";
51
	$l_tab_last		= "dernier";
52
	$l_tab_next		= "suivant";
53
	$l_tab_prev		= "précédent";
54
	$l_tab_search		= "Recherche :";
55
	$l_tab_pmenu		= "Affiche la page _PAGE_ sur _PAGES_";
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";
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 telefónico";
64
	$l_num_raison		= "Estado de su número de teléfono";
65
	$l_num_expiration	= "Vencimiento";
66
	$l_tuto_1		= "Bienvenido a la página de auto-registro";
67
	$l_tuto_2		= "Este portal le permite inscribirse enviando la contraseña que elija por SMS al siguiente número (sin recargo): ";
68
	$l_tuto_3		= "Simplemente envíe 1 palabra en su SMS.";
69
	$l_tuto_4		= "Su registro se activará cuando encuentre su número de teléfono en la siguiente tabla. Este número de teléfono deberá utilizar para iniciar sesión";
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.";
71
	$l_tab_first		= "primero";
72
	$l_tab_last		= "último";
73
	$l_tab_next		= "siguiente";
74
	$l_tab_prev		= "anterior";
75
	$l_tab_search		= "Buscar :";
76
	$l_tab_pmenu		= "Mostrando _PAGE_ a _PAGE_ de _PAGE_ entradas :";
77
	$l_tab_info		= "Mostrar _MENU_ entradas";
78
	$l_tab_infoempty	= "No se encontraron registros coincidencias";
79
	$l_autorefresh		= "Actualizar: 10 seg";
2208 tom.houday 80
} else {			// English
81
	$l_title		= "Autoregistration";
82
	$l_num_exist		= "Account enables";
83
	$l_num_flood		= "Phone number banned: Number of trial exceeded.";
84
	$l_num_num		= "Phone number";
85
	$l_num_raison		= "Status of your phone number";
86
	$l_num_expiration	= "Expiration";
87
	$l_tuto_1		= "Welcome to the auto-enrollment page";
88
	$l_tuto_2		= "This portal allows you to enroll by sending the password of you choice via SMS to the following number (no surcharge) :";
89
	$l_tuto_3		= "Just send 1 word in your SMS.";
90
	$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";
91
	$l_tuto_5		= "You can search your phone number according to the 5 last digits in your phone number.";
92
	$l_tab_first		= "first";
93
	$l_tab_last		= "last";
94
	$l_tab_next		= "next";
95
	$l_tab_prev		= "previous";
96
	$l_tab_search		= "Search :";
97
	$l_tab_pmenu		= "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
98
	$l_tab_info		= "Show _MENU_ entries";
99
	$l_tab_infoempty	= "No matching records found";
100
	$l_autorefresh		= "Refresh: 10 sec";
101
}
1400 richard 102
 
2208 tom.houday 103
// Get SMS from database
104
require('/etc/freeradius-web/config.php');
2822 rexy 105
$img_rep         = '/images/';
106
$img_sms         = 'sms.png';
1400 richard 107
 
2208 tom.houday 108
$con = mysqli_connect($config['sql_server'], $config['sql_username'], $config['sql_password'], 'gammu');
109
 
110
if (mysqli_connect_errno()) {
111
	exit('Failed to connect to ' . $config['sql_type']/* . ': ' . mysqli_connect_error()*/);
1400 richard 112
}
2208 tom.houday 113
 
114
$result = mysqli_query($con, 'SELECT * FROM `SMS_ban_perm` ORDER BY date_add DESC;');
115
 
116
$smsBanPerms = [];
117
while ($row = mysqli_fetch_array($result)) {
118
	$smsBanPerms[] = (object) [
119
		'numberHidden' => substr($row['SenderNumber'], 0, 3) . '****' . substr($row['SenderNumber'], -5),
120
		'expiration'   => $row['Expiration'],
121
		'perm'         => $row['Perm']
122
	];
123
}
124
mysqli_close($con);
125
 
1400 richard 126
?>
2208 tom.houday 127
<!DOCTYPE html>
128
<html><!-- written by Rexy -->
1349 richard 129
<head>
2208 tom.houday 130
	<meta charset="utf-8">
2822 rexy 131
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
132
	<title>ALCASAR - <?= $l_title ?></title>
133
	<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
134
	<link rel="stylesheet" type="text/css" href="/css/index.css">
2809 rexy 135
	<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.css">
2823 rexy 136
	<link rel="icon" href="/images/favicon-48.ico" type="image/ico">
2822 rexy 137
	<script src="/js/jquery.min.js"></script>
138
	<script src="/js/jquery.dataTables.js"></script>
2208 tom.houday 139
	<script>
140
	function timedRefresh(timeoutPeriod) {
141
		var interval = setInterval(refreshPage, timeoutPeriod);
142
	}
1452 richard 143
 
2208 tom.houday 144
	function refreshPage() {
145
		if ($('input[name=autoRefreshCheckboxes]').is(':checked')) {
146
			location.reload(true);
147
		}
148
	}
1452 richard 149
 
2208 tom.houday 150
	$(document).ready( function () {
151
		$('#table_id').DataTable({
152
			"language": {
153
				"paginate": {
154
					"sFirst":    "<?= $l_tab_first ?>",
155
					"sLast":     "<?= $l_tab_last ?>",
156
					"sPrevious": "<?= $l_tab_prev ?>",
157
					"sNext":     "<?= $l_tab_next ?>"
158
				},
159
				"lengthMenu":  "<?= $l_tab_info ?>",
160
				"zeroRecords": "<?= $l_tab_infoempty ?>",
161
				"info":        "<?= $l_tab_pmenu ?>",
162
				"infoEmpty":   "<?= $l_tab_infoempty ?>",
163
				"sSearch":     "<?= $l_tab_search ?>"
164
			}
165
		});
1387 richard 166
	});
2208 tom.houday 167
	</script>
1349 richard 168
</head>
2208 tom.houday 169
<body onload="timedRefresh(10000);">
2822 rexy 170
	<div class="col-xs-12 col-md-10 col-md-offset-1"> 
171
		<!-- HeaderBox -->
172
		<div class="row banner">
173
			<!-- Logo box -->
174
			<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2"> 
175
				<img class="img-responsive img-organisme" src="images/organisme.png">
176
			</div>
177
			<!-- Title -->
178
			<div id="cadre_titre" class="titre_banner col-xs-12 col-sm-8">
179
					<p id="acces_controle" class="titre_controle"><?= $l_title ?></p>
180
			</div>
181
			<!-- Logo box -->
182
			<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2">
183
				<img class="img-responsive img-organisme" src="images/logo-alcasar_70.png">
184
			</div>
2208 tom.houday 185
		</div>
2822 rexy 186
		<!-- Main content box -->
187
		<div class="row">
188
			<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
189
				<h3><?= $l_tuto_2 ?></h3>
190
				<div class="menu-container container col_xs_12 col-sm-7">
191
					<div class="box_menu_right box_menu">
192
						<span><?= $current_num ?></span>
193
						<div class="menu-image">						
194
							<img class="img-responsive" src="<?= $img_rep.$img_sms ?>">
195
						</div>
196
					</div>
197
				</div>
198
				<div class="info-box-container col-sm-5">
199
					<div id="box_infos">
200
						<p class="box_infos_explanations"><?= $l_tuto_3 ?>
201
					</div>
202
				</div>
203
			</div>
204
		</div>
205
	<p>
206
		<div class="row">
207
			<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
208
				<h4><?= $l_tuto_4 ?></h4>
209
				<h4><?= $l_tuto_5 ?></h4>
210
				<label><input type="checkbox" checked="checked" name="autoRefreshCheckboxes"><?= $l_autorefresh ?></label>
211
				<table id="table_id" class="display">
212
				<thead>
2208 tom.houday 213
					<tr>
2822 rexy 214
						<th><b><?= $l_num_num ?></b></th>
215
						<th><b><?= $l_num_raison ?></b></th>
216
						<th><b><?= $l_num_expiration ?></b></th>
217
					</tr>
218
				</thead>
219
				<tbody>
220
					<?php foreach ($smsBanPerms as $smsBanPerm): ?>
221
						<tr>
222
							<td><?= $smsBanPerm->numberHidden ?></td>
223
							<?php if ($smsBanPerm->perm == '0'): ?>
2208 tom.houday 224
							<td><?= $l_num_exist ?></td>
2822 rexy 225
							<?php elseif ($smsBanPerm->perm == '1'): ?>
2208 tom.houday 226
							<td><?= $l_num_flood ?></td>
2822 rexy 227
							<?php endif ?>
228
							<td><?= $smsBanPerm->expiration ?></td>
229
						</tr>
230
					<?php endforeach; ?>
231
				</tbody>
232
				</table>
233
			</div>
2208 tom.houday 234
		</div>
235
	</div>
1349 richard 236
</body>
237
</html>