Subversion Repositories ALCASAR

Rev

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

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