Subversion Repositories ALCASAR

Rev

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