Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1387 richard 1
<?php
2185 tom.houday 2
# $Id: autoregistration.php 2299 2017-06-22 08:45:24Z tom.houdayer $
3
 
2294 richard 4
# Test if 3G/4G key is plugged 
5
$exec_com=exec("lsusb | grep -i 067b: | cut -d ' ' -f6"); // converter "USB to UART" PL2303 (several USB-serial cables, Wavecom GSM Modem)
6
$exec_com2=exec("lsusb | grep -i 12d1: | cut -d ' ' -f6"); // Huawei Technologies (E220/E230/E270/E870
7
//$exec_com2=exec("lsusb | grep -i 2001: | cut -d ' ' -f6"); // Dlink (to test)
1380 richard 8
 
1349 richard 9
$status_key="false";
10
$script="/usr/local/bin/alcasar-sms.sh";
11
 
12
#Define
13
$gammu_puk = "";
14
$gammu_simfail = "";
15
$gammu_simsecu = "";
16
$gammu_writeerror = "";
17
$gammu_timeout = "";
18
$error_pin = "";
19
$error_time_account = "";
20
$error_nb_essais = "";
21
$error_time_perm = "";
22
$error_num_alcasar = "";
1416 richard 23
$country_filter="";
1349 richard 24
 
25
# Choice of language
26
$Language = 'en';
27
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
1380 richard 28
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
29
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
1349 richard 30
if($Language == 'fr'){
31
	$l_title = "Auto enregistrement (SMS)";
32
	$l_conf = "Configuration";
33
	$l_conf_actu = "Configuration actuelle";
34
	$l_pin = "Code PIN";
2294 richard 35
	$l_num_alcasar = "Numero de téléphone du MODEM GSM";
1380 richard 36
	$l_ban_temp = "Nombre d'essais avant le blocage";
1349 richard 37
	$l_time_account = "Durée pour une session créée";
1380 richard 38
	$l_time_perm = "Durée du blocage (en jours)";
1349 richard 39
	$l_status_gammu = "Etat du service";
40
	$l_start = "Démarrer";
2294 richard 41
	$l_status_device = "Status de votre MODEM GSM (clé 2G/3G/4G)";
1387 richard 42
	$l_key_diseable = "Aucun périphérique détecté";
2294 richard 43
	$l_key_enable = "Votre MODEM GSM est connectée à la vitesse de : ";
1349 richard 44
	$l_force_signal = "Force du signal";
45
	$l_imei_device = "IMEI du périphérique";
46
	$l_sms_received = "Nombre de SMS reçu";
47
	$l_stop = "Arrêter";
2294 richard 48
	$l_gammu_on="Le service est démarré";
49
	$l_gammu_off="Le service est arrêté";
50
	$l_edit = "Modifier";
1349 richard 51
	$l_error_label_empty = "Le champ est vide";
52
	$l_error_label_num = "Ce n'est pas un PIN valide";
53
	$l_error_label_num2 = "Ce n'est pas un nombre";
1380 richard 54
	$l_error_label_num3 = "Le format n'est pas correct: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
2294 richard 55
	$l_error_writefail = "Le service ne parvient pas à discuter avec le port du MODEM GSM (ttyUSB0).";
56
	$l_error_timeoutfail = "Impossible de se connecter au MODEM GSM (vérifiez la vitesse de connexion)";
1349 richard 57
	$l_error_simfail = "Un problème au niveau de la carte SIM a été détecté. Est elle présente?";
58
	$l_error_simsecu_l = "Attention, lors du dernier démarrage, votre code PIN était erroné.<br>
1380 richard 59
					La SIM doit être bloqué (code PUK). Consultez la documentation.";
1349 richard 60
	$l_autorefresh = "Rafraichissement : 30 sec";
61
	$l_days = "jours ";
62
	$l_num_block="Liste des numéros bloqués";
63
	$l_num_num="Numéro";
64
	$l_num_raison="Raison";
65
	$l_num_expiration="Date d'expiration";
66
	$l_num_action="Action";
67
	$l_num_exist="Un compte a été créé";
1416 richard 68
	$l_num_flood="Le nombre d'essais maximum a été dépassé";
1349 richard 69
	$l_num_unlock="Effacer";
1416 richard 70
	$l_country_enable="Activer";
71
	$l_country_disable="Désactiver";
1349 richard 72
	$l_service_status_img_ok="Démarré";
73
	$l_service_status_img_ko="Arrété";
2294 richard 74
	$l_conf_name="Modifier la vitesse de connexion : ";
1387 richard 75
	$l_tab_first = "premier";
76
	$l_tab_last = "dernier";
77
	$l_tab_next = "suivant";
78
	$l_tab_prev = "précédent";
79
	$l_tab_search = "Recherche :";
80
	$l_tab_pmenu = "Affiche la page _PAGE_ sur _PAGES_";
1416 richard 81
	$l_tab_info = "Montrer _MENU_ résultats par page";
1387 richard 82
	$l_tab_infoempty = "Aucun résultat";
1416 richard 83
	$l_country_filter = "Filtrage en cours : ";
84
	$l_country_filtering = " Filtrage par pays";
85
	$l_country_filtering_plus = " Filtrage par pays avancé";
86
	$l_phone_ban = " Numéro de téléphone bloqués";
87
	$l_country_france_ena = "Autorise les numéros français";
88
	$l_country_ue_ena = "Autorise les numéros européens";
89
	$l_country_all_ena = "Autorise tous les pays";
90
	$l_country_advanced_ena = "Autorisation personnalisé";
91
	$l_advance = "Avancé";
1349 richard 92
}
93
else {
94
	$l_title = "Auto registration (SMS)";
95
	$l_conf = "Configuration";
96
	$l_conf_actu = "Current configuration";
97
	$l_pin = "PIN password";
2294 richard 98
	$l_num_alcasar = "Phone number of the GSM MODEM";
1349 richard 99
	$l_ban_temp = "Max number of try before a permanent ban"; 
100
	$l_time_account = "Time for a new session";
101
	$l_time_perm = "Duration of a ban (for example, after X try)";
102
	$l_status_gammu = "Service status";
103
	$l_start = "Start";
2294 richard 104
	$l_status_device = "Status of your GSM MODEM (2G/3G/4G key)";
1387 richard 105
	$l_key_diseable = "No device detected";
2294 richard 106
	$l_key_enable = "Your GSM MODEM is connected at the speed of : ";
1349 richard 107
	$l_force_signal = "Signal strength";
108
	$l_imei_device = "Device IMEI";
109
	$l_sms_received = "Number of SMS received";
110
	$l_stop = "Stop";
2294 richard 111
	$l_gammu_on="The service is running";
112
	$l_gammu_off="The service is down";
113
	$l_edit = "Modify";
1349 richard 114
	$l_error_label_empty = "Field empty";
115
	$l_error_label_num = "It's not a valid PIN password";
116
	$l_error_label_num2 = "It's not a number";
1380 richard 117
	$l_error_label_num3 = "The phone number is not good: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
2294 richard 118
	$l_error_writefail = "Can not communicate with the GSM MODEM port (ttyUSB0).";
119
	$l_error_timeoutfail = "Can not connect to the GSM MODEM (verify the connection speed).";
1349 richard 120
	$l_error_simfail = "An issue with your Sim card was detected. Is it in the key?";
121
	$l_error_simsecu_l = "Warning, during the last startup, the PIN code was wrong. <br>
122
				The Sim card must be blocked. Please read the documentation.";
123
	$l_autorefresh = "Refresh : 30 sec";
124
	$l_days = "days ";
125
	$l_num_block="List of blocked phone";
126
	$l_num_num="Phone number";
127
	$l_num_raison="Reason";
128
	$l_num_expiration="Expiration date";
129
	$l_num_action="Action";
130
	$l_num_exist="An account has been created";
131
	$l_num_flood="The number of try has been reached";
132
	$l_num_unlock="Erase";
1416 richard 133
	$l_country_enable="Enable";
134
	$l_country_disable="Disable";
1349 richard 135
	$l_service_status_img_ok="Running";
136
	$l_service_status_img_ko="Stopped";
2294 richard 137
	$l_conf_name="Modify the speed : ";
1387 richard 138
	$l_tab_first = "first";
139
	$l_tab_last = "last";
140
	$l_tab_next = "next";
141
	$l_tab_prev = "previous";
142
	$l_tab_search = "Search :";
143
	$l_tab_pmenu = "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
144
	$l_tab_info = "Show _MENU_ entries";
145
	$l_tab_infoempty = "No matching records found";
1416 richard 146
	$l_country_filter = "Current filtering : ";
147
	$l_country_filtering = " Country filtering";
148
	$l_country_filtering_plus = " Country filtering advanced";
149
	$l_phone_ban = " Phone Number banned";
150
	$l_country_france_ena = "Authorize the french numbers";
151
	$l_country_ue_ena = "Authorize european numbers";
152
	$l_country_all_ena = "Authorize all countries";
153
	$l_country_advanced_ena = "Advanced Authorization";
154
	$l_advance = "Advanced";
1349 richard 155
}
1387 richard 156
?>
157
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
158
<HTML><!-- written by Rexy -->
159
<head>
1416 richard 160
<!--<META HTTP-EQUIV="Refresh" CONTENT="30">-->
1387 richard 161
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
162
<title>Auto enregistrement</title>
163
<link rel="stylesheet" href="/css/style.css">
164
<!-- DataTables CSS -->
2294 richard 165
<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.css">
1387 richard 166
<!-- jQuery -->
2294 richard 167
<script type="text/javascript" charset="utf8" src="/js/jquery.js"></script>
1387 richard 168
<!-- DataTables -->
2294 richard 169
<script type="text/javascript" charset="utf8" src="/js/jquery.dataTables.js"></script>
1387 richard 170
<script type="text/javascript">
1416 richard 171
function timedRefresh(timeoutPeriod) {
172
    var interval = setInterval(refreshPage, timeoutPeriod);
173
}
174
 
175
function refreshPage() {
176
    if ($("input[name=autoRefreshCheckboxes]").is(":checked")) {
177
        location.reload(true);
178
    }
179
}
180
 
1387 richard 181
$(document).ready( function () {
1416 richard 182
 
183
    	$('#table_id').DataTable({
1387 richard 184
		"language": {
185
			"paginate": {
1416 richard 186
			"sFirst": "<?php echo $l_tab_first; ?>",
1387 richard 187
			"sLast": "<?php echo $l_tab_last; ?>",
188
			"sPrevious": "<?php echo $l_tab_prev; ?>",
189
			"sNext": "<?php echo $l_tab_next; ?>"
190
			},
191
            "lengthMenu": "<?php echo $l_tab_info; ?>",
192
            "zeroRecords": "<?php echo $l_tab_infoempty; ?>",
193
            "info": "<?php echo $l_tab_pmenu; ?>",
194
            "infoEmpty": "<?php echo $l_tab_infoempty; ?>",
195
			"sSearch": "<?php echo $l_tab_search; ?>"
196
        }
197
	});
1416 richard 198
 
199
	$('#table_country').DataTable({
200
		"language": {
201
			"paginate": {
202
			"sFirst": "<?php echo $l_tab_first; ?>",
203
			"sLast": "<?php echo $l_tab_last; ?>",
204
			"sPrevious": "<?php echo $l_tab_prev; ?>",
205
			"sNext": "<?php echo $l_tab_next; ?>"
206
			},
207
            "lengthMenu": "<?php echo $l_tab_info; ?>",
208
            "zeroRecords": "<?php echo $l_tab_infoempty; ?>",
209
            "info": "<?php echo $l_tab_pmenu; ?>",
210
            "infoEmpty": "<?php echo $l_tab_infoempty; ?>",
211
			"sSearch": "<?php echo $l_tab_search; ?>"
212
        }
213
	});
214
	$(".showhide-div_country").slideUp("slow");	
215
	$(".showhide-div_ban").slideUp("slow");
216
	$(".showhide-div_country_plus").slideUp("slow");
217
	$(".showhide-but_country").on("click", function(){
218
	    $(".showhide-div_country").slideToggle("slow");
219
	});
220
	$(".showhide-but_country_plus").on("click", function(){
221
	    $(".showhide-div_country_plus").slideToggle("slow");
222
	});
223
	$(".showhide-but_ban").on("click", function(){
224
	    $(".showhide-div_ban").slideToggle("slow");
225
	});
1387 richard 226
} );
227
</script>
228
</head>
1416 richard 229
<body onload="JavaScript:timedRefresh(30000);">
1387 richard 230
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
231
<?php
1349 richard 232
echo "
233
	<tr>
234
		<th>$l_title</th>
235
	</tr>
236
	<tr bgcolor=\"#FFCC66\">
237
		<td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td>
238
	</tr>
239
	</TABLE>
240
	<br />
2294 richard 241
	<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' >".$l_autorefresh."
1349 richard 242
	";
243
?>
244
<center>
245
<br /><br />
2294 richard 246
<form form="GET" action="./autoregistration.php">
1349 richard 247
<table border=1 width=100%>
248
<tr>
2294 richard 249
<td colspan=2><h3><?php echo $l_status_device ?></h3></td>
1380 richard 250
</tr>
251
 
252
<tr>
1349 richard 253
<?php
254
if(!empty($exec_com) || !empty($exec_com2))
255
{
1380 richard 256
	if(isset($_GET['config_submit'])){
257
		switch ($_GET['config']) {
258
		case "at":
259
			exec("sudo $script --replace_connect  ");
260
			break;
261
		case "9600":
262
			exec("sudo $script --replace_connect 9600");
263
			break;
264
		case "19200":
265
			exec("sudo $script --replace_connect 19200");
266
			break;
267
		case "115200":
268
			exec("sudo $script --replace_connect 115200");
269
			break;
270
		}	
271
	}
272
	$current_connect = exec("sudo $script --connect");
2294 richard 273
	echo '<td width="50%">'.$l_key_enable.$current_connect.' Bauds</td>';
274
	echo '		<td align="right">	'.$l_conf_name.'
1380 richard 275
				<select name="config">
2294 richard 276
					<option value="at"></option>
277
					<option value="9600">9600 Bauds</option>
278
					<option value="19200">19200 Bauds</option>
279
					<option value="115200">115200 Bauds</option>
1380 richard 280
				</select>
2294 richard 281
				<input type="submit" name="config_submit"> 
1380 richard 282
			</td>
283
		';
1349 richard 284
	$status_key="true";
285
}
286
else
287
{
288
	echo "<td>$l_key_diseable</td>";
289
	$status_key="false";
290
}
291
?>
1380 richard 292
</tr>
1349 richard 293
</table>
2294 richard 294
</form>
1349 richard 295
</center>
296
<br /><br />
297
 
298
<?php
299
 
2294 richard 300
#Test if gammu is started
1452 richard 301
$gammu_pid=exec("sudo $script --pidof");
1349 richard 302
if ($status_key=="false")
303
{
304
	if ($gammu_pid!="")
305
	{
306
		exec("sudo $script stop");
307
		sleep(8);
308
		header('Location: autoregistration.php');	
309
	}
310
}
311
 
312
if ($status_key=="true")
313
{
314
	#Nom du fichier de log lorsque gammu est démarré
1387 richard 315
	#$file_log = "gammu-smsd.log";
1349 richard 316
 
317
	#Recuperation du code PIN actuel
318
	$current_pin = exec("sudo $script --pin");	
319
 
320
	#Recuperation du nombre de try avant le ban perm
321
	$current_try_ban = exec("sudo $script --try_ban");	
322
 
323
	#Recuperation de la durée d'une session créée
324
	$current_time_account = exec("sudo $script --time_account");	
325
 
326
	#Recuperation de la durée dun ban perm (après flood)
327
	$current_time_perm = exec("sudo $script --time_perm");	
328
 
329
	#Detection neméro de tel
330
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
331
 
332
	#Detection problème avec la SIM
333
	$current_simfail = exec("sudo $script --last_nosim");
334
 
335
	#Recuperation de la dernière ligne de START
336
	$current_last_start = exec("sudo $script --last_start");
337
 
338
	#Recuperarion de la dernière ligne de STOP
339
	$current_last_stop = exec("sudo $script --last_stop");
340
 
341
	#Recuperation de la dernière ligne de SECURITYERROR
342
	$current_last_secu = exec("sudo $script --last_secu");
343
 
344
	#Recuperation de la dernière ligne de DEVICEWRITEERROR
345
	$current_last_write = exec("sudo $script --last_writeerror");
346
 
347
	#Recuperation de la dernière ligne de TIMEOUT
348
	$current_last_timeout = exec("sudo $script --last_timeout");
1380 richard 349
 
350
	# Test si le service est lancé
1349 richard 351
	if ($gammu_pid=="")
352
	{
353
		$force_signal = "-";
354
		$imei_device = "-";
355
		$sms_received = "-";
356
 
357
		$gammu="<td><img src=\"/images/state_error.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ko."\"></td><td>$l_gammu_off</td>";	
358
		$gammu_status_on="";
359
		$gammu_status_off="disabled";
360
 
361
		if($current_last_secu!="")
362
		{
363
			if(($current_last_secu > $current_last_start) && ($current_last_secu < $current_last_stop))
364
			{
365
				$gammu_simsecu="<tr><td colspan=7><font color=red>$l_error_simsecu_l</font></td></tr>";	
366
			}
367
		}
368
	} else {
369
		# Recuperation de la force du signal et IMEI et nombre de sms reçu
370
		$val_force_signal = exec("sudo $script --signal_device");
371
		$imei_device = exec("sudo $script --imei_device");
372
		$sms_received = exec("sudo $script --sms_received");
373
 
374
		if ($val_force_signal < 21) {
375
			$force_signal = "<img src=\"/images/signal_0.png\">  --  ".$val_force_signal." %";
376
		} elseif ($val_force_signal < 41) {
377
			$force_signal = "<img src=\"/images/signal_20.png\">  --  ".$val_force_signal." %";
378
 
379
		} elseif ($val_force_signal < 61) {
380
			$force_signal = "<img src=\"/images/signal_40.png\">  --  ".$val_force_signal." %";
381
 
382
		} elseif ($val_force_signal < 81) {
383
			$force_signal = "<img src=\"/images/signal_60.png\">  --  ".$val_force_signal." %";
384
 
385
		} elseif ($val_force_signal < 101) {
386
			$force_signal = "<img src=\"/images/signal_80.png\">  --  ".$val_force_signal." %";
387
 
388
		}
389
 
390
 
391
 
392
 
393
 
394
		$gammu="<td><img src=\"/images/state_ok.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ok."\"></td><td>$l_gammu_on</td>";	
1387 richard 395
 
1349 richard 396
 
397
		if($current_last_timeout!=""){
398
			if(($current_last_timeout > $current_last_start) && ($current_last_timeout > $current_last_stop))
399
			{
400
				$gammu_timeout="<tr><td colspan=7><font color=red>$l_error_timeoutfail</font></td></tr>";	
401
			}
402
		}
403
 
404
		if($current_last_secu!="")
405
		{
406
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
407
			{
408
				exec("sudo $script --stop");
409
			}
410
		}
411
 
412
		if($current_last_write!=""){
413
			if(($current_last_write > $current_last_start) && ($current_last_write > $current_last_stop))
414
			{
415
				$gammu_writeerror="<tr><td colspan=7><font color=red>$l_error_writefail</font></td></tr>";	
416
			}
417
		}
418
 
419
		if($current_simfail!="")
420
		{
421
			if(($current_simfail > $current_last_start) && ($current_simfail > $current_last_stop))
422
			{
1380 richard 423
				$gammu_simfail="<tr><td colspan=7><font color=red>$l_error_simfail</font></td></tr>";
1349 richard 424
			}
425
		}
426
		$gammu_status_on="disabled";
427
		$gammu_status_off="";
428
	}
429
 
430
 
1380 richard 431
	#Lancement et arret de gammu-smsd 3*7sec
1349 richard 432
	if(isset($_GET["start"])){
433
		$gammu_1=exec("sudo $script --start");
434
		sleep(7);
435
 
436
		if($current_last_secu!="")
437
		{
438
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
439
			{
440
				exec("sudo $script --stop");
441
			}
442
		}
443
 
444
		sleep(7);
445
		if($current_last_secu!="")
446
		{
447
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
448
			{
449
				exec("sudo $script --stop");
450
			}
451
		}
452
 
453
		sleep(7);	
454
		if($current_last_secu!="")
455
		{
456
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
457
			{
458
				exec("sudo $script --stop");
459
			}
460
		}
461
 
462
 
463
 
464
		header('Location: autoregistration.php');
465
	}
466
 
467
	if(isset($_GET["stop"])){
468
		exec("sudo $script --stop");
469
		sleep(8);
470
		header('Location: autoregistration.php');
471
	}
472
 
473
 
474
	#Edition du NUMERO de telephone
475
	if(isset($_GET["b_num_alcasar"])){
476
		$num = $_GET["num_alcasar"];
477
		$error_num_alcasar = "";
478
		if($num !="")
479
		{
1380 richard 480
			if(preg_match('#^\+#',$num))
1349 richard 481
			{
2299 tom.houday 482
				exec("sudo $script --replace_numero_alcasar ".escapeshellarg($num));
1349 richard 483
				header('Location: autoregistration.php');
484
			}
485
			else
486
			{
1380 richard 487
				$error_num_alcasar=$l_error_label_num3;
1349 richard 488
			}
489
		}
490
		else
491
		{
492
			$error_num_alcasar=$l_error_label_empty;
493
		}
494
	}
495
 
496
	#Edition du code PIN
497
	if(isset($_GET["b_pin"])){
498
		$pin = $_GET["pin"];
499
		$error_pin = "";
500
		if($pin !="")
501
		{
502
			if(is_numeric($pin))
503
			{
2299 tom.houday 504
				exec("sudo $script --replace_pin ".escapeshellarg($pin));
1349 richard 505
				header('Location: autoregistration.php');
506
			}
507
			else
508
			{
509
				$error_pin=$l_error_label_num;			
510
			}
511
		}
512
		else
513
		{
514
			$error_pin=$l_error_label_empty;
515
		}
516
	}
1380 richard 517
 
518
 
1349 richard 519
	#Edition du nombre d'essais avant le ban perm
520
	if(isset($_GET["b_ban_temp"])){
521
		$nb_ban_temp = $_GET["nb_essais"];
522
		$error_nb_essais = "";
523
		if($nb_ban_temp !="")
524
		{
525
			if(is_numeric($nb_ban_temp))
526
			{
2299 tom.houday 527
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
1349 richard 528
				header('Location: autoregistration.php');
529
			}
530
			else
531
			{
532
				$error_nb_essais=$l_error_label_num2;			
533
			}
534
		}
535
		else
536
		{
537
			$error_nb_essais=$l_error_label_empty;
538
		}
539
	}
540
 
1380 richard 541
 
1349 richard 542
	#Edition de la durée pour un compte créé
543
	if(isset($_GET["b_time_account"])){
544
		$time_account = $_GET["time_account"];
545
		$error_time_account = "";
546
		if($time_account !="")
547
		{
548
			if(is_numeric($time_account))
549
			{
2299 tom.houday 550
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
1349 richard 551
				header('Location: autoregistration.php');
552
			}
553
			else
554
			{
1380 richard 555
				$error_time_account=$l_error_label_num2;
1349 richard 556
			}
557
		}
558
		else
559
		{
560
			$error_time_account=$l_error_label_empty;
561
		}
562
	}
563
 
564
	#Edition de la durée d'un ban perm (après flood)
565
	if(isset($_GET["b_time_perm"])){
566
		$time_perm = $_GET["time_perm"];
567
		$error_time_perm = "";
568
		if($time_perm !="")
569
		{
570
			if(is_numeric($time_perm))
571
			{
2299 tom.houday 572
				exec("sudo $script --replace_time_perm ".escapeshellarg($time_perm));
1349 richard 573
				header('Location: autoregistration.php');
574
			}
575
			else
576
			{
1380 richard 577
				$error_time_perm=$l_error_label_num2;
1349 richard 578
			}
579
		}
580
		else
581
		{
582
			$error_time_perm=$l_error_label_empty;
583
		}
584
	}
585
 
586
	# Suppression d'un numero bloqué
587
	if(isset($_GET['num_select'])){
588
		$numero=$_GET['num_select'];
589
 
2299 tom.houday 590
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
591
		exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
1349 richard 592
 
593
		exec("sudo $script --unlock_num $numero");
594
		header('Location: autoregistration.php');
595
	}
596
 
1416 richard 597
	# Edition etat pays
598
	if(isset($_GET['country_select'])){
599
		$country=utf8_decode($_GET['country_select']);
2299 tom.houday 600
		exec("sudo $script --change_country ".escapeshellarg($country));
1416 richard 601
		exec("sudo $script --change_country_filter advance");
602
		header('Location: autoregistration.php');
603
	}
1349 richard 604
 
1416 richard 605
	if(isset($_GET['b_france_enable'])){
606
		exec("sudo $script --change_country_dis_all");
607
		exec("sudo $script --change_country France");
608
		exec("sudo $script --change_country_filter fr");
609
		header('Location: autoregistration.php');
610
	}
1349 richard 611
 
1416 richard 612
	if(isset($_GET['b_ue_enable'])){
613
		exec("sudo $script --change_country_dis_all");
614
		$array_ue = array("Allemagne","Autriche","Belgique","Bulgarie","Chypre","Croatie","Danemark","Espagne","Estonie","Finlande","France","Grece","Hongrie","Irlande","Italie","Lettonie","Lituanie","Luxembourg","Malte","Pays-Bas"," Pologne","Portugal","Republique Tcheque","Roumanie","Angleterre","Slovaquie","Slovenie","Suede");
615
		foreach ($array_ue as $pays){
2299 tom.houday 616
			exec("sudo $script --change_country ".escapeshellarg($pays));
1416 richard 617
		}
618
 
619
		exec("sudo $script --change_country_filter ue");
620
		header('Location: autoregistration.php');
621
	}
622
 
623
	if(isset($_GET["b_country_enable"])){
624
		exec("sudo $script --change_country_ena_all");		
625
		exec("sudo $script --change_country_filter all");
626
		header('Location: autoregistration.php');
627
	}
628
 
629
	if(isset($_GET["b_country_disable"])){
630
		exec("sudo $script --change_country_dis_all");
631
		header('Location: autoregistration.php');
632
	}
633
 
634
 
1349 richard 635
	#Si une clé 3g est plugué
636
	echo "<form action=\"autoregistration.php\" methode=\"GET\">
637
 
638
		<table border=1>
639
		<tr>
1387 richard 640
			<td colspan=4><b>$l_status_gammu</b></td>
641
			<td><b><center>$l_force_signal</center></b></td>
642
			<td><b><center>$l_imei_device</center></b></td> 
643
			<td><b><center>$l_sms_received</center></b></td> 
1349 richard 644
		</tr>
645
		<tr>
1387 richard 646
			$gammu
647
			<td><button type=\"submit\" name=\"start\" $gammu_status_on>$l_start</button></td>		
648
			<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
649
			<td><center>$force_signal</center></td>
650
			<td><center>$imei_device</center></td>
651
			<td><center>$sms_received</center></td>
1349 richard 652
		</tr>
653
		$gammu_puk
654
		$gammu_simfail
655
		$gammu_simsecu
656
		$gammu_timeout
657
		$gammu_writeerror
658
		</table>
659
	<br /><br />
660
 
661
		<table border=1>
662
		<tr>
663
		<td colspan=3><b>$l_conf</b></td>
664
		<td><b>$l_conf_actu</b></td>
665
		</tr>
666
 
667
		<tr>
1380 richard 668
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
1349 richard 669
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
670
		<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
671
		</tr>
1380 richard 672
		<tr><td colspan=\"4\"><font color=red><b>$error_num_alcasar</b></font></td></tr>
1349 richard 673
 
1380 richard 674
		<tr>		
675
		<td> $l_pin </td><td><input type=text name='pin' maxlength=\"8\"></td>
1349 richard 676
		<td><button type=\"submit\" name=\"b_pin\" $gammu_status_on>$l_edit</button></td>
677
		<td><center><font color=\"green\">$current_pin</font></center></td>
678
		</tr>
1380 richard 679
		<tr><td colspan=\"4\"><font color=red><b>$error_pin</b></font></td></tr>
2294 richard 680
 
681
		<tr>
1380 richard 682
		<td> $l_time_account </td><td><input type=text name='time_account'> $l_days </td>
1349 richard 683
		<td><button type=\"submit\" name=\"b_time_account\" $gammu_status_on>$l_edit</button></td>	
684
		<td><center><font color=\"blue\">$current_time_account</font></center></td>
685
		</tr>
1380 richard 686
		<tr><td colspan=\"4\"><font color=red><b>$error_time_account</b></font></td></tr>
1349 richard 687
 
688
		<tr>
1380 richard 689
		<td> $l_ban_temp </td><td><input type=text name='nb_essais'></td>	
1349 richard 690
		<td><button type=\"submit\" name=\"b_ban_temp\" $gammu_status_on>$l_edit</button></td>	
691
		<td><center><font color=\"orange\">$current_try_ban</font></center></td>
692
		</tr>
1380 richard 693
		<tr><td colspan=\"4\"><font color=red><b>$error_nb_essais</b></font></td></tr>
1349 richard 694
 
695
		<tr>
1380 richard 696
		<td>$l_time_perm</td><td><input type=text name='time_perm'> $l_days</td>
1349 richard 697
		<td><button type=\"submit\" name=\"b_time_perm\" $gammu_status_on>$l_edit</button></td>	
698
		<td><center><font color=\"orange\">$current_time_perm</font></center></td>
699
		</tr>
1380 richard 700
		<tr><td colspan=\"4\"><font color=red><b>$error_time_perm</b></font></td></tr>
1349 richard 701
		</table>
1416 richard 702
		</form>";
703
 
1349 richard 704
 
705
	require('/etc/freeradius-web/config.php');
706
 
2185 tom.houday 707
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
708
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
1349 richard 709
	else{
710
		echo "<b>Could not include SQL library</b>\n";
711
		exit();
2185 tom.houday 712
	}
1349 richard 713
 
714
	$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
715
 
716
	if(mysqli_connect_errno())
717
	{
718
		echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
719
	}
720
 
721
 
1416 richard 722
	# Country table
723
 
1387 richard 724
?>
1416 richard 725
 
726
	<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
727
		 <span class="showhide-but_country"><?php echo "<strong>$l_country_filtering<strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
728
 
729
		<div class="showhide-div_country">
730
		<br />
731
			<table width=100% style="background: #BDBDBD;">
1349 richard 732
			<tr>
1416 richard 733
				<?php 
734
					$result_country_filter = mysqli_query($con, "SELECT id FROM SMS_country WHERE name = 'FILTRAGE'");
735
					$row = mysqli_fetch_array($result_country_filter);
736
 
737
					if($row['id'] == "advance") {
738
						$country_filter = $l_country_advanced_ena;
739
					} elseif($row['id'] == "ue") {
740
						$country_filter = $l_country_ue_ena;
741
					} elseif($row['id'] == "fr") {
742
						$country_filter = $l_country_france_ena;
743
					} elseif($row['id'] == "all") {
744
						$country_filter = $l_country_all_ena;
745
					} else {
746
						$country_filter = "Err.";
747
					}
748
				?>
749
				<td colspan="3" align="center"><strong><?php echo $l_country_filter; ?></strong><font size="3" color="red"><?php echo $country_filter; ?></font></td>
1349 richard 750
			</tr>
1387 richard 751
			<tr>
1416 richard 752
				<form action="autoregistration.php" methode="POST">
753
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
754
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
755
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
756
				</form>
757
			</tr>	
758
			</table>
759
			<div style="border-radius: 5px; background: #D8D8D8; margin: 15px;">
760
			<span class="showhide-but_country_plus"><?php echo "<strong>$l_country_filtering_plus<strong>" ?> <img src="/images/down2.gif" width="15" height="15"></span>
761
				<div class="showhide-div_country_plus">
762
				<table id="table_country" class="display">
763
					<thead>
764
						<tr>
765
							<th><b><font color="black">Pays</font></b></th>
766
							<th><b><font color="black">code</font></b></th>
767
							<th><b><font color="black">Etat</font></b></th>
768
						</tr>
769
					</thead>
770
					<tbody>
771
						<?php 
772
 
773
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
774
						while($row = mysqli_fetch_array($result_country))
775
						{
776
						echo "	
777
						<tr>
778
						<form action=\"autoregistration.php\" methode=\"POST\">
779
						<td>
780
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
781
							".$row['name']."
782
						</td>
783
						<td>".$row['id']."</td>
784
						";
785
 
786
						if($row['status']=='0')
787
						{
788
							echo "<td><input type='image' src=\"/images/state_error.gif\" width=\"15\" height=\"15\"></td>";
789
						}
790
						if($row['status']=='1')
791
						{
792
							echo "<td><input type='image' src=\"/images/state_ok.gif\" width=\"15\" height=\"15\"></td>";
793
						}
794
						echo "	</form>
795
							</tr>
796
							";
797
						}
798
						?>
799
					</tbody>
800
				</table>
801
				</div>
802
			</div>
803
		</div>	
804
	</div>
805
<?php 
806
	$result = mysqli_query($con, "SELECT * FROM SMS_ban_perm");
807
 
808
?>
809
 
810
<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
811
		<span class="showhide-but_ban"><?php echo "<strong>$l_phone_ban</strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
812
 
813
		<div class="showhide-div_ban">
814
 
815
			<table id="table_id" class="display">
816
				<thead>
817
					<tr>
818
						<th><b><font color="black"><?php echo $l_num_num; ?></font></b></th>
819
						<th><b><font color="black"><?php echo $l_num_raison; ?></font></b></th>
820
						<th><b><font color="black"><?php echo $l_num_expiration; ?></font></b></th>
821
						<th><b><font color="black">Action</font></b></th>
822
					</tr>
823
				</thead>
824
				<tbody>
825
					<?php 
826
					while($row = mysqli_fetch_array($result))
827
					{
828
					echo "	
829
						<tr>
830
						<form action=\"autoregistration.php\" methode=\"POST\">
831
						<td>
832
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
833
							".$row['SenderNumber']."
834
						</td>";
1349 richard 835
 
1416 richard 836
					if($row['Perm']=='0')
837
					{
838
						echo "<td>$l_num_exist</td>";
839
					}
840
					if($row['Perm']=='1')
841
					{
842
						echo "<td>$l_num_flood</td>";
843
					}
844
					echo "	<td>" . $row['Expiration']. "</td>
845
							<td>
846
								<input type='submit' value='".$l_num_unlock."'>
847
							</td>
848
							</form>
849
						</tr>
850
						";
851
					}
852
					?>
853
				</tbody>
854
			</table>
855
		</div>
856
	</div>
1387 richard 857
<?php
1349 richard 858
	mysqli_close($con);
1380 richard 859
	}
1349 richard 860
?>
861
</html>