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