Subversion Repositories ALCASAR

Rev

Rev 2991 | Rev 3076 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2991 Rev 2992
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: autoregistration.php 2915 2021-02-07 22:59:23Z rexy $
-
 
3
 
2
 
4
#Define
3
#Define
5
$gammu_wrong_port = "";
4
$gammu_wrong_port = "";
6
$gammu_puk = "";
5
$gammu_puk = "";
7
$gammu_simfail = "";
6
$gammu_simfail = "";
Line 42... Line 41...
42
{	# close gammu if it's started
41
{	# close gammu if it's started
43
	if ($gammu_pid!="")
42
	if ($gammu_pid!="")
44
	{
43
	{
45
		exec("sudo $script --stop");
44
		exec("sudo $script --stop");
46
		sleep(8);
45
		sleep(8);
47
		header('Location: autoregistration.php');
46
		header('Location: user_by_sms.php');
48
		exit();
47
		exit();
49
	}
48
	}
50
}
49
}
51
 
50
 
52
# Choice of language
51
# Choice of language
53
$Language = 'en';
52
$Language = 'en';
54
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
53
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
55
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
54
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
56
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
55
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
57
if($Language == 'fr'){
56
if($Language == 'fr'){
58
	$l_title = "Auto enregistrement (SMS)";
57
	$l_title = "Inscription par SMS";
59
	$l_conf = "Configuration";
58
	$l_conf = "Configuration";
60
	$l_conf_actu = "Configuration actuelle";
59
	$l_conf_actu = "Configuration actuelle";
61
	$l_speed = "Vitesse de connexion au MODEM";
60
	$l_speed = "Vitesse de connexion au MODEM";
62
	$l_connect_port="Port de connexion au MODEM";
61
	$l_connect_port="Port de connexion au MODEM";
63
	$l_pin = "Code PIN de la carte SIM";
62
	$l_pin = "Code PIN de la carte SIM";
Line 119... Line 118...
119
	$l_country_ue_ena = "Autorise les numéros européens";
118
	$l_country_ue_ena = "Autorise les numéros européens";
120
	$l_country_all_ena = "Autorise tous les pays";
119
	$l_country_all_ena = "Autorise tous les pays";
121
	$l_country_advanced_ena = "Autorisation personnalisée";
120
	$l_country_advanced_ena = "Autorisation personnalisée";
122
	$l_advance = "Avancé";
121
	$l_advance = "Avancé";
123
} else if($Language == 'es') {
122
} else if($Language == 'es') {
124
    $l_title = "Auto-registro (SMS)";
123
    $l_title = "Registro por SMS";
125
	$l_conf = "Configuración";
124
	$l_conf = "Configuración";
126
	$l_conf_actu = "Configuración actual";
125
	$l_conf_actu = "Configuración actual";
127
	$l_speed = "Velocidad de conexión al MODEM";
126
	$l_speed = "Velocidad de conexión al MODEM";
128
	$l_connect_port="Puerto de conexión al MODEM";
127
	$l_connect_port="Puerto de conexión al MODEM";
129
	$l_pin = "PIN de la tarjeta SIM";
128
	$l_pin = "PIN de la tarjeta SIM";
Line 185... Line 184...
185
	$l_country_ue_ena = "Autoriza números europeos";
184
	$l_country_ue_ena = "Autoriza números europeos";
186
	$l_country_all_ena = "Autorizar todos los países";
185
	$l_country_all_ena = "Autorizar todos los países";
187
	$l_country_advanced_ena = "Autorización avanzada";
186
	$l_country_advanced_ena = "Autorización avanzada";
188
	$l_advance = "Avanzado";
187
	$l_advance = "Avanzado";
189
} else {
188
} else {
190
	$l_title = "Auto registration (SMS)";
189
	$l_title = "SMS registration";
191
	$l_conf = "Configuration";
190
	$l_conf = "Configuration";
192
	$l_conf_actu = "Current configuration";
191
	$l_conf_actu = "Current configuration";
193
	$l_speed = "Connection speed to the MODEM";
192
	$l_speed = "Connection speed to the MODEM";
194
	$l_connect_port="Connection port to the MODEM";
193
	$l_connect_port="Connection port to the MODEM";
195
	$l_pin = "PIN password of the SIM card";
194
	$l_pin = "PIN password of the SIM card";
Line 376... Line 375...
376
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
375
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
377
			{
376
			{
378
				exec("sudo $script --stop");
377
				exec("sudo $script --stop");
379
			}
378
			}
380
		}
379
		}
381
		header('Location: autoregistration.php');
380
		header('Location: user_by_sms.php');
382
		exit();
381
		exit();
383
	}
382
	}
384
	if(isset($_POST["stop"])){
383
	if(isset($_POST["stop"])){
385
		exec("sudo $script --stop");
384
		exec("sudo $script --stop");
386
		sleep(8);
385
		sleep(8);
387
		header('Location: autoregistration.php');
386
		header('Location: user_by_sms.php');
388
		exit();
387
		exit();
389
	}
388
	}
390
	
389
	
391
	# Set the connexion speed to MODEM	
390
	# Set the connexion speed to MODEM	
392
	if(isset($_POST['b_speed'])){
391
	if(isset($_POST['b_speed'])){
Line 401... Line 400...
401
			exec("sudo $script --replace_speed 19200");
400
			exec("sudo $script --replace_speed 19200");
402
			break;
401
			break;
403
		case "115200":
402
		case "115200":
404
			exec("sudo $script --replace_speed 115200");
403
			exec("sudo $script --replace_speed 115200");
405
			break;
404
			break;
406
		header('Location: autoregistration.php');
405
		header('Location: user_by_sms.php');
407
		exit();
406
		exit();
408
		}
407
		}
409
	}
408
	}
410
	
409
	
411
	# Set the connexion port to MODEM	
410
	# Set the connexion port to MODEM	
412
	if(isset($_POST['b_port'])){
411
	if(isset($_POST['b_port'])){
413
		echo "speed = ".$_POST['port'];
412
		echo "speed = ".$_POST['port'];
414
		$port = $_POST['port'];
413
		$port = $_POST['port'];
415
		exec("sudo $script --replace_port ".escapeshellarg($port));
414
		exec("sudo $script --replace_port ".escapeshellarg($port));
416
		header('Location: autoregistration.php');
415
		header('Location: user_by_sms.php');
417
		exit();
416
		exit();
418
	}
417
	}
419
 
418
 
420
	# Set the SIM phone number
419
	# Set the SIM phone number
421
	if(isset($_POST["b_num_alcasar"])){
420
	if(isset($_POST["b_num_alcasar"])){
Line 425... Line 424...
425
		if($num !="")
424
		if($num !="")
426
		{
425
		{
427
			if(preg_match('#^\+#',$num))
426
			if(preg_match('#^\+#',$num))
428
			{
427
			{
429
				exec("sudo $script --replace_numero_alcasar ".escapeshellarg($num));
428
				exec("sudo $script --replace_numero_alcasar ".escapeshellarg($num));
430
				header('Location: autoregistration.php');
429
				header('Location: user_by_sms.php');
431
				exit();
430
				exit();
432
			}
431
			}
433
			else
432
			else
434
			{
433
			{
435
				$error_num_alcasar=$l_error_label_num3;
434
				$error_num_alcasar=$l_error_label_num3;
Line 448... Line 447...
448
		if($pin !="")
447
		if($pin !="")
449
		{
448
		{
450
			if(is_numeric($pin))
449
			if(is_numeric($pin))
451
			{
450
			{
452
				exec("sudo $script --replace_pin ".escapeshellarg($pin));
451
				exec("sudo $script --replace_pin ".escapeshellarg($pin));
453
				header('Location: autoregistration.php');
452
				header('Location: user_by_sms.php');
454
				exit();
453
				exit();
455
			}
454
			}
456
			else
455
			else
457
			{
456
			{
458
				$error_pin=$l_error_label_num;			
457
				$error_pin=$l_error_label_num;			
Line 471... Line 470...
471
		if($time_account !="")
470
		if($time_account !="")
472
		{
471
		{
473
			if(is_numeric($time_account))
472
			if(is_numeric($time_account))
474
			{
473
			{
475
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
474
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
476
				header('Location: autoregistration.php');
475
				header('Location: user_by_sms.php');
477
				exit();
476
				exit();
478
			}
477
			}
479
			else
478
			else
480
			{
479
			{
481
				$error_time_account=$l_error_label_num2;
480
				$error_time_account=$l_error_label_num2;
Line 494... Line 493...
494
		if($nb_ban_temp !="")
493
		if($nb_ban_temp !="")
495
		{
494
		{
496
			if(is_numeric($nb_ban_temp))
495
			if(is_numeric($nb_ban_temp))
497
			{
496
			{
498
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
497
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
499
				header('Location: autoregistration.php');
498
				header('Location: user_by_sms.php');
500
				exit();
499
				exit();
501
			}
500
			}
502
			else
501
			else
503
			{
502
			{
504
				$error_nb_essais=$l_error_label_num2;			
503
				$error_nb_essais=$l_error_label_num2;			
Line 517... Line 516...
517
		if($time_perm !="")
516
		if($time_perm !="")
518
		{
517
		{
519
			if(is_numeric($time_perm))
518
			if(is_numeric($time_perm))
520
			{
519
			{
521
				exec("sudo $script --replace_time_perm ".escapeshellarg($time_perm));
520
				exec("sudo $script --replace_time_perm ".escapeshellarg($time_perm));
522
				header('Location: autoregistration.php');
521
				header('Location: user_by_sms.php');
523
				exit();
522
				exit();
524
			}
523
			}
525
			else
524
			else
526
			{
525
			{
527
				$error_time_perm=$l_error_label_num2;
526
				$error_time_perm=$l_error_label_num2;
Line 540... Line 539...
540
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
539
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
541
		if (!empty($add_mac)) {
540
		if (!empty($add_mac)) {
542
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
541
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
543
		}
542
		}
544
		exec("sudo $script --unlock_num $numero");
543
		exec("sudo $script --unlock_num $numero");
545
		header('Location: autoregistration.php');
544
		header('Location: user_by_sms.php');
546
		exit();
545
		exit();
547
	}
546
	}
548
 
547
 
549
	# Edition etat pays
548
	# Edition etat pays
550
	if(isset($_POST['country_select'])){
549
	if(isset($_POST['country_select'])){
551
		$country=utf8_decode($_POST['country_select']);
550
		$country=utf8_decode($_POST['country_select']);
552
		exec("sudo $script --change_country ".escapeshellarg($country));
551
		exec("sudo $script --change_country ".escapeshellarg($country));
553
		exec("sudo $script --change_country_filter advance");
552
		exec("sudo $script --change_country_filter advance");
554
		header('Location: autoregistration.php');
553
		header('Location: user_by_sms.php');
555
		exit();
554
		exit();
556
	}
555
	}
557
	if(isset($_POST['b_france_enable'])){
556
	if(isset($_POST['b_france_enable'])){
558
		exec("sudo $script --change_country_dis_all");
557
		exec("sudo $script --change_country_dis_all");
559
		exec("sudo $script --change_country France");
558
		exec("sudo $script --change_country France");
560
		exec("sudo $script --change_country_filter fr");
559
		exec("sudo $script --change_country_filter fr");
561
		header('Location: autoregistration.php');
560
		header('Location: user_by_sms.php');
562
		exit();
561
		exit();
563
	}
562
	}
564
	if(isset($_POST['b_ue_enable'])){
563
	if(isset($_POST['b_ue_enable'])){
565
		exec("sudo $script --change_country_dis_all");
564
		exec("sudo $script --change_country_dis_all");
566
		$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");
565
		$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");
567
		foreach ($array_ue as $pays){
566
		foreach ($array_ue as $pays){
568
			exec("sudo $script --change_country ".escapeshellarg($pays));
567
			exec("sudo $script --change_country ".escapeshellarg($pays));
569
		}
568
		}
570
		
569
		
571
		exec("sudo $script --change_country_filter ue");
570
		exec("sudo $script --change_country_filter ue");
572
		header('Location: autoregistration.php');
571
		header('Location: user_by_sms.php');
573
		exit();
572
		exit();
574
	}
573
	}
575
	if(isset($_POST["b_country_enable"])){
574
	if(isset($_POST["b_country_enable"])){
576
		exec("sudo $script --change_country_ena_all");		
575
		exec("sudo $script --change_country_ena_all");		
577
		exec("sudo $script --change_country_filter all");
576
		exec("sudo $script --change_country_filter all");
578
		header('Location: autoregistration.php');
577
		header('Location: user_by_sms.php');
579
		exit();
578
		exit();
580
	}
579
	}
581
	if(isset($_POST["b_country_disable"])){
580
	if(isset($_POST["b_country_disable"])){
582
		exec("sudo $script --change_country_dis_all");
581
		exec("sudo $script --change_country_dis_all");
583
		header('Location: autoregistration.php');
582
		header('Location: user_by_sms.php');
584
		exit();
583
		exit();
585
	}
584
	}
586
 
585
 
587
	echo '	<td>'.$l_key_enable_1;
586
	echo '	<td>'.$l_key_enable_1;
588
	echo '<br>'.$l_key_enable_2.'<b>';
587
	echo '<br>'.$l_key_enable_2.'<b>';
Line 721... Line 720...
721
		}
720
		}
722
		$gammu_status_on="disabled";
721
		$gammu_status_on="disabled";
723
		$gammu_status_off="";
722
		$gammu_status_off="";
724
	}
723
	}
725
 
724
 
726
	echo "<form action=\"autoregistration.php\" method=\"post\">
725
	echo "<form action=\"user_by_sms.php\" method=\"post\">
727
		<table border=1>
726
		<table border=1>
728
		<tr>
727
		<tr>
729
		<td colspan=3><b>$l_conf</b></td>
728
		<td colspan=3><b>$l_conf</b></td>
730
		<td><b>$l_conf_actu</b></td>
729
		<td><b>$l_conf_actu</b></td>
731
		</tr>
730
		</tr>
Line 847... Line 846...
847
					}
846
					}
848
				?>
847
				?>
849
				<td colspan="3" align="center"><strong><?php echo $l_country_filter; ?></strong><font size="3" color="red"><?php echo $country_filter; ?></font></td>
848
				<td colspan="3" align="center"><strong><?php echo $l_country_filter; ?></strong><font size="3" color="red"><?php echo $country_filter; ?></font></td>
850
			</tr>
849
			</tr>
851
			<tr>
850
			<tr>
852
				<form action="autoregistration.php" method="post">
851
				<form action="user_by_sms.php" method="post">
853
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
852
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
854
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
853
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
855
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
854
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
856
				</form>
855
				</form>
857
			</tr>	
856
			</tr>	
Line 873... Line 872...
873
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
872
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
874
						while($row = mysqli_fetch_array($result_country))
873
						while($row = mysqli_fetch_array($result_country))
875
						{
874
						{
876
						echo "	
875
						echo "	
877
						<tr>
876
						<tr>
878
						<form action=\"autoregistration.php\" method=\"post\">
877
						<form action=\"user_by_sms.php\" method=\"post\">
879
						<td>
878
						<td>
880
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
879
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
881
							".$row['name']."
880
							".$row['name']."
882
						</td>
881
						</td>
883
						<td>".$row['id']."</td>
882
						<td>".$row['id']."</td>
Line 925... Line 924...
925
					<?php 
924
					<?php 
926
					while($row = mysqli_fetch_array($result))
925
					while($row = mysqli_fetch_array($result))
927
					{
926
					{
928
					echo "	
927
					echo "	
929
						<tr>
928
						<tr>
930
						<form action=\"autoregistration.php\" method=\"post\">
929
						<form action=\"user_by_sms.php\" method=\"post\">
931
						<td>
930
						<td>
932
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
931
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
933
							".$row['SenderNumber']."
932
							".$row['SenderNumber']."
934
						</td>";
933
						</td>";
935
		
934