Subversion Repositories ALCASAR

Rev

Rev 2550 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log

Rev 2550 Rev 2552
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: autoregistration.php 2550 2018-05-06 22:15:20Z rexy $
2
# $Id: autoregistration.php 2552 2018-05-08 22:21:47Z rexy $
3
 
3
 
4
#Define
4
#Define
-
 
5
$gammu_wrong_port = "";
5
$gammu_puk = "";
6
$gammu_puk = "";
6
$gammu_simfail = "";
7
$gammu_simfail = "";
7
$gammu_simsecu = "";
8
$gammu_simsecu = "";
8
$gammu_writeerror = "";
9
$gammu_writeerror = "";
9
$gammu_timeout = "";
10
$gammu_timeout = "";
Line 12... Line 13...
12
$error_nb_essais = "";
13
$error_nb_essais = "";
13
$error_time_perm = "";
14
$error_time_perm = "";
14
$error_num_alcasar = "";
15
$error_num_alcasar = "";
15
$country_filter="";
16
$country_filter="";
16
$find_key="false";
17
$find_key="false";
17
$status_key="false";
18
$listen_on_right_port="false";
18
$script="/usr/local/bin/alcasar-sms.sh";
19
$script="/usr/local/bin/alcasar-sms.sh";
19
 
20
 
20
# Test if a modem is plugged on serial-usb port
21
# Test if a modem is plugged on serial-usb port
21
$open_port=exec("ls /dev/ttyUSB*",$openned_ports); // list of USB-Serial ports openned by a modem
22
$open_port=exec("ls /dev/ttyUSB*",$openned_ports); // list of USB-Serial ports openned by a modem
22
if (!empty($open_port))
23
if (!empty($open_port))
Line 27... Line 28...
27
	$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port
28
	$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port 
28
	while ( list(,$row) = each($openned_ports))
29
	while ( list(,$row) = each($openned_ports))
29
	{
30
	{
30
		if ( "$row" == "$gammu_smsd_port" ) // is gammu listen on an openned port ?
31
		if ( "$row" == "$gammu_smsd_port" ) // is gammu listen on an openned port ?
31
		{
32
		{
32
			$status_key="true";
33
			$listen_on_right_port="true";
33
		}
34
		}
34
	}
35
	}
35
}	
36
}	
36
$gammu_pid=exec("sudo $script --pidof");
37
$gammu_pid=exec("sudo $script --pidof");
37
if (( $status_key == "false") || ($find_key == "false"))
38
if ($find_key == "false")
38
{	# close gammu if it's started
39
{	# close gammu if it's started
39
	if ($gammu_pid!="")
40
	if ($gammu_pid!="")
40
	{
41
	{
41
		echo "on ferme";
42
		echo "on ferme";
42
		exec("sudo $script stop");
43
		exec("sudo $script stop");
Line 53... Line 54...
53
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
54
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
54
if($Language == 'fr'){
55
if($Language == 'fr'){
55
	$l_title = "Auto enregistrement (SMS)";
56
	$l_title = "Auto enregistrement (SMS)";
56
	$l_conf = "Configuration";
57
	$l_conf = "Configuration";
57
	$l_conf_actu = "Configuration actuelle";
58
	$l_conf_actu = "Configuration actuelle";
-
 
59
	$l_speed = "Vitesse de connexion au MODEM";
-
 
60
	$l_connect_port="Port de connexion au MODEM";
58
	$l_pin = "Code PIN";
61
	$l_pin = "Code PIN de la carte SIM";
59
	$l_num_alcasar = "Numero de téléphone du MODEM GSM";
62
	$l_num_alcasar = "Numero de téléphone de la carte SIM";
60
	$l_ban_temp = "Nombre d'essais avant le blocage";
63
	$l_ban_temp = "Nombre d'essais avant le blocage";
61
	$l_time_account = "Durée de validité des comptes crées";
64
	$l_time_account = "Durée de validité des comptes crées";
62
	$l_time_perm = "Durée du blocage (en jours)";
65
	$l_time_perm = "Durée du blocage (en jours)";
63
	$l_status_gammu = "Etat du service";
66
	$l_status_gammu = "Etat du service";
64
	$l_start = "Démarrer";
67
	$l_start = "Démarrer";
65
	$l_status_device = "Status de votre MODEM GSM (clé 2G/3G/4G)";
68
	$l_status_device = "Status de votre MODEM GSM (clé 2G/3G/4G)";
66
	$l_key_diseable = "Aucun périphérique détecté";
69
	$l_key_diseable = "Aucun périphérique détecté";
67
	$l_key_enable_1 = "Un MODEM GSM '<b>".$vendor."(".$model.")</b>' est connecté à la vitesse de ";
70
	$l_key_enable_1 = "Un MODEM GSM '<b>".$vendor."(".$model.")</b>' est connecté.";
68
	$l_key_enable_2 = "Il a ouvert les ports suivants : ";
71
	$l_key_enable_2 = "Il a ouvert les ports suivants : ";
69
	$l_force_signal = "Force du signal";
72
	$l_force_signal = "Force du signal";
70
	$l_imei_device = "IMEI du périphérique";
73
	$l_imei_device = "IMEI du périphérique";
71
	$l_sms_received = "Nombre de SMS reçu";
74
	$l_sms_received = "Nombre de SMS reçu";
72
	$l_stop = "Arrêter";
75
	$l_stop = "Arrêter";
73
	$l_gammu_on="Le service est démarré";
76
	$l_gammu_on="Le service est démarré";
74
	$l_gammu_off="Le service est arrêté";
77
	$l_gammu_off="Le service est arrêté";
75
	$l_edit = "Modifier";
78
	$l_edit = "Modifier";
-
 
79
	$l_error_wrong_port = "Le port d'écoute ($gammu_smsd_port) n'existe pas";
76
	$l_error_label_empty = "Le champ est vide";
80
	$l_error_label_empty = "Le champ est vide";
77
	$l_error_label_num = "Ce n'est pas un PIN valide";
81
	$l_error_label_num = "Ce n'est pas un PIN valide";
78
	$l_error_label_num2 = "Ce n'est pas un nombre";
82
	$l_error_label_num2 = "Ce n'est pas un nombre";
79
	$l_error_label_num3 = "Le format n'est pas correct: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
83
	$l_error_label_num3 = "Le format n'est pas correct: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
80
	$l_error_writefail = "Le service ne parvient pas à discuter avec le port du MODEM GSM (ttyUSB0).";
84
	$l_error_writefail = "Le service ne parvient pas à discuter avec le port du MODEM GSM (ttyUSB0).";
Line 95... Line 99...
95
	$l_country_enable="Activer";
99
	$l_country_enable="Activer";
96
	$l_country_disable="Désactiver";
100
	$l_country_disable="Désactiver";
97
	$l_service_status_img_ok="Démarré";
101
	$l_service_status_img_ok="Démarré";
98
	$l_service_status_img_ko="Arrété";
102
	$l_service_status_img_ko="Arrété";
99
	$l_connect_speed="Modifier la vitesse de connexion : ";
103
	$l_connect_speed="Modifier la vitesse de connexion : ";
100
	$l_connect_port="Port de connexion";
-
 
101
	$l_tab_first = "premier";
104
	$l_tab_first = "premier";
102
	$l_tab_last = "dernier";
105
	$l_tab_last = "dernier";
103
	$l_tab_next = "suivant";
106
	$l_tab_next = "suivant";
104
	$l_tab_prev = "précédent";
107
	$l_tab_prev = "précédent";
105
	$l_tab_search = "Recherche :";
108
	$l_tab_search = "Recherche :";
Line 118... Line 121...
118
}
121
}
119
else {
122
else {
120
	$l_title = "Auto registration (SMS)";
123
	$l_title = "Auto registration (SMS)";
121
	$l_conf = "Configuration";
124
	$l_conf = "Configuration";
122
	$l_conf_actu = "Current configuration";
125
	$l_conf_actu = "Current configuration";
-
 
126
	$l_speed = "Connection speed to the MODEM";
-
 
127
	$l_connect_port="Connection port to the MODEM";
123
	$l_pin = "PIN password";
128
	$l_pin = "PIN password of the SIM card";
124
	$l_num_alcasar = "Phone number of the GSM MODEM";
129
	$l_num_alcasar = "Phone number of the SIM card";
125
	$l_ban_temp = "Max number of try before a permanent ban"; 
130
	$l_ban_temp = "Max number of try before a permanent ban"; 
126
	$l_time_account = "Validity period of new account";
131
	$l_time_account = "Validity period of new account";
127
	$l_time_perm = "Duration of a ban (for example, after X try)";
132
	$l_time_perm = "Duration of a ban (for example, after X try)";
128
	$l_status_gammu = "Service status";
133
	$l_status_gammu = "Service status";
129
	$l_start = "Start";
134
	$l_start = "Start";
130
	$l_status_device = "Status of your GSM MODEM (2G/3G/4G key)";
135
	$l_status_device = "Status of your GSM MODEM (2G/3G/4G key)";
131
	$l_key_diseable = "No device detected";
136
	$l_key_diseable = "No device detected";
132
	$l_key_enable_1 = "A GSM MODEM '<b>".$vendor."(".$model.")</b>' is connected at the speed of ";
137
	$l_key_enable_1 = "A GSM MODEM '<b>".$vendor."(".$model.")</b>' is connected.";
133
	$l_key_enable_2 = "It has openned the following ports : ";
138
	$l_key_enable_2 = "It has openned the following ports : ";
134
	$l_force_signal = "Signal strength";
139
	$l_force_signal = "Signal strength";
135
	$l_imei_device = "Device IMEI";
140
	$l_imei_device = "Device IMEI";
136
	$l_sms_received = "Number of SMS received";
141
	$l_sms_received = "Number of SMS received";
137
	$l_stop = "Stop";
142
	$l_stop = "Stop";
138
	$l_gammu_on="The service is running";
143
	$l_gammu_on="The service is running";
139
	$l_gammu_off="The service is down";
144
	$l_gammu_off="The service is down";
140
	$l_edit = "Modify";
145
	$l_edit = "Modify";
-
 
146
	$l_error_wrong_port = "The listening port ($gammu_smsd_port) doesn't exist";
141
	$l_error_label_empty = "Field empty";
147
	$l_error_label_empty = "Field empty";
142
	$l_error_label_num = "It's not a valid PIN password";
148
	$l_error_label_num = "It's not a valid PIN password";
143
	$l_error_label_num2 = "It's not a number";
149
	$l_error_label_num2 = "It's not a number";
144
	$l_error_label_num3 = "The phone number is not good: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
150
	$l_error_label_num3 = "The phone number is not good: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
145
	$l_error_writefail = "Can not communicate with the GSM MODEM port (ttyUSB0).";
151
	$l_error_writefail = "Can not communicate with the GSM MODEM port (ttyUSB0).";
Line 160... Line 166...
160
	$l_country_enable="Enable";
166
	$l_country_enable="Enable";
161
	$l_country_disable="Disable";
167
	$l_country_disable="Disable";
162
	$l_service_status_img_ok="Running";
168
	$l_service_status_img_ok="Running";
163
	$l_service_status_img_ko="Stopped";
169
	$l_service_status_img_ko="Stopped";
164
	$l_connect_speed="Modify the connection speed : ";
170
	$l_connect_speed="Modify the connection speed : ";
165
	$l_connect_port="Connection port";
-
 
166
	$l_tab_first = "first";
171
	$l_tab_first = "first";
167
	$l_tab_last = "last";
172
	$l_tab_last = "last";
168
	$l_tab_next = "next";
173
	$l_tab_next = "next";
169
	$l_tab_prev = "previous";
174
	$l_tab_prev = "previous";
170
	$l_tab_search = "Search :";
175
	$l_tab_search = "Search :";
Line 269... Line 274...
269
	<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' >".$l_autorefresh."
274
	<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' >".$l_autorefresh."
270
	";
275
	";
271
?>
276
?>
272
<center>
277
<center>
273
<br>
278
<br>
274
<form form="GET" action="./autoregistration.php">
279
<form method="post" action="./autoregistration.php">
275
<table border=1 width=100%>
280
<table border=1 width=100%>
276
<tr>
281
<tr>
277
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
282
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
278
</tr>
283
</tr>
279
<tr>
284
<tr>
280
<?php
285
<?php
281
if($find_key=="true")
286
if($find_key=="true")
282
{
287
{
283
	if(isset($_GET['config_submit'])){
-
 
284
		switch ($_GET['speed']) {
-
 
285
		case "at":
-
 
286
			exec("sudo $script --replace_connect  ");
-
 
287
			break;
-
 
288
		case "9600":
-
 
289
			exec("sudo $script --replace_connect 9600");
-
 
290
			break;
-
 
291
		case "19200":
-
 
292
			exec("sudo $script --replace_connect 19200");
-
 
293
			break;
-
 
294
		case "115200":
-
 
295
			exec("sudo $script --replace_connect 115200");
-
 
296
			break;
-
 
297
		}	
-
 
298
	}
-
 
299
	$current_speed = exec("sudo $script --connect");
-
 
300
	echo '	<td width="50%">'.$l_key_enable_1."<b>".str_replace("at","",$current_speed).' Bauds</b>';
-
 
301
	echo '<br>'.$l_key_enable_2.'<b>';
-
 
302
	reset ($openned_ports);
-
 
303
	while ( list(,$row) = each($openned_ports))
-
 
304
	{
-
 
305
		echo $row." ";
-
 
306
	}
-
 
307
	echo '</b></td>';
-
 
308
	echo '
-
 
309
	<td align="right">	'.$l_connect_speed.'
-
 
310
			<select name="speed">
-
 
311
				<option value="at"></option>
-
 
312
				<option value="9600">9600 Bauds</option>
-
 
313
				<option value="19200">19200 Bauds</option>
-
 
314
				<option value="115200">115200 Bauds</option>
-
 
315
			</select>
-
 
316
			<input type="submit" name="config_submit">
-
 
317
	</td>';
-
 
318
}
-
 
319
else
-
 
320
{
-
 
321
	echo "<td>$l_key_diseable</td>";
-
 
322
}
-
 
323
?>
-
 
324
</tr>
-
 
325
</table>
-
 
326
</form>
-
 
327
</center>
-
 
328
<br>
-
 
329
<?php
-
 
330
 
-
 
331
if ($find_key=="true")
-
 
332
{
-
 
333
	#Nom du fichier de log lorsque gammu est démarré
-
 
334
	#$file_log = "gammu-smsd.log";
-
 
335
 
-
 
336
	#Recuperation du code PIN actuel
-
 
337
	$current_pin = exec("sudo $script --pin");	
-
 
338
	
-
 
339
	#Recuperation du nombre de try avant le ban perm
-
 
340
	$current_try_ban = exec("sudo $script --try_ban");
-
 
341
 
-
 
342
	#Recuperation de la durée d'une session créée
-
 
343
	$current_time_account = exec("sudo $script --time_account");
-
 
344
 
-
 
345
	#Recuperation de la durée dun ban perm (après flood)
-
 
346
	$current_time_perm = exec("sudo $script --time_perm");
-
 
347
 
-
 
348
	#Detection neméro de tel
-
 
349
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
-
 
350
	
-
 
351
	#Detection problème avec la SIM
-
 
352
	$current_simfail = exec("sudo $script --last_nosim");
-
 
353
 
-
 
354
	#Recuperation de la dernière ligne de START
-
 
355
	$current_last_start = exec("sudo $script --last_start");
-
 
356
 
-
 
357
	#Recuperarion de la dernière ligne de STOP
-
 
358
	$current_last_stop = exec("sudo $script --last_stop");
-
 
359
 
-
 
360
	#Recuperation de la dernière ligne de SECURITYERROR
-
 
361
	$current_last_secu = exec("sudo $script --last_secu");
-
 
362
 
-
 
363
	#Recuperation de la dernière ligne de DEVICEWRITEERROR
-
 
364
	$current_last_write = exec("sudo $script --last_writeerror");
-
 
365
 
-
 
366
	#Recuperation de la dernière ligne de TIMEOUT
-
 
367
	$current_last_timeout = exec("sudo $script --last_timeout");
-
 
368
	
-
 
369
	# Test si le service est lancé
-
 
370
	if ($gammu_pid=="")
-
 
371
	{
-
 
372
		$force_signal = "-";
-
 
373
		$imei_device = "-";
-
 
374
		$sms_received = "-";
-
 
375
 
-
 
376
		$gammu="<td><img src=\"/images/state_error.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ko."\"></td><td>$l_gammu_off</td>";
-
 
377
		$gammu_status_on="";
-
 
378
		$gammu_status_off="disabled";
-
 
379
 
-
 
380
		if($current_last_secu!="")
-
 
381
		{
-
 
382
			if(($current_last_secu > $current_last_start) && ($current_last_secu < $current_last_stop))
-
 
383
			{
-
 
384
				$gammu_simsecu="<tr><td colspan=7><font color=red>$l_error_simsecu_l</font></td></tr>";
-
 
385
			}
-
 
386
		}
-
 
387
	} else {
-
 
388
		# Recuperation de la force du signal et IMEI et nombre de sms reçu
-
 
389
		$val_force_signal = exec("sudo $script --signal_device");
-
 
390
		$imei_device = exec("sudo $script --imei_device");
-
 
391
		$sms_received = exec("sudo $script --sms_received");
-
 
392
 
-
 
393
		if ($val_force_signal < 21) {
-
 
394
			$force_signal = "<img src=\"/images/signal_0.png\">  --  ".$val_force_signal." %";
-
 
395
		} elseif ($val_force_signal < 41) {
-
 
396
			$force_signal = "<img src=\"/images/signal_20.png\">  --  ".$val_force_signal." %";
-
 
397
 
-
 
398
		} elseif ($val_force_signal < 61) {
-
 
399
			$force_signal = "<img src=\"/images/signal_40.png\">  --  ".$val_force_signal." %";
-
 
400
 
-
 
401
		} elseif ($val_force_signal < 81) {
-
 
402
			$force_signal = "<img src=\"/images/signal_60.png\">  --  ".$val_force_signal." %";
-
 
403
 
-
 
404
		} elseif ($val_force_signal < 101) {
-
 
405
			$force_signal = "<img src=\"/images/signal_80.png\">  --  ".$val_force_signal." %";
-
 
406
 
-
 
407
		}
-
 
408
 
-
 
409
		$gammu="<td><img src=\"/images/state_ok.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ok."\"></td><td>$l_gammu_on</td>";
-
 
410
		if($current_last_timeout!=""){
-
 
411
			if(($current_last_timeout > $current_last_start) && ($current_last_timeout > $current_last_stop))
-
 
412
			{
-
 
413
				$gammu_timeout="<tr><td colspan=7><font color=red>$l_error_timeoutfail</font></td></tr>";
288
	# Start / stop of gammu-smsd (3*7sec) --> to be improve with  systemd unit (see tarball in contrib/init folder) 
414
			}
-
 
415
		}
-
 
416
		
-
 
417
		if($current_last_secu!="")
-
 
418
		{
-
 
419
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
-
 
420
			{
-
 
421
				exec("sudo $script --stop");
-
 
422
			}
-
 
423
		}
-
 
424
		
-
 
425
		if($current_last_write!=""){
-
 
426
			if(($current_last_write > $current_last_start) && ($current_last_write > $current_last_stop))
-
 
427
			{
-
 
428
				$gammu_writeerror="<tr><td colspan=7><font color=red>$l_error_writefail</font></td></tr>";
-
 
429
			}
-
 
430
		}
-
 
431
		
-
 
432
		if($current_simfail!="")
-
 
433
		{
-
 
434
			if(($current_simfail > $current_last_start) && ($current_simfail > $current_last_stop))
-
 
435
			{
-
 
436
				$gammu_simfail="<tr><td colspan=7><font color=red>$l_error_simfail</font></td></tr>";
-
 
437
			}
-
 
438
		}
-
 
439
		$gammu_status_on="disabled";
-
 
440
		$gammu_status_off="";
-
 
441
	}
-
 
442
 
-
 
443
 
-
 
444
	#Lancement et arret de gammu-smsd 3*7sec
-
 
445
	if(isset($_GET["start"])){
289
	if(isset($_GET["start"])){
446
		$gammu_1=exec("sudo $script --start");
290
		$gammu_1=exec("sudo $script --start");
447
		sleep(7);
291
		sleep(7);
448
		if($current_last_secu!="")
292
		if($current_last_secu!="")
449
		{
293
		{
Line 469... Line 313...
469
			}
313
			}
470
		}
314
		}
471
		header('Location: autoregistration.php');
315
		header('Location: autoregistration.php');
472
		exit();
316
		exit();
473
	}
317
	}
474
 
-
 
475
	if(isset($_GET["stop"])){
318
	if(isset($_GET["stop"])){
476
		exec("sudo $script --stop");
319
		exec("sudo $script --stop");
477
		sleep(8);
320
		sleep(8);
478
		header('Location: autoregistration.php');
321
		header('Location: autoregistration.php');
479
		exit();
322
		exit();
480
	}
323
	}
-
 
324
	# Set the speed connexion to MODEM	
-
 
325
	if(isset($_GET['b_speed'])){
-
 
326
			echo "speed = ".$speed;
-
 
327
		switch ($_GET['speed']) {
-
 
328
		case "at":
-
 
329
			exec("sudo $script --replace_connect  ");
-
 
330
			break;
-
 
331
		case "9600":
-
 
332
			exec("sudo $script --replace_connect 9600");
-
 
333
			break;
-
 
334
		case "19200":
-
 
335
			exec("sudo $script --replace_connect 19200");
-
 
336
			break;
-
 
337
		case "115200":
-
 
338
			exec("sudo $script --replace_connect 115200");
-
 
339
			break;
-
 
340
		}
-
 
341
		//header('Location: autoregistration.php');
-
 
342
		//exit();
-
 
343
	}
481
 
344
	
482
 
-
 
483
	#Edition du NUMERO de telephone
345
	# Set the SIM phone number
484
	if(isset($_GET["b_num_alcasar"])){
346
	if(isset($_GET["b_num_alcasar"])){
485
		$num = $_GET["num_alcasar"];
347
		$num = $_GET["num_alcasar"];
486
		$error_num_alcasar = "";
348
		$error_num_alcasar = "";
487
		if($num !="")
349
		if($num !="")
488
		{
350
		{
Line 501... Line 363...
501
		{
363
		{
502
			$error_num_alcasar=$l_error_label_empty;
364
			$error_num_alcasar=$l_error_label_empty;
503
		}
365
		}
504
	}
366
	}
505
	
367
	
506
	#Edition du code PIN
368
	# Set the SIM card PIN number
507
	if(isset($_GET["b_pin"])){
369
	if(isset($_GET["b_pin"])){
508
		$pin = $_GET["pin"];
370
		$pin = $_GET["pin"];
509
		$error_pin = "";
371
		$error_pin = "";
510
		if($pin !="")
372
		if($pin !="")
511
		{
373
		{
Line 524... Line 386...
524
		{
386
		{
525
			$error_pin=$l_error_label_empty;
387
			$error_pin=$l_error_label_empty;
526
		}
388
		}
527
	}
389
	}
528
	
390
 
529
	
-
 
530
	#Edition du nombre d'essais avant le ban perm
391
	# Set the number of tries before ban
531
	if(isset($_GET["b_ban_temp"])){
392
	if(isset($_GET["b_ban_temp"])){
532
		$nb_ban_temp = $_GET["nb_essais"];
393
		$nb_ban_temp = $_GET["nb_essais"];
533
		$error_nb_essais = "";
394
		$error_nb_essais = "";
534
		if($nb_ban_temp !="")
395
		if($nb_ban_temp !="")
535
		{
396
		{
Line 548... Line 409...
548
		{
409
		{
549
			$error_nb_essais=$l_error_label_empty;
410
			$error_nb_essais=$l_error_label_empty;
550
		}
411
		}
551
	}
412
	}
552
 
413
 
553
 
-
 
554
	#Edition de la durée pour un compte créé
414
	# Set the session timeout for each new account
555
	if(isset($_GET["b_time_account"])){
415
	if(isset($_GET["b_time_account"])){
556
		$time_account = $_GET["time_account"];
416
		$time_account = $_GET["time_account"];
557
		$error_time_account = "";
417
		$error_time_account = "";
558
		if($time_account !="")
418
		if($time_account !="")
559
		{
419
		{
Line 572... Line 432...
572
		{
432
		{
573
			$error_time_account=$l_error_label_empty;
433
			$error_time_account=$l_error_label_empty;
574
		}
434
		}
575
	}
435
	}
576
 
436
 
577
	#Edition de la durée d'un ban perm (après flood)
437
	# Set the ban timeout
578
	if(isset($_GET["b_time_perm"])){
438
	if(isset($_GET["b_time_perm"])){
579
		$time_perm = $_GET["time_perm"];
439
		$time_perm = $_GET["time_perm"];
580
		$error_time_perm = "";
440
		$error_time_perm = "";
581
		if($time_perm !="")
441
		if($time_perm !="")
582
		{
442
		{
Line 595... Line 455...
595
		{
455
		{
596
			$error_time_perm=$l_error_label_empty;
456
			$error_time_perm=$l_error_label_empty;
597
		}
457
		}
598
	}
458
	}
599
 
459
	
600
	# Suppression d'un numero bloqué
460
	# removing a banned phone number
601
	if(isset($_GET['num_select'])){
461
	if(isset($_GET['num_select'])){
602
		$numero=$_GET['num_select'];
462
		$numero=$_GET['num_select'];
603
 
463
 
604
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
464
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
605
		if (!empty($add_mac)) {
465
		if (!empty($add_mac)) {
606
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
466
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
607
		}
467
		}
608
 
-
 
609
		exec("sudo $script --unlock_num $numero");
468
		exec("sudo $script --unlock_num $numero");
610
		header('Location: autoregistration.php');
469
		header('Location: autoregistration.php');
611
		exit();
470
		exit();
612
	}
471
	}
613
 
472
 
Line 617... Line 476...
617
		exec("sudo $script --change_country ".escapeshellarg($country));
476
		exec("sudo $script --change_country ".escapeshellarg($country));
618
		exec("sudo $script --change_country_filter advance");
477
		exec("sudo $script --change_country_filter advance");
619
		header('Location: autoregistration.php');
478
		header('Location: autoregistration.php');
620
		exit();
479
		exit();
621
	}
480
	}
622
 
-
 
623
	if(isset($_GET['b_france_enable'])){
481
	if(isset($_GET['b_france_enable'])){
624
		exec("sudo $script --change_country_dis_all");
482
		exec("sudo $script --change_country_dis_all");
625
		exec("sudo $script --change_country France");
483
		exec("sudo $script --change_country France");
626
		exec("sudo $script --change_country_filter fr");
484
		exec("sudo $script --change_country_filter fr");
627
		header('Location: autoregistration.php');
485
		header('Location: autoregistration.php');
628
		exit();
486
		exit();
629
	}
487
	}
630
 
-
 
631
	if(isset($_GET['b_ue_enable'])){
488
	if(isset($_GET['b_ue_enable'])){
632
		exec("sudo $script --change_country_dis_all");
489
		exec("sudo $script --change_country_dis_all");
633
		$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");
490
		$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");
634
		foreach ($array_ue as $pays){
491
		foreach ($array_ue as $pays){
635
			exec("sudo $script --change_country ".escapeshellarg($pays));
492
			exec("sudo $script --change_country ".escapeshellarg($pays));
Line 637... Line 494...
637
		
494
		
638
		exec("sudo $script --change_country_filter ue");
495
		exec("sudo $script --change_country_filter ue");
639
		header('Location: autoregistration.php');
496
		header('Location: autoregistration.php');
640
		exit();
497
		exit();
641
	}
498
	}
642
 
-
 
643
	if(isset($_GET["b_country_enable"])){
499
	if(isset($_GET["b_country_enable"])){
644
		exec("sudo $script --change_country_ena_all");
500
		exec("sudo $script --change_country_ena_all");		
645
		exec("sudo $script --change_country_filter all");
501
		exec("sudo $script --change_country_filter all");
646
		header('Location: autoregistration.php');
502
		header('Location: autoregistration.php');
647
		exit();
503
		exit();
648
	}
504
	}
649
 
-
 
650
	if(isset($_GET["b_country_disable"])){
505
	if(isset($_GET["b_country_disable"])){
651
		exec("sudo $script --change_country_dis_all");
506
		exec("sudo $script --change_country_dis_all");
652
		header('Location: autoregistration.php');
507
		header('Location: autoregistration.php');
653
		exit();
508
		exit();
654
	}
509
	}
655
	
510
 
-
 
511
	echo '	<td>'.$l_key_enable_1;
-
 
512
	echo '<br>'.$l_key_enable_2.'<b>';
-
 
513
	reset ($openned_ports);
-
 
514
	while ( list(,$row) = each($openned_ports))
-
 
515
	{
-
 
516
		echo $row." ";
-
 
517
	}
-
 
518
	echo '</b></td>';
-
 
519
}
-
 
520
else
-
 
521
{
-
 
522
	echo "<td>$l_key_diseable</td>";
-
 
523
}
-
 
524
?>
-
 
525
</tr>
-
 
526
</table>
-
 
527
</form>
-
 
528
</center>
-
 
529
<br>
-
 
530
<?php
-
 
531
 
-
 
532
if ($find_key=="true")
-
 
533
{
-
 
534
	#Nom du fichier de log lorsque gammu est démarré
-
 
535
	#$file_log = "gammu-smsd.log";
-
 
536
 
-
 
537
	#Recuperation de la vitesse de connexion
-
 
538
	$current_speed = exec("sudo $script --connect");
-
 
539
 
-
 
540
	#Recuperation du code PIN actuel
-
 
541
	$current_pin = exec("sudo $script --pin");	
-
 
542
	
-
 
543
	#Recuperation du nombre de try avant le ban perm
-
 
544
	$current_try_ban = exec("sudo $script --try_ban");	
-
 
545
 
-
 
546
	#Recuperation de la durée d'une session créée
-
 
547
	$current_time_account = exec("sudo $script --time_account");	
-
 
548
 
-
 
549
	#Recuperation de la durée dun ban perm (après flood)
-
 
550
	$current_time_perm = exec("sudo $script --time_perm");	
-
 
551
 
-
 
552
	#Detection neméro de tel
-
 
553
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
-
 
554
	
-
 
555
	#Detection problème avec la SIM
-
 
556
	$current_simfail = exec("sudo $script --last_nosim");
-
 
557
 
-
 
558
	#Recuperation de la dernière ligne de START
-
 
559
	$current_last_start = exec("sudo $script --last_start");
-
 
560
 
-
 
561
	#Recuperarion de la dernière ligne de STOP
-
 
562
	$current_last_stop = exec("sudo $script --last_stop");
-
 
563
 
-
 
564
	#Recuperation de la dernière ligne de SECURITYERROR
-
 
565
	$current_last_secu = exec("sudo $script --last_secu");
-
 
566
 
-
 
567
	#Recuperation de la dernière ligne de DEVICEWRITEERROR
-
 
568
	$current_last_write = exec("sudo $script --last_writeerror");
-
 
569
 
-
 
570
	#Recuperation de la dernière ligne de TIMEOUT
-
 
571
	$current_last_timeout = exec("sudo $script --last_timeout");
-
 
572
	
-
 
573
	# Test si le service est lancé
-
 
574
	if ($gammu_pid=="")
-
 
575
	{
-
 
576
		$force_signal = "-";
-
 
577
		$imei_device = "-";
-
 
578
		$sms_received = "-";
-
 
579
 
-
 
580
		$gammu="<td><img src=\"/images/state_error.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ko."\"></td><td>$l_gammu_off</td>";	
-
 
581
		$gammu_status_on="";
-
 
582
		$gammu_status_off="disabled";
-
 
583
 
-
 
584
		if($current_last_secu!="")
-
 
585
		{
-
 
586
			if(($current_last_secu > $current_last_start) && ($current_last_secu < $current_last_stop))
-
 
587
			{
-
 
588
				$gammu_simsecu="<tr><td colspan=7><font color=red>$l_error_simsecu_l</font></td></tr>";	
-
 
589
			}
-
 
590
		}
-
 
591
	} else {
-
 
592
		# Recuperation de la force du signal et IMEI et nombre de sms reçu
-
 
593
		$val_force_signal = exec("sudo $script --signal_device");
-
 
594
		$imei_device = exec("sudo $script --imei_device");
-
 
595
		$sms_received = exec("sudo $script --sms_received");
-
 
596
 
-
 
597
		if ($val_force_signal < 21) {
-
 
598
			$force_signal = "<img src=\"/images/signal_0.png\">  --  ".$val_force_signal." %";
-
 
599
		} elseif ($val_force_signal < 41) {
-
 
600
			$force_signal = "<img src=\"/images/signal_20.png\">  --  ".$val_force_signal." %";
-
 
601
 
-
 
602
		} elseif ($val_force_signal < 61) {
-
 
603
			$force_signal = "<img src=\"/images/signal_40.png\">  --  ".$val_force_signal." %";
-
 
604
 
-
 
605
		} elseif ($val_force_signal < 81) {
-
 
606
			$force_signal = "<img src=\"/images/signal_60.png\">  --  ".$val_force_signal." %";
-
 
607
 
-
 
608
		} elseif ($val_force_signal < 101) {
-
 
609
			$force_signal = "<img src=\"/images/signal_80.png\">  --  ".$val_force_signal." %";
-
 
610
 
-
 
611
		}
-
 
612
		
-
 
613
		$gammu="<td><img src=\"/images/state_ok.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ok."\"></td><td>$l_gammu_on</td>";	
-
 
614
		if ($listen_on_right_port != "true"){
-
 
615
			$gammu_wrong_port="<tr><td colspan=7><font color=red>$l_error_wrong_port</font></td></tr>";
-
 
616
		}	
-
 
617
	
-
 
618
		if($current_last_timeout!=""){
-
 
619
			if(($current_last_timeout > $current_last_start) && ($current_last_timeout > $current_last_stop))
-
 
620
			{
-
 
621
				$gammu_timeout="<tr><td colspan=7><font color=red>$l_error_timeoutfail</font></td></tr>";
-
 
622
			}
-
 
623
		}
-
 
624
		
-
 
625
		if($current_last_secu!="")
-
 
626
		{
-
 
627
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
-
 
628
			{
-
 
629
				exec("sudo $script --stop");
-
 
630
			}
-
 
631
		}
-
 
632
		
-
 
633
		if($current_last_write!=""){
-
 
634
			if(($current_last_write > $current_last_start) && ($current_last_write > $current_last_stop))
-
 
635
			{
-
 
636
				$gammu_writeerror="<tr><td colspan=7><font color=red>$l_error_writefail</font></td></tr>";	
-
 
637
			}
-
 
638
		}
-
 
639
		
-
 
640
		if($current_simfail!="")
-
 
641
		{
-
 
642
			if(($current_simfail > $current_last_start) && ($current_simfail > $current_last_stop))
-
 
643
			{
-
 
644
				$gammu_simfail="<tr><td colspan=7><font color=red>$l_error_simfail</font></td></tr>";
-
 
645
			}
-
 
646
		}
-
 
647
		$gammu_status_on="disabled";
-
 
648
		$gammu_status_off="";
-
 
649
	}
-
 
650
 
656
	echo "<form action=\"autoregistration.php\" methode=\"GET\">
651
	echo "<form action=\"autoregistration.php\" method=\"post\">
657
		<table border=1>
652
		<table border=1>
658
		<tr>
653
		<tr>
659
		<td colspan=3><b>$l_conf</b></td>
654
		<td colspan=3><b>$l_conf</b></td>
660
		<td><b>$l_conf_actu</b></td>
655
		<td><b>$l_conf_actu</b></td>
661
		</tr>
656
		</tr>
662
		<tr>
657
		<tr>
-
 
658
		<td> $l_speed </td><td>
-
 
659
			<select name=\"speed\">
-
 
660
				<option value=\"at\">Auto</option>
-
 
661
				<option value=\"'9600\">9600 Bauds</option>
-
 
662
				<option value=\"19200\">19200 Bauds</option>
-
 
663
				<option value=\"'115200\">115200 Bauds</option>
-
 
664
			</select>
-
 
665
		<td><button type=\"submit\" name=\"b_speed\">$l_edit</button></td>
-
 
666
		<td><center><font color=\"green\">".str_replace("at","",$current_speed)." Bauds</font></center></td>
-
 
667
		<tr>
663
		<td> $l_connect_port </td><td><select name=\"port\">'";
668
		<td> $l_connect_port </td><td><select name=\"port\">'";
664
		reset ($openned_ports);
669
		reset ($openned_ports);
665
		while ( list(,$row) = each($openned_ports))
670
		while ( list(,$row) = each($openned_ports))
666
		{
671
		{
667
			echo '<option value="'.$row.'">'.$row.'</option>';
672
			echo '<option value="'.$row.'">'.$row.'</option>';
668
			echo $row." ";
673
			echo $row." ";
669
		}
674
		}
670
	echo "</select></td>
675
	echo "</select></td>
671
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
676
		<td><button type=\"submit\" name=\"b_port\" $gammu_status_on>$l_edit</button></td>
672
		<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
677
		<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
673
		</tr>
678
		</tr>
674
		<tr>
679
		<tr>
675
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
680
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
676
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
681
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
Line 716... Line 721...
716
			<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
721
			<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
717
			<td><center>$force_signal</center></td>
722
			<td><center>$force_signal</center></td>
718
			<td><center>$imei_device</center></td>
723
			<td><center>$imei_device</center></td>
719
			<td><center>$sms_received</center></td>
724
			<td><center>$sms_received</center></td>
720
		</tr>
725
		</tr>
-
 
726
		$gammu_wrong_port
721
		$gammu_puk
727
		$gammu_puk
722
		$gammu_simfail
728
		$gammu_simfail
723
		$gammu_simsecu
729
		$gammu_simsecu
724
		$gammu_timeout
730
		$gammu_timeout
725
		$gammu_writeerror
731
		$gammu_writeerror
Line 771... Line 777...
771
					}
777
					}
772
				?>
778
				?>
773
				<td colspan="3" align="center"><strong><?php echo $l_country_filter; ?></strong><font size="3" color="red"><?php echo $country_filter; ?></font></td>
779
				<td colspan="3" align="center"><strong><?php echo $l_country_filter; ?></strong><font size="3" color="red"><?php echo $country_filter; ?></font></td>
774
			</tr>
780
			</tr>
775
			<tr>
781
			<tr>
776
				<form action="autoregistration.php" methode="POST">
782
				<form action="autoregistration.php" method="post">
777
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
783
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
778
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
784
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
779
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
785
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
780
				</form>
786
				</form>
781
			</tr>	
787
			</tr>	
Line 797... Line 803...
797
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
803
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
798
						while($row = mysqli_fetch_array($result_country))
804
						while($row = mysqli_fetch_array($result_country))
799
						{
805
						{
800
						echo "	
806
						echo "	
801
						<tr>
807
						<tr>
802
						<form action=\"autoregistration.php\" methode=\"POST\">
808
						<form action=\"autoregistration.php\" method=\"post\">
803
						<td>
809
						<td>
804
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
810
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
805
							".$row['name']."
811
							".$row['name']."
806
						</td>
812
						</td>
807
						<td>".$row['id']."</td>
813
						<td>".$row['id']."</td>
Line 849... Line 855...
849
					<?php 
855
					<?php 
850
					while($row = mysqli_fetch_array($result))
856
					while($row = mysqli_fetch_array($result))
851
					{
857
					{
852
					echo "	
858
					echo "	
853
						<tr>
859
						<tr>
854
						<form action=\"autoregistration.php\" methode=\"POST\">
860
						<form action=\"autoregistration.php\" method=\"post\">
855
						<td>
861
						<td>
856
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
862
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
857
							".$row['SenderNumber']."
863
							".$row['SenderNumber']."
858
						</td>";
864
						</td>";
859
		
865