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