Subversion Repositories ALCASAR

Rev

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