forked from poppyred/1.6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miniadm.network.routes.php
executable file
·693 lines (548 loc) · 19.1 KB
/
miniadm.network.routes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
<?php
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
ini_set('error_prepend_string',"<p class='text-error'>");
ini_set('error_append_string',"</p>");
include_once(dirname(__FILE__)."/ressources/class.templates.inc");
include_once(dirname(__FILE__)."/ressources/class.ldap.inc");
include_once(dirname(__FILE__)."/ressources/class.users.menus.inc");
include_once(dirname(__FILE__)."/ressources/class.system.network.inc");
include_once(dirname(__FILE__)."/ressources/class.system.nics.inc");
include_once(dirname(__FILE__)."/ressources/class.maincf.multi.inc");
include_once(dirname(__FILE__)."/ressources/class.tcpip.inc");
include_once(dirname(__FILE__)."/ressources/class.miniadm.inc");
if(isset($_GET["ruleid"])){ruleid_js();exit;}
if(isset($_GET["routes-search"])){routes_search();exit;}
if(isset($_GET["routes-list"])){routes_section();exit;}
if(isset($_GET["mainroutes-list"])){mainroutes_section();exit;}
if(isset($_GET["mainroutes-search"])){mainroutes_search();exit;}
if(isset($_GET["mainrouteid"])){mainroutes_js();exit;}
if(isset($_GET["mainrouteid-popup"])){mainroutes_popup();exit;}
if(isset($_POST["zmd5"])){mainroutes_save();exit;}
if(isset($_POST["mainroute-delete"])){mainroutes_delete();exit;}
if(isset($_GET["ruleid-tabs"])){route_tabs();exit;}
if(isset($_GET["ruleid-popup"])){route_settings();exit;}
if(isset($_POST["routename"])){route_settings_save();exit;}
if(isset($_GET["ruleid-rules"])){rules_section();exit;}
if(isset($_GET["rules-search"])){rules_search();exit;}
if(isset($_GET["subruleid"])){subrules_js();exit;}
if(isset($_GET["subruleid-popup"])){subrules_popup();exit;}
if(isset($_POST["subruleid"])){subrules_save();exit;}
if(isset($_POST["route-delete"])){route_delete();exit;}
if(isset($_POST["rule-delete"])){rule_delete();exit;}
if(isset($_GET["routes-apply-js"])){route_apply_js();exit;}
if(isset($_GET["routes-apply-popup"])){route_apply_popup();exit;}
if(isset($_GET["routes-display"])){route_display();exit;}
tabs();
function tabs(){
$users=new usersMenus();
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$boot=new boostrap_form();
$array["{main_routes}"]="$page?mainroutes-list=yes";
$array["{routes_tables}"]="$page?routes-list=yes";
$array["{display_routes}"]="$page?routes-display=yes";
echo $boot->build_tab($array);
}
function routes_section(){
$q=new mysql();
$q->BuildTables();
$boot=new boostrap_form();
$page=CurrentPageName();
$compile_rules=null;
$EXPLAIN["BUTTONS"][]=button("{new_group}","Loadjs('$page?ruleid=0');",16);
$EXPLAIN["BUTTONS"][]=$compile_rules;
echo $boot->SearchFormGen("rulename","routes-search",null,$EXPLAIN);
}
function mainroutes_section(){
$q=new mysql();
$q->BuildTables();
$boot=new boostrap_form();
$page=CurrentPageName();
$compile_rules=null;
$EXPLAIN["BUTTONS"][]=button("{new_route}","Loadjs('$page?mainrouteid=');",16);
$EXPLAIN["BUTTONS"][]=button("{apply_parameters}","Loadjs('$page?routes-apply-js');",16);;
echo $boot->SearchFormGen("pattern,gateway","mainroutes-search",null,$EXPLAIN);
}
function rules_section(){
$q=new mysql();
$q->BuildTables();
$boot=new boostrap_form();
$page=CurrentPageName();
$compile_rules=null;
$EXPLAIN["BUTTONS"][]=button("{new_rule}","Loadjs('$page?subruleid=0&rule-id={$_GET["rule-id"]}');",16);
echo $boot->SearchFormGen("src,destination","rules-search","&rule-id={$_GET["rule-id"]}",$EXPLAIN);
}
function mainroutes_js(){
header("content-type: application/x-javascript");
$tpl=new templates();
$page=CurrentPageName();
$title=$tpl->_ENGINE_parse_body("{new_rule}");
$ID=$_GET["mainrouteid"];
if($ID>0){
$q=new mysql();
$sql="SELECT `pattern`,`gateway` FROM nic_routes WHERE zmd5='$ID'";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$title=$tpl->_ENGINE_parse_body("{$ligne["pattern"]} {$ligne["gateway"]}");
}
$html="YahooWin2('850','$page?mainrouteid-popup=yes&zmd5=$ID','$title');";
echo $html;
}
function route_apply_js(){
header("content-type: application/x-javascript");
$tpl=new templates();
$page=CurrentPageName();
$title=$tpl->_ENGINE_parse_body("{apply_parameters}");
$html="YahooWin2('850','$page?routes-apply-popup=yes','$title');";
echo $html;
}
function route_apply_popup(){
$sock=new sockets();
$sock->getFrameWork("system.php?routes-apply-perform=yes");
$f=explode("\n",@file_get_contents("/usr/share/artica-postfix/ressources/logs/web/routes-apply.log"));
while (list ($index, $line) = each ($f) ){
if($line==null){continue;}
$tt[]=$line;
}
echo "<textarea style='margin-top:5px;font-family:Courier New;
font-weight:bold;width:95%;height:520px;border:5px solid #8E8E8E;overflow:auto;font-size:12.5px !important'
id='textarea$t'>".@implode("\n", $tt)."</textarea>";
}
function route_display(){
$sock=new sockets();
$datas=unserialize(base64_decode($sock->getFrameWork("system.php?routes-show=yes")));
echo "<textarea style='margin-top:5px;font-family:Courier New;
font-weight:bold;width:95%;height:520px;border:5px solid #8E8E8E;overflow:auto;font-size:16px !important'
id='textarea$t'>".@implode("\n", $datas)."</textarea>";
}
function ruleid_js(){
header("content-type: application/x-javascript");
$tpl=new templates();
$page=CurrentPageName();
$title=$tpl->_ENGINE_parse_body("{new_rule}");
$ID=$_GET["ruleid"];
if($ID>0){
$q=new mysql();
$sql="SELECT `routename` FROM iproute_table WHERE ID=$ID";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$title=$tpl->_ENGINE_parse_body("$ID::{$ligne["routename"]}");
}
$html="YahooWin2('850','$page?ruleid-tabs=yes&rule-id=$ID','$title');";
echo $html;
}
function subrules_js(){
header("content-type: application/x-javascript");
$tpl=new templates();
$page=CurrentPageName();
$title=$tpl->_ENGINE_parse_body("{new_rule}");
$ruleid=$_GET["rule-id"];
$subruleid=$_GET["subruleid"];
if($subruleid>0){
$q=new mysql();
$sql="SELECT `src`,`destination` FROM iproute_rules WHERE ID=$subruleid";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$title=$tpl->_ENGINE_parse_body("$subruleid::{$ligne["src"]} - {$ligne["destination"]}");
}
$html="YahooWin3('850','$page?subruleid-popup=yes&rule-id=$ruleid&subrule=$subruleid','$title');";
echo $html;
}
function route_tabs(){
$ID=$_GET["rule-id"];
$users=new usersMenus();
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$boot=new boostrap_form();
$array["{parameters}"]="$page?ruleid-popup=yes&rule-id=$ID";
if($ID>0){
$array["{rules}"]="$page?ruleid-rules=yes&rule-id=$ID";
}
echo $boot->build_tab($array);
}
function route_settings_save(){
$q=new mysql();
$ID=$_POST["ID"];
unset($_POST["ID"]);
include_once(dirname(__FILE__)."/ressources/class.html.tools.inc");
$html=new htmltools_inc();
$_POST["routename"]=$html->StripSpecialsChars($_POST["routename"]);
while (list ($key, $value) = each ($_POST) ){
$fields[]="`$key`";
$values[]="'".mysql_escape_string2($value)."'";
$edit[]="`$key`='".mysql_escape_string2($value)."'";
}
if($ID>0){
$sql="UPDATE iproute_table SET ".@implode(",", $edit)." WHERE ID='$ID'";
}else{
$sql="INSERT IGNORE INTO iproute_table (".@implode(",", $fields).") VALUES (".@implode(",", $values).")";
}
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?ip-build-routes=yes");
}
function rule_delete(){
$ID=$_POST["rule-delete"];
$q=new mysql();
$sql="DELETE FROM iproute_rules WHERE ID=$ID";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?ip-build-routes=yes");
}
function mainroutes_delete(){
$ID=$_POST["mainroute-delete"];
$q=new mysql();
if($ID==null){echo "No such id;..\n";}
$sql="DELETE FROM nic_routes WHERE zmd5='$ID'";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?ip-build-routes=yes");
}
function route_delete(){
$ID=$_POST["route-delete"];
$q=new mysql();
$sql="DELETE FROM iproute_rules WHERE ruleid=$ID";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sql="DELETE FROM iproute_table WHERE ID=$ID";
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?ip-build-routes=yes");
}
function subrules_save(){
$q=new mysql();
$ID=$_POST["subruleid"];
unset($_POST["subruleid"]);
while (list ($key, $value) = each ($_POST) ){
$fields[]="`$key`";
$values[]="'".mysql_escape_string2($value)."'";
$edit[]="`$key`='".mysql_escape_string2($value)."'";
}
if($ID>0){
$sql="UPDATE iproute_rules SET ".@implode(",", $edit)." WHERE ID='$ID'";
}else{
$sql="INSERT IGNORE INTO iproute_rules (".@implode(",", $fields).") VALUES (".@implode(",", $values).")";
}
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?ip-build-routes=yes");
}
function route_settings(){
$ID=$_GET["rule-id"];
$users=new usersMenus();
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$buttonname="{add}";
$boot=new boostrap_form();
if($ID>0){
$q=new mysql();
$sql="SELECT * FROM iproute_table WHERE ID=$ID";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$title=$tpl->_ENGINE_parse_body("$ID::{$ligne["routename"]}");
$buttonname="{apply}";
}else{
$boot->set_CloseYahoo("YahooWin2");
}
$ip=new networking();
$Interfaces=$ip->Local_interfaces();
unset($Interfaces["lo"]);
if(!is_numeric($ligne["enable"])){$ligne["enable"]=1;}
$boot->set_formtitle($title);
$boot->set_hidden("ID", $ID);
$boot->set_field("routename", "{groupname}", $ligne["routename"]);
$boot->set_field("gateway", "{gateway}", $ligne["gateway"]);
$boot->set_list("interface", "{interface}", $Interfaces,$ligne["interface"]);
$boot->set_checkbox("enable", "{enabled}", $ligne["enable"]);
$users=new usersMenus();
if(!$users->AsSystemAdministrator){
$boot->set_form_locked();
}
$boot->set_button($buttonname);
$boot->set_RefreshSearchs();
echo $boot->Compile();
}
function mainroutes_popup(){
$zmd5=$_GET["zmd5"];
$users=new usersMenus();
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$buttonname="{add}";
$boot=new boostrap_form();
if($zmd5<>null){
$q=new mysql();
$sql="SELECT * FROM nic_routes WHERE zmd5='$zmd5'";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$title=$tpl->_ENGINE_parse_body("{$ligne["pattern"]}");
$buttonname="{apply}";
}else{
$boot->set_CloseYahoo("YahooWin2");
}
$nics[null]="{select}";
$types[1]="{network_nic}";
$types[2]="{host}";
$ip=new networking();
$Interfaces=$ip->Local_interfaces();
unset($Interfaces["lo"]);
$Interfaces[null]="{select}";
if(!is_numeric($ligne["enable"])){$ligne["enable"]=1;}
$boot->set_formtitle($title);
$boot->set_hidden("zmd5", $zmd5);
//$boot->set_checkbox("enable", "{enabled}", $ligne["enable"],array("DISABLEALL"=>true));
$boot->set_list("type", "{type}", $types,$ligne["type"]);
$boot->set_field("pattern", "{destination}", $ligne["pattern"]);
$boot->set_field("gateway", "{gateway}", $ligne["gateway"]);
$boot->set_list("nic", "{interface}", $Interfaces,$ligne["interface"]);
$users=new usersMenus();
if(!$users->AsSystemAdministrator){
$boot->set_form_locked();
}
$boot->set_button($buttonname);
$boot->set_RefreshSearchs();
echo $boot->Compile();
}
function mainroutes_save(){
$q=new mysql();
$zmd5=$_POST["zmd5"];
unset($_POST["zmd5"]);
if($zmd5==null){
$fields[]="`zmd5`";
$values[]="'".$md5=md5(serialize($_POST))."'";
}
while (list ($key, $value) = each ($_POST) ){
$fields[]="`$key`";
$values[]="'".mysql_escape_string2($value)."'";
$edit[]="`$key`='".mysql_escape_string2($value)."'";
}
if($zmd5<>null){
$sql="UPDATE nic_routes SET ".@implode(",", $edit)." WHERE zmd5='$zmd5'";
}else{
$sql="INSERT IGNORE INTO nic_routes (".@implode(",", $fields).") VALUES (".@implode(",", $values).")";
}
$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){echo $q->mysql_error;return;}
$sock=new sockets();
$sock->getFrameWork("cmd.php?ip-build-routes=yes");
}
function subrules_popup(){
$ruleid=$_GET["rule-id"];
$ID=$_GET["subrule"];
$users=new usersMenus();
$page=CurrentPageName();
$tpl=new templates();
$t=time();
$buttonname="{add}";
$boot=new boostrap_form();
if($ID>0){
$q=new mysql();
$sql="SELECT * FROM iproute_rules WHERE ID=$ID";
$ligne=mysql_fetch_array($q->QUERY_SQL($sql,"artica_backup"));
$title=$tpl->_ENGINE_parse_body("$ID::{$ligne["src"]} - {$ligne["destination"]}");
$buttonname="{apply}";
}else{
$boot->set_CloseYahoo("YahooWin3");
}
if(!is_numeric($ligne["enable"])){$ligne["enable"]=1;}
$boot->set_formtitle($title);
$boot->set_formdescription("{iprules_explain}");
$boot->set_hidden("subruleid", $ID);
$boot->set_hidden("ruleid", $ruleid);
$boot->set_field("src", "{source}", $ligne["source"]);
$boot->set_field("destination", "{destination}", $ligne["destination"]);
$boot->set_field("priority", "{priority}", $ligne["priority"]);
$boot->set_checkbox("enable", "{enabled}", $ligne["enable"]);
$users=new usersMenus();
if(!$users->AsSystemAdministrator){
$boot->set_form_locked();
}
$boot->set_button($buttonname);
$boot->set_RefreshSearchs();
echo $boot->Compile();
}
function rules_search(){
$q=new mysql();
$page=CurrentPageName();
$tpl=new templates();
$boot=new boostrap_form();
$t=time();
//$q->QUERY_SQL("DROP TABLE iproute_table","artica_backup");
$q->BuildTables();
$search=string_to_flexquery("rules-search");
$sql="SELECT * FROM iproute_rules WHERE ruleid={$_GET["rule-id"]} $search ORDER BY priority LIMIT 0,500";
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){senderror($q->mysql_error);}
while ($ligne = mysql_fetch_assoc($results)) {
$link=$boot->trswitch("Loadjs('$page?subruleid={$ligne["ID"]}&rule-id={$_GET["rule-id"]}');");
$delete=imgtootltip("delete-32.png",null,"Delete$t({$ligne["ID"]})");
$tr[]="<tr>
<td style='font-size:14px' width=50% nowrap $link>{$ligne["src"]}</td>
<td style='font-size:14px' width=50% nowrap $link>{$ligne["destination"]}</td>
<td style='font-size:14px' width=1% nowrap $link>{$ligne["priority"]}</td>
<td width=1% nowrap>$delete</td>
</tr>
";
}
$deleteTXT=$tpl->javascript_parse_text("{delete_rule}");
echo $tpl->_ENGINE_parse_body("
<table class='table table-bordered table-hover'>
<thead>
<tr>
<th>{source}</th>
<th>{destination}</th>
<th>PRIO</th>
<th> </th>
</tr>
</thead>
<tbody>
").@implode("\n", $tr)." </tbody>
</table>
<script>
var FreeWebIDMEM$t='';
var xDelete$t=function (obj) {
var results=obj.responseText;
if(results.length>10){alert(results);return;}
ExecuteByClassName('SearchFunction');
}
function Delete$t(id){
if(confirm('$deleteTXT \"'+id+'\" ?')){
var XHR = new XHRConnection();
XHR.appendData('rule-delete',id);
XHR.sendAndLoad('$page', 'POST',xDelete$t);
}
}
</script> ";
}
function mainroutes_search(){
$q=new mysql();
$page=CurrentPageName();
$tpl=new templates();
$boot=new boostrap_form();
$t=time();
//$q->QUERY_SQL("DROP TABLE iproute_table","artica_backup");
$q->BuildTables();
$types[1]="{network_nic}";
$types[2]="{host}";
$search=string_to_flexquery("mainroutes-search");
$sql="SELECT * FROM nic_routes WHERE 1 $search ORDER BY pattern LIMIT 0,500";
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){senderror($q->mysql_error);}
while ($ligne = mysql_fetch_assoc($results)) {
$link=$boot->trswitch("Loadjs('$page?mainrouteid={$ligne["zmd5"]}');");
$delete=imgtootltip("delete-64.png",null,"Delete$t('{$ligne["zmd5"]}')");
$color="black";
/* if($ligne["enable"]==0){
$color="#A9A9A9";
}
*/
$tr[]="<tr id='R{$ligne["ID"]}'>
<td width=1% nowrap $link><img src='img/64-ip-settings.png'></td>
<td style='font-size:18px;color:$color' nowrap $link> ". $tpl->javascript_parse_text($types[$ligne["type"]])."</td>
<td style='font-size:18px;color:$color' nowrap $link> {$ligne["nic"]}</td>
<td style='font-size:18px;color:$color' nowrap $link> {$ligne["pattern"]}</td>
<td style='font-size:18px;color:$color' nowrap $link> {$ligne["gateway"]}</td>
<td width=1% nowrap>$delete</td>
</tr>
";
}
$deleteTXT=$tpl->javascript_parse_text("{delete_route}");
echo $tpl->_ENGINE_parse_body("
<table class='table table-bordered table-hover'>
<thead>
<tr>
<th colspan=2>{type}</th>
<th>{nic}</th>
<th>{pattern}</th>
<th>{gateway}</th>
<th> </th>
</tr>
</thead>
<tbody>
").@implode("\n", $tr)." </tbody>
</table>
<script>
var FreeWebIDMEM$t='';
var xDelete$t=function (obj) {
var results=obj.responseText;
if(results.length>10){alert(results);return;}
ExecuteByClassName('SearchFunction');
}
function Delete$t(id){
if(confirm('$deleteTXT \"'+id+'\" ?')){
var XHR = new XHRConnection();
XHR.appendData('mainroute-delete',id);
XHR.sendAndLoad('$page', 'POST',xDelete$t);
}
}
</script>
";
}
function routes_search(){
$q=new mysql();
$page=CurrentPageName();
$tpl=new templates();
$boot=new boostrap_form();
$t=time();
//$q->QUERY_SQL("DROP TABLE iproute_table","artica_backup");
$q->BuildTables();
$search=string_to_flexquery("routes-search");
$sql="SELECT * FROM iproute_table WHERE 1 $search ORDER BY routename LIMIT 0,500";
$results=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){senderror($q->mysql_error);}
while ($ligne = mysql_fetch_assoc($results)) {
$link=$boot->trswitch("Loadjs('$page?ruleid={$ligne["ID"]}');");
$sql="SELECT * FROM iproute_rules WHERE ruleid={$ligne["ID"]} ORDER BY priority LIMIT 0,10";
$results2=$q->QUERY_SQL($sql,"artica_backup");
if(!$q->ok){senderror($q->mysql_error);}
$ff=array();
while ($ligne2 = mysql_fetch_assoc($results2)) {
$ff[]="<div style='font-size:14px'>{$ligne2["src"]} - {$ligne2["destination"]}</div>";
}
$delete=imgtootltip("delete-64.png",null,"Delete$t({$ligne["ID"]})");
$tr[]="<tr id='R{$ligne["ID"]}'>
<td width=1% nowrap $link><img src='img/64-ip-settings.png'></td>
<td style='font-size:18px' $link>{$ligne["routename"]}</td>
<td style='font-size:18px' $link width=1% nowrap $link>{$ligne["interface"]}</td>
<td style='font-size:18px' $link width=1% nowrap $link>{$ligne["gateway"]}</td>
<td $link width=1% nowrap>".@implode("\n", $ff)."</td>
<td width=1% nowrap>$delete</td>
</tr>
";
}
$deleteTXT=$tpl->javascript_parse_text("{delete_group}");
echo $tpl->_ENGINE_parse_body("
<table class='table table-bordered table-hover'>
<thead>
<tr>
<th colspan=2>{groupname}</th>
<th>{interface}</th>
<th>{gateway}</th>
<th> </th>
<th> </th>
</tr>
</thead>
<tbody>
").@implode("\n", $tr)." </tbody>
</table>
<script>
var FreeWebIDMEM$t='';
var xDelete$t=function (obj) {
var results=obj.responseText;
if(results.length>10){alert(results);return;}
ExecuteByClassName('SearchFunction');
}
function Delete$t(id){
if(confirm('$deleteTXT \"'+id+'\" ?')){
var XHR = new XHRConnection();
XHR.appendData('route-delete',id);
XHR.sendAndLoad('$page', 'POST',xDelete$t);
}
}
</script>
";
}