File tree Expand file tree Collapse file tree 5 files changed +93
-6
lines changed
Expand file tree Collapse file tree 5 files changed +93
-6
lines changed Original file line number Diff line number Diff line change 1212 exit ;
1313}
1414
15+ // Get ipset lists
16+ exec (HESTIA_CMD ."v-list-firewall-ipset 'json' " , $ output , $ return_var );
17+ check_return_code ($ return_var ,$ output );
18+ $ data = json_decode (implode ('' , $ output ), true );
19+
20+ $ ipset_lists =[];
21+ foreach ($ data as $ key => $ value ) {
22+ if (isset ($ value ['SUSPENDED ' ]) && $ value ['SUSPENDED ' ] === 'yes ' ) {
23+ continue ;
24+ }
25+ if (isset ($ value ['IP_VERSION ' ]) && $ value ['IP_VERSION ' ] !== 'v4 ' ) {
26+ continue ;
27+ }
28+ array_push ($ ipset_lists , ['name ' =>$ key ]);
29+ }
30+ $ ipset_lists_json =json_encode ($ ipset_lists );
31+
1532// Check POST request
1633if (!empty ($ _POST ['ok ' ])) {
1734
Original file line number Diff line number Diff line change 4141 $ v_status = 'active ' ;
4242}
4343
44+ // Get ipset lists
45+ exec (HESTIA_CMD ."v-list-firewall-ipset 'json' " , $ output , $ return_var );
46+ check_return_code ($ return_var ,$ output );
47+ $ data = json_decode (implode ('' , $ output ), true );
48+
49+ $ ipset_lists =[];
50+ foreach ($ data as $ key => $ value ) {
51+ if (isset ($ value ['SUSPENDED ' ]) && $ value ['SUSPENDED ' ] === 'yes ' ) {
52+ continue ;
53+ }
54+ if (isset ($ value ['IP_VERSION ' ]) && $ value ['IP_VERSION ' ] !== 'v4 ' ) {
55+ continue ;
56+ }
57+ array_push ($ ipset_lists , ['name ' =>$ key ]);
58+ }
59+ $ ipset_lists_json =json_encode ($ ipset_lists );
60+
4461// Check POST request
4562if (!empty ($ _POST ['save ' ])) {
4663
Original file line number Diff line number Diff line change 9898 </ tr >
9999 < tr >
100100 < td >
101- < input type ="text " size ="20 " class ="vst-input " name ="v_ip " value ="<?=htmlentities(trim($v_ip, "'"))?> ">
101+ < select class ="vst-list " id ="quickips_list " onchange ="this.nextElementSibling.value=this.value ">
102+ < option value =""> clear</ option >
103+ </ select >
104+ < input type ="text " size ="20 " class ="vst-input vst-list-editor " name ="v_ip " value ="<?=htmlentities(trim($v_ip, "'"))?> ">
102105 </ td >
103106 </ tr >
104107 < tr >
120123 </ table >
121124 </ from >
122125
123- </ div >
126+ </ div >
127+
128+ < script >
129+ var iplists = JSON . parse ( '<?=$ipset_lists_json?>' ) ;
130+ iplists . sort ( function ( a , b ) {
131+ return a . name > b . name ;
132+ } ) ;
133+
134+ $ ( function ( ) {
135+ var targetelement = document . getElementById ( 'quickips_list' ) ;
136+
137+ var newEl = document . createElement ( "option" ) ;
138+ newEl . text = "Ipset Lists" ;
139+ newEl . disabled = true ;
140+ targetelement . appendChild ( newEl ) ;
141+
142+ iplists . forEach ( iplist => {
143+ var newEl = document . createElement ( "option" ) ;
144+ newEl . text = iplist . name ;
145+ newEl . value = "ipset:" + iplist . name ;
146+ targetelement . appendChild ( newEl ) ;
147+ } ) ;
148+ } ) ;
149+ </ script >
Original file line number Diff line number Diff line change 9999 </ tr >
100100 < tr >
101101 < td >
102- < input type ="text " size ="20 " class ="vst-input " name ="v_ip " value ="<?=htmlentities(trim($v_ip, "'"))?> ">
102+ < select class ="vst-list " id ="quickips_list " onchange ="this.nextElementSibling.value=this.value ">
103+ < option value =""> clear</ option >
104+ </ select >
105+ < input type ="text " size ="20 " class ="vst-input vst-list-editor " name ="v_ip " value ="<?=htmlentities(trim($v_ip, "'"))?> ">
103106 </ td >
104107 </ tr >
105108 < tr >
120123 </ table >
121124 </ form >
122125 </ div >
126+
127+ < script >
128+ var iplists = JSON . parse ( '<?=$ipset_lists_json?>' ) ;
129+ iplists . sort ( function ( a , b ) {
130+ return a . name > b . name ;
131+ } ) ;
132+
133+ $ ( function ( ) {
134+ var targetelement = document . getElementById ( 'quickips_list' ) ;
135+
136+ var newEl = document . createElement ( "option" ) ;
137+ newEl . text = "Ipset Lists" ;
138+ newEl . disabled = true ;
139+ targetelement . appendChild ( newEl ) ;
140+
141+ iplists . forEach ( iplist => {
142+ var newEl = document . createElement ( "option" ) ;
143+ newEl . text = iplist . name ;
144+ newEl . value = "ipset:" + iplist . name ;
145+ targetelement . appendChild ( newEl ) ;
146+ } ) ;
147+ } ) ;
148+ </ script >
Original file line number Diff line number Diff line change 33 < div class ="l-unit-toolbar__buttonstrip ">
44 < a class ="ui-button cancel " id ="btn-back " href ="/list/server/ "> < i class ="fas fa-arrow-left status-icon blue "> </ i > < ?=__('Back')?> </ a >
55 < a href ="/add/firewall/ " id ="btn-create " class ="ui-button cancel " title ="<?=__('Add Rule')?> "> < i class ="fas fa-plus-circle status-icon green "> </ i > < ?=__('Add Rule')?> </ a >
6- < ? if(!empty($_SESSION['FIREWALL_EXTENSION'])) {
7- echo '< a class ="ui-button cancel " href ="/list/firewall/banlist/ "> < i class ="fas fa-eye status-icon red "> </ i > '.__('list fail2ban').'</ a > ';
8- } ?>
6+ < ?php if(!empty($_SESSION['FIREWALL_EXTENSION'])): ?>
7+ < a class ="ui-button cancel " href ="/list/firewall/banlist/ "> < i class ="fas fa-eye status-icon red "> </ i > < ?=__('list fail2ban')?> </ a >
8+ < a class ="ui-button cancel " href ="/list/firewall/ipset/ "> < i class ="fas fa-list status-icon green "> </ i > < ?=__('list ipset')?> </ a >
9+ < ?php endif; ?>
910 </ div >
1011 < ul class ="context-menu sort-order animated fadeIn " style ="display:none; ">
1112 < li entity ="sort-action "> < span class ="name "> < ?=__('Action')?> < i class ="fas fa-sort-amount-down "> </ i > </ span > < span class ="up active "> < i class ="fas fa-sort-amount-up "> </ i > </ span > </ li >
You can’t perform that action at this time.
0 commit comments