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