Subversion Repositories ALCASAR

Rev

Rev 2574 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2574 Rev 2602
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: autoregistration.php 2574 2018-07-20 21:27:51Z rexy $
2
# $Id: autoregistration.php 2602 2018-08-20 00:03:21Z tom.houdayer $
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 15... Line 15...
15
$error_num_alcasar = "";
15
$error_num_alcasar = "";
16
$country_filter="";
16
$country_filter="";
17
$find_key="false";
17
$find_key="false";
18
$listen_on_right_port="false";
18
$listen_on_right_port="false";
19
$script="/usr/local/bin/alcasar-sms.sh";
19
$script="/usr/local/bin/alcasar-sms.sh";
-
 
20
$vendor='';
-
 
21
$model='';
-
 
22
$gammu_smsd_port='';
20
 
23
 
21
# Test if a modem is plugged on serial-usb port
24
# Test if a modem is plugged on serial-usb port
22
$open_port=exec("ls /dev/ttyUSB*",$openned_ports); // list of USB-Serial ports openned by a modem
25
$open_port=exec("ls /dev/ttyUSB*",$openned_ports); // list of USB-Serial ports openned by a modem
23
if (!empty($open_port))
26
if (!empty($open_port))
24
{
27
{
25
	$find_key="true";
28
	$find_key="true";
26
	$vendor=exec("udevadm info -n $openned_ports[1] | grep 'MODEL=' | cut -d'=' -f2"); 
29
	$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");
30
	$model=exec("udevadm info -n $openned_ports[1] | grep 'MODEL_FROM_DATABASE=' | cut -d'=' -f2");
28
	$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port 
31
	$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep '^port\s\?=' | cut -d ' ' -f3"); // Gammu_smsd listen port 
29
	while ( list(,$row) = each($openned_ports))
32
	while ( list(,$row) = each($openned_ports))
30
	{
33
	{
31
		if ( "$row" == "$gammu_smsd_port" ) // is gammu listen on an openned port ?
34
		if ( "$row" == "$gammu_smsd_port" ) // is gammu listen on an openned port ?
32
		{
35
		{
33
			$listen_on_right_port="true";
36
			$listen_on_right_port="true";
Line 37... Line 40...
37
$gammu_pid=exec("sudo $script --pidof");
40
$gammu_pid=exec("sudo $script --pidof");
38
if ($find_key == "false")
41
if ($find_key == "false")
39
{	# close gammu if it's started
42
{	# close gammu if it's started
40
	if ($gammu_pid!="")
43
	if ($gammu_pid!="")
41
	{
44
	{
42
		echo "on ferme";
-
 
43
		exec("sudo $script stop");
45
		exec("sudo $script --stop");
44
		sleep(8);
46
		sleep(8);
45
		header('Location: autoregistration.php');
47
		header('Location: autoregistration.php');
46
		exit();
48
		exit();
47
	}
49
	}
48
}
50
}