Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1387 richard 1
<?php
2185 tom.houday 2
# $Id: autoregistration.php 2552 2018-05-08 22:21:47Z rexy $
3
 
1349 richard 4
#Define
2552 rexy 5
$gammu_wrong_port = "";
1349 richard 6
$gammu_puk = "";
7
$gammu_simfail = "";
8
$gammu_simsecu = "";
9
$gammu_writeerror = "";
10
$gammu_timeout = "";
11
$error_pin = "";
12
$error_time_account = "";
13
$error_nb_essais = "";
14
$error_time_perm = "";
15
$error_num_alcasar = "";
1416 richard 16
$country_filter="";
2550 rexy 17
$find_key="false";
2552 rexy 18
$listen_on_right_port="false";
2550 rexy 19
$script="/usr/local/bin/alcasar-sms.sh";
1349 richard 20
 
2550 rexy 21
# 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
23
if (!empty($open_port))
24
{
25
	$find_key="true";
2552 rexy 26
	$vendor=exec("udevadm info -n $openned_ports[1] | grep 'MODEL=' | cut -d'=' -f2"); 
2550 rexy 27
	$model=exec("udevadm info -n $openned_ports[1] | grep 'MODEL_FROM_DATABASE=' | cut -d'=' -f2");
2552 rexy 28
	$gammu_smsd_port=exec("cat /etc/gammu_smsd_conf| grep port | cut -d ' ' -f3"); // Gammu_smsd listen port 
2550 rexy 29
	while ( list(,$row) = each($openned_ports))
30
	{
31
		if ( "$row" == "$gammu_smsd_port" ) // is gammu listen on an openned port ?
32
		{
2552 rexy 33
			$listen_on_right_port="true";
2550 rexy 34
		}
35
	}
36
}	
37
$gammu_pid=exec("sudo $script --pidof");
2552 rexy 38
if ($find_key == "false")
2550 rexy 39
{	# close gammu if it's started
40
	if ($gammu_pid!="")
41
	{
42
		echo "on ferme";
43
		exec("sudo $script stop");
44
		sleep(8);
45
		header('Location: autoregistration.php');
46
		exit();
47
	}
48
}
49
 
1349 richard 50
# Choice of language
51
$Language = 'en';
52
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
1380 richard 53
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
54
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
1349 richard 55
if($Language == 'fr'){
56
	$l_title = "Auto enregistrement (SMS)";
57
	$l_conf = "Configuration";
58
	$l_conf_actu = "Configuration actuelle";
2552 rexy 59
	$l_speed = "Vitesse de connexion au MODEM";
60
	$l_connect_port="Port de connexion au MODEM";
61
	$l_pin = "Code PIN de la carte SIM";
62
	$l_num_alcasar = "Numero de téléphone de la carte SIM";
1380 richard 63
	$l_ban_temp = "Nombre d'essais avant le blocage";
2550 rexy 64
	$l_time_account = "Durée de validité des comptes crées";
1380 richard 65
	$l_time_perm = "Durée du blocage (en jours)";
1349 richard 66
	$l_status_gammu = "Etat du service";
67
	$l_start = "Démarrer";
2294 richard 68
	$l_status_device = "Status de votre MODEM GSM (clé 2G/3G/4G)";
1387 richard 69
	$l_key_diseable = "Aucun périphérique détecté";
2552 rexy 70
	$l_key_enable_1 = "Un MODEM GSM '<b>".$vendor."(".$model.")</b>' est connecté.";
2542 rexy 71
	$l_key_enable_2 = "Il a ouvert les ports suivants : ";
1349 richard 72
	$l_force_signal = "Force du signal";
73
	$l_imei_device = "IMEI du périphérique";
74
	$l_sms_received = "Nombre de SMS reçu";
75
	$l_stop = "Arrêter";
2294 richard 76
	$l_gammu_on="Le service est démarré";
77
	$l_gammu_off="Le service est arrêté";
78
	$l_edit = "Modifier";
2552 rexy 79
	$l_error_wrong_port = "Le port d'écoute ($gammu_smsd_port) n'existe pas";
1349 richard 80
	$l_error_label_empty = "Le champ est vide";
81
	$l_error_label_num = "Ce n'est pas un PIN valide";
82
	$l_error_label_num2 = "Ce n'est pas un nombre";
1380 richard 83
	$l_error_label_num3 = "Le format n'est pas correct: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
2294 richard 84
	$l_error_writefail = "Le service ne parvient pas à discuter avec le port du MODEM GSM (ttyUSB0).";
85
	$l_error_timeoutfail = "Impossible de se connecter au MODEM GSM (vérifiez la vitesse de connexion)";
2542 rexy 86
	$l_error_simfail = "Un problème au niveau de la carte SIM a été détecté. Est-elle présente?";
1349 richard 87
	$l_error_simsecu_l = "Attention, lors du dernier démarrage, votre code PIN était erroné.<br>
1380 richard 88
					La SIM doit être bloqué (code PUK). Consultez la documentation.";
1349 richard 89
	$l_autorefresh = "Rafraichissement : 30 sec";
90
	$l_days = "jours ";
91
	$l_num_block="Liste des numéros bloqués";
92
	$l_num_num="Numéro";
93
	$l_num_raison="Raison";
94
	$l_num_expiration="Date d'expiration";
95
	$l_num_action="Action";
96
	$l_num_exist="Un compte a été créé";
1416 richard 97
	$l_num_flood="Le nombre d'essais maximum a été dépassé";
1349 richard 98
	$l_num_unlock="Effacer";
1416 richard 99
	$l_country_enable="Activer";
100
	$l_country_disable="Désactiver";
1349 richard 101
	$l_service_status_img_ok="Démarré";
102
	$l_service_status_img_ko="Arrété";
2542 rexy 103
	$l_connect_speed="Modifier la vitesse de connexion : ";
1387 richard 104
	$l_tab_first = "premier";
105
	$l_tab_last = "dernier";
106
	$l_tab_next = "suivant";
107
	$l_tab_prev = "précédent";
108
	$l_tab_search = "Recherche :";
109
	$l_tab_pmenu = "Affiche la page _PAGE_ sur _PAGES_";
1416 richard 110
	$l_tab_info = "Montrer _MENU_ résultats par page";
1387 richard 111
	$l_tab_infoempty = "Aucun résultat";
1416 richard 112
	$l_country_filter = "Filtrage en cours : ";
113
	$l_country_filtering = " Filtrage par pays";
114
	$l_country_filtering_plus = " Filtrage par pays avancé";
115
	$l_phone_ban = " Numéro de téléphone bloqués";
116
	$l_country_france_ena = "Autorise les numéros français";
117
	$l_country_ue_ena = "Autorise les numéros européens";
118
	$l_country_all_ena = "Autorise tous les pays";
2542 rexy 119
	$l_country_advanced_ena = "Autorisation personnalisée";
1416 richard 120
	$l_advance = "Avancé";
1349 richard 121
}
122
else {
123
	$l_title = "Auto registration (SMS)";
124
	$l_conf = "Configuration";
125
	$l_conf_actu = "Current configuration";
2552 rexy 126
	$l_speed = "Connection speed to the MODEM";
127
	$l_connect_port="Connection port to the MODEM";
128
	$l_pin = "PIN password of the SIM card";
129
	$l_num_alcasar = "Phone number of the SIM card";
1349 richard 130
	$l_ban_temp = "Max number of try before a permanent ban"; 
2550 rexy 131
	$l_time_account = "Validity period of new account";
1349 richard 132
	$l_time_perm = "Duration of a ban (for example, after X try)";
133
	$l_status_gammu = "Service status";
134
	$l_start = "Start";
2294 richard 135
	$l_status_device = "Status of your GSM MODEM (2G/3G/4G key)";
1387 richard 136
	$l_key_diseable = "No device detected";
2552 rexy 137
	$l_key_enable_1 = "A GSM MODEM '<b>".$vendor."(".$model.")</b>' is connected.";
2542 rexy 138
	$l_key_enable_2 = "It has openned the following ports : ";
1349 richard 139
	$l_force_signal = "Signal strength";
140
	$l_imei_device = "Device IMEI";
141
	$l_sms_received = "Number of SMS received";
142
	$l_stop = "Stop";
2294 richard 143
	$l_gammu_on="The service is running";
144
	$l_gammu_off="The service is down";
145
	$l_edit = "Modify";
2552 rexy 146
	$l_error_wrong_port = "The listening port ($gammu_smsd_port) doesn't exist";
1349 richard 147
	$l_error_label_empty = "Field empty";
148
	$l_error_label_num = "It's not a valid PIN password";
149
	$l_error_label_num2 = "It's not a number";
1380 richard 150
	$l_error_label_num3 = "The phone number is not good: +xxxYYYYYYYYY (xxx: code pays / YYYYYYYYY: numéro de téléphone)";
2294 richard 151
	$l_error_writefail = "Can not communicate with the GSM MODEM port (ttyUSB0).";
152
	$l_error_timeoutfail = "Can not connect to the GSM MODEM (verify the connection speed).";
1349 richard 153
	$l_error_simfail = "An issue with your Sim card was detected. Is it in the key?";
154
	$l_error_simsecu_l = "Warning, during the last startup, the PIN code was wrong. <br>
155
				The Sim card must be blocked. Please read the documentation.";
156
	$l_autorefresh = "Refresh : 30 sec";
157
	$l_days = "days ";
158
	$l_num_block="List of blocked phone";
159
	$l_num_num="Phone number";
160
	$l_num_raison="Reason";
161
	$l_num_expiration="Expiration date";
162
	$l_num_action="Action";
163
	$l_num_exist="An account has been created";
164
	$l_num_flood="The number of try has been reached";
165
	$l_num_unlock="Erase";
1416 richard 166
	$l_country_enable="Enable";
167
	$l_country_disable="Disable";
1349 richard 168
	$l_service_status_img_ok="Running";
169
	$l_service_status_img_ko="Stopped";
2542 rexy 170
	$l_connect_speed="Modify the connection speed : ";
1387 richard 171
	$l_tab_first = "first";
172
	$l_tab_last = "last";
173
	$l_tab_next = "next";
174
	$l_tab_prev = "previous";
175
	$l_tab_search = "Search :";
176
	$l_tab_pmenu = "Showing _PAGE_ to _PAGE_ of _PAGE_ entries :";
177
	$l_tab_info = "Show _MENU_ entries";
178
	$l_tab_infoempty = "No matching records found";
1416 richard 179
	$l_country_filter = "Current filtering : ";
180
	$l_country_filtering = " Country filtering";
181
	$l_country_filtering_plus = " Country filtering advanced";
182
	$l_phone_ban = " Phone Number banned";
183
	$l_country_france_ena = "Authorize the french numbers";
184
	$l_country_ue_ena = "Authorize european numbers";
185
	$l_country_all_ena = "Authorize all countries";
186
	$l_country_advanced_ena = "Advanced Authorization";
187
	$l_advance = "Advanced";
1349 richard 188
}
1387 richard 189
?>
190
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
191
<HTML><!-- written by Rexy -->
192
<head>
1416 richard 193
<!--<META HTTP-EQUIV="Refresh" CONTENT="30">-->
1387 richard 194
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
195
<title>Auto enregistrement</title>
196
<link rel="stylesheet" href="/css/style.css">
197
<!-- DataTables CSS -->
2294 richard 198
<link rel="stylesheet" type="text/css" href="/css/jquery.dataTables.css">
1387 richard 199
<!-- jQuery -->
2317 tom.houday 200
<script type="text/javascript" charset="utf8" src="/js/jquery.min.js"></script>
1387 richard 201
<!-- DataTables -->
2294 richard 202
<script type="text/javascript" charset="utf8" src="/js/jquery.dataTables.js"></script>
1387 richard 203
<script type="text/javascript">
1416 richard 204
function timedRefresh(timeoutPeriod) {
205
    var interval = setInterval(refreshPage, timeoutPeriod);
206
}
207
 
208
function refreshPage() {
209
    if ($("input[name=autoRefreshCheckboxes]").is(":checked")) {
210
        location.reload(true);
211
    }
212
}
213
 
1387 richard 214
$(document).ready( function () {
1416 richard 215
 
216
    	$('#table_id').DataTable({
1387 richard 217
		"language": {
218
			"paginate": {
1416 richard 219
			"sFirst": "<?php echo $l_tab_first; ?>",
1387 richard 220
			"sLast": "<?php echo $l_tab_last; ?>",
221
			"sPrevious": "<?php echo $l_tab_prev; ?>",
222
			"sNext": "<?php echo $l_tab_next; ?>"
223
			},
224
            "lengthMenu": "<?php echo $l_tab_info; ?>",
225
            "zeroRecords": "<?php echo $l_tab_infoempty; ?>",
226
            "info": "<?php echo $l_tab_pmenu; ?>",
227
            "infoEmpty": "<?php echo $l_tab_infoempty; ?>",
228
			"sSearch": "<?php echo $l_tab_search; ?>"
229
        }
230
	});
1416 richard 231
 
232
	$('#table_country').DataTable({
233
		"language": {
234
			"paginate": {
235
			"sFirst": "<?php echo $l_tab_first; ?>",
236
			"sLast": "<?php echo $l_tab_last; ?>",
237
			"sPrevious": "<?php echo $l_tab_prev; ?>",
238
			"sNext": "<?php echo $l_tab_next; ?>"
239
			},
240
            "lengthMenu": "<?php echo $l_tab_info; ?>",
241
            "zeroRecords": "<?php echo $l_tab_infoempty; ?>",
242
            "info": "<?php echo $l_tab_pmenu; ?>",
243
            "infoEmpty": "<?php echo $l_tab_infoempty; ?>",
244
			"sSearch": "<?php echo $l_tab_search; ?>"
245
        }
246
	});
2552 rexy 247
	$(".showhide-div_country").slideUp("slow");	
1416 richard 248
	$(".showhide-div_ban").slideUp("slow");
249
	$(".showhide-div_country_plus").slideUp("slow");
250
	$(".showhide-but_country").on("click", function(){
251
	    $(".showhide-div_country").slideToggle("slow");
252
	});
253
	$(".showhide-but_country_plus").on("click", function(){
254
	    $(".showhide-div_country_plus").slideToggle("slow");
255
	});
256
	$(".showhide-but_ban").on("click", function(){
257
	    $(".showhide-div_ban").slideToggle("slow");
258
	});
1387 richard 259
} );
260
</script>
261
</head>
1416 richard 262
<body onload="JavaScript:timedRefresh(30000);">
1387 richard 263
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
264
<?php
1349 richard 265
echo "
266
	<tr>
267
		<th>$l_title</th>
268
	</tr>
269
	<tr bgcolor=\"#FFCC66\">
270
		<td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td>
271
	</tr>
272
	</TABLE>
2550 rexy 273
	<br>
2294 richard 274
	<input type='checkbox' checked='checked' name='autoRefreshCheckboxes' >".$l_autorefresh."
1349 richard 275
	";
276
?>
277
<center>
2550 rexy 278
<br>
2552 rexy 279
<form method="post" action="./autoregistration.php">
1349 richard 280
<table border=1 width=100%>
281
<tr>
2542 rexy 282
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
1380 richard 283
</tr>
284
<tr>
1349 richard 285
<?php
2550 rexy 286
if($find_key=="true")
1349 richard 287
{
2552 rexy 288
	# Start / stop of gammu-smsd (3*7sec) --> to be improve with  systemd unit (see tarball in contrib/init folder) 
1349 richard 289
	if(isset($_GET["start"])){
290
		$gammu_1=exec("sudo $script --start");
291
		sleep(7);
292
		if($current_last_secu!="")
293
		{
294
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
295
			{
296
				exec("sudo $script --stop");
297
			}
298
		}
299
		sleep(7);
300
		if($current_last_secu!="")
301
		{
302
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
303
			{
304
				exec("sudo $script --stop");
305
			}
306
		}
307
		sleep(7);	
308
		if($current_last_secu!="")
309
		{
310
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
311
			{
312
				exec("sudo $script --stop");
313
			}
314
		}
315
		header('Location: autoregistration.php');
2300 tom.houday 316
		exit();
1349 richard 317
	}
318
	if(isset($_GET["stop"])){
319
		exec("sudo $script --stop");
320
		sleep(8);
321
		header('Location: autoregistration.php');
2300 tom.houday 322
		exit();
1349 richard 323
	}
2552 rexy 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
	}
344
 
345
	# Set the SIM phone number
1349 richard 346
	if(isset($_GET["b_num_alcasar"])){
347
		$num = $_GET["num_alcasar"];
348
		$error_num_alcasar = "";
349
		if($num !="")
350
		{
1380 richard 351
			if(preg_match('#^\+#',$num))
1349 richard 352
			{
2299 tom.houday 353
				exec("sudo $script --replace_numero_alcasar ".escapeshellarg($num));
1349 richard 354
				header('Location: autoregistration.php');
2300 tom.houday 355
				exit();
1349 richard 356
			}
357
			else
358
			{
1380 richard 359
				$error_num_alcasar=$l_error_label_num3;
1349 richard 360
			}
361
		}
362
		else
363
		{
364
			$error_num_alcasar=$l_error_label_empty;
365
		}
366
	}
367
 
2552 rexy 368
	# Set the SIM card PIN number
1349 richard 369
	if(isset($_GET["b_pin"])){
370
		$pin = $_GET["pin"];
371
		$error_pin = "";
372
		if($pin !="")
373
		{
374
			if(is_numeric($pin))
375
			{
2299 tom.houday 376
				exec("sudo $script --replace_pin ".escapeshellarg($pin));
1349 richard 377
				header('Location: autoregistration.php');
2300 tom.houday 378
				exit();
1349 richard 379
			}
380
			else
381
			{
2552 rexy 382
				$error_pin=$l_error_label_num;			
1349 richard 383
			}
384
		}
385
		else
386
		{
387
			$error_pin=$l_error_label_empty;
388
		}
389
	}
2552 rexy 390
 
391
	# Set the number of tries before ban
1349 richard 392
	if(isset($_GET["b_ban_temp"])){
393
		$nb_ban_temp = $_GET["nb_essais"];
394
		$error_nb_essais = "";
395
		if($nb_ban_temp !="")
396
		{
397
			if(is_numeric($nb_ban_temp))
398
			{
2299 tom.houday 399
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
1349 richard 400
				header('Location: autoregistration.php');
2300 tom.houday 401
				exit();
1349 richard 402
			}
403
			else
404
			{
405
				$error_nb_essais=$l_error_label_num2;			
406
			}
407
		}
408
		else
409
		{
410
			$error_nb_essais=$l_error_label_empty;
411
		}
412
	}
413
 
2552 rexy 414
	# Set the session timeout for each new account
1349 richard 415
	if(isset($_GET["b_time_account"])){
416
		$time_account = $_GET["time_account"];
417
		$error_time_account = "";
418
		if($time_account !="")
419
		{
420
			if(is_numeric($time_account))
421
			{
2299 tom.houday 422
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
1349 richard 423
				header('Location: autoregistration.php');
2300 tom.houday 424
				exit();
1349 richard 425
			}
426
			else
427
			{
1380 richard 428
				$error_time_account=$l_error_label_num2;
1349 richard 429
			}
430
		}
431
		else
432
		{
433
			$error_time_account=$l_error_label_empty;
434
		}
435
	}
436
 
2552 rexy 437
	# Set the ban timeout
1349 richard 438
	if(isset($_GET["b_time_perm"])){
439
		$time_perm = $_GET["time_perm"];
440
		$error_time_perm = "";
441
		if($time_perm !="")
442
		{
443
			if(is_numeric($time_perm))
444
			{
2299 tom.houday 445
				exec("sudo $script --replace_time_perm ".escapeshellarg($time_perm));
1349 richard 446
				header('Location: autoregistration.php');
2300 tom.houday 447
				exit();
1349 richard 448
			}
449
			else
450
			{
1380 richard 451
				$error_time_perm=$l_error_label_num2;
1349 richard 452
			}
453
		}
454
		else
455
		{
456
			$error_time_perm=$l_error_label_empty;
457
		}
458
	}
2552 rexy 459
 
460
	# removing a banned phone number
1349 richard 461
	if(isset($_GET['num_select'])){
462
		$numero=$_GET['num_select'];
463
 
2299 tom.houday 464
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
2349 tom.houday 465
		if (!empty($add_mac)) {
466
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
467
		}
1349 richard 468
		exec("sudo $script --unlock_num $numero");
469
		header('Location: autoregistration.php');
2300 tom.houday 470
		exit();
1349 richard 471
	}
472
 
1416 richard 473
	# Edition etat pays
474
	if(isset($_GET['country_select'])){
475
		$country=utf8_decode($_GET['country_select']);
2299 tom.houday 476
		exec("sudo $script --change_country ".escapeshellarg($country));
1416 richard 477
		exec("sudo $script --change_country_filter advance");
478
		header('Location: autoregistration.php');
2300 tom.houday 479
		exit();
1416 richard 480
	}
481
	if(isset($_GET['b_france_enable'])){
482
		exec("sudo $script --change_country_dis_all");
483
		exec("sudo $script --change_country France");
484
		exec("sudo $script --change_country_filter fr");
485
		header('Location: autoregistration.php');
2300 tom.houday 486
		exit();
1416 richard 487
	}
488
	if(isset($_GET['b_ue_enable'])){
489
		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");
491
		foreach ($array_ue as $pays){
2299 tom.houday 492
			exec("sudo $script --change_country ".escapeshellarg($pays));
1416 richard 493
		}
494
 
495
		exec("sudo $script --change_country_filter ue");
496
		header('Location: autoregistration.php');
2300 tom.houday 497
		exit();
1416 richard 498
	}
499
	if(isset($_GET["b_country_enable"])){
2552 rexy 500
		exec("sudo $script --change_country_ena_all");		
1416 richard 501
		exec("sudo $script --change_country_filter all");
502
		header('Location: autoregistration.php');
2300 tom.houday 503
		exit();
1416 richard 504
	}
505
	if(isset($_GET["b_country_disable"])){
506
		exec("sudo $script --change_country_dis_all");
507
		header('Location: autoregistration.php');
2300 tom.houday 508
		exit();
1416 richard 509
	}
2552 rexy 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");	
2550 rexy 542
 
2552 rexy 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
 
651
	echo "<form action=\"autoregistration.php\" method=\"post\">
1349 richard 652
		<table border=1>
653
		<tr>
2550 rexy 654
		<td colspan=3><b>$l_conf</b></td>
655
		<td><b>$l_conf_actu</b></td>
1349 richard 656
		</tr>
657
		<tr>
2552 rexy 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>
2550 rexy 668
		<td> $l_connect_port </td><td><select name=\"port\">'";
669
		reset ($openned_ports);
670
		while ( list(,$row) = each($openned_ports))
671
		{
672
			echo '<option value="'.$row.'">'.$row.'</option>';
673
			echo $row." ";
674
		}
675
	echo "</select></td>
2552 rexy 676
		<td><button type=\"submit\" name=\"b_port\" $gammu_status_on>$l_edit</button></td>
2550 rexy 677
		<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
1349 richard 678
		</tr>
679
		<tr>
1380 richard 680
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
1349 richard 681
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
682
		<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
683
		</tr>
1380 richard 684
		<tr><td colspan=\"4\"><font color=red><b>$error_num_alcasar</b></font></td></tr>
685
		<tr>		
686
		<td> $l_pin </td><td><input type=text name='pin' maxlength=\"8\"></td>
1349 richard 687
		<td><button type=\"submit\" name=\"b_pin\" $gammu_status_on>$l_edit</button></td>
688
		<td><center><font color=\"green\">$current_pin</font></center></td>
689
		</tr>
1380 richard 690
		<tr><td colspan=\"4\"><font color=red><b>$error_pin</b></font></td></tr>
2294 richard 691
		<tr>
1380 richard 692
		<td> $l_time_account </td><td><input type=text name='time_account'> $l_days </td>
2552 rexy 693
		<td><button type=\"submit\" name=\"b_time_account\" $gammu_status_on>$l_edit</button></td>	
1349 richard 694
		<td><center><font color=\"blue\">$current_time_account</font></center></td>
695
		</tr>
1380 richard 696
		<tr><td colspan=\"4\"><font color=red><b>$error_time_account</b></font></td></tr>
1349 richard 697
		<tr>
2552 rexy 698
		<td> $l_ban_temp </td><td><input type=text name='nb_essais'></td>	
699
		<td><button type=\"submit\" name=\"b_ban_temp\" $gammu_status_on>$l_edit</button></td>	
1349 richard 700
		<td><center><font color=\"orange\">$current_try_ban</font></center></td>
701
		</tr>
1380 richard 702
		<tr><td colspan=\"4\"><font color=red><b>$error_nb_essais</b></font></td></tr>
1349 richard 703
		<tr>
1380 richard 704
		<td>$l_time_perm</td><td><input type=text name='time_perm'> $l_days</td>
2552 rexy 705
		<td><button type=\"submit\" name=\"b_time_perm\" $gammu_status_on>$l_edit</button></td>	
1349 richard 706
		<td><center><font color=\"orange\">$current_time_perm</font></center></td>
707
		</tr>
1380 richard 708
		<tr><td colspan=\"4\"><font color=red><b>$error_time_perm</b></font></td></tr>
1349 richard 709
		</table>
2550 rexy 710
		<br>
711
		<table border=1>
712
		<tr>
713
			<td colspan=4><b>$l_status_gammu</b></td>
714
			<td><b><center>$l_force_signal</center></b></td>
2552 rexy 715
			<td><b><center>$l_imei_device</center></b></td> 
716
			<td><b><center>$l_sms_received</center></b></td> 
2550 rexy 717
		</tr>
718
		<tr>
719
			$gammu
2552 rexy 720
			<td><button type=\"submit\" name=\"start\" $gammu_status_on>$l_start</button></td>		
2550 rexy 721
			<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
722
			<td><center>$force_signal</center></td>
723
			<td><center>$imei_device</center></td>
724
			<td><center>$sms_received</center></td>
725
		</tr>
2552 rexy 726
		$gammu_wrong_port
2550 rexy 727
		$gammu_puk
728
		$gammu_simfail
729
		$gammu_simsecu
730
		$gammu_timeout
731
		$gammu_writeerror
732
		</table>
1416 richard 733
		</form>";
1349 richard 734
 
735
	require('/etc/freeradius-web/config.php');
736
 
2185 tom.houday 737
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
738
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
1349 richard 739
	else{
740
		echo "<b>Could not include SQL library</b>\n";
741
		exit();
2185 tom.houday 742
	}
1349 richard 743
 
744
	$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
745
 
746
	if(mysqli_connect_errno())
747
	{
748
		echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
749
	}
750
 
751
 
1416 richard 752
	# Country table
753
 
1387 richard 754
?>
1416 richard 755
 
756
	<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
757
		 <span class="showhide-but_country"><?php echo "<strong>$l_country_filtering<strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
758
 
759
		<div class="showhide-div_country">
760
		<br />
761
			<table width=100% style="background: #BDBDBD;">
1349 richard 762
			<tr>
1416 richard 763
				<?php 
764
					$result_country_filter = mysqli_query($con, "SELECT id FROM SMS_country WHERE name = 'FILTRAGE'");
765
					$row = mysqli_fetch_array($result_country_filter);
766
 
767
					if($row['id'] == "advance") {
768
						$country_filter = $l_country_advanced_ena;
769
					} elseif($row['id'] == "ue") {
770
						$country_filter = $l_country_ue_ena;
771
					} elseif($row['id'] == "fr") {
772
						$country_filter = $l_country_france_ena;
773
					} elseif($row['id'] == "all") {
774
						$country_filter = $l_country_all_ena;
775
					} else {
776
						$country_filter = "Err.";
777
					}
778
				?>
779
				<td colspan="3" align="center"><strong><?php echo $l_country_filter; ?></strong><font size="3" color="red"><?php echo $country_filter; ?></font></td>
1349 richard 780
			</tr>
1387 richard 781
			<tr>
2552 rexy 782
				<form action="autoregistration.php" method="post">
1416 richard 783
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
784
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
785
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
786
				</form>
787
			</tr>	
788
			</table>
789
			<div style="border-radius: 5px; background: #D8D8D8; margin: 15px;">
790
			<span class="showhide-but_country_plus"><?php echo "<strong>$l_country_filtering_plus<strong>" ?> <img src="/images/down2.gif" width="15" height="15"></span>
791
				<div class="showhide-div_country_plus">
792
				<table id="table_country" class="display">
793
					<thead>
794
						<tr>
795
							<th><b><font color="black">Pays</font></b></th>
796
							<th><b><font color="black">code</font></b></th>
797
							<th><b><font color="black">Etat</font></b></th>
798
						</tr>
799
					</thead>
800
					<tbody>
801
						<?php 
802
 
803
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
804
						while($row = mysqli_fetch_array($result_country))
805
						{
806
						echo "	
807
						<tr>
2552 rexy 808
						<form action=\"autoregistration.php\" method=\"post\">
1416 richard 809
						<td>
810
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
811
							".$row['name']."
812
						</td>
813
						<td>".$row['id']."</td>
814
						";
815
 
816
						if($row['status']=='0')
817
						{
818
							echo "<td><input type='image' src=\"/images/state_error.gif\" width=\"15\" height=\"15\"></td>";
819
						}
820
						if($row['status']=='1')
821
						{
822
							echo "<td><input type='image' src=\"/images/state_ok.gif\" width=\"15\" height=\"15\"></td>";
823
						}
824
						echo "	</form>
825
							</tr>
826
							";
827
						}
828
						?>
829
					</tbody>
830
				</table>
831
				</div>
832
			</div>
833
		</div>	
834
	</div>
835
<?php 
836
	$result = mysqli_query($con, "SELECT * FROM SMS_ban_perm");
837
 
838
?>
839
 
840
<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
841
		<span class="showhide-but_ban"><?php echo "<strong>$l_phone_ban</strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
842
 
843
		<div class="showhide-div_ban">
844
 
845
			<table id="table_id" class="display">
846
				<thead>
847
					<tr>
848
						<th><b><font color="black"><?php echo $l_num_num; ?></font></b></th>
849
						<th><b><font color="black"><?php echo $l_num_raison; ?></font></b></th>
850
						<th><b><font color="black"><?php echo $l_num_expiration; ?></font></b></th>
851
						<th><b><font color="black">Action</font></b></th>
852
					</tr>
853
				</thead>
854
				<tbody>
855
					<?php 
856
					while($row = mysqli_fetch_array($result))
857
					{
858
					echo "	
859
						<tr>
2552 rexy 860
						<form action=\"autoregistration.php\" method=\"post\">
1416 richard 861
						<td>
862
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
863
							".$row['SenderNumber']."
864
						</td>";
1349 richard 865
 
1416 richard 866
					if($row['Perm']=='0')
867
					{
868
						echo "<td>$l_num_exist</td>";
869
					}
870
					if($row['Perm']=='1')
871
					{
872
						echo "<td>$l_num_flood</td>";
873
					}
874
					echo "	<td>" . $row['Expiration']. "</td>
875
							<td>
876
								<input type='submit' value='".$l_num_unlock."'>
877
							</td>
878
							</form>
879
						</tr>
880
						";
881
					}
882
					?>
883
				</tbody>
884
			</table>
885
		</div>
886
	</div>
1387 richard 887
<?php
1349 richard 888
	mysqli_close($con);
1380 richard 889
	}
1349 richard 890
?>
891
</html>