Subversion Repositories ALCASAR

Rev

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

Rev 2552 Rev 2553
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: autoregistration.php 2552 2018-05-08 22:21:47Z rexy $
2
# $Id: autoregistration.php 2553 2018-05-09 22:04:53Z 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("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port 
28
	$gammu_smsd_port=exec("sudo $script --port"); // 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 274... Line 274...
274
	<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' >".$l_autorefresh."
274
	<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' >".$l_autorefresh."
275
	";
275
	";
276
?>
276
?>
277
<center>
277
<center>
278
<br>
278
<br>
279
<form method="post" action="./autoregistration.php">
-
 
280
<table border=1 width=100%>
279
<table border=1 width=100%>
281
<tr>
280
<tr>
282
<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>
283
</tr>
282
</tr>
284
<tr>
283
<tr>
285
<?php
284
<?php
-
 
285
echo "port = ".$b_port;
286
if($find_key=="true")
286
if($find_key=="true")
287
{
287
{
288
	# Start / stop of gammu-smsd (3*7sec) --> to be improve with  systemd unit (see tarball in contrib/init folder) 
288
	# Start / stop of gammu-smsd (3*7sec) --> to be improve with  systemd unit (see tarball in contrib/init folder) 
289
	if(isset($_GET["start"])){
289
	if(isset($_POST["start"])){
290
		$gammu_1=exec("sudo $script --start");
290
		$gammu_1=exec("sudo $script --start");
291
		sleep(7);
291
		sleep(7);
292
		if($current_last_secu!="")
292
		if($current_last_secu!="")
293
		{
293
		{
294
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
294
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
Line 313... Line 313...
313
			}
313
			}
314
		}
314
		}
315
		header('Location: autoregistration.php');
315
		header('Location: autoregistration.php');
316
		exit();
316
		exit();
317
	}
317
	}
318
	if(isset($_GET["stop"])){
318
	if(isset($_POST["stop"])){
319
		exec("sudo $script --stop");
319
		exec("sudo $script --stop");
320
		sleep(8);
320
		sleep(8);
321
		header('Location: autoregistration.php');
321
		header('Location: autoregistration.php');
322
		exit();
322
		exit();
323
	}
323
	}
324
	# Set the speed connexion to MODEM	
324
	# Set the speed connexion to MODEM	
325
	if(isset($_GET['b_speed'])){
325
	if(isset($_POST["b_speed"])){
326
			echo "speed = ".$speed;
326
		$speed = $_POST["speed"];
327
		switch ($_GET['speed']) {
327
		switch ($speed) {
328
		case "at":
328
		case "at":
329
			exec("sudo $script --replace_connect  ");
329
			exec("sudo $script --replace_speed  ");
330
			break;
330
			break;
331
		case "9600":
331
		case "9600":
332
			exec("sudo $script --replace_connect 9600");
332
			exec("sudo $script --replace_speed 9600");
333
			break;
333
			break;
334
		case "19200":
334
		case "19200":
335
			exec("sudo $script --replace_connect 19200");
335
			exec("sudo $script --replace_speed 19200");
336
			break;
336
			break;
337
		case "115200":
337
		case "115200":
338
			exec("sudo $script --replace_connect 115200");
338
			exec("sudo $script --replace_speed 115200");
339
			break;
339
			break;
340
		}
340
		}
341
		//header('Location: autoregistration.php');
341
		//header('Location: autoregistration.php');
342
		//exit();
342
		//exit();
343
	}
343
	}
344
	
344
	
-
 
345
	# Set the com port
-
 
346
	if(isset($_POST["b_port"])){
-
 
347
		$port = $_POST["port"];
-
 
348
		exec("sudo $script --replace_port ".escapeshellarg($port));
-
 
349
		header('Location: autoregistration.php');
-
 
350
		exit();
-
 
351
	}
-
 
352
	
345
	# Set the SIM phone number
353
	# Set the SIM phone number
346
	if(isset($_GET["b_num_alcasar"])){
354
	if(isset($_POST["b_num_alcasar"])){
347
		$num = $_GET["num_alcasar"];
355
		$num = $_POST["num_alcasar"];
348
		$error_num_alcasar = "";
356
		$error_num_alcasar = "";
349
		if($num !="")
357
		if($num !="")
350
		{
358
		{
351
			if(preg_match('#^\+#',$num))
359
			if(preg_match('#^\+#',$num))
352
			{
360
			{
Line 364... Line 372...
364
			$error_num_alcasar=$l_error_label_empty;
372
			$error_num_alcasar=$l_error_label_empty;
365
		}
373
		}
366
	}
374
	}
367
	
375
	
368
	# Set the SIM card PIN number
376
	# Set the SIM card PIN number
369
	if(isset($_GET["b_pin"])){
377
	if(isset($_POST["b_pin"])){
370
		$pin = $_GET["pin"];
378
		$pin = $_POST["pin"];
371
		$error_pin = "";
379
		$error_pin = "";
372
		if($pin !="")
380
		if($pin !="")
373
		{
381
		{
374
			if(is_numeric($pin))
382
			if(is_numeric($pin))
375
			{
383
			{
Line 387... Line 395...
387
			$error_pin=$l_error_label_empty;
395
			$error_pin=$l_error_label_empty;
388
		}
396
		}
389
	}
397
	}
390
 
398
 
391
	# Set the number of tries before ban
399
	# Set the number of tries before ban
392
	if(isset($_GET["b_ban_temp"])){
400
	if(isset($_POST["b_ban_temp"])){
393
		$nb_ban_temp = $_GET["nb_essais"];
401
		$nb_ban_temp = $_POST["nb_essais"];
394
		$error_nb_essais = "";
402
		$error_nb_essais = "";
395
		if($nb_ban_temp !="")
403
		if($nb_ban_temp !="")
396
		{
404
		{
397
			if(is_numeric($nb_ban_temp))
405
			if(is_numeric($nb_ban_temp))
398
			{
406
			{
Line 410... Line 418...
410
			$error_nb_essais=$l_error_label_empty;
418
			$error_nb_essais=$l_error_label_empty;
411
		}
419
		}
412
	}
420
	}
413
 
421
 
414
	# Set the session timeout for each new account
422
	# Set the session timeout for each new account
415
	if(isset($_GET["b_time_account"])){
423
	if(isset($_POST["b_time_account"])){
416
		$time_account = $_GET["time_account"];
424
		$time_account = $_POST["time_account"];
417
		$error_time_account = "";
425
		$error_time_account = "";
418
		if($time_account !="")
426
		if($time_account !="")
419
		{
427
		{
420
			if(is_numeric($time_account))
428
			if(is_numeric($time_account))
421
			{
429
			{
Line 433... Line 441...
433
			$error_time_account=$l_error_label_empty;
441
			$error_time_account=$l_error_label_empty;
434
		}
442
		}
435
	}
443
	}
436
 
444
 
437
	# Set the ban timeout
445
	# Set the ban timeout
438
	if(isset($_GET["b_time_perm"])){
446
	if(isset($_POST["b_time_perm"])){
439
		$time_perm = $_GET["time_perm"];
447
		$time_perm = $_POST["time_perm"];
440
		$error_time_perm = "";
448
		$error_time_perm = "";
441
		if($time_perm !="")
449
		if($time_perm !="")
442
		{
450
		{
443
			if(is_numeric($time_perm))
451
			if(is_numeric($time_perm))
444
			{
452
			{
Line 456... Line 464...
456
			$error_time_perm=$l_error_label_empty;
464
			$error_time_perm=$l_error_label_empty;
457
		}
465
		}
458
	}
466
	}
459
	
467
	
460
	# removing a banned phone number
468
	# removing a banned phone number
461
	if(isset($_GET['num_select'])){
469
	if(isset($_POST['num_select'])){
462
		$numero=$_GET['num_select'];
470
		$numero=$_POST['num_select'];
463
 
471
 
464
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
472
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
465
		if (!empty($add_mac)) {
473
		if (!empty($add_mac)) {
466
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
474
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
467
		}
475
		}
Line 469... Line 477...
469
		header('Location: autoregistration.php');
477
		header('Location: autoregistration.php');
470
		exit();
478
		exit();
471
	}
479
	}
472
 
480
 
473
	# Edition etat pays
481
	# Edition etat pays
474
	if(isset($_GET['country_select'])){
482
	if(isset($_POST['country_select'])){
475
		$country=utf8_decode($_GET['country_select']);
483
		$country=utf8_decode($_POST['country_select']);
476
		exec("sudo $script --change_country ".escapeshellarg($country));
484
		exec("sudo $script --change_country ".escapeshellarg($country));
477
		exec("sudo $script --change_country_filter advance");
485
		exec("sudo $script --change_country_filter advance");
478
		header('Location: autoregistration.php');
486
		header('Location: autoregistration.php');
479
		exit();
487
		exit();
480
	}
488
	}
481
	if(isset($_GET['b_france_enable'])){
489
	if(isset($_POST['b_france_enable'])){
482
		exec("sudo $script --change_country_dis_all");
490
		exec("sudo $script --change_country_dis_all");
483
		exec("sudo $script --change_country France");
491
		exec("sudo $script --change_country France");
484
		exec("sudo $script --change_country_filter fr");
492
		exec("sudo $script --change_country_filter fr");
485
		header('Location: autoregistration.php');
493
		header('Location: autoregistration.php');
486
		exit();
494
		exit();
487
	}
495
	}
488
	if(isset($_GET['b_ue_enable'])){
496
	if(isset($_POST['b_ue_enable'])){
489
		exec("sudo $script --change_country_dis_all");
497
		exec("sudo $script --change_country_dis_all");
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");
498
		$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");
491
		foreach ($array_ue as $pays){
499
		foreach ($array_ue as $pays){
492
			exec("sudo $script --change_country ".escapeshellarg($pays));
500
			exec("sudo $script --change_country ".escapeshellarg($pays));
493
		}
501
		}
494
		
502
		
495
		exec("sudo $script --change_country_filter ue");
503
		exec("sudo $script --change_country_filter ue");
496
		header('Location: autoregistration.php');
504
		header('Location: autoregistration.php');
497
		exit();
505
		exit();
498
	}
506
	}
499
	if(isset($_GET["b_country_enable"])){
507
	if(isset($_POST["b_country_enable"])){
500
		exec("sudo $script --change_country_ena_all");		
508
		exec("sudo $script --change_country_ena_all");		
501
		exec("sudo $script --change_country_filter all");
509
		exec("sudo $script --change_country_filter all");
502
		header('Location: autoregistration.php');
510
		header('Location: autoregistration.php');
503
		exit();
511
		exit();
504
	}
512
	}
505
	if(isset($_GET["b_country_disable"])){
513
	if(isset($_POST["b_country_disable"])){
506
		exec("sudo $script --change_country_dis_all");
514
		exec("sudo $script --change_country_dis_all");
507
		header('Location: autoregistration.php');
515
		header('Location: autoregistration.php');
508
		exit();
516
		exit();
509
	}
517
	}
510
 
518
 
Line 522... Line 530...
522
	echo "<td>$l_key_diseable</td>";
530
	echo "<td>$l_key_diseable</td>";
523
}
531
}
524
?>
532
?>
525
</tr>
533
</tr>
526
</table>
534
</table>
527
</form>
-
 
528
</center>
535
</center>
529
<br>
536
<br>
530
<?php
537
<?php
531
 
538
 
532
if ($find_key=="true")
539
if ($find_key=="true")
533
{
540
{
534
	#Nom du fichier de log lorsque gammu est démarré
541
	#Nom du fichier de log lorsque gammu est démarré
535
	#$file_log = "gammu-smsd.log";
542
	#$file_log = "gammu-smsd.log";
536
 
543
 
537
	#Recuperation de la vitesse de connexion
544
	#Recuperation de la vitesse de connexion
538
	$current_speed = exec("sudo $script --connect");
545
	$current_speed = exec("sudo $script --speed");
-
 
546
	$current_speed=str_replace("at","",$current_speed)." bauds";
-
 
547
	if ($current_speed == " bauds") {
-
 
548
		$current_speed = "Auto";
-
 
549
	}
539
 
550
 
540
	#Recuperation du code PIN actuel
551
	#Recuperation du code PIN actuel
541
	$current_pin = exec("sudo $script --pin");	
552
	$current_pin = exec("sudo $script --pin");	
542
	
553
	
543
	#Recuperation du nombre de try avant le ban perm
554
	#Recuperation du nombre de try avant le ban perm
544
	$current_try_ban = exec("sudo $script --try_ban");	
555
	$current_try_ban = exec("sudo $script --try_ban");	
545
 
556
 
546
	#Recuperation de la durée d'une session créée
557
	#Recuperation de la durée d'une session créée
547
	$current_time_account = exec("sudo $script --time_account");	
558
	$current_time_account = exec("sudo $script --time_account");	
548
 
559
 
549
	#Recuperation de la durée dun ban perm (après flood)
560
	#Recuperation de la durée du ban perm (après flood)
550
	$current_time_perm = exec("sudo $script --time_perm");	
561
	$current_time_perm = exec("sudo $script --time_perm");	
551
 
562
 
552
	#Detection neméro de tel
563
	#Detection neméro de tel
553
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
564
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
554
	
565
	
Line 568... Line 579...
568
	$current_last_write = exec("sudo $script --last_writeerror");
579
	$current_last_write = exec("sudo $script --last_writeerror");
569
 
580
 
570
	#Recuperation de la dernière ligne de TIMEOUT
581
	#Recuperation de la dernière ligne de TIMEOUT
571
	$current_last_timeout = exec("sudo $script --last_timeout");
582
	$current_last_timeout = exec("sudo $script --last_timeout");
572
	
583
	
573
	# Test si le service est lancé
-
 
574
	if ($gammu_pid=="")
584
	if ($gammu_pid=="") # gammu_smsd is not started
575
	{
585
	{
576
		$force_signal = "-";
586
		$force_signal = "-";
577
		$imei_device = "-";
587
		$imei_device = "-";
578
		$sms_received = "-";
588
		$sms_received = "-";
579
 
589
 
Line 646... Line 656...
646
		}
656
		}
647
		$gammu_status_on="disabled";
657
		$gammu_status_on="disabled";
648
		$gammu_status_off="";
658
		$gammu_status_off="";
649
	}
659
	}
650
 
660
 
-
 
661
	echo "
651
	echo "<form action=\"autoregistration.php\" method=\"post\">
662
		<form action=\"autoregistration.php\" method=\"post\">
652
		<table border=1>
663
		<table border=1>
653
		<tr>
664
		<tr>
654
		<td colspan=3><b>$l_conf</b></td>
665
		<td colspan=3><b>$l_conf</b></td>
655
		<td><b>$l_conf_actu</b></td>
666
		<td><b>$l_conf_actu</b></td>
656
		</tr>
667
		</tr>
657
		<tr>
668
		<tr>
658
		<td> $l_speed </td><td>
669
		<td> $l_speed </td><td>
659
			<select name=\"speed\">
670
			<select name=\"speed\">
660
				<option value=\"at\">Auto</option>
671
				<option value=\"at\">Auto</option>
661
				<option value=\"'9600\">9600 Bauds</option>
672
				<option value=\"9600\">9600 Bauds</option>
662
				<option value=\"19200\">19200 Bauds</option>
673
				<option value=\"19200\">19200 Bauds</option>
663
				<option value=\"'115200\">115200 Bauds</option>
674
				<option value=\"115200\">115200 Bauds</option>
664
			</select>
675
			</select>
665
		<td><button type=\"submit\" name=\"b_speed\">$l_edit</button></td>
676
		<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>
677
		<td><center><font color=\"green\">".$current_speed."</font></center></td>
667
		<tr>
678
		<tr>
668
		<td> $l_connect_port </td><td><select name=\"port\">'";
679
		<td> $l_connect_port </td><td><select name=\"port\">'";
669
		reset ($openned_ports);
680
		reset ($openned_ports);
670
		while ( list(,$row) = each($openned_ports))
681
		while ( list(,$row) = each($openned_ports))
671
		{
682
		{