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 2300 2017-06-22 09:00:27Z 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);
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");
599
		exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
1349 richard 600
 
601
		exec("sudo $script --unlock_num $numero");
602
		header('Location: autoregistration.php');
2300 tom.houday 603
		exit();
1349 richard 604
	}
605
 
1416 richard 606
	# Edition etat pays
607
	if(isset($_GET['country_select'])){
608
		$country=utf8_decode($_GET['country_select']);
2299 tom.houday 609
		exec("sudo $script --change_country ".escapeshellarg($country));
1416 richard 610
		exec("sudo $script --change_country_filter advance");
611
		header('Location: autoregistration.php');
2300 tom.houday 612
		exit();
1416 richard 613
	}
1349 richard 614
 
1416 richard 615
	if(isset($_GET['b_france_enable'])){
616
		exec("sudo $script --change_country_dis_all");
617
		exec("sudo $script --change_country France");
618
		exec("sudo $script --change_country_filter fr");
619
		header('Location: autoregistration.php');
2300 tom.houday 620
		exit();
1416 richard 621
	}
1349 richard 622
 
1416 richard 623
	if(isset($_GET['b_ue_enable'])){
624
		exec("sudo $script --change_country_dis_all");
625
		$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");
626
		foreach ($array_ue as $pays){
2299 tom.houday 627
			exec("sudo $script --change_country ".escapeshellarg($pays));
1416 richard 628
		}
629
 
630
		exec("sudo $script --change_country_filter ue");
631
		header('Location: autoregistration.php');
2300 tom.houday 632
		exit();
1416 richard 633
	}
634
 
635
	if(isset($_GET["b_country_enable"])){
636
		exec("sudo $script --change_country_ena_all");		
637
		exec("sudo $script --change_country_filter all");
638
		header('Location: autoregistration.php');
2300 tom.houday 639
		exit();
1416 richard 640
	}
641
 
642
	if(isset($_GET["b_country_disable"])){
643
		exec("sudo $script --change_country_dis_all");
644
		header('Location: autoregistration.php');
2300 tom.houday 645
		exit();
1416 richard 646
	}
647
 
648
 
1349 richard 649
	#Si une clé 3g est plugué
650
	echo "<form action=\"autoregistration.php\" methode=\"GET\">
651
 
652
		<table border=1>
653
		<tr>
1387 richard 654
			<td colspan=4><b>$l_status_gammu</b></td>
655
			<td><b><center>$l_force_signal</center></b></td>
656
			<td><b><center>$l_imei_device</center></b></td> 
657
			<td><b><center>$l_sms_received</center></b></td> 
1349 richard 658
		</tr>
659
		<tr>
1387 richard 660
			$gammu
661
			<td><button type=\"submit\" name=\"start\" $gammu_status_on>$l_start</button></td>		
662
			<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
663
			<td><center>$force_signal</center></td>
664
			<td><center>$imei_device</center></td>
665
			<td><center>$sms_received</center></td>
1349 richard 666
		</tr>
667
		$gammu_puk
668
		$gammu_simfail
669
		$gammu_simsecu
670
		$gammu_timeout
671
		$gammu_writeerror
672
		</table>
673
	<br /><br />
674
 
675
		<table border=1>
676
		<tr>
677
		<td colspan=3><b>$l_conf</b></td>
678
		<td><b>$l_conf_actu</b></td>
679
		</tr>
680
 
681
		<tr>
1380 richard 682
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
1349 richard 683
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
684
		<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
685
		</tr>
1380 richard 686
		<tr><td colspan=\"4\"><font color=red><b>$error_num_alcasar</b></font></td></tr>
1349 richard 687
 
1380 richard 688
		<tr>		
689
		<td> $l_pin </td><td><input type=text name='pin' maxlength=\"8\"></td>
1349 richard 690
		<td><button type=\"submit\" name=\"b_pin\" $gammu_status_on>$l_edit</button></td>
691
		<td><center><font color=\"green\">$current_pin</font></center></td>
692
		</tr>
1380 richard 693
		<tr><td colspan=\"4\"><font color=red><b>$error_pin</b></font></td></tr>
2294 richard 694
 
695
		<tr>
1380 richard 696
		<td> $l_time_account </td><td><input type=text name='time_account'> $l_days </td>
1349 richard 697
		<td><button type=\"submit\" name=\"b_time_account\" $gammu_status_on>$l_edit</button></td>	
698
		<td><center><font color=\"blue\">$current_time_account</font></center></td>
699
		</tr>
1380 richard 700
		<tr><td colspan=\"4\"><font color=red><b>$error_time_account</b></font></td></tr>
1349 richard 701
 
702
		<tr>
1380 richard 703
		<td> $l_ban_temp </td><td><input type=text name='nb_essais'></td>	
1349 richard 704
		<td><button type=\"submit\" name=\"b_ban_temp\" $gammu_status_on>$l_edit</button></td>	
705
		<td><center><font color=\"orange\">$current_try_ban</font></center></td>
706
		</tr>
1380 richard 707
		<tr><td colspan=\"4\"><font color=red><b>$error_nb_essais</b></font></td></tr>
1349 richard 708
 
709
		<tr>
1380 richard 710
		<td>$l_time_perm</td><td><input type=text name='time_perm'> $l_days</td>
1349 richard 711
		<td><button type=\"submit\" name=\"b_time_perm\" $gammu_status_on>$l_edit</button></td>	
712
		<td><center><font color=\"orange\">$current_time_perm</font></center></td>
713
		</tr>
1380 richard 714
		<tr><td colspan=\"4\"><font color=red><b>$error_time_perm</b></font></td></tr>
1349 richard 715
		</table>
1416 richard 716
		</form>";
717
 
1349 richard 718
 
719
	require('/etc/freeradius-web/config.php');
720
 
2185 tom.houday 721
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
722
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
1349 richard 723
	else{
724
		echo "<b>Could not include SQL library</b>\n";
725
		exit();
2185 tom.houday 726
	}
1349 richard 727
 
728
	$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
729
 
730
	if(mysqli_connect_errno())
731
	{
732
		echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
733
	}
734
 
735
 
1416 richard 736
	# Country table
737
 
1387 richard 738
?>
1416 richard 739
 
740
	<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
741
		 <span class="showhide-but_country"><?php echo "<strong>$l_country_filtering<strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
742
 
743
		<div class="showhide-div_country">
744
		<br />
745
			<table width=100% style="background: #BDBDBD;">
1349 richard 746
			<tr>
1416 richard 747
				<?php 
748
					$result_country_filter = mysqli_query($con, "SELECT id FROM SMS_country WHERE name = 'FILTRAGE'");
749
					$row = mysqli_fetch_array($result_country_filter);
750
 
751
					if($row['id'] == "advance") {
752
						$country_filter = $l_country_advanced_ena;
753
					} elseif($row['id'] == "ue") {
754
						$country_filter = $l_country_ue_ena;
755
					} elseif($row['id'] == "fr") {
756
						$country_filter = $l_country_france_ena;
757
					} elseif($row['id'] == "all") {
758
						$country_filter = $l_country_all_ena;
759
					} else {
760
						$country_filter = "Err.";
761
					}
762
				?>
763
				<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 764
			</tr>
1387 richard 765
			<tr>
1416 richard 766
				<form action="autoregistration.php" methode="POST">
767
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
768
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
769
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
770
				</form>
771
			</tr>	
772
			</table>
773
			<div style="border-radius: 5px; background: #D8D8D8; margin: 15px;">
774
			<span class="showhide-but_country_plus"><?php echo "<strong>$l_country_filtering_plus<strong>" ?> <img src="/images/down2.gif" width="15" height="15"></span>
775
				<div class="showhide-div_country_plus">
776
				<table id="table_country" class="display">
777
					<thead>
778
						<tr>
779
							<th><b><font color="black">Pays</font></b></th>
780
							<th><b><font color="black">code</font></b></th>
781
							<th><b><font color="black">Etat</font></b></th>
782
						</tr>
783
					</thead>
784
					<tbody>
785
						<?php 
786
 
787
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
788
						while($row = mysqli_fetch_array($result_country))
789
						{
790
						echo "	
791
						<tr>
792
						<form action=\"autoregistration.php\" methode=\"POST\">
793
						<td>
794
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
795
							".$row['name']."
796
						</td>
797
						<td>".$row['id']."</td>
798
						";
799
 
800
						if($row['status']=='0')
801
						{
802
							echo "<td><input type='image' src=\"/images/state_error.gif\" width=\"15\" height=\"15\"></td>";
803
						}
804
						if($row['status']=='1')
805
						{
806
							echo "<td><input type='image' src=\"/images/state_ok.gif\" width=\"15\" height=\"15\"></td>";
807
						}
808
						echo "	</form>
809
							</tr>
810
							";
811
						}
812
						?>
813
					</tbody>
814
				</table>
815
				</div>
816
			</div>
817
		</div>	
818
	</div>
819
<?php 
820
	$result = mysqli_query($con, "SELECT * FROM SMS_ban_perm");
821
 
822
?>
823
 
824
<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
825
		<span class="showhide-but_ban"><?php echo "<strong>$l_phone_ban</strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
826
 
827
		<div class="showhide-div_ban">
828
 
829
			<table id="table_id" class="display">
830
				<thead>
831
					<tr>
832
						<th><b><font color="black"><?php echo $l_num_num; ?></font></b></th>
833
						<th><b><font color="black"><?php echo $l_num_raison; ?></font></b></th>
834
						<th><b><font color="black"><?php echo $l_num_expiration; ?></font></b></th>
835
						<th><b><font color="black">Action</font></b></th>
836
					</tr>
837
				</thead>
838
				<tbody>
839
					<?php 
840
					while($row = mysqli_fetch_array($result))
841
					{
842
					echo "	
843
						<tr>
844
						<form action=\"autoregistration.php\" methode=\"POST\">
845
						<td>
846
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
847
							".$row['SenderNumber']."
848
						</td>";
1349 richard 849
 
1416 richard 850
					if($row['Perm']=='0')
851
					{
852
						echo "<td>$l_num_exist</td>";
853
					}
854
					if($row['Perm']=='1')
855
					{
856
						echo "<td>$l_num_flood</td>";
857
					}
858
					echo "	<td>" . $row['Expiration']. "</td>
859
							<td>
860
								<input type='submit' value='".$l_num_unlock."'>
861
							</td>
862
							</form>
863
						</tr>
864
						";
865
					}
866
					?>
867
				</tbody>
868
			</table>
869
		</div>
870
	</div>
1387 richard 871
<?php
1349 richard 872
	mysqli_close($con);
1380 richard 873
	}
1349 richard 874
?>
875
</html>