Subversion Repositories ALCASAR

Rev

Rev 2992 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
2992 rexy 1
<?php
2
#
3
# SMS Autoregistration
4
# By Rexy
5
 
6
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
7
 
8
// Read CONF_FILE
9
$file_conf = fopen(CONF_FILE, 'r');
10
if (!$file_conf) {
11
	exit('Error opening the file '.CONF_FILE);
12
}
13
while (!feof($file_conf)) {
14
	$buffer = fgets($file_conf, 4096);
15
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
16
		$tmp = explode('=', $buffer, 2);
17
		$conf[trim($tmp[0])] = trim($tmp[1]);
18
	}
19
}
20
fclose($file_conf);
21
 
22
// Check if the SMS service is enable
23
if ($conf['SMS'] !== 'on') {
24
	header('Location: /');
25
	exit();
26
}
3027 rexy 27
$page = "sms_registration";
2992 rexy 28
$organisme   = $conf['ORGANISM'];
29
$current_num = $conf['SMS_NUM'];
30
 
31
 
32
// Choice of language
33
$Language = 'en';
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		= "Numéro de GSM / identifiant de compte";
43
	$l_num_raison	= "État de votre numéro de GSM / compte";
44
	$l_num_expiration	= "Expiration";
45
	$l_tuto_1		= "Bienvenue sur la page d'auto enregistrement.";
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>";
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 GSM dans le tableau ci-dessous.";
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";
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 GSM / identificador de cuenta";
64
	$l_num_raison	= "Estado de su número GSM / cuenta";
65
	$l_num_expiration	= "Vencimiento";
66
	$l_tuto_1		= "Bienvenido a la página de auto-registro";
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> ";
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 GSM en la siguiente tabla.";
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";
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";
101
} else {			// English
102
	$l_title		= "Autoregistration";
103
	$l_num_exist		= "Account enabled";
104
	$l_num_flood		= "Phone number banned: Number of trial exceeded.";
105
	$l_num_num		= "Mobile phone number / account identifier";
106
	$l_num_raison		= "Status of your phone number / account";
107
	$l_num_expiration	= "Expiration";
108
	$l_tuto_1		= "Welcome to the auto-enrollment page";
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>";
110
	$l_tuto_3		= "Just send 1 word in your SMS.";
111
	$l_tuto_4		= "Your registration will be activated when you'll find your phone number in the following table.";
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
}
123
 
124
// Get SMS from database
125
require('/etc/freeradius-web/config.php');
126
$img_rep         = '/images/';
127
$img_sms         = 'sms.png';
128
 
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()*/);
133
}
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
 
147
?>
148
<!DOCTYPE html>
149
<html><!-- written by Rexy -->
150
<head>
151
	<meta charset="utf-8">
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">
156
	<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.css">
157
	<link rel="icon" href="/images/favicon-48.ico" type="image/ico">
158
	<script src="/js/jquery.min.js"></script>
159
	<script src="/js/jquery.dataTables.js"></script>
160
	<script>
161
	function timedRefresh(timeoutPeriod) {
162
		var interval = setInterval(refreshPage, timeoutPeriod);
163
	}
164
 
165
	function refreshPage() {
166
		if ($('input[name=autoRefreshCheckboxes]').is(':checked')) {
167
			location.reload(true);
168
		}
169
	}
170
 
171
	$(document).ready( function () {
172
		$('#table_id').DataTable({
173
			"order": [[ 2, "desc" ]],		
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 ?>"
186
				}
187
		});
188
	});
189
	</script>
190
</head>
191
<body onload="timedRefresh(10000);">
3027 rexy 192
	<div class="col-12 col-lg-10 offset-lg-1">
193
		<?php require_once(__DIR__.'/header.php'); ?>
2992 rexy 194
		<!-- Main content box -->
195
		<div class="row">
3027 rexy 196
			<div id="contenu_acces" class="col-12 offset-lg-1 col-lg-10">
2992 rexy 197
				<h3><?= $l_tuto_2 ?></h3>
3027 rexy 198
				<div class="menu-container container col-12 col-md-7">
2992 rexy 199
					<div class="box_menu_right box_menu">
200
						<span><?= $l_tuto_3 ?></span>
201
						<div class="menu-image">						
3027 rexy 202
							<img class="img-fluid" src="<?= $img_rep.$img_sms ?>">
2992 rexy 203
						</div>
204
					</div>
205
				</div>
206
			</div>
207
		</div>
208
	<p>
209
		<div class="row">
3027 rexy 210
			<div id="contenu_acces" class="col-12 offset-xl-1 col-xl-10">
2992 rexy 211
				<h4><?= $l_tuto_4 ?></h4>
212
				<h4><?= $l_tuto_5 ?></h4>
213
				<label><input type="checkbox" checked="checked" name="autoRefreshCheckboxes"><?= $l_autorefresh ?></label>
214
				<table id="table_id" class="display">
215
				<thead>
216
					<tr>
217
						<th><b><?= $l_num_num ?></b></th>
218
						<th><b><?= $l_num_raison ?></b></th>
219
						<th><b><?= $l_num_expiration ?></b></th>
220
					</tr>
221
				</thead>
222
				<tbody>
223
					<?php foreach ($smsBanPerms as $smsBanPerm): ?>
224
						<tr>
225
							<td><?= $smsBanPerm->numberHidden ?></td>
226
							<?php if ($smsBanPerm->perm == '0'): ?>
227
							<td><?= $l_num_exist ?></td>
228
							<?php elseif ($smsBanPerm->perm == '1'): ?>
229
							<td><?= $l_num_flood ?></td>
230
							<?php endif ?>
231
							<td><?= $smsBanPerm->expiration ?></td>
232
						</tr>
233
					<?php endforeach; ?>
234
				</tbody>
235
				</table>
236
			</div>
237
		</div>
238
	</div>
239
</body>
240
</html>