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 2557 2018-06-03 21:06:17Z 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");
2557 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>
1349 richard 279
<table border=1 width=100%>
280
<tr>
2542 rexy 281
<td colspan=2><h3><center><?php echo $l_status_device ?></center></h3></td>
1380 richard 282
</tr>
283
<tr>
1349 richard 284
<?php
2550 rexy 285
if($find_key=="true")
1349 richard 286
{
2552 rexy 287
	# Start / stop of gammu-smsd (3*7sec) --> to be improve with  systemd unit (see tarball in contrib/init folder) 
2553 rexy 288
	if(isset($_POST["start"])){
1349 richard 289
		$gammu_1=exec("sudo $script --start");
290
		sleep(7);
291
		if($current_last_secu!="")
292
		{
293
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
294
			{
295
				exec("sudo $script --stop");
296
			}
297
		}
298
		sleep(7);
299
		if($current_last_secu!="")
300
		{
301
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
302
			{
303
				exec("sudo $script --stop");
304
			}
305
		}
306
		sleep(7);	
307
		if($current_last_secu!="")
308
		{
309
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
310
			{
311
				exec("sudo $script --stop");
312
			}
313
		}
314
		header('Location: autoregistration.php');
2300 tom.houday 315
		exit();
1349 richard 316
	}
2553 rexy 317
	if(isset($_POST["stop"])){
1349 richard 318
		exec("sudo $script --stop");
319
		sleep(8);
320
		header('Location: autoregistration.php');
2300 tom.houday 321
		exit();
1349 richard 322
	}
2557 rexy 323
 
324
	# Set the connexion speed to MODEM	
325
	if(isset($_POST['b_speed'])){
326
		switch ($_POST['speed']) {
2552 rexy 327
		case "at":
2557 rexy 328
			exec("sudo $script --replace_speed");
2552 rexy 329
			break;
330
		case "9600":
2553 rexy 331
			exec("sudo $script --replace_speed 9600");
2552 rexy 332
			break;
333
		case "19200":
2553 rexy 334
			exec("sudo $script --replace_speed 19200");
2552 rexy 335
			break;
336
		case "115200":
2553 rexy 337
			exec("sudo $script --replace_speed 115200");
2552 rexy 338
			break;
2557 rexy 339
		header('Location: autoregistration.php');
340
		exit();
2552 rexy 341
		}
342
	}
343
 
2557 rexy 344
	# Set the connexion port to MODEM	
345
	if(isset($_POST['b_port'])){
346
		echo "speed = ".$_POST['port'];
347
		$port = $_POST['port'];
348
		exec("sudo $script --replace_port $port");
2553 rexy 349
		header('Location: autoregistration.php');
350
		exit();
351
	}
2557 rexy 352
 
2552 rexy 353
	# Set the SIM phone number
2553 rexy 354
	if(isset($_POST["b_num_alcasar"])){
2557 rexy 355
		echo "speed = ".$_POST['num_alcasar'];
2553 rexy 356
		$num = $_POST["num_alcasar"];
1349 richard 357
		$error_num_alcasar = "";
358
		if($num !="")
359
		{
1380 richard 360
			if(preg_match('#^\+#',$num))
1349 richard 361
			{
2299 tom.houday 362
				exec("sudo $script --replace_numero_alcasar ".escapeshellarg($num));
1349 richard 363
				header('Location: autoregistration.php');
2300 tom.houday 364
				exit();
1349 richard 365
			}
366
			else
367
			{
1380 richard 368
				$error_num_alcasar=$l_error_label_num3;
1349 richard 369
			}
370
		}
371
		else
372
		{
373
			$error_num_alcasar=$l_error_label_empty;
374
		}
375
	}
376
 
2552 rexy 377
	# Set the SIM card PIN number
2553 rexy 378
	if(isset($_POST["b_pin"])){
379
		$pin = $_POST["pin"];
1349 richard 380
		$error_pin = "";
381
		if($pin !="")
382
		{
383
			if(is_numeric($pin))
384
			{
2299 tom.houday 385
				exec("sudo $script --replace_pin ".escapeshellarg($pin));
1349 richard 386
				header('Location: autoregistration.php');
2300 tom.houday 387
				exit();
1349 richard 388
			}
389
			else
390
			{
2552 rexy 391
				$error_pin=$l_error_label_num;			
1349 richard 392
			}
393
		}
394
		else
395
		{
396
			$error_pin=$l_error_label_empty;
397
		}
398
	}
2552 rexy 399
 
2557 rexy 400
	# Set the session timeout for each new account
401
	if(isset($_POST["b_time_account"])){
402
		$time_account = $_POST["time_account"];
403
		$error_time_account = "";
404
		if($time_account !="")
1349 richard 405
		{
2557 rexy 406
			if(is_numeric($time_account))
1349 richard 407
			{
2557 rexy 408
				exec("sudo $script --replace_time_account ".escapeshellarg($time_account));
1349 richard 409
				header('Location: autoregistration.php');
2300 tom.houday 410
				exit();
1349 richard 411
			}
412
			else
413
			{
2557 rexy 414
				$error_time_account=$l_error_label_num2;
1349 richard 415
			}
416
		}
417
		else
418
		{
2557 rexy 419
			$error_time_account=$l_error_label_empty;
1349 richard 420
		}
421
	}
422
 
2557 rexy 423
	# Set the number of tries before ban
424
	if(isset($_POST["b_ban_temp"])){
425
		$nb_ban_temp = $_POST["nb_essais"];
426
		$error_nb_essais = "";
427
		if($nb_ban_temp !="")
1349 richard 428
		{
2557 rexy 429
			if(is_numeric($nb_ban_temp))
1349 richard 430
			{
2557 rexy 431
				exec("sudo $script --replace_try_ban ".escapeshellarg($nb_ban_temp));
1349 richard 432
				header('Location: autoregistration.php');
2300 tom.houday 433
				exit();
1349 richard 434
			}
435
			else
436
			{
2557 rexy 437
				$error_nb_essais=$l_error_label_num2;			
1349 richard 438
			}
439
		}
440
		else
441
		{
2557 rexy 442
			$error_nb_essais=$l_error_label_empty;
1349 richard 443
		}
444
	}
445
 
2552 rexy 446
	# Set the ban timeout
2553 rexy 447
	if(isset($_POST["b_time_perm"])){
448
		$time_perm = $_POST["time_perm"];
1349 richard 449
		$error_time_perm = "";
450
		if($time_perm !="")
451
		{
452
			if(is_numeric($time_perm))
453
			{
2299 tom.houday 454
				exec("sudo $script --replace_time_perm ".escapeshellarg($time_perm));
1349 richard 455
				header('Location: autoregistration.php');
2300 tom.houday 456
				exit();
1349 richard 457
			}
458
			else
459
			{
1380 richard 460
				$error_time_perm=$l_error_label_num2;
1349 richard 461
			}
462
		}
463
		else
464
		{
465
			$error_time_perm=$l_error_label_empty;
466
		}
467
	}
2552 rexy 468
 
469
	# removing a banned phone number
2553 rexy 470
	if(isset($_POST['num_select'])){
471
		$numero=$_POST['num_select'];
1349 richard 472
 
2299 tom.houday 473
		$add_mac=exec("sudo /usr/sbin/chilli_query list | grep ".escapeshellarg($numero)." | cut -d ' ' -f1");
2349 tom.houday 474
		if (!empty($add_mac)) {
475
			exec("sudo /usr/sbin/chilli_query logout ".escapeshellarg($add_mac));
476
		}
1349 richard 477
		exec("sudo $script --unlock_num $numero");
478
		header('Location: autoregistration.php');
2300 tom.houday 479
		exit();
1349 richard 480
	}
481
 
1416 richard 482
	# Edition etat pays
2553 rexy 483
	if(isset($_POST['country_select'])){
484
		$country=utf8_decode($_POST['country_select']);
2299 tom.houday 485
		exec("sudo $script --change_country ".escapeshellarg($country));
1416 richard 486
		exec("sudo $script --change_country_filter advance");
487
		header('Location: autoregistration.php');
2300 tom.houday 488
		exit();
1416 richard 489
	}
2553 rexy 490
	if(isset($_POST['b_france_enable'])){
1416 richard 491
		exec("sudo $script --change_country_dis_all");
492
		exec("sudo $script --change_country France");
493
		exec("sudo $script --change_country_filter fr");
494
		header('Location: autoregistration.php');
2300 tom.houday 495
		exit();
1416 richard 496
	}
2553 rexy 497
	if(isset($_POST['b_ue_enable'])){
1416 richard 498
		exec("sudo $script --change_country_dis_all");
499
		$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");
500
		foreach ($array_ue as $pays){
2299 tom.houday 501
			exec("sudo $script --change_country ".escapeshellarg($pays));
1416 richard 502
		}
503
 
504
		exec("sudo $script --change_country_filter ue");
505
		header('Location: autoregistration.php');
2300 tom.houday 506
		exit();
1416 richard 507
	}
2553 rexy 508
	if(isset($_POST["b_country_enable"])){
2552 rexy 509
		exec("sudo $script --change_country_ena_all");		
1416 richard 510
		exec("sudo $script --change_country_filter all");
511
		header('Location: autoregistration.php');
2300 tom.houday 512
		exit();
1416 richard 513
	}
2553 rexy 514
	if(isset($_POST["b_country_disable"])){
1416 richard 515
		exec("sudo $script --change_country_dis_all");
516
		header('Location: autoregistration.php');
2300 tom.houday 517
		exit();
1416 richard 518
	}
2552 rexy 519
 
520
	echo '	<td>'.$l_key_enable_1;
521
	echo '<br>'.$l_key_enable_2.'<b>';
522
	reset ($openned_ports);
523
	while ( list(,$row) = each($openned_ports))
524
	{
525
		echo $row." ";
526
	}
527
	echo '</b></td>';
528
}
529
else
530
{
531
	echo "<td>$l_key_diseable</td>";
532
}
533
?>
534
</tr>
535
</table>
536
</center>
537
<br>
538
<?php
539
 
540
if ($find_key=="true")
541
{
542
	#Nom du fichier de log lorsque gammu est démarré
543
	#$file_log = "gammu-smsd.log";
544
 
545
	#Recuperation de la vitesse de connexion
2557 rexy 546
	$current_speed = exec("sudo $script --connect");
2552 rexy 547
 
548
	#Recuperation du code PIN actuel
549
	$current_pin = exec("sudo $script --pin");	
2550 rexy 550
 
2552 rexy 551
	#Recuperation du nombre de try avant le ban perm
552
	$current_try_ban = exec("sudo $script --try_ban");	
553
 
554
	#Recuperation de la durée d'une session créée
555
	$current_time_account = exec("sudo $script --time_account");	
556
 
2557 rexy 557
	#Recuperation de la durée dun ban perm (après flood)
2552 rexy 558
	$current_time_perm = exec("sudo $script --time_perm");	
559
 
560
	#Detection neméro de tel
561
	$current_num_alcasar = exec("sudo $script --numero_alcasar");
562
 
563
	#Detection problème avec la SIM
564
	$current_simfail = exec("sudo $script --last_nosim");
565
 
566
	#Recuperation de la dernière ligne de START
567
	$current_last_start = exec("sudo $script --last_start");
568
 
569
	#Recuperarion de la dernière ligne de STOP
570
	$current_last_stop = exec("sudo $script --last_stop");
571
 
572
	#Recuperation de la dernière ligne de SECURITYERROR
573
	$current_last_secu = exec("sudo $script --last_secu");
574
 
575
	#Recuperation de la dernière ligne de DEVICEWRITEERROR
576
	$current_last_write = exec("sudo $script --last_writeerror");
577
 
578
	#Recuperation de la dernière ligne de TIMEOUT
579
	$current_last_timeout = exec("sudo $script --last_timeout");
580
 
2557 rexy 581
	# Test si le service est lancé
582
	if ($gammu_pid=="")
2552 rexy 583
	{
584
		$force_signal = "-";
585
		$imei_device = "-";
586
		$sms_received = "-";
587
 
588
		$gammu="<td><img src=\"/images/state_error.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ko."\"></td><td>$l_gammu_off</td>";	
589
		$gammu_status_on="";
590
		$gammu_status_off="disabled";
591
 
592
		if($current_last_secu!="")
593
		{
594
			if(($current_last_secu > $current_last_start) && ($current_last_secu < $current_last_stop))
595
			{
596
				$gammu_simsecu="<tr><td colspan=7><font color=red>$l_error_simsecu_l</font></td></tr>";	
597
			}
598
		}
599
	} else {
600
		# Recuperation de la force du signal et IMEI et nombre de sms reçu
601
		$val_force_signal = exec("sudo $script --signal_device");
602
		$imei_device = exec("sudo $script --imei_device");
603
		$sms_received = exec("sudo $script --sms_received");
604
 
605
		if ($val_force_signal < 21) {
606
			$force_signal = "<img src=\"/images/signal_0.png\">  --  ".$val_force_signal." %";
607
		} elseif ($val_force_signal < 41) {
608
			$force_signal = "<img src=\"/images/signal_20.png\">  --  ".$val_force_signal." %";
609
 
610
		} elseif ($val_force_signal < 61) {
611
			$force_signal = "<img src=\"/images/signal_40.png\">  --  ".$val_force_signal." %";
612
 
613
		} elseif ($val_force_signal < 81) {
614
			$force_signal = "<img src=\"/images/signal_60.png\">  --  ".$val_force_signal." %";
615
 
616
		} elseif ($val_force_signal < 101) {
617
			$force_signal = "<img src=\"/images/signal_80.png\">  --  ".$val_force_signal." %";
618
 
619
		}
620
 
621
		$gammu="<td><img src=\"/images/state_ok.gif\" width=\"15\" height=\"15\" alt=\"".$l_service_status_img_ok."\"></td><td>$l_gammu_on</td>";	
622
		if ($listen_on_right_port != "true"){
623
			$gammu_wrong_port="<tr><td colspan=7><font color=red>$l_error_wrong_port</font></td></tr>";
624
		}	
625
 
626
		if($current_last_timeout!=""){
627
			if(($current_last_timeout > $current_last_start) && ($current_last_timeout > $current_last_stop))
628
			{
629
				$gammu_timeout="<tr><td colspan=7><font color=red>$l_error_timeoutfail</font></td></tr>";
630
			}
631
		}
632
 
633
		if($current_last_secu!="")
634
		{
635
			if(($current_last_secu > $current_last_start) && ($current_last_secu > $current_last_stop))
636
			{
637
				exec("sudo $script --stop");
638
			}
639
		}
640
 
641
		if($current_last_write!=""){
642
			if(($current_last_write > $current_last_start) && ($current_last_write > $current_last_stop))
643
			{
644
				$gammu_writeerror="<tr><td colspan=7><font color=red>$l_error_writefail</font></td></tr>";	
645
			}
646
		}
647
 
648
		if($current_simfail!="")
649
		{
650
			if(($current_simfail > $current_last_start) && ($current_simfail > $current_last_stop))
651
			{
652
				$gammu_simfail="<tr><td colspan=7><font color=red>$l_error_simfail</font></td></tr>";
653
			}
654
		}
655
		$gammu_status_on="disabled";
656
		$gammu_status_off="";
657
	}
658
 
2557 rexy 659
	echo "<form action=\"autoregistration.php\" method=\"post\">
1349 richard 660
		<table border=1>
661
		<tr>
2550 rexy 662
		<td colspan=3><b>$l_conf</b></td>
663
		<td><b>$l_conf_actu</b></td>
1349 richard 664
		</tr>
665
		<tr>
2550 rexy 666
		<td> $l_connect_port </td><td><select name=\"port\">'";
667
		reset ($openned_ports);
668
		while ( list(,$row) = each($openned_ports))
669
		{
2557 rexy 670
			echo '<option value="'.$row.'"';;if ("$row" == "$gammu_smsd_port") echo " selected";echo '>'.$row.'</option>';
2550 rexy 671
			echo $row." ";
672
		}
673
	echo "</select></td>
2552 rexy 674
		<td><button type=\"submit\" name=\"b_port\" $gammu_status_on>$l_edit</button></td>
2550 rexy 675
		<td><center><font color=\"green\">$gammu_smsd_port</font></center></td>
1349 richard 676
		</tr>
2557 rexy 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>
1349 richard 686
		<tr>
2557 rexy 687
		<tr>
1380 richard 688
		<td> $l_num_alcasar </td><td><input type=text name='num_alcasar' maxlength=\"20\"></td>
1349 richard 689
		<td><button type=\"submit\" name=\"b_num_alcasar\" $gammu_status_on>$l_edit</button></td>
690
		<td><center><font color=\"green\">$current_num_alcasar</font></center></td>
691
		</tr>
1380 richard 692
		<tr><td colspan=\"4\"><font color=red><b>$error_num_alcasar</b></font></td></tr>
693
		<tr>		
694
		<td> $l_pin </td><td><input type=text name='pin' maxlength=\"8\"></td>
1349 richard 695
		<td><button type=\"submit\" name=\"b_pin\" $gammu_status_on>$l_edit</button></td>
696
		<td><center><font color=\"green\">$current_pin</font></center></td>
697
		</tr>
1380 richard 698
		<tr><td colspan=\"4\"><font color=red><b>$error_pin</b></font></td></tr>
2294 richard 699
		<tr>
1380 richard 700
		<td> $l_time_account </td><td><input type=text name='time_account'> $l_days </td>
2552 rexy 701
		<td><button type=\"submit\" name=\"b_time_account\" $gammu_status_on>$l_edit</button></td>	
1349 richard 702
		<td><center><font color=\"blue\">$current_time_account</font></center></td>
703
		</tr>
1380 richard 704
		<tr><td colspan=\"4\"><font color=red><b>$error_time_account</b></font></td></tr>
1349 richard 705
		<tr>
2552 rexy 706
		<td> $l_ban_temp </td><td><input type=text name='nb_essais'></td>	
707
		<td><button type=\"submit\" name=\"b_ban_temp\" $gammu_status_on>$l_edit</button></td>	
1349 richard 708
		<td><center><font color=\"orange\">$current_try_ban</font></center></td>
709
		</tr>
1380 richard 710
		<tr><td colspan=\"4\"><font color=red><b>$error_nb_essais</b></font></td></tr>
1349 richard 711
		<tr>
1380 richard 712
		<td>$l_time_perm</td><td><input type=text name='time_perm'> $l_days</td>
2552 rexy 713
		<td><button type=\"submit\" name=\"b_time_perm\" $gammu_status_on>$l_edit</button></td>	
1349 richard 714
		<td><center><font color=\"orange\">$current_time_perm</font></center></td>
715
		</tr>
1380 richard 716
		<tr><td colspan=\"4\"><font color=red><b>$error_time_perm</b></font></td></tr>
1349 richard 717
		</table>
2550 rexy 718
		<br>
719
		<table border=1>
720
		<tr>
721
			<td colspan=4><b>$l_status_gammu</b></td>
722
			<td><b><center>$l_force_signal</center></b></td>
2552 rexy 723
			<td><b><center>$l_imei_device</center></b></td> 
724
			<td><b><center>$l_sms_received</center></b></td> 
2550 rexy 725
		</tr>
726
		<tr>
727
			$gammu
2552 rexy 728
			<td><button type=\"submit\" name=\"start\" $gammu_status_on>$l_start</button></td>		
2550 rexy 729
			<td><button type=\"submit\" name=\"stop\" $gammu_status_off>$l_stop</button></td>
730
			<td><center>$force_signal</center></td>
731
			<td><center>$imei_device</center></td>
732
			<td><center>$sms_received</center></td>
733
		</tr>
2552 rexy 734
		$gammu_wrong_port
2550 rexy 735
		$gammu_puk
736
		$gammu_simfail
737
		$gammu_simsecu
738
		$gammu_timeout
739
		$gammu_writeerror
740
		</table>
1416 richard 741
		</form>";
1349 richard 742
 
743
	require('/etc/freeradius-web/config.php');
2185 tom.houday 744
	if (is_file("../lib/sql/drivers/$config[sql_type]/functions.php"))
745
		include_once("../lib/sql/drivers/$config[sql_type]/functions.php");
1349 richard 746
	else{
747
		echo "<b>Could not include SQL library</b>\n";
748
		exit();
2185 tom.houday 749
	}
1349 richard 750
	$con = mysqli_connect("$config[sql_server]","$config[sql_username]","$config[sql_password]","gammu");
751
	if(mysqli_connect_errno())
752
	{
753
		echo "Fail to connect to $config[sql_type]" . mysqli_connect_error();
754
	}
755
 
1416 richard 756
	# Country table
1387 richard 757
?>
1416 richard 758
 
759
	<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
2557 rexy 760
		 <span class="showhide-but_country"><?php echo "<strong>$l_country_filtering</strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
1416 richard 761
 
762
		<div class="showhide-div_country">
763
		<br />
764
			<table width=100% style="background: #BDBDBD;">
1349 richard 765
			<tr>
1416 richard 766
				<?php 
767
					$result_country_filter = mysqli_query($con, "SELECT id FROM SMS_country WHERE name = 'FILTRAGE'");
768
					$row = mysqli_fetch_array($result_country_filter);
769
 
770
					if($row['id'] == "advance") {
771
						$country_filter = $l_country_advanced_ena;
772
					} elseif($row['id'] == "ue") {
773
						$country_filter = $l_country_ue_ena;
774
					} elseif($row['id'] == "fr") {
775
						$country_filter = $l_country_france_ena;
776
					} elseif($row['id'] == "all") {
777
						$country_filter = $l_country_all_ena;
778
					} else {
779
						$country_filter = "Err.";
780
					}
781
				?>
782
				<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 783
			</tr>
1387 richard 784
			<tr>
2552 rexy 785
				<form action="autoregistration.php" method="post">
1416 richard 786
					<td align="center" width=33%><button type="submit" name="b_france_enable"><?php echo "$l_country_france_ena" ?></button></td>
787
					<td align="center" width=34%><button type="submit" name="b_ue_enable"><?php echo "$l_country_ue_ena" ?></button></td>
788
					<td align="center" width=33%><button type="submit" name="b_country_enable"><?php echo "$l_country_all_ena" ?></button></td>
789
				</form>
790
			</tr>	
791
			</table>
792
			<div style="border-radius: 5px; background: #D8D8D8; margin: 15px;">
2557 rexy 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>
1416 richard 794
				<div class="showhide-div_country_plus">
795
				<table id="table_country" class="display">
796
					<thead>
797
						<tr>
798
							<th><b><font color="black">Pays</font></b></th>
799
							<th><b><font color="black">code</font></b></th>
800
							<th><b><font color="black">Etat</font></b></th>
801
						</tr>
802
					</thead>
803
					<tbody>
804
						<?php 
805
 
806
						$result_country = mysqli_query($con, "SELECT * FROM SMS_country WHERE name != 'FILTRAGE'");
807
						while($row = mysqli_fetch_array($result_country))
808
						{
809
						echo "	
810
						<tr>
2552 rexy 811
						<form action=\"autoregistration.php\" method=\"post\">
1416 richard 812
						<td>
813
							<input type=\"hidden\" name=\"country_select\" value=\"" .$row['name']."\">	
814
							".$row['name']."
815
						</td>
816
						<td>".$row['id']."</td>
817
						";
818
 
819
						if($row['status']=='0')
820
						{
821
							echo "<td><input type='image' src=\"/images/state_error.gif\" width=\"15\" height=\"15\"></td>";
822
						}
823
						if($row['status']=='1')
824
						{
825
							echo "<td><input type='image' src=\"/images/state_ok.gif\" width=\"15\" height=\"15\"></td>";
826
						}
827
						echo "	</form>
828
							</tr>
829
							";
830
						}
831
						?>
832
					</tbody>
833
				</table>
834
				</div>
835
			</div>
836
		</div>	
837
	</div>
838
<?php 
839
	$result = mysqli_query($con, "SELECT * FROM SMS_ban_perm");
840
 
841
?>
842
 
843
<div style="border-radius: 5px; background: #BDBDBD; margin-top: 15px;">
844
		<span class="showhide-but_ban"><?php echo "<strong>$l_phone_ban</strong>" ?><img src="/images/down2.gif" width="15" height="15"></span>
845
 
846
		<div class="showhide-div_ban">
847
 
848
			<table id="table_id" class="display">
849
				<thead>
850
					<tr>
851
						<th><b><font color="black"><?php echo $l_num_num; ?></font></b></th>
852
						<th><b><font color="black"><?php echo $l_num_raison; ?></font></b></th>
853
						<th><b><font color="black"><?php echo $l_num_expiration; ?></font></b></th>
854
						<th><b><font color="black">Action</font></b></th>
855
					</tr>
856
				</thead>
857
				<tbody>
858
					<?php 
859
					while($row = mysqli_fetch_array($result))
860
					{
861
					echo "	
862
						<tr>
2552 rexy 863
						<form action=\"autoregistration.php\" method=\"post\">
1416 richard 864
						<td>
865
							<input type=\"hidden\" name=\"num_select\" value=\"" .$row['SenderNumber']."\">	
866
							".$row['SenderNumber']."
867
						</td>";
1349 richard 868
 
1416 richard 869
					if($row['Perm']=='0')
870
					{
871
						echo "<td>$l_num_exist</td>";
872
					}
873
					if($row['Perm']=='1')
874
					{
875
						echo "<td>$l_num_flood</td>";
876
					}
877
					echo "	<td>" . $row['Expiration']. "</td>
878
							<td>
879
								<input type='submit' value='".$l_num_unlock."'>
880
							</td>
881
							</form>
882
						</tr>
883
						";
884
					}
885
					?>
886
				</tbody>
887
			</table>
888
		</div>
889
	</div>
1387 richard 890
<?php
1349 richard 891
	mysqli_close($con);
1380 richard 892
	}
1349 richard 893
?>
894
</html>