Subversion Repositories ALCASAR

Rev

Rev 2317 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
1387 richard 1
<?php
2185 tom.houday 2
# $Id: autoregistration.php 2349 2017-07-22 12:20:21Z 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 -->
2317 tom.houday 167
<script type="text/javascript" charset="utf8" src="/js/jquery.min.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);
2300 tom.houday 308
		header('Location: autoregistration.php');
309
		exit();
1349 richard 310
	}
311
}
312
 
313
if ($status_key=="true")
314
{
315
	#Nom du fichier de log lorsque gammu est démarré
1387 richard 316
	#$file_log = "gammu-smsd.log";
1349 richard 317
 
318
	#Recuperation du code PIN actuel
319
	$current_pin = exec("sudo $script --pin");	
320
 
321
	#Recuperation du nombre de try avant le ban perm
322
	$current_try_ban = exec("sudo $script --try_ban");	
323
 
324
	#Recuperation de la durée d'une session créée
325
	$current_time_account = exec("sudo $script --time_account");	
326
 
327
	#Recuperation de la durée dun ban perm (après flood)
328
	$current_time_perm = exec("sudo $script --time_perm");	
329
 
330
	#Detection neméro de tel
331
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
332
 
333
	#Detection problème avec la SIM
334
	$current_simfail = exec("sudo $script --last_nosim");
335
 
336
	#Recuperation de la dernière ligne de START
337
	$current_last_start = exec("sudo $script --last_start");
338
 
339
	#Recuperarion de la dernière ligne de STOP
340
	$current_last_stop = exec("sudo $script --last_stop");
341
 
342
	#Recuperation de la dernière ligne de SECURITYERROR
343
	$current_last_secu = exec("sudo $script --last_secu");
344
 
345
	#Recuperation de la dernière ligne de DEVICEWRITEERROR
346
	$current_last_write = exec("sudo $script --last_writeerror");
347
 
348
	#Recuperation de la dernière ligne de TIMEOUT
349
	$current_last_timeout = exec("sudo $script --last_timeout");
1380 richard 350
 
351
	# Test si le service est lancé
1349 richard 352
	if ($gammu_pid=="")
353
	{
354
		$force_signal = "-";
355
		$imei_device = "-";
356
		$sms_received = "-";
357
 
358
		$gammu="<td><img src=\"/images/state_error.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ko."\"></td><td>$l_gammu_off</td>";	
359
		$gammu_status_on="";
360
		$gammu_status_off="disabled";
361
 
362
		if($current_last_secu!="")
363
		{
364
			if(($current_last_secu > $current_last_start) && ($current_last_secu < $current_last_stop))
365
			{
366
				$gammu_simsecu="<tr><td colspan=7><font color=red>$l_error_simsecu_l</font></td></tr>";	
367
			}
368
		}
369
	} else {
370
		# Recuperation de la force du signal et IMEI et nombre de sms reçu
371
		$val_force_signal = exec("sudo $script --signal_device");
372
		$imei_device = exec("sudo $script --imei_device");
373
		$sms_received = exec("sudo $script --sms_received");
374
 
375
		if ($val_force_signal < 21) {
376
			$force_signal = "<img src=\"/images/signal_0.png\">  --  ".$val_force_signal." %";
377
		} elseif ($val_force_signal < 41) {
378
			$force_signal = "<img src=\"/images/signal_20.png\">  --  ".$val_force_signal." %";
379
 
380
		} elseif ($val_force_signal < 61) {
381
			$force_signal = "<img src=\"/images/signal_40.png\">  --  ".$val_force_signal." %";
382
 
383
		} elseif ($val_force_signal < 81) {
384
			$force_signal = "<img src=\"/images/signal_60.png\">  --  ".$val_force_signal." %";
385
 
386
		} elseif ($val_force_signal < 101) {
387
			$force_signal = "<img src=\"/images/signal_80.png\">  --  ".$val_force_signal." %";
388
 
389
		}
390
 
391
 
392
 
393
 
394
 
395
		$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 396
 
1349 richard 397
 
398
		if($current_last_timeout!=""){
399
			if(($current_last_timeout > $current_last_start) && ($current_last_timeout > $current_last_stop))
400
			{
401
				$gammu_timeout="<tr><td colspan=7><font color=red>$l_error_timeoutfail</font></td></tr>";	
402
			}
403
		}
404
 
405
		if($current_last_secu!="")
406
		{
407
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
408
			{
409
				exec("sudo $script --stop");
410
			}
411
		}
412
 
413
		if($current_last_write!=""){
414
			if(($current_last_write > $current_last_start) && ($current_last_write > $current_last_stop))
415
			{
416
				$gammu_writeerror="<tr><td colspan=7><font color=red>$l_error_writefail</font></td></tr>";	
417
			}
418
		}
419
 
420
		if($current_simfail!="")
421
		{
422
			if(($current_simfail > $current_last_start) && ($current_simfail > $current_last_stop))
423
			{
1380 richard 424
				$gammu_simfail="<tr><td colspan=7><font color=red>$l_error_simfail</font></td></tr>";
1349 richard 425
			}
426
		}
427
		$gammu_status_on="disabled";
428
		$gammu_status_off="";
429
	}
430
 
431
 
1380 richard 432
	#Lancement et arret de gammu-smsd 3*7sec
1349 richard 433
	if(isset($_GET["start"])){
434
		$gammu_1=exec("sudo $script --start");
435
		sleep(7);
436
 
437
		if($current_last_secu!="")
438
		{
439
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
440
			{
441
				exec("sudo $script --stop");
442
			}
443
		}
444
 
445
		sleep(7);
446
		if($current_last_secu!="")
447
		{
448
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
449
			{
450
				exec("sudo $script --stop");
451
			}
452
		}
453
 
454
		sleep(7);	
455
		if($current_last_secu!="")
456
		{
457
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
458
			{
459
				exec("sudo $script --stop");
460
			}
461
		}
462
 
463
 
464
 
465
		header('Location: autoregistration.php');
2300 tom.houday 466
		exit();
1349 richard 467
	}
468
 
469
	if(isset($_GET["stop"])){
470
		exec("sudo $script --stop");
471
		sleep(8);
472
		header('Location: autoregistration.php');
2300 tom.houday 473
		exit();
1349 richard 474
	}
475
 
476
 
477
	#Edition du NUMERO de telephone
478
	if(isset($_GET["b_num_alcasar"])){
479
		$num = $_GET["num_alcasar"];
480
		$error_num_alcasar = "";
481
		if($num !="")
482
		{
1380 richard 483
			if(preg_match('#^\+#',$num))
1349 richard 484
			{
2299 tom.houday 485
				exec("sudo $script --replace_numero_alcasar ".escapeshellarg($num));
1349 richard 486
				header('Location: autoregistration.php');
2300 tom.houday 487
				exit();
1349 richard 488
			}
489
			else
490
			{
1380 richard 491
				$error_num_alcasar=$l_error_label_num3;
1349 richard 492
			}
493
		}
494
		else
495
		{
496
			$error_num_alcasar=$l_error_label_empty;
497
		}
498
	}
499
 
500
	#Edition du code PIN
501
	if(isset($_GET["b_pin"])){
502
		$pin = $_GET["pin"];
503
		$error_pin = "";
504
		if($pin !="")
505
		{
506
			if(is_numeric($pin))
507
			{
2299 tom.houday 508
				exec("sudo $script --replace_pin ".escapeshellarg($pin));
1349 richard 509
				header('Location: autoregistration.php');
2300 tom.houday 510
				exit();
1349 richard 511
			}
512
			else
513
			{
514
				$error_pin=$l_error_label_num;			
515
			}
516
		}
517
		else
518
		{
519
			$error_pin=$l_error_label_empty;
520
		}
521
	}
1380 richard 522
 
523
 
1349 richard 524
	#Edition du nombre d'essais avant le ban perm
525
	if(isset($_GET["b_ban_temp"])){
526
		$nb_ban_temp = $_GET["nb_essais"];
527
		$error_nb_essais = "";
528
		if($nb_ban_temp !="")
529
		{
530
			if(is_numeric($nb_ban_temp))
531
			{
2299 tom.houday 532
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
1349 richard 533
				header('Location: autoregistration.php');
2300 tom.houday 534
				exit();
1349 richard 535
			}
536
			else
537
			{
538
				$error_nb_essais=$l_error_label_num2;			
539
			}
540
		}
541
		else
542
		{
543
			$error_nb_essais=$l_error_label_empty;
544
		}
545
	}
546
 
1380 richard 547
 
1349 richard 548
	#Edition de la durée pour un compte créé
549
	if(isset($_GET["b_time_account"])){
550
		$time_account = $_GET["time_account"];
551
		$error_time_account = "";
552
		if($time_account !="")
553
		{
554
			if(is_numeric($time_account))
555
			{
2299 tom.houday 556
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
1349 richard 557
				header('Location: autoregistration.php');
2300 tom.houday 558
				exit();
1349 richard 559
			}
560
			else
561
			{
1380 richard 562
				$error_time_account=$l_error_label_num2;
1349 richard 563
			}
564
		}
565
		else
566
		{
567
			$error_time_account=$l_error_label_empty;
568
		}
569
	}
570
 
571
	#Edition de la durée d'un ban perm (après flood)
572
	if(isset($_GET["b_time_perm"])){
573
		$time_perm = $_GET["time_perm"];
574
		$error_time_perm = "";
575
		if($time_perm !="")
576
		{
577
			if(is_numeric($time_perm))
578
			{
2299 tom.houday 579
				exec("sudo $script --replace_time_perm ".escapeshellarg($time_perm));
1349 richard 580
				header('Location: autoregistration.php');
2300 tom.houday 581
				exit();
1349 richard 582
			}
583
			else
584
			{
1380 richard 585
				$error_time_perm=$l_error_label_num2;
1349 richard 586
			}
587
		}
588
		else
589
		{
590
			$error_time_perm=$l_error_label_empty;
591
		}
592
	}
593
 
594
	# Suppression d'un numero bloqué
595
	if(isset($_GET['num_select'])){
596
		$numero=$_GET['num_select'];
597
 
2299 tom.houday 598
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
2349 tom.houday 599
		if (!empty($add_mac)) {
600
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
601
		}
1349 richard 602
 
603
		exec("sudo $script --unlock_num $numero");
604
		header('Location: autoregistration.php');
2300 tom.houday 605
		exit();
1349 richard 606
	}
607
 
1416 richard 608
	# Edition etat pays
609
	if(isset($_GET['country_select'])){
610
		$country=utf8_decode($_GET['country_select']);
2299 tom.houday 611
		exec("sudo $script --change_country ".escapeshellarg($country));
1416 richard 612
		exec("sudo $script --change_country_filter advance");
613
		header('Location: autoregistration.php');
2300 tom.houday 614
		exit();
1416 richard 615
	}
1349 richard 616
 
1416 richard 617
	if(isset($_GET['b_france_enable'])){
618
		exec("sudo $script --change_country_dis_all");
619
		exec("sudo $script --change_country France");
620
		exec("sudo $script --change_country_filter fr");
621
		header('Location: autoregistration.php');
2300 tom.houday 622
		exit();
1416 richard 623
	}
1349 richard 624
 
1416 richard 625
	if(isset($_GET['b_ue_enable'])){
626
		exec("sudo $script --change_country_dis_all");
627
		$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");
628
		foreach ($array_ue as $pays){
2299 tom.houday 629
			exec("sudo $script --change_country ".escapeshellarg($pays));
1416 richard 630
		}
631
 
632
		exec("sudo $script --change_country_filter ue");
633
		header('Location: autoregistration.php');
2300 tom.houday 634
		exit();
1416 richard 635
	}
636
 
637
	if(isset($_GET["b_country_enable"])){
638
		exec("sudo $script --change_country_ena_all");		
639
		exec("sudo $script --change_country_filter all");
640
		header('Location: autoregistration.php');
2300 tom.houday 641
		exit();
1416 richard 642
	}
643
 
644
	if(isset($_GET["b_country_disable"])){
645
		exec("sudo $script --change_country_dis_all");
646
		header('Location: autoregistration.php');
2300 tom.houday 647
		exit();
1416 richard 648
	}
649
 
650
 
1349 richard 651
	#Si une clé 3g est plugué
652
	echo "<form action=\"autoregistration.php\" methode=\"GET\">
653
 
654
		<table border=1>
655
		<tr>
1387 richard 656
			<td colspan=4><b>$l_status_gammu</b></td>
657
			<td><b><center>$l_force_signal</center></b></td>
658
			<td><b><center>$l_imei_device</center></b></td> 
659
			<td><b><center>$l_sms_received</center></b></td> 
1349 richard 660
		</tr>
661
		<tr>
1387 richard 662
			$gammu
663
			<td><button type=\"submit\" name=\"start\" $gammu_status_on>$l_start</button></td>		
664
			<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
665
			<td><center>$force_signal</center></td>
666
			<td><center>$imei_device</center></td>
667
			<td><center>$sms_received</center></td>
1349 richard 668
		</tr>
669
		$gammu_puk
670
		$gammu_simfail
671
		$gammu_simsecu
672
		$gammu_timeout
673
		$gammu_writeerror
674
		</table>
675
	<br /><br />
676
 
677
		<table border=1>
678
		<tr>
679
		<td colspan=3><b>$l_conf</b></td>
680
		<td><b>$l_conf_actu</b></td>
681
		</tr>
682
 
683
		<tr>
1380 richard 684
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
1349 richard 685
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
686
		<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
687
		</tr>
1380 richard 688
		<tr><td colspan=\"4\"><font color=red><b>$error_num_alcasar</b></font></td></tr>
1349 richard 689
 
1380 richard 690
		<tr>		
691
		<td> $l_pin </td><td><input type=text name='pin' maxlength=\"8\"></td>
1349 richard 692
		<td><button type=\"submit\" name=\"b_pin\" $gammu_status_on>$l_edit</button></td>
693
		<td><center><font color=\"green\">$current_pin</font></center></td>
694
		</tr>
1380 richard 695
		<tr><td colspan=\"4\"><font color=red><b>$error_pin</b></font></td></tr>
2294 richard 696
 
697
		<tr>
1380 richard 698
		<td> $l_time_account </td><td><input type=text name='time_account'> $l_days </td>
1349 richard 699
		<td><button type=\"submit\" name=\"b_time_account\" $gammu_status_on>$l_edit</button></td>	
700
		<td><center><font color=\"blue\">$current_time_account</font></center></td>
701
		</tr>
1380 richard 702
		<tr><td colspan=\"4\"><font color=red><b>$error_time_account</b></font></td></tr>
1349 richard 703
 
704
		<tr>
1380 richard 705
		<td> $l_ban_temp </td><td><input type=text name='nb_essais'></td>	
1349 richard 706
		<td><button type=\"submit\" name=\"b_ban_temp\" $gammu_status_on>$l_edit</button></td>	
707
		<td><center><font color=\"orange\">$current_try_ban</font></center></td>
708
		</tr>
1380 richard 709
		<tr><td colspan=\"4\"><font color=red><b>$error_nb_essais</b></font></td></tr>
1349 richard 710
 
711
		<tr>
1380 richard 712
		<td>$l_time_perm</td><td><input type=text name='time_perm'> $l_days</td>
1349 richard 713
		<td><button type=\"submit\" name=\"b_time_perm\" $gammu_status_on>$l_edit</button></td>	
714
		<td><center><font color=\"orange\">$current_time_perm</font></center></td>
715
		</tr>
1380 richard 716
		<tr><td colspan=\"4\"><font color=red><b>$error_time_perm</b></font></td></tr>
1349 richard 717
		</table>
1416 richard 718
		</form>";
719
 
1349 richard 720
 
721
	require('/etc/freeradius-web/config.php');
722
 
2185 tom.houday 723
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
724
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
1349 richard 725
	else{
726
		echo "<b>Could not include SQL library</b>\n";
727
		exit();
2185 tom.houday 728
	}
1349 richard 729
 
730
	$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
731
 
732
	if(mysqli_connect_errno())
733
	{
734
		echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
735
	}
736
 
737
 
1416 richard 738
	# Country table
739
 
1387 richard 740
?>
1416 richard 741
 
742
	<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
743
		 <span class="showhide-but_country"><?php echo "<strong>$l_country_filtering<strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
744
 
745
		<div class="showhide-div_country">
746
		<br />
747
			<table width=100% style="background: #BDBDBD;">
1349 richard 748
			<tr>
1416 richard 749
				<?php 
750
					$result_country_filter = mysqli_query($con, "SELECT id FROM SMS_country WHERE name = 'FILTRAGE'");
751
					$row = mysqli_fetch_array($result_country_filter);
752
 
753
					if($row['id'] == "advance") {
754
						$country_filter = $l_country_advanced_ena;
755
					} elseif($row['id'] == "ue") {
756
						$country_filter = $l_country_ue_ena;
757
					} elseif($row['id'] == "fr") {
758
						$country_filter = $l_country_france_ena;
759
					} elseif($row['id'] == "all") {
760
						$country_filter = $l_country_all_ena;
761
					} else {
762
						$country_filter = "Err.";
763
					}
764
				?>
765
				<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 766
			</tr>
1387 richard 767
			<tr>
1416 richard 768
				<form action="autoregistration.php" methode="POST">
769
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
770
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
771
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
772
				</form>
773
			</tr>	
774
			</table>
775
			<div style="border-radius: 5px; background: #D8D8D8; margin: 15px;">
776
			<span class="showhide-but_country_plus"><?php echo "<strong>$l_country_filtering_plus<strong>" ?> <img src="/images/down2.gif" width="15" height="15"></span>
777
				<div class="showhide-div_country_plus">
778
				<table id="table_country" class="display">
779
					<thead>
780
						<tr>
781
							<th><b><font color="black">Pays</font></b></th>
782
							<th><b><font color="black">code</font></b></th>
783
							<th><b><font color="black">Etat</font></b></th>
784
						</tr>
785
					</thead>
786
					<tbody>
787
						<?php 
788
 
789
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
790
						while($row = mysqli_fetch_array($result_country))
791
						{
792
						echo "	
793
						<tr>
794
						<form action=\"autoregistration.php\" methode=\"POST\">
795
						<td>
796
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
797
							".$row['name']."
798
						</td>
799
						<td>".$row['id']."</td>
800
						";
801
 
802
						if($row['status']=='0')
803
						{
804
							echo "<td><input type='image' src=\"/images/state_error.gif\" width=\"15\" height=\"15\"></td>";
805
						}
806
						if($row['status']=='1')
807
						{
808
							echo "<td><input type='image' src=\"/images/state_ok.gif\" width=\"15\" height=\"15\"></td>";
809
						}
810
						echo "	</form>
811
							</tr>
812
							";
813
						}
814
						?>
815
					</tbody>
816
				</table>
817
				</div>
818
			</div>
819
		</div>	
820
	</div>
821
<?php 
822
	$result = mysqli_query($con, "SELECT * FROM SMS_ban_perm");
823
 
824
?>
825
 
826
<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
827
		<span class="showhide-but_ban"><?php echo "<strong>$l_phone_ban</strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
828
 
829
		<div class="showhide-div_ban">
830
 
831
			<table id="table_id" class="display">
832
				<thead>
833
					<tr>
834
						<th><b><font color="black"><?php echo $l_num_num; ?></font></b></th>
835
						<th><b><font color="black"><?php echo $l_num_raison; ?></font></b></th>
836
						<th><b><font color="black"><?php echo $l_num_expiration; ?></font></b></th>
837
						<th><b><font color="black">Action</font></b></th>
838
					</tr>
839
				</thead>
840
				<tbody>
841
					<?php 
842
					while($row = mysqli_fetch_array($result))
843
					{
844
					echo "	
845
						<tr>
846
						<form action=\"autoregistration.php\" methode=\"POST\">
847
						<td>
848
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
849
							".$row['SenderNumber']."
850
						</td>";
1349 richard 851
 
1416 richard 852
					if($row['Perm']=='0')
853
					{
854
						echo "<td>$l_num_exist</td>";
855
					}
856
					if($row['Perm']=='1')
857
					{
858
						echo "<td>$l_num_flood</td>";
859
					}
860
					echo "	<td>" . $row['Expiration']. "</td>
861
							<td>
862
								<input type='submit' value='".$l_num_unlock."'>
863
							</td>
864
							</form>
865
						</tr>
866
						";
867
					}
868
					?>
869
				</tbody>
870
			</table>
871
		</div>
872
	</div>
1387 richard 873
<?php
1349 richard 874
	mysqli_close($con);
1380 richard 875
	}
1349 richard 876
?>
877
</html>