<?php

//////////////////////////////////////////////////////////////
//===========================================================
// firewall_theme.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Alons
// Date:       8th Mar 2010
// Time:       23:00 hrs
// Site:       https://www.virtualizor.com/ (SOFTACULOUS VIRTUALIZOR)
// ----------------------------------------------------------
// Please Read the Terms of use at https://www.virtualizor.com
// ----------------------------------------------------------
//===========================================================
// (c)Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////

if(!defined('VIRTUALIZOR')){

	die('Hacking Attempt');

}

function firewall_theme(){

global $theme, $l, $globals,$cluster,$user, $getservices,$do,$done,$kernel,$output,$view_rule,$error,$protocol_array, $refined_ports, $refined_ips, $firewall_info, $no_service_found;

if(optGET('ajax')){
	if(!empty($output)){
		foreach ($output as $key => $value){
			
			$port_exist = 0;
			if(!empty($output['port_exist']) || !empty($value['port_exist'])){
				$port_exist = 1;
				unset($value['port_exist']);
			}
			$ip_exist = 0;
			if(!empty($output['ip_exist']) || !empty($value['ip_exist'])){
				$ip_exist = 1;
				unset($value['ip_exist']);
			}

			echo '<pre>'.print_r($value, 1).'</pre>';
			
			if(!empty($port_exist)){
				echo '<pre><font color="RED">'.__('This port number already exists.').'</font></pre>';
			}
			if(!empty($ip_exist)){
				echo '<pre><font color="RED">'.__('This IP Address already exists.').'</font></pre>';
			}			
		}

	}
	
	if(isset($error)){
		error_handle($error, 100, false, false, 1);
	}
	return;
}

softheader($l['<title>']);
										
// Is it offline ?
$hypervisor_status = $cluster->statewise($globals['server']);
if($hypervisor_status == 0 || $hypervisor_status == 2){
	show_alert($globals['hypervisor_status'][$hypervisor_status] ,"1");
	echo '<div class="e_notice"><b>'.__('Note').' : </b>&nbsp; '.$globals['hypervisor_status'][$hypervisor_status].'</div>';
}else{
	 $span_id = array('start','stop','restart','status', 'testing_interval' ,'view','search','version','block','setpolicy','allow','ip_block','ip_allow', 'temp_ip_allow', 'temp_ip_block', 'change_test_mode');	
	echo '<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
	function ipvalidation(ip){	
	
	  if ((ip.length==0) || (ip == null)) {
		  return false;	
	  }
	  if(!ip.match(/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/ ) || ip=="0"){
		  return false;	
	  }
	  return true;
	};

	function delete_rule(id){
		$_("view_td").innerHTML = "<button type=\"button\" class=\"close\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>";
		$(".close").each(function(){
			$(this).click(function(){
				$_("view_td").style.display="none";
			});
		});
		AJAX("'.$globals['index'].'act=firewall&ajax=true&delete_rule="+id, "firewall_button(re,\"view\")")
	};
	
	function portvalidation(port){
		if ((port.length==0) || (port==null)){
			return false;	
		}
		
		return true;
	};
	$(document).ready(function(){
	';
	$event = array('start' => __J('Firewall  Enable '), 
					'restart' => __J('Firewall  Restart '),
					'stop' => __J('Firewall  Disable '),
					'status' => __J('Firewall  Status '),
					'testing_interval' => __J('Set testing interval'),
					'change_test_mode' => __J('Testing Mode'),
					'setpolicy' => __J(' Factory Reset '),
					'version' => __J(' Firewall version '),
					'view' => __J(' View IPtables Rules '),
					'block' => __J('Block Port '),
					'allow' => __J('Allow Port '),
					'ip_block' => __J('Block IP Address '),
					'ip_allow' => __J('Allow IP Address '),
					'temp_ip_block' => __J('Block IP Address with port'),
					'temp_ip_allow' => __J('Allow IP Address with port'),
					'search' => __J(' Search IP ')
				);
	
	foreach($event as $id => $title){
		$ele = '$(\'a[title="'.$title.'"]\').click(function(){';
		if($id == 'change_test_mode'){
			$ele = '$(\'#change_test_mode\').on("change", function(){';
		}
		echo $ele.'
			var ele = $("#'.$id.'_td").parent().prev().find("a");
			if(ele.find(".loader").length <= 0){
				ele.append(\'<div class="loader ml-2"></div>\');
			}
		});';
	}			
	echo'
	});
	function firewall_onclick(id){
		if(id=="'.__J('Firewall  Enable ').'"){																		//enable firewall
			AJAX("'.$globals['index'].'act=firewall&ajax=true&start=true", "firewall_button(re,\"start\")")	
		}else if(id=="'.__J('Firewall  Restart ').'"){															// restart firewall
			AJAX("'.$globals['index'].'act=firewall&ajax=true&restart=true", "firewall_button(re,\"restart\")")
		}else if(id=="'.__J('Firewall  Disable ').'"){																//stop firewall
			AJAX("'.$globals['index'].'act=firewall&ajax=true&stop=true", "firewall_button(re,\"stop\")")
		}else if(id=="'.__J('Firewall  Status ').'"){   														// status firewall
			AJAX("'.$globals['index'].'act=firewall&ajax=true&status=true", "firewall_button(re,\"status\")")	
		}else if(id=="'.__J('Set testing interval').'"){
			var testing_interval = $_("testing_interval").value;   														
			AJAX("'.$globals['index'].'act=firewall&ajax=true&testing_interval="+testing_interval, "firewall_button(re,\"testing_interval\")")	
		}else if(id=="'.__J('Testing Mode').'"){   	
			var mode = ($("#change_test_mode").prop("checked") == true ? "enable" : "disable")													
			AJAX("'.$globals['index'].'act=firewall&ajax=true&firewall_testing="+mode, "firewall_button(re,\"change_test_mode\")")	
		}else if(id=="'.__J(' Factory Reset ').'"){															//setpolicy firewall
			AJAX("'.$globals['index'].'act=firewall&ajax=true&setpolicy=true", "firewall_button(re,\"setpolicy\")")
		}else if(id=="'.__J(' Firewall version ').'"){   															// version firewall
			AJAX("'.$globals['index'].'act=firewall&ajax=true&version=true", "firewall_button(re,\"version\")")
		}else if(id=="'.__J(' View IPtables Rules ').'"){														//view firewall
			AJAX("'.$globals['index'].'act=firewall&ajax=true&view=true", "firewall_button(re,\"view\")")
		}else if(id=="'.__J('Block Port ').'"){				
			
			var port=$_("txtblockport").value;

			if(port=="4082" || port=="4083" || port=="4084" || port=="4085" ){		// Access is denied to block port
				showalert("'.__J('Virtualizor service may get affected if you block this port, hence this is denied').'" ,"1")			
				return false;
			}
			
			AJAX("'.$globals['index'].'act=firewall&ajax=true&block=true&port="+port, "firewall_button(re,\"block\")")
			
		}else if(id=="'.__J('Allow Port ').'"){													//allow portfirewall
			var port=$_("txtallowport").value;

			AJAX("'.$globals['index'].'act=firewall&ajax=true&allow=true&port="+port, "firewall_button(re,\"allow\")")

		}else if(id=="'.__J('Block IP Address ').'"){													//ipblock firewall
			var ip = $_("txtblockip").value;
			AJAX("'.$globals['index'].'act=firewall&ajax=true&ip_block=true&ip="+ip, "firewall_button(re,\"ip_block\")");

		}else if(id=="'.__J('Allow IP Address ').'"){   												// ipallow firewall
			var ip = $_("txtallowip").value;
			AJAX("'.$globals['index'].'act=firewall&ajax=true&ip_allow=true&ip="+ip, "firewall_button(re,\"ip_allow\", \"'.__J('Allow IP Address ').'\")");

		}else if(id=="'.__J('Block IP Address with port').'"){													//ipblock firewall
			var ip = $_("temp_txtblockip").value;
			var ip_protocol = $_("txtblockip_protocol").value;
			var ip_port = $_("txtblockip_port").value;
			if(ip_port=="4081" || ip_port=="4082" || ip_port=="4083" || ip_port=="4084" || ip_port=="4085" ){		// Access is denied to block port
				showalert("'.__J('Virtualizor service may get affected if you block this port, hence this is denied').'" ,"1")
				return false;
			}

			if(!empty(ip_port) && !portvalidation(ip_port)){
				showalert("'.__J('Please enter valid port number.').'" ,"1");
				return false;
			}

			AJAX("'.$globals['index'].'act=firewall&ajax=true&ip_block=true&ip="+ip+"&ip_protocol="+ip_protocol+"&ip_port="+ip_port+"&is_temp=1", "firewall_button(re,\"temp_ip_block\")");

		}else if(id=="'.__J('Allow IP Address with port').'"){   												// ipallow firewall
			var ip = $_("temp_txtallowip").value;
			var ip_protocol = $_("txtallowip_protocol").value;
			var ip_port = $_("txtallowip_port").value;

			if(!empty(ip_port) && !portvalidation(ip_port)){
				showalert("'.__J('Please enter valid port number.').'" ,"1");
				return false;
			}

			AJAX("'.$globals['index'].'act=firewall&ajax=true&ip_allow=true&ip="+ip+"&ip_protocol="+ip_protocol+"&ip_port="+ip_port+"&is_temp=1", "firewall_button(re,\"temp_ip_allow\")");

		}else if(id=="'.__J(' Search IP ').'"){ 												// search  firewall
			var ip = $_("txtsearchip").value;
			if(ipvalidation(ip)){
				AJAX("'.$globals['index'].'act=firewall&ajax=true&search=true&ip="+ip, "firewall_button(re,\"search\")")
				$_("txtsearchip").value="";
			}else{
				$_("search_td").style.display="none";
				$_("txtsearchip").focus();
				var ele = $("#search_td").parent().prev().find("a");
				ele.find("div").remove()
				showalert("'.__J('Please enter valid IP Address.').'" ,"1");			
				return false;	
			}
		}			
	}
	
	function firewall_button(re,opt){';
		foreach($span_id AS $k => $v){
			echo'
			if(opt=="'.$v.'"){
				var ele = $("#'.$v.'_td").parent().prev().find("a");
				ele.find("div").remove()
				$_("'.$v.'_td").innerHTML="<button type=\"button\" class=\"close\" aria-label=\"Close\"><span aria-hidden=\"true\">×</span></button>"+re;
				$_("'.$v.'_td").style.display="block";						
			}else{
				$_("'.$v.'_td").style.display="none";														
			}
			$("#'.$v.'_td pre").addClass("mb-0");
			$(".close").each(function(){
				$(this).click(function(){
					$_("'.$v.'_td").style.display="none";
				});
			});';
		}	// foreach close.
echo '}
// ]]></script>';

echo '
<style>
.firewall_protocol{
width:60px !important;
}
</style>
';

$GLOBALS['breadcrumbs'] = ['dashboard', 'lm_firewall', 'lms_firewall'];

echo page_header(__('Firewall Services '), 'fas fa-shield-alt', $globals['docs'].'firewall', 0, 0, '');

echo '
<div class="card p-2 mx-3">';
echo '<div class="notice"><b>'.__('Note').' : '.__('This Firewall wizard is deprecated and will be removed soon').'</b></div>';
echo'<div class="notice "><b>'.__('Note').' : </b>&nbsp; '.__('Use firewall if you know how the iptables work. Please note the if you enable the firewall from panel then INPUT chain policy will be set as DROP by default').'</div>
	<div class="notice "><b>'.__('Note').' : </b>&nbsp; '.__('Please make sure you do not add the following port in BLOCK list : 4081-4085.<br> We also use following ports for VNC so make sure you do not add the following ports to BLOCK list: 5900-6000').'</div>';

if(empty($firewall_info['firewall_enable'])){
	echo '<div class="e_notice my-2 mx-0"><b>'.__('Note').' : </b>&nbsp; '.__('Firewall is disabled!').'</div>';
}

if(!empty($firewall_info['firewall_enable']) && $firewall_info['test_option'] == 'enable'){
	echo '<div class="notice "><b>'.__('Note').' : </b>&nbsp; '.__('Testing Mode is enabled - Don\'t forget to disable TESTING').'</div>';
}

if(!empty($done)){
	show_alert(__('The action was completed successfully. Reloading Page!'));
}

echo'
<form accept-charset="'.$globals['charset'].'" id="firewallform" name ="firewallform" method="post" action="" class="form-horizontal">
	  		
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0 h6">
				<a class="d-flex align-items-center"><i class="fas fa-vial mr-2 ml-3"></i>'.__('Testing Mode').'</a>
			</div>
			<div class="col-sm-10">
				<div class="custom-control custom-switch ml-3 mb-2" title="'.__('Testing Mode').'">
					<input type="checkbox" class="custom-control-input" id="change_test_mode" title="'.__('Testing Mode').'" onchange="firewall_onclick(this.title);" '.(!empty($firewall_info['test_option'] == 'enable') ? 'checked' : '').'>
					<label class="custom-control-label m-0" for="change_test_mode"></label>  
				</div>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="change_test_mode_td" style="display: none"></span >	
			</div>
		</div>
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="onfirewall" title="'.__('Firewall  Enable ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-toggle-on"></i>&nbsp;&nbsp;&nbsp;'.__('Firewall  Enable ').'</a>
			</div>
			<div class="col-sm-10" valign="top">
				<label class="control-label">'.__('Starts the IPtables Service').'</label><br/><br/>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="start_td" style="display: none"></span >	  
			</div>	
		</div>		
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="restartfirewall" title="'.__('Firewall  Restart ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-sync-alt"></i>&nbsp;&nbsp;&nbsp;'.__('Firewall  Restart ').'</a>
			</div>
			<div class="col-sm-10">
				<label class="control-label">'.__('Restarts the IPtables Service').'</label><br/><br/>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="restart_td" style="display: none"></span >
			</div>	
		</div>	
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="stopfirewall" title="'.__('Firewall  Disable ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);" >
				<i class="fas fa-toggle-off"></i>&nbsp;&nbsp;&nbsp;'.__('Firewall  Disable ').'</a>
			</div>
			<div class="col-sm-10">
				<label class="control-label">'.__('Stops the Firewall').'</label><br/><br/>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="stop_td" style="display: none"></span >
			</div>
		</div>
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="statusfirewall" title="'.__('Firewall  Status ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title)">
				<i class="fas fa-shield-alt"></i>&nbsp;&nbsp;&nbsp;'.__('Firewall  Status ').'
				</a>
			</div>
			<div class="col-sm-10">
				<label class="control-label">'.__('Shows the IPtables status').'</label ><br/><br/>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="status_td" style="display: none">
				</span >
			</div>
		</div>
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="testing_interval" title="'.__('Set testing interval').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title)">
				<i class="fas fa-clock"></i>&nbsp;&nbsp;&nbsp;'.__('Set testing interval').'
				</a>
			</div>
			<div class="col-sm-10">
				<div class="row w-100 mx-auto mb-2 mb-2">
					<div class="col-sm-12 p-0">
						<label class="control-label">'.__('Interval field sets the cron’s interval in minutes. Setting this value in ‘n’ minutes means that after n minutes as per system clock, all your rules will be cleared, and the original rule will be reapplied again. For example, if you set cron’s interval to 5 minutes, firewall will be cleared and will apply default rules in 0-5 minutes from the firewall start').'</label ><br/>
					</div>
					<div class="col-sm-12 p-0 d-flex align-items-center mt-2">
						<label class="mt-0">'.__('Set testing interval').' '.__('for').'</label > <input type="text" id="testing_interval" class="form-control" min="1" name="testing_interval" style="width : 50px;" value="'.(!empty($firewall_info['mins']) ? $firewall_info['mins'] : 0).'"> <label class="mt-0">'.__('minutes').'</label >
					</div>
				</div>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="testing_interval_td" style="display: none">
				</span >
			</div>
		</div>
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0" width="15%" valign="top" >
				<a href="javascript:void(0)" name="setfirewallpolicy" title="'.__(' Factory Reset ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-redo"></i>&nbsp;&nbsp;&nbsp;'.__(' Factory Reset ').'</a>
			</div>
			<div class="col-sm-10" valign="top">
				<label class="control-label"> '.__('Will reset the Firewall to the Factory settings').'</label><br/><br/>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="setpolicy_td" style="display: none"></span >
			</div>
		</div>
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0" width="15%" valign="top">
				<a href="javascript:void(0)" name="versionfirewall" title="'.__(' Firewall version ').'"
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-info-circle"></i>&nbsp;&nbsp;&nbsp;'.__(' Firewall version ').'</a>
			</div>
			<div class="col-sm-10" valign="top"> 
				<label class="control-label">'.__('Shows the IPtables Version').'</label><br/><br/>
				<span class="alert alert-info fade in alert-dismissible show mb-1" id="version_td" style="display: none"></span >
			</div>
		</div>
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="viewfirewall" title="'.__(' View IPtables Rules ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-list-alt"></i>&nbsp;&nbsp;&nbsp;'.__(' View IPtables Rules ').'</a>
			</div>
			<div class="col-sm-10" valign="top">	 
				<label class="control-label">'.__('Lists the IPtable rules of all chains').'</label><br/><br/>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="view_td" style="display: none"></span >				
			</div>
		</div>		
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="blockfirewall" title="'.__('Block Port ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-ban"></i>&nbsp;&nbsp;&nbsp;'.__('Block Port ').'</a>
			</div>
			<div class="col-sm-10">
				<div class="d-flex align-items-center">
					<label class="mt-0">'.__('Block Port Number ').'</label>
					<input type="text" placeholder="Eg: 2000,300-305,600" id="txtblockport" value="'.implode(',',$refined_ports['DROP']).'" class="form-control alert alert-danger m-0 ml-3" name="txtblockport" style="width : 380px;"><label class="mt-0"> '.__(' through the firewall').'</label>
				</div>
				
				<span class="mt-3 alert alert-primary fade in alert-dismissible show mb-1" id="block_td" style="display: none"></span >
			</div>
		</div>		
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="allowfirewall" title="'.__('Allow Port ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-flag"></i>&nbsp;&nbsp;&nbsp;'.__('Allow Port ').'</a>
			</div>
			<div class="col-sm-10">
				<div class="d-flex align-items-center">
					<label class="mt-0">'.__('Allow Port Number ').'</label>
					<input type="text" placeholder="Eg: 2000,300-305,600" id="txtallowport" value="'.implode(',',$refined_ports['ACCEPT']).'" class="form-control alert alert-success m-0 ml-3" name="txtallowport" style="width : 380px;"><label class="mt-0"> '.__(' through the firewall').'</label>
				</div>
				
				<span class="mt-3 alert alert-primary fade in alert-dismissible show mb-1" id="allow_td" style="display: none"></span >
			</div>
		</div>		
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="ip_blockfirewall" title="'.__('Block IP Address ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-ban"></i>&nbsp;&nbsp;&nbsp;'.__('Block IP Address ').'</a>
			</div>
			<div class="col-sm-10">
				<div class="d-flex align-items-center">
					<label class="mt-0">'.__('Block IP Address ').'</label>
					<input type="text" id="txtblockip" value="'.implode(',',$refined_ips['DROP']).'" class="form-control alert alert-danger m-0 ml-3" name="txtblockip" style="width : 150px;">
				</div>
				
				<span class="mt-3 alert alert-primary fade in alert-dismissible show mb-1" id="ip_block_td" style="display: none"></span >
			</div>
		</div>		
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="ip_allowfirewall" title="'.__('Allow IP Address ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-flag"></i>&nbsp;&nbsp;&nbsp;'.__('Allow IP Address ').'</a>
			</div>
			<div class="col-sm-10">
				<div class="d-flex align-items-center">
					<label class="mt-0">'.__('Allow IP Address ').'</label>
					<input type="text" id="txtallowip" value="'.implode(',',$refined_ips['ACCEPT']).'" class="form-control alert alert-success m-0 ml-3" name="txtallowip" style="width : 150px;">
				</div>
				
				<span class="mt-3 alert alert-primary fade in alert-dismissible show mb-1" id="ip_allow_td" style="display: none"></span >
			</div>
		</div>

		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="temp_ip_blockfirewall" title="'.__('Block IP Address with port').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-ban"></i>&nbsp;&nbsp;&nbsp;'.__('Block IP Address with port').'</a>
			</div>
			<div class="col-sm-10">
				<div class="d-flex align-items-center">
					<label class="mt-0">'.__('Block IP Address ').'</label>
					<input type="text" id="temp_txtblockip" class="form-control alert alert-danger m-0 ml-3" name="temp_txtblockip" style="width : 150px;"><label class="mt-0"> '.__('for').' </label><select id="txtblockip_protocol" name="txtblockip_protocol" class="custom-select firewall_protocol ml-2">';
					foreach($protocol_array as $k => $v){
						echo '<option value="'.$k.'">'.$v.'</option>';
					}
					echo'</select><label class="mt-0"> '.__('protocol and').' </label><input type="text" id="txtblockip_port" placeholder="('.__('Optional').') Eg: 2000,300-305,600" class="form-control" name="txtblockip_port" style="width : 250px;"><label class="mt-0"> '.__('port').' '.__(' through the firewall').'</label>
				</div>
				<span class="mt-3 alert alert-primary fade in alert-dismissible show mb-1" id="temp_ip_block_td" style="display: none"></span >
			</div>
		</div>		
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="temp_ip_allowfirewall" title="'.__('Allow IP Address with port').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-flag"></i>&nbsp;&nbsp;&nbsp;'.__('Allow IP Address with port').'</a>
			</div>
			<div class="col-sm-10">
				<div class="d-flex align-items-center">
					<label class="mt-0">'.__('Allow IP Address ').'</label>
					<input type="text" id="temp_txtallowip" class="form-control alert alert-success m-0 ml-3" name="temp_txtallowip" style="width : 150px;"><label class="mt-0"> '.__('for').' </label><select id="txtallowip_protocol" name="txtallowip_protocol" class="custom-select firewall_protocol ml-2">';
					foreach($protocol_array as $k => $v){
						echo '<option value="'.$k.'">'.$v.'</option>';
					}
					echo'</select><label class="mt-0"> '.__('protocol and').' </label><input type="text" id="txtallowip_port" placeholder="('.__('Optional').') Eg: 2000,300-305,600" class="form-control" name="txtallowip_port" style="width : 250px;"><label class="mt-0"> '.__('port').' '.__(' through the firewall').'</label>
				</div>
				
				<span class="mt-3 alert alert-primary fade in alert-dismissible show mb-1" id="temp_ip_allow_td" style="display: none"></span >
			</div>
		</div>
		<div class="row w-100 mx-auto mb-2">
			<div class="col-sm-2 p-0">
				<a href="javascript:void(0)" name="searchip" title="'.__(' Search IP ').'" 
				class="btn cursor-pointer d-flex align-items-center" onclick="firewall_onclick(this.title);">
				<i class="fas fa-search"></i>&nbsp;&nbsp;&nbsp;'.__(' Search IP ').'</a>
			</div>
			<div class="col-sm-10" valign="top">
				 <label class="control-label">'.__('Search IPtables for IP Address').' </label>
				 <input type="text" id="txtsearchip" class="form-control" name="txtsearchip" style="width : 150px;">
				 <br/><br/>
				<span class="alert alert-primary fade in alert-dismissible show mb-1" id="search_td" style="display: none"></span >
			</div>
		</div>
	
	</form> ';
}
 
 echo '</div>';
softfooter();

}


