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