1349 |
richard |
1 |
<?php
|
2208 |
tom.houday |
2 |
# $Id: autoregistrationinfo.php 2822 2020-05-23 16:03:33Z 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é.";
|
1400 |
richard |
42 |
|
2208 |
tom.houday |
43 |
$l_num_num = "Numero de téléphone";
|
|
|
44 |
$l_num_raison = "Etat de votre numéro";
|
|
|
45 |
$l_num_expiration = "Expiration du bloquage";
|
1400 |
richard |
46 |
|
2208 |
tom.houday |
47 |
$l_tuto_1 = "Bienvenue sur la page d'auto enregistrement.";
|
|
|
48 |
$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é).";
|
|
|
49 |
$l_tuto_3 = "Votre SMS ne doit contenir qu'un seul mot.";
|
|
|
50 |
$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";
|
|
|
51 |
$l_tuto_5 = "Le champ de recherche ci-dessous vous permet de retrouver votre numéro suivant les 5 derniers chiffres.";
|
1400 |
richard |
52 |
|
2208 |
tom.houday |
53 |
$l_tab_first = "premier";
|
|
|
54 |
$l_tab_last = "dernier";
|
|
|
55 |
$l_tab_next = "suivant";
|
|
|
56 |
$l_tab_prev = "précédent";
|
|
|
57 |
$l_tab_search = "Recherche :";
|
|
|
58 |
$l_tab_pmenu = "Affiche la page _PAGE_ sur _PAGES_";
|
|
|
59 |
$l_tab_info = "Montrer _MENU_ résultats par page";
|
|
|
60 |
$l_tab_infoempty = "Aucun résultat";
|
1400 |
richard |
61 |
|
2208 |
tom.houday |
62 |
$l_autorefresh = "Rafraichissement : 10 sec";
|
|
|
63 |
} else { // English
|
|
|
64 |
$l_title = "Autoregistration";
|
|
|
65 |
$l_num_exist = "Account enables";
|
|
|
66 |
$l_num_flood = "Phone number banned: Number of trial exceeded.";
|
1400 |
richard |
67 |
|
2208 |
tom.houday |
68 |
$l_num_num = "Phone number";
|
|
|
69 |
$l_num_raison = "Status of your phone number";
|
|
|
70 |
$l_num_expiration = "Expiration";
|
|
|
71 |
|
|
|
72 |
$l_tuto_1 = "Welcome to the auto-enrollment page";
|
|
|
73 |
$l_tuto_2 = "This portal allows you to enroll by sending the password of you choice via SMS to the following number (no surcharge) :";
|
|
|
74 |
$l_tuto_3 = "Just send 1 word in your SMS.";
|
|
|
75 |
$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";
|
|
|
76 |
$l_tuto_5 = "You can search your phone number according to the 5 last digits in your phone number.";
|
1400 |
richard |
77 |
|
2208 |
tom.houday |
78 |
$l_tab_first = "first";
|
|
|
79 |
$l_tab_last = "last";
|
|
|
80 |
$l_tab_next = "next";
|
|
|
81 |
$l_tab_prev = "previous";
|
|
|
82 |
$l_tab_search = "Search :";
|
|
|
83 |
$l_tab_pmenu = "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
|
|
|
84 |
$l_tab_info = "Show _MENU_ entries";
|
|
|
85 |
$l_tab_infoempty = "No matching records found";
|
1400 |
richard |
86 |
|
2208 |
tom.houday |
87 |
$l_autorefresh = "Refresh: 10 sec";
|
|
|
88 |
}
|
1400 |
richard |
89 |
|
2208 |
tom.houday |
90 |
// Get SMS from database
|
|
|
91 |
require('/etc/freeradius-web/config.php');
|
2822 |
rexy |
92 |
$img_rep = '/images/';
|
|
|
93 |
$img_sms = 'sms.png';
|
1400 |
richard |
94 |
|
2208 |
tom.houday |
95 |
$con = mysqli_connect($config['sql_server'], $config['sql_username'], $config['sql_password'], 'gammu');
|
|
|
96 |
|
|
|
97 |
if (mysqli_connect_errno()) {
|
|
|
98 |
exit('Failed to connect to ' . $config['sql_type']/* . ': ' . mysqli_connect_error()*/);
|
1400 |
richard |
99 |
}
|
2208 |
tom.houday |
100 |
|
|
|
101 |
$result = mysqli_query($con, 'SELECT * FROM `SMS_ban_perm` ORDER BY date_add DESC;');
|
|
|
102 |
|
|
|
103 |
$smsBanPerms = [];
|
|
|
104 |
while ($row = mysqli_fetch_array($result)) {
|
|
|
105 |
$smsBanPerms[] = (object) [
|
|
|
106 |
'numberHidden' => substr($row['SenderNumber'], 0, 3) . '****' . substr($row['SenderNumber'], -5),
|
|
|
107 |
'expiration' => $row['Expiration'],
|
|
|
108 |
'perm' => $row['Perm']
|
|
|
109 |
];
|
|
|
110 |
}
|
|
|
111 |
mysqli_close($con);
|
|
|
112 |
|
1400 |
richard |
113 |
?>
|
2208 |
tom.houday |
114 |
<!DOCTYPE html>
|
|
|
115 |
<html><!-- written by Rexy -->
|
1349 |
richard |
116 |
<head>
|
2208 |
tom.houday |
117 |
<meta charset="utf-8">
|
2822 |
rexy |
118 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
119 |
<title>ALCASAR - <?= $l_title ?></title>
|
|
|
120 |
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
|
|
|
121 |
<link rel="stylesheet" type="text/css" href="/css/index.css">
|
2809 |
rexy |
122 |
<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.css">
|
2822 |
rexy |
123 |
<script src="/js/jquery.min.js"></script>
|
|
|
124 |
<script src="/js/jquery.dataTables.js"></script>
|
2208 |
tom.houday |
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);">
|
2822 |
rexy |
156 |
<div class="col-xs-12 col-md-10 col-md-offset-1">
|
|
|
157 |
<!-- HeaderBox -->
|
|
|
158 |
<div class="row banner">
|
|
|
159 |
<!-- Logo box -->
|
|
|
160 |
<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2">
|
|
|
161 |
<img class="img-responsive img-organisme" src="images/organisme.png">
|
|
|
162 |
</div>
|
|
|
163 |
<!-- Title -->
|
|
|
164 |
<div id="cadre_titre" class="titre_banner col-xs-12 col-sm-8">
|
|
|
165 |
<p id="acces_controle" class="titre_controle"><?= $l_title ?></p>
|
|
|
166 |
</div>
|
|
|
167 |
<!-- Logo box -->
|
|
|
168 |
<div class="img_banner hidden-xs col-sm-3 col-md-2 col-lg-2">
|
|
|
169 |
<img class="img-responsive img-organisme" src="images/logo-alcasar_70.png">
|
|
|
170 |
</div>
|
2208 |
tom.houday |
171 |
</div>
|
2822 |
rexy |
172 |
<!-- Main content box -->
|
|
|
173 |
<div class="row">
|
|
|
174 |
<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
|
|
|
175 |
<h3><?= $l_tuto_2 ?></h3>
|
|
|
176 |
<div class="menu-container container col_xs_12 col-sm-7">
|
|
|
177 |
<div class="box_menu_right box_menu">
|
|
|
178 |
<span><?= $current_num ?></span>
|
|
|
179 |
<div class="menu-image">
|
|
|
180 |
<img class="img-responsive" src="<?= $img_rep.$img_sms ?>">
|
|
|
181 |
</div>
|
|
|
182 |
</div>
|
|
|
183 |
</div>
|
|
|
184 |
<div class="info-box-container col-sm-5">
|
|
|
185 |
<div id="box_infos">
|
|
|
186 |
<p class="box_infos_explanations"><?= $l_tuto_3 ?>
|
|
|
187 |
</div>
|
|
|
188 |
</div>
|
|
|
189 |
</div>
|
|
|
190 |
</div>
|
|
|
191 |
<p>
|
|
|
192 |
<div class="row">
|
|
|
193 |
<div id="contenu_acces" class="col-xs-12 col-lg-offset-1 col-lg-10">
|
|
|
194 |
<h4><?= $l_tuto_4 ?></h4>
|
|
|
195 |
<h4><?= $l_tuto_5 ?></h4>
|
|
|
196 |
<label><input type="checkbox" checked="checked" name="autoRefreshCheckboxes"><?= $l_autorefresh ?></label>
|
|
|
197 |
<table id="table_id" class="display">
|
|
|
198 |
<thead>
|
2208 |
tom.houday |
199 |
<tr>
|
2822 |
rexy |
200 |
<th><b><?= $l_num_num ?></b></th>
|
|
|
201 |
<th><b><?= $l_num_raison ?></b></th>
|
|
|
202 |
<th><b><?= $l_num_expiration ?></b></th>
|
|
|
203 |
</tr>
|
|
|
204 |
</thead>
|
|
|
205 |
<tbody>
|
|
|
206 |
<?php foreach ($smsBanPerms as $smsBanPerm): ?>
|
|
|
207 |
<tr>
|
|
|
208 |
<td><?= $smsBanPerm->numberHidden ?></td>
|
|
|
209 |
<?php if ($smsBanPerm->perm == '0'): ?>
|
2208 |
tom.houday |
210 |
<td><?= $l_num_exist ?></td>
|
2822 |
rexy |
211 |
<?php elseif ($smsBanPerm->perm == '1'): ?>
|
2208 |
tom.houday |
212 |
<td><?= $l_num_flood ?></td>
|
2822 |
rexy |
213 |
<?php endif ?>
|
|
|
214 |
<td><?= $smsBanPerm->expiration ?></td>
|
|
|
215 |
</tr>
|
|
|
216 |
<?php endforeach; ?>
|
|
|
217 |
</tbody>
|
|
|
218 |
</table>
|
|
|
219 |
</div>
|
2208 |
tom.houday |
220 |
</div>
|
|
|
221 |
</div>
|
1349 |
richard |
222 |
</body>
|
|
|
223 |
</html>
|