Subversion Repositories ALCASAR

Rev

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

Rev 2553 Rev 2557
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: autoregistration.php 2553 2018-05-09 22:04:53Z rexy $
2
# $Id: autoregistration.php 2557 2018-06-03 21:06:17Z rexy $
3
 
3
 
4
#Define
4
#Define
5
$gammu_wrong_port = "";
5
$gammu_wrong_port = "";
6
$gammu_puk = "";
6
$gammu_puk = "";
7
$gammu_simfail = "";
7
$gammu_simfail = "";
Line 23... Line 23...
23
if (!empty($open_port))
23
if (!empty($open_port))
24
{
24
{
25
	$find_key="true";
25
	$find_key="true";
26
	$vendor=exec("udevadm info -n $openned_ports[1] | grep 'MODEL=' | cut -d'=' -f2"); 
26
	$vendor=exec("udevadm info -n $openned_ports[1] | grep 'MODEL=' | cut -d'=' -f2"); 
27
	$model=exec("udevadm info -n $openned_ports[1] | grep 'MODEL_FROM_DATABASE=' | cut -d'=' -f2");
27
	$model=exec("udevadm info -n $openned_ports[1] | grep 'MODEL_FROM_DATABASE=' | cut -d'=' -f2");
28
	$gammu_smsd_port=exec("sudo $script --port"); // Gammu_smsd listen port 
28
	$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port 
29
	while ( list(,$row) = each($openned_ports))
29
	while ( list(,$row) = each($openned_ports))
30
	{
30
	{
31
		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 ?
32
		{
32
		{
33
			$listen_on_right_port="true";
33
			$listen_on_right_port="true";
Line 280... Line 280...
280
<tr>
280
<tr>
281
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
281
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
282
</tr>
282
</tr>
283
<tr>
283
<tr>
284
<?php
284
<?php
285
echo "port = ".$b_port;
-
 
286
if($find_key=="true")
285
if($find_key=="true")
287
{
286
{
288
	# Start / stop of gammu-smsd (3*7sec) --> to be improve with  systemd unit (see tarball in contrib/init folder) 
287
	# Start / stop of gammu-smsd (3*7sec) --> to be improve with  systemd unit (see tarball in contrib/init folder) 
289
	if(isset($_POST["start"])){
288
	if(isset($_POST["start"])){
290
		$gammu_1=exec("sudo $script --start");
289
		$gammu_1=exec("sudo $script --start");
Line 319... Line 318...
319
		exec("sudo $script --stop");
318
		exec("sudo $script --stop");
320
		sleep(8);
319
		sleep(8);
321
		header('Location: autoregistration.php');
320
		header('Location: autoregistration.php');
322
		exit();
321
		exit();
323
	}
322
	}
-
 
323
	
324
	# Set the speed connexion to MODEM	
324
	# Set the connexion speed to MODEM	
325
	if(isset($_POST["b_speed"])){
325
	if(isset($_POST['b_speed'])){
326
		$speed = $_POST["speed"];
-
 
327
		switch ($speed) {
326
		switch ($_POST['speed']) {
328
		case "at":
327
		case "at":
329
			exec("sudo $script --replace_speed  ");
328
			exec("sudo $script --replace_speed");
330
			break;
329
			break;
331
		case "9600":
330
		case "9600":
332
			exec("sudo $script --replace_speed 9600");
331
			exec("sudo $script --replace_speed 9600");
333
			break;
332
			break;
334
		case "19200":
333
		case "19200":
335
			exec("sudo $script --replace_speed 19200");
334
			exec("sudo $script --replace_speed 19200");
336
			break;
335
			break;
337
		case "115200":
336
		case "115200":
338
			exec("sudo $script --replace_speed 115200");
337
			exec("sudo $script --replace_speed 115200");
339
			break;
338
			break;
-
 
339
		header('Location: autoregistration.php');
-
 
340
		exit();
340
		}
341
		}
341
		//header('Location: autoregistration.php');
-
 
342
		//exit();
-
 
343
	}
342
	}
344
	
343
	
345
	# Set the com port
344
	# Set the connexion port to MODEM	
346
	if(isset($_POST["b_port"])){
345
	if(isset($_POST['b_port'])){
-
 
346
		echo "speed = ".$_POST['port'];
347
		$port = $_POST["port"];
347
		$port = $_POST['port'];
348
		exec("sudo $script --replace_port ".escapeshellarg($port));
348
		exec("sudo $script --replace_port $port");
349
		header('Location: autoregistration.php');
349
		header('Location: autoregistration.php');
350
		exit();
350
		exit();
351
	}
351
	}
352
	
352
 
353
	# Set the SIM phone number
353
	# Set the SIM phone number
354
	if(isset($_POST["b_num_alcasar"])){
354
	if(isset($_POST["b_num_alcasar"])){
-
 
355
		echo "speed = ".$_POST['num_alcasar'];
355
		$num = $_POST["num_alcasar"];
356
		$num = $_POST["num_alcasar"];
356
		$error_num_alcasar = "";
357
		$error_num_alcasar = "";
357
		if($num !="")
358
		if($num !="")
358
		{
359
		{
359
			if(preg_match('#^\+#',$num))
360
			if(preg_match('#^\+#',$num))
Line 394... Line 395...
394
		{
395
		{
395
			$error_pin=$l_error_label_empty;
396
			$error_pin=$l_error_label_empty;
396
		}
397
		}
397
	}
398
	}
398
 
399
 
399
	# Set the number of tries before ban
400
	# Set the session timeout for each new account
400
	if(isset($_POST["b_ban_temp"])){
401
	if(isset($_POST["b_time_account"])){
401
		$nb_ban_temp = $_POST["nb_essais"];
402
		$time_account = $_POST["time_account"];
402
		$error_nb_essais = "";
403
		$error_time_account = "";
403
		if($nb_ban_temp !="")
404
		if($time_account !="")
404
		{
405
		{
405
			if(is_numeric($nb_ban_temp))
406
			if(is_numeric($time_account))
406
			{
407
			{
407
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
408
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
408
				header('Location: autoregistration.php');
409
				header('Location: autoregistration.php');
409
				exit();
410
				exit();
410
			}
411
			}
411
			else
412
			else
412
			{
413
			{
413
				$error_nb_essais=$l_error_label_num2;			
414
				$error_time_account=$l_error_label_num2;
414
			}
415
			}
415
		}
416
		}
416
		else
417
		else
417
		{
418
		{
418
			$error_nb_essais=$l_error_label_empty;
419
			$error_time_account=$l_error_label_empty;
419
		}
420
		}
420
	}
421
	}
421
 
422
 
422
	# Set the session timeout for each new account
423
	# Set the number of tries before ban
423
	if(isset($_POST["b_time_account"])){
424
	if(isset($_POST["b_ban_temp"])){
424
		$time_account = $_POST["time_account"];
425
		$nb_ban_temp = $_POST["nb_essais"];
425
		$error_time_account = "";
426
		$error_nb_essais = "";
426
		if($time_account !="")
427
		if($nb_ban_temp !="")
427
		{
428
		{
428
			if(is_numeric($time_account))
429
			if(is_numeric($nb_ban_temp))
429
			{
430
			{
430
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
431
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
431
				header('Location: autoregistration.php');
432
				header('Location: autoregistration.php');
432
				exit();
433
				exit();
433
			}
434
			}
434
			else
435
			else
435
			{
436
			{
436
				$error_time_account=$l_error_label_num2;
437
				$error_nb_essais=$l_error_label_num2;			
437
			}
438
			}
438
		}
439
		}
439
		else
440
		else
440
		{
441
		{
441
			$error_time_account=$l_error_label_empty;
442
			$error_nb_essais=$l_error_label_empty;
442
		}
443
		}
443
	}
444
	}
444
 
445
 
445
	# Set the ban timeout
446
	# Set the ban timeout
446
	if(isset($_POST["b_time_perm"])){
447
	if(isset($_POST["b_time_perm"])){
Line 540... Line 541...
540
{
541
{
541
	#Nom du fichier de log lorsque gammu est démarré
542
	#Nom du fichier de log lorsque gammu est démarré
542
	#$file_log = "gammu-smsd.log";
543
	#$file_log = "gammu-smsd.log";
543
 
544
 
544
	#Recuperation de la vitesse de connexion
545
	#Recuperation de la vitesse de connexion
545
	$current_speed = exec("sudo $script --speed");
546
	$current_speed = exec("sudo $script --connect");
546
	$current_speed=str_replace("at","",$current_speed)." bauds";
-
 
547
	if ($current_speed == " bauds") {
-
 
548
		$current_speed = "Auto";
-
 
549
	}
-
 
550
 
547
 
551
	#Recuperation du code PIN actuel
548
	#Recuperation du code PIN actuel
552
	$current_pin = exec("sudo $script --pin");	
549
	$current_pin = exec("sudo $script --pin");	
553
	
550
	
554
	#Recuperation du nombre de try avant le ban perm
551
	#Recuperation du nombre de try avant le ban perm
555
	$current_try_ban = exec("sudo $script --try_ban");	
552
	$current_try_ban = exec("sudo $script --try_ban");	
556
 
553
 
557
	#Recuperation de la durée d'une session créée
554
	#Recuperation de la durée d'une session créée
558
	$current_time_account = exec("sudo $script --time_account");	
555
	$current_time_account = exec("sudo $script --time_account");	
559
 
556
 
560
	#Recuperation de la durée du ban perm (après flood)
557
	#Recuperation de la durée dun ban perm (après flood)
561
	$current_time_perm = exec("sudo $script --time_perm");	
558
	$current_time_perm = exec("sudo $script --time_perm");	
562
 
559
 
563
	#Detection neméro de tel
560
	#Detection neméro de tel
564
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
561
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
565
	
562
	
Line 579... Line 576...
579
	$current_last_write = exec("sudo $script --last_writeerror");
576
	$current_last_write = exec("sudo $script --last_writeerror");
580
 
577
 
581
	#Recuperation de la dernière ligne de TIMEOUT
578
	#Recuperation de la dernière ligne de TIMEOUT
582
	$current_last_timeout = exec("sudo $script --last_timeout");
579
	$current_last_timeout = exec("sudo $script --last_timeout");
583
	
580
	
-
 
581
	# Test si le service est lancé
584
	if ($gammu_pid=="") # gammu_smsd is not started
582
	if ($gammu_pid=="")
585
	{
583
	{
586
		$force_signal = "-";
584
		$force_signal = "-";
587
		$imei_device = "-";
585
		$imei_device = "-";
588
		$sms_received = "-";
586
		$sms_received = "-";
589
 
587
 
Line 656... Line 654...
656
		}
654
		}
657
		$gammu_status_on="disabled";
655
		$gammu_status_on="disabled";
658
		$gammu_status_off="";
656
		$gammu_status_off="";
659
	}
657
	}
660
 
658
 
661
	echo "
-
 
662
		<form action=\"autoregistration.php\" method=\"post\">
659
	echo "<form action=\"autoregistration.php\" method=\"post\">
663
		<table border=1>
660
		<table border=1>
664
		<tr>
661
		<tr>
665
		<td colspan=3><b>$l_conf</b></td>
662
		<td colspan=3><b>$l_conf</b></td>
666
		<td><b>$l_conf_actu</b></td>
663
		<td><b>$l_conf_actu</b></td>
667
		</tr>
664
		</tr>
668
		<tr>
665
		<tr>
669
		<td> $l_speed </td><td>
-
 
670
			<select name=\"speed\">
-
 
671
				<option value=\"at\">Auto</option>
-
 
672
				<option value=\"9600\">9600 Bauds</option>
-
 
673
				<option value=\"19200\">19200 Bauds</option>
-
 
674
				<option value=\"115200\">115200 Bauds</option>
-
 
675
			</select>
-
 
676
		<td><button type=\"submit\" name=\"b_speed\">$l_edit</button></td>
-
 
677
		<td><center><font color=\"green\">".$current_speed."</font></center></td>
-
 
678
		<tr>
-
 
679
		<td> $l_connect_port </td><td><select name=\"port\">'";
666
		<td> $l_connect_port </td><td><select name=\"port\">'";
680
		reset ($openned_ports);
667
		reset ($openned_ports);
681
		while ( list(,$row) = each($openned_ports))
668
		while ( list(,$row) = each($openned_ports))
682
		{
669
		{
683
			echo '<option value="'.$row.'">'.$row.'</option>';
670
			echo '<option value="'.$row.'"';;if ("$row" == "$gammu_smsd_port") echo " selected";echo '>'.$row.'</option>';
684
			echo $row." ";
671
			echo $row." ";
685
		}
672
		}
686
	echo "</select></td>
673
	echo "</select></td>
687
		<td><button type=\"submit\" name=\"b_port\" $gammu_status_on>$l_edit</button></td>
674
		<td><button type=\"submit\" name=\"b_port\" $gammu_status_on>$l_edit</button></td>
688
		<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
675
		<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
689
		</tr>
676
		</tr>
-
 
677
		<td> $l_speed </td><td>
-
 
678
			<select name=\"speed\">
-
 
679
				<option value=\"at\"";if ($current_speed == "at") echo " selected";echo ">Auto</option>
-
 
680
				<option value=\"9600\"";if ($current_speed == "at9600") echo " selected"; echo ">9600 Bauds</option>
-
 
681
				<option value=\"19200\"";if ($current_speed == "at19200") echo " selected"; echo ">19200 Bauds</option>
-
 
682
				<option value=\"115200\"";if ($current_speed == "at115200") echo " selected";echo ">115200 Bauds</option>
-
 
683
			</select>
-
 
684
		<td><button type=\"submit\" name=\"b_speed\">$l_edit</button></td>
-
 
685
		<td><center><font color=\"green\">".str_replace("at","",$current_speed);if ($current_speed == "at"){ echo "Auto"; } else { echo " Bauds";}echo "</font></center></td>
-
 
686
		<tr>
690
		<tr>
687
		<tr>
691
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
688
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
692
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
689
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
693
		<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
690
		<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
694
		</tr>
691
		</tr>
Line 742... Line 739...
742
		$gammu_writeerror
739
		$gammu_writeerror
743
		</table>
740
		</table>
744
		</form>";
741
		</form>";
745
	
742
	
746
	require('/etc/freeradius-web/config.php');
743
	require('/etc/freeradius-web/config.php');
747
 
-
 
748
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
744
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
749
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
745
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
750
	else{
746
	else{
751
		echo "<b>Could not include SQL library</b>\n";
747
		echo "<b>Could not include SQL library</b>\n";
752
		exit();
748
		exit();
753
	}
749
	}
754
 
-
 
755
	$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
750
	$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
756
 
-
 
757
	if(mysqli_connect_errno())
751
	if(mysqli_connect_errno())
758
	{
752
	{
759
		echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
753
		echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
760
	}
754
	}
761
 
755
 
762
 
-
 
763
	# Country table
756
	# Country table
764
 
-
 
765
?>
757
?>
766
 
758
 
767
	<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
759
	<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
768
		 <span class="showhide-but_country"><?php echo "<strong>$l_country_filtering<strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
760
		 <span class="showhide-but_country"><?php echo "<strong>$l_country_filtering</strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
769
 
761
 
770
		<div class="showhide-div_country">
762
		<div class="showhide-div_country">
771
		<br />
763
		<br />
772
			<table width=100% style="background: #BDBDBD;">
764
			<table width=100% style="background: #BDBDBD;">
773
			<tr>
765
			<tr>
Line 796... Line 788...
796
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
788
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
797
				</form>
789
				</form>
798
			</tr>	
790
			</tr>	
799
			</table>
791
			</table>
800
			<div style="border-radius: 5px; background: #D8D8D8; margin: 15px;">
792
			<div style="border-radius: 5px; background: #D8D8D8; margin: 15px;">
801
			<span class="showhide-but_country_plus"><?php echo "<strong>$l_country_filtering_plus<strong>" ?> <img src="/images/down2.gif" width="15" height="15"></span>
793
			<span class="showhide-but_country_plus"><?php echo "<strong>$l_country_filtering_plus</strong>" ?> <img src="/images/down2.gif" width="15" height="15"></span>
802
				<div class="showhide-div_country_plus">
794
				<div class="showhide-div_country_plus">
803
				<table id="table_country" class="display">
795
				<table id="table_country" class="display">
804
					<thead>
796
					<thead>
805
						<tr>
797
						<tr>
806
							<th><b><font color="black">Pays</font></b></th>
798
							<th><b><font color="black">Pays</font></b></th>