Subversion Repositories ALCASAR

Rev

Rev 2054 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2054 Rev 2208
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
# $Id: autoregistrationinfo.php 2208 2017-05-06 18:13:26Z tom.houdayer $
-
 
3
 
2
# CHECK IF the SMS service is enable
4
// CHECK IF the SMS service is enable
3
$service_SMS_status=false;
5
$service_SMS_status=false;
4
 
6
 
5
if(!$service_SMS_status){
7
if (!$service_SMS_status) {
6
	header('Location: ./');
8
	header('Location: /');
-
 
9
	exit();
7
}
10
}
8
?>
-
 
9
<?php
-
 
10
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
-
 
11
 
11
 
12
$ouvre=fopen(CONF_FILE,"r");
-
 
13
if($ouvre){
-
 
14
	while(!feof ($ouvre))
-
 
15
	{
-
 
16
		$tampon = fgets($ouvre, 4096);
-
 
17
		if(strpos($tampon,"=")!=false)
-
 
18
		{
-
 
19
			$tmp = explode("=",$tampon);
-
 
20
			$conf[$tmp[0]] = $tmp[1];
-
 
21
		}
-
 
22
		
-
 
23
	} 
-
 
24
} else {
-
 
25
	exit("Erreur d'ouverture du fichier".CONF_FILE);
-
 
26
}
-
 
27
fclose($ouvre);
-
 
28
$organisme = trim($conf["ORGANISM"]);
-
 
29
 
12
 
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'){
-
 
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
 
-
 
43
	$l_num_num = "Numero de téléphone";
13
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
44
	$l_num_raison = "Etat de votre numéro";
-
 
45
	$l_num_expiration = "Expiration du bloquage";
-
 
46
 
-
 
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.";	
-
 
52
 
-
 
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";
-
 
61
	$l_autorefresh = "Rafraichissement : 10 sec";
-
 
62
	
-
 
63
} elseif($Language == 'en'){
-
 
64
	$l_title = "Autoregistration";
-
 
65
	$l_num_exist = "Account enables";
-
 
66
	$l_num_flood = "Phone number banned: Number of trial exceeded.";
-
 
67
 
-
 
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.";	
-
 
77
	
-
 
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";
-
 
86
	
-
 
87
	$l_autorefresh = "Rafraichissement : 10 sec";
-
 
88
	
-
 
89
} else {
-
 
90
 
14
 
91
	$l_title = "Autoregistration";
-
 
92
	$l_num_exist = "Account enables";
-
 
93
	$l_num_flood = "Phone number banned: Number of trial exceeded.";
-
 
94
 
-
 
95
	$l_num_num = "Phone number";
-
 
96
	$l_num_raison = "Status of your phone number";
-
 
97
	$l_num_expiration = "Expiration";
-
 
98
 
-
 
99
	$l_tuto_1 = "Welcome";
-
 
100
	$l_tuto_2 = "You can have an acces to the Internet if you send a password via SMS to this phone number (no surcharge) :";
-
 
101
	$l_tuto_3 = "Just send 1 word in your SMS.";
-
 
102
	$l_tuto_4 = "If your registration is a success or a failure, you can find the raison in the table bellow.";
-
 
103
	$l_tuto_5 = "You can search your phone number according to the 5 last digits in your phone number.";	
-
 
104
	
-
 
105
	$l_tab_first = "first";
-
 
106
	$l_tab_last = "last";
-
 
107
	$l_tab_next = "next";
15
// Read CONF_FILE
108
	$l_tab_prev = "previous";
-
 
109
	$l_tab_search = "Search :";
-
 
110
	$l_tab_pmenu = "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
-
 
111
	$l_tab_info = "Show _MENU_ entries";
16
$file_conf = fopen(CONF_FILE, 'r');
112
	$l_tab_infoempty = "No matching records found";
-
 
113
	
-
 
114
	$l_autorefresh = "Refresh : 10 sec";
-
 
115
}
-
 
116
?>
-
 
117
<!DOCTYPE HTML>
-
 
118
<HTML><!-- written by Rexy -->
-
 
119
<head>
-
 
120
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-
 
121
<title>Auto enregistrement</title>
-
 
122
<link rel="stylesheet" href="/css/style_intercept.css">
-
 
123
<style type=text/css"></style>
-
 
124
<!-- DataTables CSS -->
17
if (!$file_conf) {
125
<link rel="stylesheet" type="text/css" href="../css/jquery.dataTables.css">
-
 
126
<!-- jQuery -->
-
 
127
<script type="text/javascript" charset="utf8" src="../js/jquery.js"></script>
-
 
128
<!-- DataTables -->
-
 
129
<script type="text/javascript" charset="utf8" src="../js/jquery.dataTables.js"></script>
-
 
130
<script type="text/javascript">
-
 
131
function timedRefresh(timeoutPeriod) {
18
	exit('Error opening the file '.CONF_FILE);
132
    var interval = setInterval(refreshPage, timeoutPeriod);
-
 
133
}
19
}
134
 
-
 
135
function refreshPage() {
20
while (!feof($file_conf)) {
-
 
21
	$buffer = fgets($file_conf, 4096);
136
    if ($("input[name=autoRefreshCheckboxes]").is(":checked")) {
22
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
137
        location.reload(true);
23
		$tmp = explode('=', $buffer);
-
 
24
		$conf[$tmp[0]] = trim($tmp[1]);
138
    }
25
	}
139
}
26
}
-
 
27
fclose($file_conf);
140
 
28
 
141
$(document).ready( function () {
29
$organisme = trim($conf["ORGANISM"]);
142
    $('#table_id').DataTable({
30
$current_num='XXXXXXXXXX';
143
		"language": {
-
 
144
			"paginate": {
-
 
145
			"sFirst": "<?php echo $l_tab_first; ?>",
-
 
146
			"sLast": "<?php echo $l_tab_last; ?>",
-
 
147
			"sPrevious": "<?php echo $l_tab_prev; ?>",
-
 
148
			"sNext": "<?php echo $l_tab_next; ?>"
-
 
149
			},
-
 
150
            "lengthMenu": "<?php echo $l_tab_info; ?>",
-
 
151
            "zeroRecords": "<?php echo $l_tab_infoempty; ?>",
-
 
152
            "info": "<?php echo $l_tab_pmenu; ?>",
-
 
153
            "infoEmpty": "<?php echo $l_tab_infoempty; ?>",
-
 
154
			"sSearch": "<?php echo $l_tab_search; ?>"
-
 
155
        }
-
 
156
	});
-
 
157
} );
-
 
158
</script>
-
 
159
</head>
-
 
160
<body onload="JavaScript:timedRefresh(10000);">
-
 
161
 
31
 
162
<center>
-
 
163
 
32
 
-
 
33
// Choice of language
-
 
34
$Language = 'en';
-
 
35
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
-
 
36
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
-
 
37
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
-
 
38
}
-
 
39
if ($Language === 'fr') {	// French
-
 
40
	$l_title		= "Page d'auto enregistrement";
-
 
41
	$l_num_exist		= "Compte actif";
-
 
42
	$l_num_flood		= "Numéro bloqué: nombre d'essai dépassé.";
-
 
43
 
-
 
44
	$l_num_num		= "Numero de téléphone";
-
 
45
	$l_num_raison		= "Etat de votre numéro";
-
 
46
	$l_num_expiration	= "Expiration du bloquage";
-
 
47
 
-
 
48
	$l_tuto_1		= "Bienvenue sur la page d'auto enregistrement.";
-
 
49
	$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é).";
-
 
50
	$l_tuto_3		= "Votre SMS ne doit contenir qu'un seul mot.";
-
 
51
	$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";
-
 
52
	$l_tuto_5		= "Le champ de recherche ci-dessous vous permet de retrouver votre numéro suivant les 5 derniers chiffres.";	
-
 
53
 
-
 
54
	$l_tab_first		= "premier";
-
 
55
	$l_tab_last		= "dernier";
-
 
56
	$l_tab_next		= "suivant";
-
 
57
	$l_tab_prev		= "précédent";
-
 
58
	$l_tab_search		= "Recherche :";
-
 
59
	$l_tab_pmenu		= "Affiche la page _PAGE_ sur _PAGES_";
-
 
60
	$l_tab_info		= "Montrer _MENU_ résultats par page";
-
 
61
	$l_tab_infoempty	= "Aucun résultat";
-
 
62
 
-
 
63
	$l_autorefresh		= "Rafraichissement : 10 sec";
-
 
64
} else {			// English
-
 
65
	$l_title		= "Autoregistration";
-
 
66
	$l_num_exist		= "Account enables";
-
 
67
	$l_num_flood		= "Phone number banned: Number of trial exceeded.";
-
 
68
 
-
 
69
	$l_num_num		= "Phone number";
-
 
70
	$l_num_raison		= "Status of your phone number";
-
 
71
	$l_num_expiration	= "Expiration";
-
 
72
 
-
 
73
	$l_tuto_1		= "Welcome to the auto-enrollment page";
-
 
74
	$l_tuto_2		= "This portal allows you to enroll by sending the password of you choice via SMS to the following number (no surcharge) :";
-
 
75
	$l_tuto_3		= "Just send 1 word in your SMS.";
-
 
76
	$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";
-
 
77
	$l_tuto_5		= "You can search your phone number according to the 5 last digits in your phone number.";
-
 
78
	
-
 
79
	$l_tab_first		= "first";
-
 
80
	$l_tab_last		= "last";
-
 
81
	$l_tab_next		= "next";
-
 
82
	$l_tab_prev		= "previous";
-
 
83
	$l_tab_search		= "Search :";
-
 
84
	$l_tab_pmenu		= "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
-
 
85
	$l_tab_info		= "Show _MENU_ entries";
-
 
86
	$l_tab_infoempty	= "No matching records found";
164
 
87
 
165
<div id="logon">
-
 
166
<h1><?php echo "$organisme" ?></h1>
-
 
167
<h2><?php echo "$l_title" ?></h2>
-
 
168
<div>
-
 
169
<table id="boite-info">
-
 
170
	<tr>
-
 
171
		<td rowspan="6" width="30%"><img id="logo-organ" src="/images/organisme.png"></td>
-
 
172
	</tr>
-
 
173
	<tr>
-
 
174
		<td><?php echo "$l_tuto_1" ?></td>
88
	$l_autorefresh		= "Refresh: 10 sec";
175
	</tr>
-
 
176
	<tr>
-
 
177
		<td><?php echo "$l_tuto_2" ?></td>
-
 
178
	</tr>
-
 
179
 
89
}
180
	<tr>
-
 
181
		<td align="center">
-
 
182
			<h3>	
-
 
183
			<?php 	
-
 
184
				$current_num='XXXXXXXXXX';
-
 
185
				echo "$current_num";
-
 
186
			?>
-
 
187
			</h3>
-
 
188
		</td>
-
 
189
	</tr>
-
 
190
 
-
 
191
	<tr>
-
 
192
		<td><?php echo "$l_tuto_3" ?></td>
-
 
193
	</tr>
-
 
194
	<tr>
-
 
195
		<td><?php echo "$l_tuto_4" ?></td>
-
 
196
	</tr>
-
 
197
<!--	<tr>
-
 
198
		<td colspan="2"><?php echo "$l_tuto_5" ?></td>
-
 
199
	</tr>
-
 
200
-->
-
 
201
</table>
-
 
202
</div>
-
 
203
<?php
-
 
204
 
90
 
-
 
91
// Get SMS from database
205
require('/etc/freeradius-web/config.php');
92
require('/etc/freeradius-web/config.php');
206
 
93
 
207
$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
94
$con = mysqli_connect($config['sql_server'], $config['sql_username'], $config['sql_password'], 'gammu');
208
 
95
 
209
if(mysqli_connect_errno())
96
if (mysqli_connect_errno()) {
210
{
-
 
211
	echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
97
	exit('Failed to connect to ' . $config['sql_type']/* . ': ' . mysqli_connect_error()*/);
212
}
98
}
213
 
99
 
214
$result = mysqli_query($con, "SELECT * 
100
$result = mysqli_query($con, 'SELECT * FROM `SMS_ban_perm` ORDER BY date_add DESC;');
-
 
101
 
-
 
102
$smsBanPerms = [];
-
 
103
while ($row = mysqli_fetch_array($result)) {
215
				FROM `SMS_ban_perm` 
104
	$smsBanPerms[] = (object) [
-
 
105
		'numberHidden' => substr($row['SenderNumber'], 0, 3) . '****' . substr($row['SenderNumber'], -5),
-
 
106
		'expiration'   => $row['Expiration'],
216
				ORDER BY date_add DESC;");
107
		'perm'         => $row['Perm']
-
 
108
	];
-
 
109
}
-
 
110
mysqli_close($con);
-
 
111
 
217
?>
112
?>
218
<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' ><?php echo $l_autorefresh; ?></input>
-
 
-
 
113
<!DOCTYPE html>
219
<table id="table_id" class="display">
114
<html><!-- written by Rexy -->
220
    <thead>
115
<head>
221
        <tr>
116
	<meta charset="utf-8">
222
            <th><b><?php echo $l_num_num; ?></b></th>
-
 
223
			<th><b><?php echo $l_num_raison; ?></b></th>
117
	<title>Auto enregistrement</title>
224
			<th><b><?php echo $l_num_expiration; ?></b></th>
118
	<link rel="stylesheet" type="text/css" href="/css/style_intercept.css">
225
        </tr>
119
	<!-- DataTables CSS -->
226
    </thead>
120
	<link rel="stylesheet" type="text/css" href="../css/jquery.dataTables.css">
227
    <tbody>
121
	<!-- jQuery -->
228
<?php 
-
 
229
while($row = mysqli_fetch_array($result))
122
	<script charset="utf8" src="../js/jquery.js"></script>
230
{
-
 
231
	$start = substr($row['SenderNumber'], 0, 3);
123
	<!-- DataTables -->
232
	$end = substr($row['SenderNumber'], -5);
124
	<script charset="utf8" src="../js/jquery.dataTables.js"></script>
233
	echo "	
-
 
234
		<tr>
125
	<script>
235
		<td>".$start."****".$end."</td>";
126
	function timedRefresh(timeoutPeriod) {
236
	
-
 
237
	if($row['Perm']=='0')
-
 
238
	{
-
 
239
		echo "<td>$l_num_exist</td>";
127
		var interval = setInterval(refreshPage, timeoutPeriod);
240
	}
128
	}
-
 
129
 
241
	if($row['Perm']=='1')
130
	function refreshPage() {
-
 
131
		if ($('input[name=autoRefreshCheckboxes]').is(':checked')) {
-
 
132
			location.reload(true);
242
	{
133
		}
243
		echo "<td>$l_num_flood</td>";
-
 
244
	}
134
	}
245
	echo "	<td>" . $row['Expiration']. "</td>
-
 
246
		</tr>";
-
 
247
}
-
 
248
?>
-
 
249
    </tbody>
-
 
250
</table>
-
 
251
 
135
 
-
 
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
		});
-
 
152
	});
-
 
153
	</script>
-
 
154
</head>
-
 
155
<body onload="timedRefresh(10000);">
-
 
156
	<center>
-
 
157
	<div id="logon">
-
 
158
		<h1><?= $organisme ?></h1>
-
 
159
		<h2><?= $l_title ?></h2>
-
 
160
 
-
 
161
		<div>
-
 
162
		<table id="boite-info">
-
 
163
			<tr>
-
 
164
				<td rowspan="6" width="30%"><img id="logo-organ" src="/images/organisme.png"></td>
-
 
165
			</tr>
-
 
166
			<tr>
-
 
167
				<td><?= $l_tuto_1 ?></td>
-
 
168
			</tr>
-
 
169
			<tr>
-
 
170
				<td><?= $l_tuto_2 ?></td>
-
 
171
			</tr>
-
 
172
			<tr>
-
 
173
				<td align="center"><h3><?= $current_num ?></h3></td>
-
 
174
			</tr>
-
 
175
			<tr>
-
 
176
				<td><?= $l_tuto_3 ?></td>
-
 
177
			</tr>
-
 
178
			<tr>
-
 
179
				<td><?= $l_tuto_4 ?></td>
-
 
180
			</tr>
-
 
181
<!--
-
 
182
			<tr>
-
 
183
				<td colspan="2"><?= $l_tuto_5 ?></td>
-
 
184
			</tr>
-
 
185
-->
-
 
186
		</table>
-
 
187
		</div>
-
 
188
 
-
 
189
		<div>
-
 
190
		<label><input type="checkbox" checked="checked" name="autoRefreshCheckboxes"><?= $l_autorefresh ?></label>
-
 
191
		<table id="table_id" class="display">
-
 
192
			<thead>
-
 
193
				<tr>
-
 
194
					<th><b><?= $l_num_num ?></b></th>
-
 
195
					<th><b><?= $l_num_raison ?></b></th>
-
 
196
					<th><b><?= $l_num_expiration ?></b></th>
-
 
197
				</tr>
-
 
198
			</thead>
-
 
199
			<tbody>
-
 
200
				<?php foreach ($smsBanPerms as $smsBanPerm): ?>
-
 
201
					<tr>
-
 
202
						<td><?= $smsBanPerm->numberHidden ?></td>
-
 
203
 
-
 
204
						<?php if ($smsBanPerm->perm == '0'): ?>
-
 
205
							<td><?= $l_num_exist ?></td>
-
 
206
						<?php elseif ($smsBanPerm->perm == '1'): ?>
-
 
207
							<td><?= $l_num_flood ?></td>
-
 
208
						<?php endif ?>
-
 
209
 
-
 
210
						<td><?= $smsBanPerm->expiration ?></td>
-
 
211
					</tr>
252
<?php mysqli_close($con); ?>
212
				<?php endforeach; ?>
-
 
213
			</tbody>
-
 
214
		</table>
253
<br />
215
		</div>
254
</div>
216
	</div>
255
</center>
217
	</center>
256
</body>
218
</body>
257
</html>
219
</html>