Subversion Repositories ALCASAR

Rev

Rev 2991 | Rev 3076 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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