<?php

//////////////////////////////////////////////////////////////
//===========================================================
// haproxy.php
//===========================================================
// SOFTACULOUS VIRTUALIZOR
// Version : 1.0
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Abhijeet
// Date:       10th Feb 2017
// Time:       16:30 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 haproxy_theme(){

global $theme, $l, $globals, $servergroups, $servers, $supported_protocols, $haproxydata, $vpses, $l, $error, $done, $server_haconfigs,$arr_haproxy_src_ips;

softheader($l['<title>']);
echo '
<style>

</style>
';

echo '<link rel="stylesheet" type="text/css" href="'.$theme['url'].'/css2/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="'.$theme['url'].'/js2/jquery.dataTables.min.js"></script>';

echo '
<script>';

// Parse and include haproxy.js file
echo parse_lang(file_get_contents($theme['url'].'/js/haproxy.js'));

$breadcrumbs = array( 'dashboard', 'lm_vs', 'lms_haproxy');

echo '
	
	var $server_haconfigs = '.json_encode($server_haconfigs).';
	var $haproxydata = '.json_encode($haproxydata).';
	var $servers = '.json_encode($servers).';
	var $vpses = '.json_encode($vpses).';
	var $supported_protocols = '.json_encode($supported_protocols).';
	var $l = '.json_encode($l).';
	
	var $edit = null; 
	
	var is_admin = 1;
	vdf_edit_ico = "fas fa-cog cursor-pointer";
	vdf_save_ico = "fas fa-save";
	vdf_delete_ico = "fas fa-delete";
	vdf_revert_ico = "fas fa-undo";
	arr_haproxy_src_ips = '.json_encode($arr_haproxy_src_ips).';
	
	var vdf_url = window.location.origin+window.location.pathname+"?act=haproxy&api=json&page='.(int) optREQ('page').'&reslen='.(int) optREQ('reslen').'"+(window.location.search.includes("debug=died") ? "&debug=died" : "");
	
	$(document).ready(function(){
		update_record_alerts();
	});
	
	function ajaxprocess(self, postdata, success, fail, showprocess){
		
		var url_path = window.location.origin+window.location.pathname+"?act=";
		
		//Show processing
		if(showprocess != undefined){
			var progressbar = "<div class=\"w-100 d-flex justify-content-center py-1\"><div class=\"loader\"></div></div>";
			var oldhtml = $(self).html();
			var oldclass = $(self).attr("class");
			$(self).html(progressbar);
		}
		
		$.ajax({
			type: "post",
			url: url_path+"haproxy&api=json"+(window.location.search.includes("debug=died") ? "&debug=died" : ""),
			data: postdata,
			dataType : "json",
			success: function (data){
				//Remove processing
				if(showprocess != undefined){
					$(self).html(oldhtml);
					$(self).attr("class", oldclass);
				}
				eval(success)(self, data);
				
			},
			error: function(data){
				//Remove processing
				if(showprocess != undefined){
					$(self).html(oldhtml);
					$(self).attr("class", oldclass);
				}
				
				var reg_pat = /could\snot\smake\sthe\squery/i;
				var alert_str = (reg_pat.test(data.responseText) == true ? "'.__J('Database Query Error').'" : "'.__J('Unknown Error').'");
				showalert(alert_str,"1");
				eval(fail)(self, data);
			}
		});
	}
	
	// Script to Manage HAProxy Servers
	function showhaservers_page(){
		$("#showhaserversbtn").attr("id", "showvdfbtn");
		$("#showvdfbtn").attr("onclick", "showvdf_page()");
		$("#showvdfbtn").html("'.__J('List Records').'");
		$("#vdf_search_link").hide();
		$("#showvdfformbtn").hide();
		$("#search_btn").parent().attr("style", "display: none !important");
		
		$("#domain_forwarders_div").hide();
		$("#haservers_div").show();
		show_ha_servers_tbl();
	}
	
	function showvdf_page(){
		$("#showvdfbtn").attr("id", "showhaserversbtn");
		$("#showhaserversbtn").attr("onclick", "showhaservers_page()");
		$("#showhaserversbtn").html("'.__J('View Servers').'");
		$("#vdf_search_link").show();
		$("#showvdfformbtn").show();
		$("#search_btn").parent().attr("style", "display: flex !important");
		
		$("#domain_forwarders_div").show();
		$("#haservers_div").hide();
		$("#haservers_div").html("");
		
	}
	$(document).ready(function(){
		var server_btn = "&nbsp;<button id=\"showhaserversbtn\" class=\"go_btn\" onclick=\"showhaservers_page()\" >'.__J('View Servers').'</button>";
		$("#showvdfformbtn").parent().append(server_btn);
	});
	
	function show_ha_servers_tbl(){
		$str = "";
		$str += "<div class=\"row w-100 mx-auto\"> \
			<div class=\"col-sm-12 p-0\">\
				<table class=\"table table-hover tablesorter\" id=\"ha_servers_tbl\">\
					<thead>\
						<tr>\
							<th style=\"width: 20px;\">'.__J('ID').'</th>\
							<th style=\"width: 350px;\">'.__J('Server ID').'</th>\
							<th style=\"width: 50px;\">'.__J('Enabled').'</th>\
							<th style=\"width: 50px;\">'.__J('Status').'</th>\
							<th style=\"width: 150px;\">'.__J('Actions').'</th>\
						</tr>\
					</thead>\
					<tbody></tbody>\
					<tfoot></tfoot>\
				</table>\
			</div>\
		</div><br />"
		$("#haservers_div").html($str);
		
		ajaxprocess("", "server_page=1", populate_ha_servers_tbl, populate_ha_servers_tbl);
		
		$("#ha_servers_tbl").after("<div class=\"row w-100 wait_img\"><div class=\"col-sm-12 justify-content-center d-flex\"><div class=\"progress w-25\">\
			<div class=\"progress-bar bg-primary progress-bar-striped progress-bar-animated w-100\">\
			</div>\
		</div></div></div>");
	}
	
	function populate_ha_servers_tbl(self ,ajaxdata){
		
		if(ajaxdata != undefined && ajaxdata.servers != undefined){
			$servers = (!!ajaxdata.servers ? ajaxdata.servers : {});
		}
		
		$("#haservers_div .wait_img").remove();
		var strdata = "";
		$.each($servers, function(i,t){
			var status = "--";
			if(t["haproxy_status"] == "1"){
				status = "'.__J('Error Occurred').'";
			}
			if(t["haproxy_status"] == "0"){
				status = "'.__J('Running').'";
			}
			if(t["haproxy_status"] == "3"){
				status = "'.__J('Stopped').'";
			}
			
			strdata += "\
			<tr>\
				<td class=\"text-center\">"+t["serid"]+"</td> \
				<td class=\"text-center\">"+t["server_name"]+"</td> \
				<td class=\"text-center\">"+(t["haproxy_enable"] ? "'.__J('Yes').'" : "'.__J('No').'")+"</td> \
				<td class=\"text-center\">"+status+"</td> \
				<td class=\"text-right ha_servers_actions\" id=\""+t["serid"]+"_server_actions\">\
					<span ><button class=\"go_btn mr-2 mb-1\"  data-placement=\"auto\" tooltip=\"'.__J('Update servers source IPs').'\" onclick=\"show_update_server_src_ips_form(this);\" >'.__J('Map IPs').'</button></span> \
					<span ><button class=\"go_btn mr-2 mb-1\"   data-placement=\"auto\" tooltip=\"'.__J('Reload HAProxy service').'\" onclick=\"reload_haproxy_service(this);\" >'.__J('Reload').'</button></span> \
				</td> \
			</tr>\
			";
		});
		$("#ha_servers_tbl tbody").eq(0).html(strdata);
		show_tooltip();
	}
	
	function reload_haproxy_service(self, ajaxdata){
		var serid = $(self).parents().eq(1).attr("id").split("_")[0];
		
		if(ajaxdata == undefined){
			ajaxprocess(self, "server_page=1&reload=1&serid="+encodeURIComponent(serid), reload_haproxy_service, reload_haproxy_service, 1);
			return;
		}else{
			if(ajaxdata.done != undefined && ajaxdata.done.success != undefined){
				showalert("'.__J('Reloaded service successfully').'");
				populate_ha_servers_tbl("", ajaxdata);
				
			}else if(ajaxdata.error != undefined){
				var str = "";
				$.each(ajaxdata.error, function(i,t){
					str += t+"\n";
				});
				showalert("'.__J('Errors').':\n"+str, "1");
			}else{
				showalert("'.__J('Error reloading HAProxy service on server ID: {{serid}}, check HAProxy task logs for more information').'", "1");
			}
		}
	}
	function show_update_server_src_ips_form(self, ajaxdata){
		var serid = $(self).parents().eq(1).attr("id").split("_")[0];
		
		if(ajaxdata == undefined){
			ajaxprocess(self, "server_page=1&get_server_old_src_ips=1&serid="+encodeURIComponent(serid)+"", show_update_server_src_ips_form, show_update_server_src_ips_form, 1)
			return true;
		}else{
			if(ajaxdata.done != undefined){
				if(ajaxdata.server_old_src_ips == undefined || ajaxdata.server_old_src_ips.length == 0){
					showalert("'.__J('No old source IPs found for this server').'","1");
					return;
				}
				$str = "<div class=\"w-100 p-0\" id=\"update_server_src_ips_form_div\">";
				$str += "<div class=\"row mx-auto w-100 h5\"><div class=\"col-sm-12\" ><span>"+$servers[serid]["server_name"]+"</span></div></div><hr />";
				$str += "<div class=\"row mx-auto w-100\"><div class=\"col-sm-6\"><span>'.__J('Old Source IP(s)').'</span></div><div class=\"col-sm-6\"><span>'.__J('New Source IPs').'</span></div></div><hr />";
				$str += "<form id=\"update_server_src_ips_form\" name=\"update_server_src_ips_form\" action=\"\" onsubmit=\"return false;\" >";
				$.each(ajaxdata.server_old_src_ips[serid], function(i, t){
					$str += "<div class=\"row mx-auto w-100 form-group\"><div class=\"col-sm-6\"><label>"+t+"</label></div><div class=\"col-sm-6\"><select class=\"virt-select\" name=\"src_ips["+t+"]\">";
						$str += "<option value=\"-1\" >'.__J('Select IP').'</option>";
						$.each($servers[serid]["arr_haproxy_src_ips"], function(k, v){
							$str += "<option value=\""+v+"\" >"+v+"</option>";
						});
					$str += "</select></div></div>";
				});
				$str += "<input type=\"hidden\" name=\"serid\" value=\""+serid+"\" >";
				$str += "<div class=\"row mx-auto w-100\"><div class=\"col-sm-12 text-center\"><span onclick=\"update_server_src_ips(this)\" ><button class=\"go_btn go_btn-sm\" >'.__J('Update').'</button></span></div></div>";
				$str += "<div>";
				$("#haproxymodal1 .modal-body").eq(0).html($str);
				$("#haproxymodal1").modal({show:true});		
				$(".virt-select").select2({width:"100%"});		
			}else if(ajaxdata.error != undefined){
				var str = "";
				$.each(ajaxdata.error, function(i,t){
					str += t+"\n";
				});
				showalert("'.__J('Errors').':\n"+str,"1");
			}else{
				showalert("'.__J('Error processing request').'","1");
				return false;
			}
		}
	}
	
	function update_server_src_ips(self, ajaxdata){
		
		if(ajaxdata == undefined){
			
			showalert("'.__J('Are you sure you want to update the source IPs for this server ?').'" ,"3" ,function(confirm){
				if(confirm == false){
					return false;
				}else{
					var postdata = "";
					postdata += "server_page=1&update_server_src_ips=1&"+$("#update_server_src_ips_form").serialize();
			
					ajaxprocess(self, postdata, update_server_src_ips, update_server_src_ips, 1)
			
					return true;
				}
			});	
		}else{
			
			if(ajaxdata.done != undefined && ajaxdata.done.success != undefined){
				$haproxydata = (!!ajaxdata.haproxydata ? ajaxdata.haproxydata : {});
				showalert("'.__J('Updated data successfully').'");
				$("#haproxymodal1").modal("hide");
				
			}else if(ajaxdata.error != undefined){
				
				var str = "";
				$.each(ajaxdata.error, function(i,t){
					str += t+"\n";
				});
				
				showalert("'.__J('Errors').':\n"+str,"1");
				
			}else{
				
				showalert("'.__J('Error processing request').'","1");
				
				return false;
			}
		}
	}
</script>

<!-- Update server\'s source IPs form modal -->
<div class="modal fade" id="haproxymodal1">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header d-flex align-items-center">
				<h6>'.__('Update Old Source IPs with New').'</h6>
				<button type="button" class="close text-always-white" data-dismiss="modal">×</button>
			</div>
			<div class="modal-body"></div>
		</div>
	</div>
</div>
<div class="card2 p-3 mx-3 mt-3">
	<div class="row">
		<div class="card2-title col d-flex align-items-center">
			<i class="icon icon-firewall2 h4 m-0 text-admin"></i> '.__('VPS Domain Forwarding').'
		</div>
		<div class="col col d-flex justify-content-end">
			<span class="search_btn icon-fix d-flex align-items-center justify-content-center mr-2" style="float: right !important">
				<a href="javascript:void(0)" onclick="$(\'#vdf_infobox\').slideToggle();">
					<i class="fas fa-info text-black" ></i>
				</a>
			</span>
			<span class="search_btn icon-fix d-flex align-items-center justify-content-center mr-2" style="float: right !important">
				<a href="'.$globals['docs'].'Manage_VPS_Domain_Forwarding" target="_blank" tooltip="'.__('You can do a Wildcard search using *<br>e.g. abc* will match emails starting with abc').'">
					<i class="fas fa-question text-black" ></i>
				</a>
			</span>
			<span class="search_btn icon-fix d-flex align-items-center justify-content-center" style="float: right !important">
				<a href="javascript:showsearch();" class="search_btn text-light" id="search_btn">
					<i class="fas fa-search text-black"></i>
				</a>
			</span>
		</div>
	</div>
	
</div>';
echo get_breadcrumb($breadcrumbs);
echo'<div class="card mx-3 p-2">
		<div id="vdf_infobox" style="display:none;">
			<div class="heading">'.__('Information').'</div>
			<div class="body">
				<div class="scrollbar-virt">
					<div>';
					foreach($server_haconfigs as $k => $v){
						echo '<div>
							<b>'.__('Server').':</b> '.$servers[$k]["server_name"].'<br/>
							<b>'.__('Reserved ports').':</b> '.$v["haproxy_reservedports"].'<br/>
							<b>'.__('Reserved Ports only for HTTP/HTTPS').':</b> '.$v["haproxy_reservedports_http"].'<br/>
							<b>'.__('Allowed ports').':</b> '.$v["haproxy_allowedports"].'<br/>
							</div><br/>
						';
					}
				echo '</div>
				</div>
			</div>
		</div>';
//-------------- Search VDF Block Starts ---------------------
echo '<div id="showsearch" style="display:'.(optREQ('haproxysearch') || (!empty($haproxydata) && !empty($globals['showsearch'])) ? "" : "none").';" class="mb-3">
<form accept-charset="'.$globals ['charset'].'" name="haproxysearchform" method="get" action="" id="haproxysearchform" class="form-horizontal">
<input type="hidden" name="act" value="haproxy">
<div class="form-group_head">
	<div class="row mx-auto w-100">
	    <div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('ID').'</label></div>
			<div class="col-xs-12"><input class="form-control" type="text" name="s_id" id="s_id" size="15" value="'.REQval('s_id','').'"/></div>
		</div>
		<div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('Server').'</label></div>
			<div class="col-xs-12 server-select-lg">
				<select name="s_serid" id="s_serid" class="form-control virt-select">
					<option value="-1" '.(REQval('s_serid') == - 1 ? 'selected="selected"' : '').'>'.__('Select Server').'</option>';
					foreach($servers as $key => $id) {
						echo '<option value="'.$key.'" '.(isset($_REQUEST ['s_serid']) && REQval('s_serid') == $key ? 'selected="selected"' : '').'>'.$id ['server_name'].'</option>';
					}
		
		echo 	'</select>
			</div>
		</div>
		<div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('VPS').'</label></div>
			<div class="col-xs-12"><input class="form-control" type="text" name="s_vpsid" id="s_vpsuuid" size="15" value="'.REQval('s_vpsid','').'"/></div>
		</div>
		<div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('Protocol').'</label></div>
			<div class="col-xs-12">
				<select name="s_protocol" id="s_protocol" class="custom-select">
					<option value="-1" '.(REQval('s_protocol') == - 1 ? 'selected="selected"' : '').'>'.__('Select Protocol').'</option>';
					foreach($supported_protocols as $key => $id) {
						echo '<option value="'.$id.'" '.(isset($_REQUEST ['s_protocol']) && REQval('s_protocol') == $id ? 'selected="selected"' : '').'>'.$id.'</option>';
					}
		
		echo 	'</select>
			</div>
		</div>
  	</div>
  	<div class="row mx-auto w-100">
		<div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('Source Domain/IP').'</label></div>
			<div class="col-xs-12"><input type="text" class="form-control" name="s_src_hostname" id="s_src_hostname" size="25" value="'.REQval('s_src_hostname','').'"/></div>
		</div>
		<div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('Source Port').'</label></div>
			<div class="col-xs-12"><input type="number" class="form-control" name="s_src_port" id="s_src_port" size="25" value="'.REQval('s_src_port','').'"/></div>
		</div>
		<div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('Destination IP').'</label></div>
			<div class="col-xs-12"><input type="text" class="form-control" name="s_dest_ip" id="s_dest_ip" size="25" value="'.REQval('s_dest_ip','').'"/></div>
		</div>
		<div class="col-sm-3">
			<div class="col-xs-12"><label>'.__('Destination Port').'</label></div>
			<div class="col-xs-12"><input type="number" class="form-control" name="s_dest_port" id="s_dest_port" size="25" value="'.REQval('s_dest_port','').'"/></div>
		</div>
  	</div>
	<div class="row mx-auto w-100 my-2">
		<div class="col-sm-12 text-center"><button type="submit" name="haproxysearch" class="go_btn" value="1"/>'.__('Search').'</button></div>
	</div>
</div>
</form>		
</div>';
//-------------- Search VDF Block Ends ---------------------
error_handle($error);
if(!empty($done)){
	show_alert(__('The action was completed successfully. Reloading Page!'));
}
echo '<script>
</script>';
echo '<div class="row mx-auto w-100 mb-3"><div class="col-sm-12 text-right"><button id="showvdfformbtn" class="go_btn text-center" onclick="showvdfform();">'.__('New').'</button></div></div>';
echo '
	<div class="mx-auto w-100" id="addvdf_form_div" style="display: none;">
		<div class="row title"><div class="col-xs-12">'.__('New Domain Forwarding Record').'</div></div>
		<form name="addvdf" id="addvdf" method="post" action="" onsubmit="return false;">
			<div class="row mx-auto w-100 my-3">
				<div class="col-sm-3">
					<label class="control-label" for="serid">'.__('Server').'</label>
					<select class="form-select virt-select" id="serid" name="serid" onchange="processaddvdfform(this)" ></select>
				</div>
				<div class="col-sm-3">
					<label class="control-label" for="vpsuuid">'.__('VPS').'</label>
					<select class="form-select virt-select" id="vpsuuid" name="vpsuuid" onchange="processaddvdfform(this)" ></select>
				</div>
				<div class="col-sm-3">
					<label class="control-label" for="protocol">'.__('Protocol').'</label>
					<select class="form-select virt-select" id="protocol" name="protocol" onchange="processaddvdfform(this)" ></select>
				</div>
				<div class="col-sm-3">
					<label class="control-label" for="src_hostname">'.__('Source Domain/IP').'</label>
					<input type="text" class="form-control" id="src_hostname" name="src_hostname" />
				</div>
			</div>
			<div class="row mx-auto w-100 my-3">
				<div class="col-sm-3">
					<label class="control-label" for="src_port">'.__('Source Port').'</label>
					<input type="number" min="0" class="form-control" id="src_port" name="src_port" />
				</div>
				<div class="col-sm-3">
					<label class="control-label" for="dest_ip">'.__('Destination IP').'</label>
					<select class="form-select virt-select" id="dest_ip" name="dest_ip" ></select>
				</div>
				<div class="col-sm-3">
					<label class="control-label" for="dest_port">'.__('Destination Port').'</label>
					<input type="number" min="0" class="form-control" id="dest_port" name="dest_port" />
				</div>
			</div>
			<div class="row text-center my-2">
				<button id="submitaddvdf" onclick="processaddvdfform(this);" class="go_btn text-center m-2" name="submitaddvdf" >'.__('Add').'</button> 
				<button class="go_btn text-center m-2" onclick=\'$("#addvdf_form_div").css("display", "none"); $("#showvdfformbtn").parents().eq(1).show();\'>'.__('Close').'</button>
				<input type="hidden" value="addvdf" name="action" />
			</div>	
		</form>
	</div>
	';
	echo'
	<div id="domain_forwarders_div">
		<div class="row mx-auto w-100 mb-3">
			<div class="col-sm-8 col-lg-8 col-md-6 p-0 d-flex align-items-center">';
				page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
			echo''.get_num_records($globals['num_res']).'
			</div>
			<div class="col-sm-4 col-lg-4 col-md-6 text-right px-4 d-flex align-items-center">
				<div class="bottom-menu float-right w-100">
					<div class="row mx-1">
						<div class="col-4 p-0">
							<label class="float-end">'.__('With Selected').'</label>
						</div>
						<div class="col-6 p-0">
							<select name="haproxy_multis" id="haproxy_multiselect_action_1" class="custom-select">
								<option value="0">---</option>
								<option value="1">'.__('Delete').'</option>
							</select>
						</div>
						<div class="col-2">
							<input type="submit" id ="haproxy_task_submit" class="go_btn" name="haproxy_task_submit" value="'.__('GO').'" onclick="vdf_confirm(0 ,1);">
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="w-100 sticky">
		<table class="table table-hover tablesorter common-table" id="vps_forwarders_tbl">
			<thead>
				<tr class="table_heading">
					<th class="min_width z-index-1">
						'.get_checkbox('select_all', '', 'select_all', array('chk_it' => 0), '', 'select_all').'
					</th>
					<th class="min_width">'.__('ID').'</th>
					<th>'.__('VPS').'</th>
					<th>'.__('Server').'</th>
					<th>'.__('Protocol').'</th>
					<th>'.__('Source Domain/IP').'</th>
					<th width="80">'.__('Source Port').'</th>
					<th>'.__('Destination IP').'</th>
					<th width="30">'.__('Destination Port').'</th>
					<th class="text-right" width="150px">'.__('Actions').'</th>
				</tr>
			</thead>
			<tbody>';
			foreach($haproxydata as $k => $v){
				echo '<tr class="text-center">
				<td>
					<span id="'.$v['id'].'_checkbox">
						'.get_checkbox('vdf_list[]', '', '', array('chk_it' => 0), $v['id']).'
					</span>
				</td>
				<td><span id="'.$k.'_id"><span class="coldat">'.$v['id'].'</span></span></td>
				<td class="text-left"><span id="'.$k.'_vpsuuid"><span class="coldat ml-1">'.$v['vpsid'].' ('.$v['hostname'].')'.'</span></span></td>
				<td class="text-left"><span id="'.$k.'_serid"><span class="coldat ml-1">'.$servers[$v['serid']]['server_name'].'</span></span></td>
				<td class="text-left"><span id="'.$k.'_protocol"><span class="coldat ml-1">'.$v['protocol'].'</span></span></td>
				<td class="text-left"><span id="'.$k.'_src_hostname"><span class="coldat ml-1">'.$v['src_hostname'].'</span></span></td>
				<td class="text-left"><span id="'.$k.'_src_port"><span class="coldat ml-1">'.$v['src_port'].'</span></span></td>
				<td class="text-left"><span id="'.$k.'_dest_ip"><span class="coldat ml-1">'.$v['dest_ip'].'</span></span></td>
				<td class="text-left"><span id="'.$k.'_dest_port"><span class="coldat ml-1">'.$v['dest_port'].'</span></span></td>
				<td class="float-right">
					<div class="badge_container">
						<span class="vdf_actions" id="'.$v['id'].'_vdf_actions">
							<span class="vdf_edit" id="'.$v['id'].'_edit">
								<a class="badge badge-settings">
									<i class="fas fa-cog cursor-pointer" onclick="edit_row(this, '.$v['id'].')" tooltip="'.__('Edit this record').'"></i>
								</a>
							</span>
							<span class="vdf_delete">
								<a class="badge badge-trash" class="mx-2">
									<i class="fas fa-trash" onclick="vdf_confirm('.$v['id'].');" tooltip="'.__('Delete this record').'"></i>
								</a>
							</span>
						</span>
					</div>
				</td>
				</tr>';
			}
			echo '
			</tbody>
			<tfoot></tfoot>
		</table>
		</div>';
		echo'<div class="row mx-auto w-100 mt-5">
			<div class="col-sm-8 col-lg-8 col-md-6 mb-3 p-0">';
				page_links($globals['num_res'], $globals['cur_page'], $globals['reslen']);
			echo'
			</div>
			<div class="col-sm-4 col-lg-4 col-md-6 text-right mb-3 px-4">
				<div class="bottom-menu float-right w-100">
					<div class="row mx-1">
						<div class="col-4 p-0">
							<label class="float-end">'.__('With Selected').'</label>
						</div>
						<div class="col-6 p-0">
							<select name="haproxy_multis" id="haproxy_multiselect_action_1" class="custom-select">
								<option value="0">---</option>
								<option value="1">'.__('Delete').'</option>
							</select>
						</div>
						<div class="col-2">
							<input type="submit" id ="haproxy_task_submit" class="go_btn" name="haproxy_task_submit" value="'.__('GO').'" onclick="vdf_confirm(0 ,1);">
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
		<div id="haservers_div" class="overflow-auto">
		</div>
		</div>
			
	</div>
	
';
// echo '</div>'; // End of BG html class
softfooter();
echo '
<div id="processing_symb"><div class="loader-lg"></div></div>
';
}

?>