Location: PHPKode > projects > SCOP Heartbeat Administration interface > scop-2.0/html/scop/config/display.php

<?

include ("../inc/header.inc");
include ("../inc/functions.inc");

# This code opens a file, reads it into an array and then writes it back to a file.

If ($srcfile=="ldirectord") { // Slightly pointless check ?

	parse_config_file(); // Read the file and setup the global variables

	if ($action=="display") { // Just output the current ldirectord.cf file to screen
		$trans="2";
		$a2 = "${$l.$trans}";
		$trans="13a";
		$a13a = "${$l.$trans}";

		?>
		<div id="contentArea">
		<h1><a href="/scop/index.php?menu=viewconf&l=<?=$l?>"><?=$a2?></a> &gt; <?=$a13a?></h1>
		<div class="border">
		<?
		echo "<table width=\"60%\" align=\"center\"><tr><td><PRE>";
		for ( $i=0; $i<count($arrtext); $i++) {
			echo("$arrtext[$i]");
		}
		echo "</PRE></td></tr></table>";
		?>
		</div>
		<div class="bottom"><span>-----</span></div>
		</div>
		<?
	}

	if ($action=="modreal") { // The real servers are dealt with here
		$newreal = $_POST['newreal'];
		$newweight = $_POST['newweight'];
		$fwd = $_POST['fwd'];

		if ($subaction=="add") { // Simple addittion of real servers

			$theport = Get_port($VIRTUAL[$v]);

			// Setup the java script first
			?>
			<script language="javascript" type="text/javascript">
			<!--
			function checkformaddrealserver()
			{ // Check the new user fields are correct
				var weight = document.addrealserver.newweight.value;
				if (weight =="" )
				{
					alert  ("Please specify a weight for the real server (0..65,535).");
					document.addrealserver.newweight.select();
					return false

				}
				if (  isNaN(weight) )
				{
					alert  ("Please specify an integer weight for the real server (0..65,535).");
					document.addrealserver.newweight.select();
					return false
				}
				if (weight  > 65535 )
				{
					alert  ("Please specify a VALID weight for the real server (0..65,535).");
					document.addrealserver.newweight.select();
					return false

				}
				if (document.addrealserver.newreal.value =="" )
				{
					alert  ("Please fill in the the real servers IP Address andd Port no i.e. 10.0.0.112:80 ");
					document.addrealserver.newreal.select();
					return false

				}
				var stringtotest = document.addrealserver.newreal.value;
				var testresult = -1;
				var testresult = -1;
				testresult = stringtotest.indexOf(':',0);
				testresult2 = stringtotest.indexOf('IPAddress',0);
				if (testresult == -1 || testresult2 != -1 || stringtotest.length < 10)
				{
					alert  ("Please fill in the the real servers IP Address and Port no i.e. 10.0.0.112:80 ");
					document.addrealserver.newreal.select();
					return false

				}


					var ipbit = Left (stringtotest,testresult);
					var check = verifyIP(ipbit);
						if ( !check  ) return check

					var rightbit =(String(stringtotest).length - testresult) -1;
					var portbit = Right (stringtotest,rightbit);
					if (  isNaN(portbit) )
					{
						alert ("Please enter a valid IPAddress:Port i.e. 10.0.0.20:80");
						return false
					}


				return true
			}
			//-->
			</script>
			<?

			// It would be nice to be able to choose a drop down port list AS WELL.
			//echo "<h2>Add a real server to <b>Virtual Server $v</b> ..</h2>";
			$trans="7bb";
			$ars = "${$l.$trans}";
			$trans="3";
			$a3 = "${$l.$trans}";
			//echo "<center><h2>$ars</h2></center>";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> &gt; <?=$ars?></h1>
<div class="border">
<?

						$trans="38";
						$a38 = "${$l.$trans}";
						$trans="39";
						$a39 = "${$l.$trans}";
						$trans="23";
						$a23 = "${$l.$trans}";
						$trans="21";
			$a21 = "${$l.$trans}";
			//echo "Please specify the IP address and service in the following format :</br>";
			//echo " IPAddress:Port i.e. 10.0.0.35:$theport </br>";
			//echo "Specify the relative weight of the server 0 = offline, 1..65,535 = online</br></br>";


			echo "<FORM method=\"post\" action=\"display.php?srcfile=ldirectord&action=modreal&subaction=adddata&v=$v&t=$t\" name=\"addrealserver\">";
			?><table border="0" cellspacing="0" align="center" class="form"><td colspan="3" class="sep2"></td><?
			echo "<tr><th>$a21 </th><td><INPUT type=\"text\" size=20 name=\"label\" value=\"RIP Name\"></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "<tr class=\"altLine\"><th>$a23 </th><td><INPUT type=\"text\" size=20 name=\"newreal\" value=\"IPAddress:$theport\"></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "<tr><th>$a39 </th><td><INPUT type=\"text\" size=5 name=\"newweight\" value=\"1\"></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "<tr class=\"altLine\"><th>$a38 </th><td>";
			echo "<select name=\"fwd\">";
				echo "<OPTION VALUE=\"gate\" ";
				If ($FWDMETHOD[$v]=="gate"){echo "selected=\"true\"";}
				echo ">gate";
				echo "<OPTION VALUE=\"ipip\" ";
				If ($FWDMETHOD[$v]=="ipip"){echo "selected=\"true\"";}
				echo ">ipip";
				echo "<OPTION VALUE=\"masq\" ";
				If ($FWDMETHOD[$v]=="masq"){echo "selected=\"true\"";}
				echo ">masq";
				echo "</select></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "</table>";
			echo "<center> <INPUT type=\"submit\" value=\"$ars\" name=\"go\" onclick=\"return checkformaddrealserver()\"></center>";
			echo "</FORM>";
?>
</div>
<div class="bottom"><span>-----</span></div>
</div>
<?
		}
		if ($subaction=="modify") {



			// Setup the java script first
			?>
			<script language="javascript" type="text/javascript">
			<!--
			function checkformmodifyrealserver()
			{ // Check the new user fields are correct
				var weight = document.modifyrealserver.newweight.value;
				if (weight =="" )
				{
					alert  ("Please specify a weight for the real server (0..65,535).");
					document.modifyrealserver.newweight.select();
					return false
				}
				if (  isNaN(weight) )
				{
					alert  ("Please specify an integer weight for the real server (0..65,535).");
					document.modifyrealserver.newweight.select();
					return false
				}

				if ( weight > 65535 )
				{
					alert  ("Please specify a VALID weight for the real server (0..65,535).");
					document.modifyrealserver.newweight.select();
					return false

				}
				if (document.modifyrealserver.newreal.value =="" )
				{
					alert  ("Please fill in the the real servers IP Address andd Port no i.e. 10.0.0.112:80 ");
					document.modifyrealserver.newreal.select();
					return false

				}
				var stringtotest = document.modifyrealserver.newreal.value;
				var testresult = -1;
				var testresult = -1;
				testresult = stringtotest.indexOf(':',0);
				testresult2 = stringtotest.indexOf('IPAddress',0);
				if (testresult == -1 || testresult2 != -1 || stringtotest.length < 10)
				{
					alert  ("Please fill in the the real servers IP Address and Port no i.e. 10.0.0.112:80 ");
					document.modifyrealserver.newreal.select();
					return false

				}

				var ipbit = Left (stringtotest,testresult);
				var check = verifyIP(ipbit);
					if ( !check  ) return check

				var rightbit =(String(stringtotest).length - testresult) -1;
				var portbit = Right (stringtotest,rightbit);
				if (  isNaN(portbit) || portbit.length<1 )
				{
					alert ("Please enter a valid IPAddress:Port i.e. 10.0.0.20:80");
					return false
				}
				return true
			}
			//-->
			</script>
			<?


			//echo "<h2>Modify Real Server </b> ..</h2>";
			$trans="7b";
			$txt = "${$l.$trans}";
			$trans="3";
			$a3 = "${$l.$trans}";
			//echo "<center><h2>$txt</h2></center>";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> &gt; <?=$txt?></h1>
<div class="border">
<?

			$trans="38";
			$a38 = "${$l.$trans}";
			$trans="39";
			$a39 = "${$l.$trans}";
			$trans="23";
			$a23 = "${$l.$trans}";
			$trans="21";
			$a21 = "${$l.$trans}";
			//echo "Please specify the IP address and service in the following format :</br>";
			//echo " ipaddress:port i.e. 10.0.0.35:80 </br>";
			echo "<FORM method=\"post\" action=\"display.php?srcfile=ldirectord&action=modreal&subaction=modifydata&v=$v&t=$t\" name=\"modifyrealserver\">";

			?><table border="0" cellspacing="0" align="center" class="form"><td colspan="3" class="sep2"></td><?
			echo "<tr><th>$a21</th><td><INPUT type=\"text\" size=20 name=\"label\" value=\"".  $REAL_LABEL[$v][$r] . "\"></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "<tr class=\"altLine\"><th>$a23 </th><td><INPUT type=\"text\" size=20 name=\"newreal\" value=\"".  $REAL[$v][$r] . "\"></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "<tr><th>$a39 </th><td><INPUT type=\"text\" size=5 name=\"newweight\" value=\"" .  $REALWEIGHT[$v][$r] . "\"></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "<tr class=\"altLine\"><th>$a38  </th><td>";
			echo "<select name=\"fwd\">";
				echo "<OPTION VALUE=\"gate\" ";
				If ($REALSERVICE[$v][$r]=="gate"){echo "selected=\"true\"";}
				echo ">gate";
				echo "<OPTION VALUE=\"ipip\" ";
				If ($REALSERVICE[$v][$r]=="ipip"){echo "selected=\"true\"";}
				echo ">ipip";
				echo "<OPTION VALUE=\"masq\" ";
				If ($REALSERVICE[$v][$r]=="masq"){echo "selected=\"true\"";}
				echo ">masq";
				echo "</select></td></tr>";
			?><td colspan="3" class="sep1"></td><?
			echo "</table>";
			echo "<INPUT type=\"hidden\" value=\"$v\" name=\"v\"><INPUT type=\"hidden\" value=\"$r\" name=\"r\">";
			echo "<center> <INPUT type=\"submit\" value=\"$txt\" name=\"go\" onclick=\"return checkformmodifyrealserver()\"></center>";
			echo "</FORM>";
?>
</div>
<div class="bottom"><span>-----</span></div>
</div>
<?
		}



		if ($subaction=="adddata" and $newreal<>"") {
			$exists = RIP_Exists($VIRTUAL[$v],$newreal);
			$ripcount = count($REAL[$v]);
			if (!$exists) {
				If ( strstr($newreal,":") && !strstr($newreal,"IP") ) {
					$thevipport = Get_port($VIRTUAL[$v]);
					$theripport = Get_port($newreal);
					//if ($thevipport != $theripport ) {
					//	draw_error ("WARNING : The RIP port does not match the VIP port !");
					//}
					$r = $_POST['r'];
					$label = $_POST['label'];
					$label = str_replace(" ","_",$label);
					$WRITEFILE=TRUE;
					//echo "<p>The real server has now been added.</p>";
					SCOP_log("Config : New real server added $label.");
					if ($newweight==0) { echo "The real server is currently offline (i.e. weight=0)"; }
					$r = count($REAL[$v]);
					$REAL[$v][$r]=$newreal;
					$REALSERVICE[$v][$r]=$fwd;
					$REALWEIGHT[$v][$r]=$newweight;
					$REAL_LABEL[$v][$r]=$label;
					$rnum++;
				} else {
					draw_error ("ERROR: $newreal</b> <i>doesn't look right ?</br> it should be 10.10.10.10:80 or similar...</i>");
				}

			} else {
				draw_error ("ERROR: $newreal</b> <i>is a duplicate entry</i>");
			}

		}
		if ($subaction=="modifydata" and $newreal<>"") {

				If ( strstr($newreal,":") && !strstr($newreal,"IP")  ) {
					$thevipport = Get_port($VIRTUAL[$v]);
					$theripport = Get_port($newreal);
					//if ($thevipport != $theripport ) {
					//	draw_error ("WARNING : The RIP port does not match the VIP port !");
					//}
					$r = $_POST['r'];
					$label = $_POST['label'];
					$label = str_replace(" ","_",$label);

					$WRITEFILE=TRUE;
					//echo "<p>The real server has now been modified.</p>";
					SCOP_log("Config : Real Server $label changed.");
					//if ($newweight==0) { echo "<p>The real server is currently offline (i.e. weight=0)</p>"; }
					$REAL[$v][$r]=$newreal;
					$REALWEIGHT[$v][$r]=$newweight;
					$REALSERVICE[$v][$r]=$fwd;
					$REAL_LABEL[$v][$r]=$label;
				} else {
					draw_error ("ERROR: $newreal</b> <i>doesn't look right ?</br> it should be 10.10.10.10:80 or similar...</i>");
				}


		}
		if ($subaction=="remove") {
			$WRITEFILE=TRUE;

			# $v & $r will be used to not write this to file....later...

		echo "</br> <center><p>The requested real server has been removed.</p></center> ";
		SCOP_log("Config : Real server removed.");
		//echo "click <a href=\"?srcfile=ldirectord&action=modreal&t=$t\">here</a> to return.";

		}

		else {
			//echo "<h2>Modify Real Servers</h2></br>";
			$trans="7b";
			$txt = "${$l.$trans}";
			$trans="3";
			$a3 = "${$l.$trans}";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> &gt; <?=$txt?></h1>
<div class="border">
<?
			//echo "<center><h2>$txt</h2></br></center>";
			$trans="7a";
			$mvs = "${$l.$trans}";
			$trans="7bb";
			$ars = "${$l.$trans}";
			$trans="19";
			$mod = "${$l.$trans}";
			$trans="20";
			$del = "${$l.$trans}";
			//echo "Clients requesting web pages from the Virtual IP address will be trasparently re-directed to the associated real web servers :</br>";
			//echo "Real Servers are defined by their internal IP address and port number i.e. 10.0.0.35:80 for HTTP or 10.0.0.35:443 for HTTPS.</br>";
			//echo "The Real Server will only be able to repond to this redirected packet if it has the VIP on its loopback adapter, </br>";
			//echo "and the Real Servers response will go directly to the client through the default gateway.</br></br>";

			for ( $i=1; $i<count($VIRTUAL); $i++) {
				echo "<table border=\"0\" class=\"datagrid\" align=\"center\">";
				?><tr><td colspan="5" class="sep2"></td></tr><?
				echo "<tr><td>VIP $i</td><td><b><i>$VIRTUAL_LABEL[$i]</i></td><td>($VIRTUAL[$i])</td><td>";
				echo "[ <a href=\"display.php?srcfile=ldirectord&action=modreal&subaction=add&v=$i&t=$t\" class=\"action\">$ars</a> ]</td></tr>";

				//echo "<th><b>Virtual Server $i</b></th><th><b>($VIRTUAL[$i])</b></th>";
				//If ($PERSISTENT[$i]<>"") { echo "<th>Persistent</th>"; }
				//for ( $b=0; $b<count($REAL[$i]); $b++) {
				for ( $b=count($REAL[$i])-1; $b>-1; $b--) {
					$x=$b+1;
					?><tr><td colspan="5" class="sep1"></td></tr><?
					echo "<tr><td> RIP $x </td><td><i>" . $REAL_LABEL[$i][$b] . " </i></td><td><b>" . $REAL[$i][$b] . "</b></td>";
					echo "<td><i>" . $REALWEIGHT[$i][$b] . "</i></td><td>[ <a href=\"display.php?srcfile=ldirectord&action=modreal&subaction=modify&v=$i&r=$b&t=$t\" class=\"action\"> $mod </a> ]";
					echo  "</td><td>[ <a href=\"display.php?srcfile=ldirectord&action=modreal&subaction=remove&v=$i&r=$b\" class=\"action\" onclick=\"return areyousure('Are you sure you want to remove the real server ? (" . $REAL[$i][$b] . ")')\"> $del </a> ]</td>";
				}
				//echo "</table>";



				//echo "<a href=\"display.php?srcfile=ldirectord&action=modreal&subaction=add&v=$i&t=$t\" class=\"MainLink\">$ars</a>";

			}
			// Or offer to add a virtual server
			echo "<tr><td colspan=\"5\" style=\"text-align:left\">[ <a href=\"display.php?srcfile=ldirectord&action=modvirtual&t=$t\" class=\"action\">$mvs</a> ]";
			echo "</td></tr></table>";

?></div>
<div class="bottom"><span>-----</span></div>
</div>
<?

		}

	}

	if ($action=="modvirtual") {
		if ($subaction=="remove") {
			$WRITEFILE=TRUE;
			$DELETEVIRTUAL=$v;
			SCOP_log("Config : Virtual Server removed.");

			// Remove the virtual server from the array
			// Don't forget to remove the REAL server entry as well !
			//if ($v==count($VIRTUAL)-1) {
			//	array_splice ($VIRTUAL, $v) ;
			//}
			//else {
			//	$a = count($VIRTUAL)-$v-1;
			//	array_splice ($VIRTUAL, $v, -$a) ;
			//}
			$ip = strtok($VIRTUAL[$v],":");
                        remove_physical_vip($ip);

		}

		if ($subaction=="add") {

			$trans="7aa";
			$a7aa = "${$l.$trans}";
			$trans="3";
			$a3 = "${$l.$trans}";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> &gt; <?=$a7aa?></h1>
<div class="border">
<?

			// Need some Javascript
			echo "<script language=\"javascript\" type=\"text/javascript\"> \n ";
			echo "<!-- \n";
			?>

			function checkformaddvirt()
			{ // Check the new user fields are correct
				var virt = document.addvirt.virt.value;

				if (  isNaN(virt) && virt.length<4)
				{
					alert  ("VIP is not a valid IPAddress:Port or Firewall Mark");
					document.modifyrealserver.newweight.select();
					return false
				}

				var stringtotest = document.addvirt.virt.value;
				var testresult = -1;
				var testresult = -1;
				testresult = stringtotest.indexOf(':',0);
				testresult2 = stringtotest.indexOf('IPAddress',0);
				if (testresult == -1 || testresult2 != -1 || stringtotest.length < 10)
				{
					alert  ("VIP is not a valid IPAddress:Port or Firewall Mark");
					document.addvirt.virt.select();
					return false

				}

				if (  virt.length>4)
				{
					var ipbit = Left (stringtotest,testresult);
					var check = verifyIP(ipbit);
						if ( !check  ) return check

					var rightbit =(String(stringtotest).length - testresult) -1;
					var portbit = Right (stringtotest,rightbit);
					if (  isNaN(portbit) || portbit.length<1 )
					{
						alert ("Please enter a valid IPAddress:Port i.e. 10.0.0.20:80");
						document.addvirt.virt.select();
						return false
					}
				}

			return true
			}

			<?
			echo "function updateportno() \n";
			echo "{ \n";
			echo " var text = document.addvirt.portno.value; \n";
			echo " alert(text); \n";
			echo "} \n";
			echo "//-->";
			echo "</script>";

			// Now draw the form
			//echo "<h2>$anvs Add A New Virtual Server</h2>";

			//echo "A virtual server only responds to one service i.e. HTTP (port 80) or HTTPS (port 443)..</br>";
			//echo "Please specify the IP address and service in the following format :</br>";
			//echo " IPAddress:Port i.e. 10.0.0.20:80 </br>";
			//echo "NB. Dont forget to add the physical IP Address relating to the Virtual one...</br> </br>";
			$trans="21";
			$label = "${$l.$trans}";
			$trans="22";
			$persistent = "${$l.$trans}";
			$trans="24";
			$a24 = "${$l.$trans}";
			echo "<FORM method=\"post\" action=\"display.php?srcfile=ldirectord&action=modvirtual&subaction=adddata&t=$t\" name=\"addvirt\">";
			?><table border="0" cellspacing="0" align="center" class="form"><td colspan="3" class="sep2"></td><?

			echo "<tr><th>$label </th><td> <INPUT type=\"text\" size=20 name=\"label\" value=\"VIP Name\"></td></tr>";
			?><td colspan="3" class="sep1"><?
			echo "<tr class=\"altLine\"><th>$a24 </th><td> <INPUT type=\"text\" size=20 name=\"virt\" value=\"10.0.0.20:80\"></td>";
			?><td colspan="3" class="sep1"><?
			// echo "<td>";
			// draw_portlist();
			//echo "</td>";
			echo "</tr>";

			echo "<tr><th>$persistent </th>";
			echo "<td><select name=\"persist\">";
				echo "<OPTION VALUE=\"yes\" ";
				echo ">yes";
				echo "<OPTION VALUE=\"no\" ";
				echo "selected=\"true\"";
				echo ">no";
				echo "</select></td></tr>";
			?><td colspan="3" class="sep1"><?
			//echo "<tr><td>Automaticaly add the related physical VIP?</td>";
			echo "<input type=\"HIDDEN\" name=\"addphys\" value=\"yes\" >";
			echo "</table>";
			echo "<center><INPUT type=\"submit\" value=\"$a7aa\" name=\"go\" onclick=\"return checkformaddvirt()\" ></center>";


			echo "</FORM>";
?></div>
<div class="bottom"><span>-----</span></div>
</div>
<?
		}
		if ($subaction=="adddata") {
			global $VIRTUAL;
			$virt = $_POST['virt'];
			$persist = $_POST['persist'];
			$label = $_POST['label'];
			$emailalert = $_POST['emailalert'];
			$database = $_POST['database'];
			$emailalertfreq = $_POST['emailalertfreq'];
			$addphys = $_POST['addphys'];
			$portno = $_POST['portno'];

			$label = str_replace(" ","_",$label);

			# Check for valid virt:port or fwmark
			$exists = VIP_Exists($virt);
			$vipcount = count($VIRTUAL);
			if (!$exists) {
				If ( strstr($virt,":") OR strlen($virt)<=4 ) {
					$WRITEFILE=TRUE;
					//echo "<p>The virtual server has now been added.</p>";
					SCOP_log("Config : Virtual server $label added.");
					if (strlen($virt)>2) {
						$theport = Get_port($virt);
					} else { #Its a firewall mark
						$theport = "80";
					}
					$theservice = Get_service($theport);
					$ip = Get_ip($virt);
					$vnum++;
					$rnum=0;
					$VIRTUAL[$vnum]=$virt;
					$VIRTUAL_LABEL[$vnum]=$label;

					//if ($theport != $portno) {
					//	draw_error ("WARNING: The 'VIP port number' ($theport) does not match the 'drop down list port no' ($portno)!");
					//}

					if ($theport == "0" OR  $persist=="yes" ) {
						$persist="yes";
						$PERSISTENT[$vnum]=300;
					}

					$REQUEST[$vnum]="\"check.txt\"";
					$RECEIVE[$vnum]="\"OK\"";
					$SCHEDULER[$vnum]="wrr";
					$FALLBACK[$vnum]="127.0.0.1:$theport";
					$CHECKTYPE[$vnum]="connect";
					$SERVICE[$vnum]="$theservice";
					if (strlen($virt)>4)  {
						$PROTOCOL[$vnum]="tcp";
					} else {
						$PROTOCOL[$vnum]="fwm";
					}
					$NETMASK[$vnum]="255.255.255.255";
					$FWDMETHOD[$vnum]="gate";

					// Now check if we need to add the physical VIP to haresources
					if ($demo=="FALSE") {
						if ($addphys=="yes" && strlen($virt)>4) {
						  add_physical_vip($ip);
                                                  //byLeal
                                                  exec ("sudo scp /etc/ha.d/ldirectord.cf hide@address.com:/etc/ha.d/ldirectord.cf > /dev/null 2>&1 & ");
						}
					}
				}
				else {
					draw_error ("ERROR : The virtual server didn't contain a port number.  Are you sure that is correct ?");
				}
			} else {
				draw_error ("ERROR: $virt</b> <i>is a duplicate entry</i>");
			}

		}
		if ($subaction=="edit") {


					// Need some Javascript
					echo "<script language=\"javascript\" type=\"text/javascript\"> \n ";
					echo "<!-- \n";
					?>

					function checkformeditvirt()
					{ // Check the new user fields are correct


							if (  isNaN(document.editvirt.persisttime.value) || document.editvirt.persisttime.value==0 )
							{
								alert ("Persistence time should be an integer >0.");
								document.editvirt.persisttime.select();
								return false
							}
							if (  isNaN(document.editvirt.checkport.value) )
							{
								alert ("Checkport should be an integer.");
								document.editvirt.checkport.select();
								return false
							}

								var fall = document.editvirt.fall.value;
								var stringtotest = fall;
								var testresult = -1;
								var testresult = -1;
								testresult = stringtotest.indexOf(':',0);
								testresult2 = stringtotest.indexOf('IPAddress',0);
								if (testresult == -1 || testresult2 != -1 || stringtotest.length < 10)
								{

									alert  ("Fallback is not a valid IPAddress:Port");
									document.editvirt.fall.select();
									return false

								}

								if (  fall.length>4)
								{

									var ipbit = Left (stringtotest,testresult);
									var check = verifyIP(ipbit);
										if ( !check  ) return check

									var rightbit =(String(stringtotest).length - testresult) -1;
									var portbit = Right (stringtotest,rightbit);
									if (  isNaN(portbit) || portbit.length<1 )
									{
										alert ("Please enter a valid Fallback IPAddress:Port i.e. 127.0.0.1:80");
										document.editvirt.fall.select();
										return false
									}
								}


						var virt = document.editvirt.virt.value;


								if (  isNaN(virt) && virt.length<4)
								{

									alert  ("VIP is not a valid IPAddress:Port or Firewall Mark");
									document.editvirt.virt.select();
									return false
								}
								if (  !isNaN(virt) && virt.length<4)
								{
									//Firewall mark so return true
									return true
								}


								var stringtotest = virt;
								var testresult = -1;
								var testresult = -1;
								testresult = stringtotest.indexOf(':',0);
								testresult2 = stringtotest.indexOf('IPAddress',0);
								if (testresult == -1 || testresult2 != -1 || stringtotest.length < 10)
								{

									alert  ("VIP is not a valid IPAddress:Port or Firewall Mark");
									document.editvirt.virt.select();
									return false

								}

								if (  virt.length>4)
								{

									var ipbit = Left (stringtotest,testresult);
									var check = verifyIP(ipbit);
										if ( !check  ) return check

									var rightbit =(String(stringtotest).length - testresult) -1;
									var portbit = Right (stringtotest,rightbit);
									if (  isNaN(portbit) || portbit.length<1 )
									{
										alert ("Please enter a valid IPAddress:Port i.e. 10.0.0.20:80");
										document.editvirt.virt.select();
										return false
									}
								}


					return true
					}

					<?
					echo "function updateportno() \n";
					echo "{ \n";
					echo " var text = document.addvirt.portno.value; \n";
					echo " alert(text); \n";
					echo "} \n";
					echo "//-->";
			echo "</script>";

			$per=0;
			//echo "<h2>Edit Virtual Server $v Configuration</h2>";
			$trans="7a";
			$txt = "${$l.$trans}";
			$trans="3";
			$a3 = "${$l.$trans}";
			//echo "<center><h2>$txt</h2></center>";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> &gt; <?=$txt?></h1>
<div class="border">
<?

echo "<FORM method=\"post\" name=\"editvirt\" action=\"display.php?srcfile=ldirectord&action=modvirtual&subaction=editdata&v=$v&t=$t\">";
			?><table border="0" cellspacing="0" align="center" class="form">
				<tr><td colspan="3" class="sep2"></td></tr>	<?

			$trans="21";
			$a21 = "${$l.$trans}";
			$trans="24";
			$a24 = "${$l.$trans}";
			$trans="22";
			$a22 = "${$l.$trans}";
			$trans="25";
			$a25 = "${$l.$trans}";
			$trans="26";
			$a26 = "${$l.$trans}";
			$trans="27";
			$a27 = "${$l.$trans}";
			$trans="28";
			$a28 = "${$l.$trans}";
			$trans="29";
			$a29 = "${$l.$trans}";
			$trans="30";
			$a30 = "${$l.$trans}";
			$trans="31";
			$a31 = "${$l.$trans}";
			$trans="32";
			$a32 = "${$l.$trans}";
			$trans="33";
			$a33 = "${$l.$trans}";
			$trans="34";
			$a34 = "${$l.$trans}";
			$trans="35";
			$a35 = "${$l.$trans}";
			$trans="36";
			$a36 = "${$l.$trans}";
			$trans="37";
			$a37 = "${$l.$trans}";
			$trans="38";
			$a38 = "${$l.$trans}";
			$trans="38b";
			$a38b = "${$l.$trans}";
			$trans="121";
			$a121 = "${$l.$trans}";
			$trans="122";
			$a122 = "${$l.$trans}";
			$trans="123";
			$a123 = "${$l.$trans}";



			echo "<tr><th>$a21</th><td> <INPUT type=\"text\" size=20 name=\"label\" value=\"$VIRTUAL_LABEL[$v]\"></td><td>";
			helpitem("5-1-1");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr class=\"altLine\"><th>$a24</th><td> <INPUT type=\"text\" size=20 name=\"virt\" value=\"$VIRTUAL[$v]\"></td><td>";
			echo " ";
			// draw_portlist();
			helpitem("5-1-2");

			if ($PERSISTENT[$v]==NULL ) {

				echo "<tr><th>$a22</th><td>";
				echo "<select name=\"persist\">";
				echo "<OPTION VALUE=\"yes\" ";
				echo ">yes";
				echo "<OPTION VALUE=\"no\" ";
				echo "selected=\"true\"";
				echo ">no";
				echo "</select></td><td>";
				helpitem("5-1-3");
				echo "</td></tr>";
				echo "<tr class=\"altLine\"><th>$a25</th><td> <INPUT type=\"text\" size=\"6\" name=\"persisttime\" value=\"300\"></td><td>";
				helpitem("5-1-4");
				echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			} else {
				echo "<tr><th>$a22</th><td>";
				echo "<select name=\"persist\">";
				echo "<OPTION VALUE=\"yes\" ";
				echo "selected=\"true\"";
				echo ">yes";
				echo "<OPTION VALUE=\"no\" ";
				echo ">no";
				echo "</select></td><td>";
				helpitem("5-1-3");
				echo "</td></tr>";
				echo "<tr class=\"altLine\"><th>$a25</th><td> <INPUT type=\"text\" size=\"6\" name=\"persisttime\" value=\"$PERSISTENT[$v]\"></td><td>";
				helpitem("5-1-4");
				echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			}
			echo "<tr><th>$a26 </th><td>";
			echo "<select name=\"sched\">";
				echo "<OPTION VALUE=\"wlc\" ";
				If ($SCHEDULER[$v]=="wlc"){echo "selected=\"true\"";}
				echo ">wlc";
				echo "<OPTION VALUE=\"rr\" ";
				If ($SCHEDULER[$v]=="rr"){echo "selected=\"true\"";}
				echo ">rr";
				echo "<OPTION VALUE=\"wrr\" " ;
				If ($SCHEDULER[$v]=="wrr"){echo "selected=\"true\"";}
				echo ">wrr";
				echo "<OPTION VALUE=\"lc\" " ;
				If ($SCHEDULER[$v]=="lc"){echo "selected=\"true\"";}
				echo ">lc";
				echo "<OPTION VALUE=\"dh\" " ;
				If ($SCHEDULER[$v]=="dh"){echo "selected=\"true\"";}
				echo ">dh";
				echo "<OPTION VALUE=\"sh\" " ;
				If ($SCHEDULER[$v]=="sh"){echo "selected=\"true\"";}
				echo ">sh";
				echo "</select></td><td>";
				helpitem("5-1-5");
				echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?



			echo "<tr class=\"altLine\"><th>$a27 </th><td> <INPUT type=\"text\" size=20 name=\"fall\" value=\"$FALLBACK[$v]\"></td><td>";
			helpitem("5-1-6");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a28  </th><td>";
			echo "<select name=\"check\">";
				echo "<OPTION VALUE=\"negotiate\" ";
				If ($CHECKTYPE[$v]=="negotiate"){echo "selected=\"true\"";}
				echo ">negotiate";
				echo "<OPTION VALUE=\"connect\" ";
				If ($CHECKTYPE[$v]=="connect"){echo "selected=\"true\"";}
				echo ">connect";
				echo "<OPTION VALUE=\"ping\" " ;
				If ($CHECKTYPE[$v]=="ping"){echo "selected=\"true\"";}
				echo ">ping";
				echo "<OPTION VALUE=\"off\" " ;
				If ($CHECKTYPE[$v]=="off"){echo "selected=\"true\"";}
				echo ">off";
				echo "<OPTION VALUE=\"on\" " ;
				If ($CHECKTYPE[$v]=="on"){echo "selected=\"true\"";}
				echo ">on";
				echo "<OPTION VALUE=\"5\" " ;
				If ($CHECKTYPE[$v]=="5"){echo "selected=\"true\"";}
				echo ">5";
				echo "<OPTION VALUE=\"10\" " ;
				If ($CHECKTYPE[$v]=="10"){echo "selected=\"true\"";}
				echo ">10";
				echo "</select></td><td>";
				helpitem("5-1-7");
				echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a121 </th><td> <INPUT type=\"text\" size=40 name=\"emailalert\" value=$EMAILALERT[$v]></td><td>";
			helpitem("5-1-6");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a122 </th><td> <INPUT type=\"text\" size=10 name=\"emailalertfreq\" value=$EMAILALERTFREQ[$v]></td><td>";
			helpitem("5-1-6");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a123 </th><td> <INPUT type=\"text\" size=40 name=\"database\" value=$DATABASE[$v]></td><td>";
			helpitem("5-1-6");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?


			echo "<tr class=\"altLine\"><th>$a29  </th><td>";
			echo "<select name=\"serv\">";
				echo "<OPTION VALUE=\"http\" ";
				If ($SERVICE[$v]=="http"){echo "selected=\"true\"";}
				echo ">http";
				echo "<OPTION VALUE=\"https\" ";
				If ($SERVICE[$v]=="https"){echo "selected=\"true\"";}
				echo ">https";
				echo "<OPTION VALUE=\"ftp\" " ;
				If ($SERVICE[$v]=="ftp"){echo "selected=\"true\"";}
				echo ">ftp";
				echo "<OPTION VALUE=\"imap\" " ;
				If ($SERVICE[$v]=="imap"){echo "selected=\"true\"";}
				echo ">imap";
				echo "<OPTION VALUE=\"pop\" " ;
				If ($SERVICE[$v]=="pop"){echo "selected=\"true\"";}
				echo ">pop";
				echo "<OPTION VALUE=\"ldap\" " ;
				If ($SERVICE[$v]=="ldap"){echo "selected=\"true\"";}
				echo ">ldap";
				echo "<OPTION VALUE=\"smtp\" " ;
				If ($SERVICE[$v]=="smtp"){echo "selected=\"true\"";}
				echo ">smtp";
				echo "<OPTION VALUE=\"nntp\" " ;
				If ($SERVICE[$v]=="nntp"){echo "selected=\"true\"";}
				echo ">nntp";
				echo "<OPTION VALUE=\"dns\" " ;
				If ($SERVICE[$v]=="dns"){echo "selected=\"true\"";}
				echo ">dns";
				echo "<OPTION VALUE=\"mysql\" " ;
				If ($SERVICE[$v]=="mysql"){echo "selected=\"true\"";}
				echo ">mysql";
				echo "<OPTION VALUE=\"sip\" " ;
				If ($SERVICE[$v]=="sip"){echo "selected=\"true\"";}
				echo ">sip";
				echo "<OPTION VALUE=\"telnet\" " ;
				If ($SERVICE[$v]=="telnet"){echo "selected=\"true\"";}
				echo ">telnet";
				echo "<OPTION VALUE=\"none\" " ;
				If ($SERVICE[$v]=="none"){echo "selected=\"true\"";}
				echo ">none";
				echo "</select></td><td>";
				helpitem("5-1-8");
				echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a30  </th><td>";
			echo "<INPUT type=\"text\" size=\"6\" name=\"checkport\" value=\"$CHECKPORT[$v]\"></td><td>";
			helpitem("5-1-14");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr class=\"altLine\"><th>$a31  </th><td>";
			echo "<INPUT type=\"text\" size=\"20\" name=\"virtualhost\" value=$VIRTUALHOST[$v]></td><td>";
			helpitem("5-1-15");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a32  </th><td>";
			echo "<INPUT type=\"text\" size=\"20\" name=\"login\" value=$LOGIN[$v]></td><td>";
			helpitem("5-1-16");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr class=\"altLine\"><th>$a33  </th><td>";
			echo "<INPUT type=\"text\" size=\"20\" name=\"passwd\" value=$PASSWD[$v]></td><td>";
			helpitem("5-1-17");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?

			echo "<tr><th>$a34  </th><td>";
			echo "<select name=\"proto\">";
				echo "<OPTION VALUE=\"tcp\" ";
				If ($PROTOCOL[$v]=="tcp"){echo "selected=\"true\"";}
				echo ">tcp";
				echo "<OPTION VALUE=\"udp\" ";
				If ($PROTOCOL[$v]=="udp"){echo "selected=\"true\"";}
				echo ">udp";
				echo "<OPTION VALUE=\"ops\" ";
				If ($PROTOCOL[$v]=="ops"){echo "selected=\"true\"";}
				echo ">ops";
				echo "<OPTION VALUE=\"fwm\" ";
				If ($PROTOCOL[$v]=="fwm"){echo "selected=\"true\"";}
				echo ">fwm";
				echo "</select></td><td>";
				helpitem("5-1-9");
				echo "</td></tr>";

			if (strlen($NETMASK[$v]) < 4) {
				$NETMASK[$v] = "255.255.255.255";
			}
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr class=\"altLine\"><th>$a35 </th><td> <INPUT type=\"text\" size=20 name=\"gran\" value=$NETMASK[$v]></td><td>";
			helpitem("5-1-10");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a36 </th><td> <INPUT type=\"text\" size=20 name=\"req\" value=$REQUEST[$v]></td><td>";
			helpitem("5-1-11");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr class=\"altLine\"><th>$a37 </th><td> <INPUT type=\"text\" size=20 name=\"rec\" value=$RECEIVE[$v]></td><td>";
			helpitem("5-1-12");
			echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr><th>$a38 </th><td>";
			echo "<select name=\"fwd\">";
				echo "<OPTION VALUE=\"gate\" ";
				If ($FWDMETHOD[$v]=="gate"){echo "selected=\"true\"";}
				echo ">gate";
				echo "<OPTION VALUE=\"ipip\" ";
				If ($FWDMETHOD[$v]=="ipip"){echo "selected=\"true\"";}
				echo ">ipip";
				echo "<OPTION VALUE=\"masq\" ";
				If ($FWDMETHOD[$v]=="masq"){echo "selected=\"true\"";}
				echo ">masq";
				echo "</select></td><td>";
				helpitem("5-1-13");
				echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "<tr class=\"altLine\"><th>$a38b </th><td>";
			echo "<select name=\"fdbck\">";
				echo "<OPTION VALUE=\"agent\" ";
				If ($FEEDBACK[$v]=="agent"){echo "selected=\"true\"";}
				echo ">agent";
				echo "<OPTION VALUE=\"http\" ";
				If ($FEEDBACK[$v]=="http"){echo "selected=\"true\"";}
				echo ">http";
				echo "<OPTION VALUE=\"none\" ";
				If ($FEEDBACK[$v]!="agent" && $FEEDBACK[$v]!="http"){echo "selected=\"true\"";}
				echo ">none";
				echo "</select></td><td>";
				helpitem("5-1-18");
				echo "</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			echo "</table><center><INPUT type=\"submit\" value=\"$txt\" name=\"go\" onclick=\"return checkformeditvirt()\" ></center>";
			echo "</FORM>";

?>
</div>
<div class="bottom"><span>-----</span></div>
</div>
<br />
<?
		}
		if ($subaction=="editdata") {
			$label = $_POST['label'];
			$virt = $_POST['virt'];
			$persist = $_POST['persist'];
			$persisttime = $_POST['persisttime'];
			$req = $_POST['req'];
			$rec = $_POST['rec'];
			$sched = $_POST['sched'];
			$emailalert = $_POST['emailalert'];
			$emailalertfreq = $_POST['emailalertfreq'];
			$database = $_POST['database'];
			$fall = $_POST['fall'];
			$check = $_POST['check'];
			$serv = $_POST['serv'];
			$checkport = $_POST['checkport'];
			$virtualhost = $_POST['virtualhost'];
			$login = $_POST['login'];
			$passwd = $_POST['passwd'];
			$proto = $_POST['proto'];
			$gran = $_POST['gran'];
			$fwd = $_POST['fwd'];
			$portno = $_POST['portno'];
			$fdbck = $_POST['fdbck'];
			$label = str_replace(" ","_",$label);
			$thevirtport = Get_port($virt);
			$thefallport = Get_port($fall);
			$thevirtip = Get_ip($virt);

			#byLeal
			$oldip = strtok($VIRTUAL[$v],":");
			if ( $oldip != $thevirtip ) {
			 remove_physical_vip($oldip);
			}

			If ( strlen($virt)<=4 ) { $proto = "fwm"; }
			If ( strlen($virt)>=4 && $proto=="fwm" ) { $proto = "tcp"; }

			if ($fwd=="gate" && $proto<>"fwm"){
			// Fallback port must be same as virt in DR mode
				if ($thevirtport<>$thefallport){
				 $fall="127.0.0.1:$thevirtport";
				}
			}

			if ($thevirtport==0) {
				$persist = "yes";
			}

			//if ($thevirtport != $portno AND $thevirtport!=0) {
			//	draw_error ("WARNING: The 'VIP port number' ($thevirtport) does not match the 'drop down list port no' ($portno)!");
			//}
			//if ($thevirtport != $thefallport AND $thevirtport!=0 ) {
			//	draw_error ("WARNING: The 'VIP port number' ($thevirtport) does not match the 'Fallback port no' ($thefallport)!");
			//}
			$theservice = Get_service($thevirtport);
			if ($theservice != $serv AND $thevirtport!=0 AND $proto!="fwm" AND $serv!="none" AND $serv!="telnet" AND $check=="negotiate") {
				draw_error ("WARNING: The 'Service to check' ($serv) does not match the 'VIP port number' ($thevirtport)!");
			}
			//If ( !strstr($virt,":") AND strlen($virt)>=3 ) {
			//	draw_error ("WARNING: The 'virtual service' ($virt) does not have a port number !");
			//}

			If ( strlen($virt)>3 AND $proto=="fwm") {
				draw_error ("WARNING: The 'virtual service' ($virt) should be an integer for the FWM protocol!");
			}

			If (strlen($req)<=2) {$req="/";}
			If (strlen($rec)<=1) {$rec="OK";}
			//byLeal
			// $req = str_replace(" ","",$req);
			$rec = str_replace(" ","",$rec);


				$WRITEFILE=TRUE;
				//echo "<center><p>The virtual server has now been modified.</p></center>";
				SCOP_log("Config : Virtual server $label modified.");
				//If a VIP has been modified need to check haresources to see if we need to add it.
				if($proto != "fwm") {
				add_physical_vip($thevirtip);
				}					


			$VIRTUAL[$v]=$virt;
			$VIRTUAL_LABEL[$v]=$label;

			if ($persist=="yes") {
				$PERSISTENT[$v]=$persisttime;

			}
			else {
					$PERSISTENT[$v]=NULL;
			}


			$REQUEST[$v]=$req;
			$RECEIVE[$v]=$rec;
			$SCHEDULER[$v]=$sched;
			$EMAILALERT[$v]=$emailalert;
			$EMAILALERTFREQ[$v]=$emailalertfreq;
			$DATABASE[$v]=$database;
			$FALLBACK[$v]=$fall;
			$CHECKTYPE[$v]=$check;
			$CHECKPORT[$v]=$checkport;
			$VIRTUALHOST[$v]=$virtualhost;
			$LOGIN[$v]=$login;
			$PASSWD[$v]=$passwd;
			$SERVICE[$v]=$serv;
			$PROTOCOL[$v]=$proto;
			$NETMASK[$v]=$gran;
			$FWDMETHOD[$v]=$fwd;
			$FEEDBACK[$v]=$fdbck;
		}

		//echo "<h2>Modify Virtual Servers</h2>";
		$trans="7a";
		$txt = "${$l.$trans}";
		$trans="3";
		$a3 = "${$l.$trans}";
		//echo "<center><h2>$txt</h2></center>";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> &gt; <?=$txt?></h1>
<div class="border">
<?

		$trans="7b";
		$mlrs = "${$l.$trans}";
		$trans="7aa";
		$anvs = "${$l.$trans}";
					$trans="19";
					$mod = "${$l.$trans}";
					$trans="20";
			$del = "${$l.$trans}";

		//echo "Clients requesting web pages from the Virtual IP address will be trasparently re-directed to the associated real web servers :</br>";
		//echo "Virtual Servers are defined by their Vitual IP address and port number i.e. 10.0.0.35:80 for HTTP or 10.0.0.35:443 for HTTPS.</br>";
		//echo "The Real Server associated with the VIP will only be able to repond to this redirected packet if they have the VIP on its loopback adapter, </br>";
		//echo "and the Real Servers response will go directly to the client through the default gateway.</br></br>";

		//echo "The SCOP is responding to requests on the following :</br>";
		?><table border="0" class="datagrid" align="center">
			<tr><td colspan="3" style="text-align:left;">
		<?
		echo "[ <a href=\"display.php?srcfile=ldirectord&action=modvirtual&subaction=add&t=$t\" class=\"action\">$anvs</a> ] ";
		echo "[ <a href=\"display.php?srcfile=ldirectord&action=modreal&t=$t\" class=\"action\">$mlrs</a> ]</td></tr>";

		for ( $i=1; $i<count($VIRTUAL); $i++) {
			if ($DELETEVIRTUAL<>$i) {
				echo "<tr><td>VIP<b>$i</b> <i>$VIRTUAL_LABEL[$i]</i></td>";
				echo "<td><b>$VIRTUAL[$i]</b></td>";
				echo "<td style=\"text-align:right\">[ <a href=\"display.php?srcfile=ldirectord&action=modvirtual&subaction=edit&v=$i&t=$t\" class=\"action\"> $mod </a> ]</td> ";

				echo "<td style=\"text-align:right\">[ <a href=\"display.php?srcfile=ldirectord&action=modvirtual&subaction=remove&v=$i&t=$t\" class=\"action\" onclick=\"return areyousure('Are you sure you want to remove the virtual server ? ($VIRTUAL[$i])')\"> $del </a> ]</td></tr>";
			?><tr><td colspan="3" class="sep1"></td></tr><?
			} //End of check for deleted virtual

		}
		echo "</table>";

?>
</div>
<div class="bottom"><span>-----</span></div>
</div>
<?



	}
	if ($action=="modrealweight") {

		if ($subaction=="change") {
			$WRITEFILE=TRUE;
			if ($REALWEIGHT[$v][$r]==0) {
				$REALWEIGHT[$v][$r]=1;
			}
			else {

				$REALWEIGHT[$v][$r]=0;
			}
		}


		echo "<h2>!!!!!!Modify The Status Of Real Servers</h2><BR>";

		//echo "Clients requesting web pages from a Virtual IP Address will be trasparently re-directed to the associated cluster of real servers :</br>";
		for ( $i=1; $i<count($VIRTUAL); $i++) {



			echo "<table align=\"center\" width=\"60%\"><th><b>Virtual Server $i</b></th><th><b>($VIRTUAL[$i])</b></th>";
			If ($PERSISTENT[$i]<>"") { echo "<th>Persistent</th>";}
			for ( $b=0; $b<count($REAL[$i]); $b++) {
				echo "<tr><td>Real Server <b>$b</b> </td><td><center><b>" . $REAL[$i][$b] . "</b></center></td>";
				if ($REALWEIGHT[$i][$b]==0) {
					echo "<td><b><center><font color=\"red\" >OFFLINE</font></center></b></td><td><center><a href=\"display.php?srcfile=ldirectord&action=modrealweight&subaction=change&v=$i&r=$b&t=$t\">bring online</a></center></td></tr>";
				}
				else {
					echo "<td><b><center><font color=\"#0ef42d\"> ONLINE</font></center></b></td><td><center><a href=\"display.php?srcfile=ldirectord&action=modrealweight&subaction=change&v=$i&r=$b&t=$t\">take offline</a></center></td></tr>";
				}
			}
			echo "</table>";

		}
		echo "</br></br>Taking a server offline will change its weight to 0, and the weighted least connection algorithm will no longer use this server.<BR>This is ideal if you need to perform maintenance on a server in the cluster.</br>";
		echo "</br>NB. When you bring it back online the weight is set to 1, when you are sure its OK increase the weight as required. </br>";
	}

if ($action=="modglobal") {

		if ($subaction=="edit") {
					// Setup the java script first
					?>
					<script language="javascript" type="text/javascript">
					<!--
					function checkformmodglobal()
					{ // Check the new user fields are correct
						var cint = document.modglobal.cint.value;
						if (cint =="" )
						{
							alert  ("Please specify check interval");
							document.modglobal.cint.select();
							return false
						}

						if (  isNaN(cint) )
						{
							alert  ("Please specify a integer value");
							document.modglobal.cint.select();
							return false

						}
						var ctime = document.modglobal.ctime.value;
						if (ctime =="" )
						{
							alert  ("Please specify check time");
							document.modglobal.ctime.select();
							return false

						}
						if (  isNaN(ctime) )
						{
							alert  ("Please specify a integer value");
							document.modglobal.ctime.select();
							return false

						}
						var ntime = document.modglobal.ntime.value;
						if (ntime =="" )
						{
							alert  ("Please specify negotiate time");
							document.modglobal.ntime.select();
							return false

						}
						if (  isNaN(ntime) )
						{
							alert  ("Please specify a integer value");
							document.modglobal.ntime.select();
							return false

						}

						return true
					}
					//-->
					</script>
			<?
			$per=0;
			//echo "<h2>Edit Global Settings</h2>";
			$trans="7c";
			$a7c = "${$l.$trans}";
			$trans="3";
			$a3 = "${$l.$trans}";
			//echo "<center><h2>$txt</h2></center>";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> &gt; <?=$a7c?></h1>
<div class="border">
<?

			$trans="40";
			$a40 = "${$l.$trans}";
			$trans="41";
			$a41 = "${$l.$trans}";
			$trans="41b";
			$a41b = "${$l.$trans}";
			$trans="42";
			$a42 = "${$l.$trans}";
			//echo "You can edit the frequency of the real server health checks here :</br>";
			//echo "Don't set it too small ! <i>(checkinterval=10, checktimeout=5 is fine for most situations)</i></br>";
			//echo "NB. If you require persistent virtual servers Quiescent=no should be used.</br></br>";
			echo "<FORM method=\"post\" name=\"modglobal\" action=\"display.php?srcfile=ldirectord&action=modglobal&subaction=editdata&t=$t\">";
			?><table border="0" cellspacing="0" align="center" class="form"><td colspan="3" class="sep2"></td><?


			echo "<tr><td>$a40 </td><td> <INPUT type=\"text\" size=2 name=\"cint\" value=$CHECKINTERVAL></td><td>";
			helpitem(6);
			echo "</td></tr>";
?><td colspan="3" class="sep1"></td><?
			echo "<tr class=\"altLine\"><td>$a41 </td><td> <INPUT type=\"text\" size=2 name=\"ctime\" value=$CHECKTIMEOUT></td><td>";
			helpitem(6);
			echo "</td></tr>";
?><td colspan="3" class="sep1"></td><?
			echo "<tr class=\"altLine\"><td>$a41b </td><td> <INPUT type=\"text\" size=2 name=\"ntime\" value=$NEGOTIATETIMEOUT></td><td>";
			helpitem(6);
			echo "</td></tr>";
?><td colspan="3" class="sep1"></td><?
			echo "<tr><td>$a42 </td><td><select name=\"quies\">";
				echo "<OPTION VALUE=\"yes\" ";
				if ($QUIESCENT=="yes") {
					echo "selected=\"true\"";
				}
				echo ">yes";
				echo "<OPTION VALUE=\"no\" ";
				if ($QUIESCENT=="no") {
					echo "selected=\"true\"";
				}
				echo ">no";
				echo "</select></td><td>";
				helpitem(6);
				echo "</td></tr>";
			echo "</table> </br><center><INPUT type=\"submit\" value=\"$a7c\" name=\"go\" onclick=\"return checkformmodglobal()\"></center>";
?><td colspan="3" class="sep1"></td><?
echo "</FORM>";
?>
</div>
<div class="bottom"><span>-----</span></div>
</div>
<?
		}
		if ($subaction=="editdata") {
			$ctime = $_POST['ctime'];
			$ntime = $_POST['ntime'];
			$cint = $_POST['cint'];
			$quies = $_POST['quies'];

			$WRITEFILE=TRUE;

			$trans="56";
			$a56 = "${$l.$trans}";
			echo "<center><p>$a56</p></center>";

			$CHECKTIMEOUT=$ctime;
			$NEGOTIATETIMEOUT=$ntime;
			$CHECKINTERVAL=$cint;
			$QUIESCENT=$quies;

		}


	}

 if ($action=="CreateRRDToolDBs") {
	$notdb = $_GET['notdb'];

	if ($notdb!=true) {
		$trans="18d";
		$a18d = "${$l.$trans}";
		$trans="4";
		$a4 = "${$l.$trans}";
		//echo "<center><h2>$a18d</h2>";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=maint&l=<?=$l?>"><?=$a4?></a> &gt; <?=$a18d?></h1>
<div class="border">
<?
		SCOP_log("Config : RRDTool database generated.");
		// Create a Db for each VS
		for ( $i=1; $i<count($VIRTUAL); $i++) {
			$rdb="/etc/scop/VS" . $i .".rrd";
			$detail="DS:active:GAUGE:600:U:U ";
			$detail=$detail . "DS:inactive:GAUGE:600:U:U ";
			$detail=$detail . "RRA:AVERAGE:0.5:1:600 ";
			$detail=$detail . "RRA:AVERAGE:0.5:6:700 ";
			$detail=$detail . "RRA:AVERAGE:0.5:24:775 ";
			$detail=$detail . "RRA:AVERAGE:0.5:288:797 ";
			$detail=$detail . "RRA:MAX:0.5:1:600 ";
			$detail=$detail . "RRA:MAX:0.5:6:700 ";
			$detail=$detail . "RRA:MAX:0.5:24:775 ";
			$detail=$detail . "RRA:MAX:0.5:288:797 ";

			exec ("sudo /usr/bin/rrdtool create $rdb $detail ");
			echo "$rdb ... <br />";



		}


		// Create a Db for each RS in the VS
		for ( $i=1; $i<count($VIRTUAL); $i++) {
			$rdb="/etc/scop/RS" . $i . ".rrd";
			$detail="";
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				$detail=$detail . "DS:www" . $r . ":GAUGE:600:U:U ";
			}

			$detail=$detail . "RRA:AVERAGE:0.5:1:600 ";
			$detail=$detail . "RRA:AVERAGE:0.5:6:700 ";
			$detail=$detail . "RRA:AVERAGE:0.5:24:775 ";
			$detail=$detail . "RRA:AVERAGE:0.5:288:797 ";
			$detail=$detail . "RRA:MAX:0.5:1:600 ";
			$detail=$detail . "RRA:MAX:0.5:6:700 ";
			$detail=$detail . "RRA:MAX:0.5:24:775 ";
			$detail=$detail . "RRA:MAX:0.5:288:797 ";

			exec ("sudo /usr/bin/rrdtool create $rdb $detail ");
			echo "$rdb ... <br />";


		}
	?>
</div>
<div class="bottom"><span>-----</span></div>
</div>
<?
	} // end of create dbs
	$trans="18e";
	$a18e = "${$l.$trans}";
	$trans="4";
	$a4 = "${$l.$trans}";
	//echo "<center><h2>$a18e</h2>";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=maint&l=<?=$l?>"><?=$a4?></a> &gt; <?=$a18e?></h1>
<div class="border">
<?

	$COLOUR[0]="FF0000";
	$COLOUR[1]="FFFF00";
	$COLOUR[2]="AAFFAA";
	$COLOUR[3]="FF00FF";
	$COLOUR[4]="0000FF";
	$COLOUR[5]="00FF00";
	$COLOUR[6]="990000";
	$COLOUR[7]="999900";
	$COLOUR[8]="999999";
	$COLOUR[9]="990099";
	$COLOUR[10]="009900";



	for ( $i=1; $i<count($VIRTUAL); $i++) {
	echo "/usr/local/bin/lvsgsp.dailyRS$i <br />";
	exec ("sudo chmod 777 /usr/local/bin/lvsgsp.dailyRS$i");
		if ($file=fopen("/usr/local/bin/lvsgsp.dailyRS$i","w")) {
			fputs($file,"#!/bin/bash\n");
			fputs($file,"# Lvsgsp cofiguration file generated bySCOP\n");
			fputs($file,"RRDTOOL=\"/usr/bin/rrdtool\"\n");
			fputs($file,"DB=\"/etc/scop/RS$i.rrd\"\n");
			fputs($file,"OUTPUT=\"/var/www/html/scop/stats/RS$i-daily.gif\"\n");
			fputs($file,"SNMPOUT=\"/var/www/html/scop/stats/ActiveCons\"\n");
			fputs($file,"LVSGSP=\"/usr/local/bin/lvsgsp\"\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				$string=$VIRTUAL[$i];
				$vport=$var = eregi_replace(":", " ", $string);
				$string=$REAL[$i][$r];
				$rport=$var = eregi_replace(":", " ", $string);

				fputs($file,"TMP=`\$LVSGSP -v $vport -r " . $rport .  "`\n");
				fputs($file,"WWW$r=`echo \$TMP | cut -d' ' -f1`\n");
			}

			fputs($file,"TIME=`date +%T`\n");
			fputs($file,"\$RRDTOOL update \$DB N:");
			fputs($file,"\$WWW0");
			for ( $r=1; $r<count($REAL[$i]); $r++ ) {
				fputs($file,":\$WWW$r");
			}
			fputs($file,"\n");
			fputs($file,"#Generate output graph\n");
			fputs($file,"\$RRDTOOL graph \$OUTPUT --start -86400 -w 550 -h 150 -v \"Connection Number\" \\\n ");
			fputs($file,"-t \"Loadbalancer.org connection tracking : Daily report for $VIRTUAL_LABEL[$i] $VIRTUAL[$i]\" --alt-autoscale-max \\\n");
			fputs($file,"COMMENT:\"Current active connections - \$TIME\\n\" \\\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				fputs($file,"DEF:web$r=\$DB:www$r:AVERAGE \\\n");
			}
			$c=0;
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				If ($c==10) { $c=0 ;}
				fputs($file,"LINE1:web$r#$COLOUR[$c]:\"" . $REAL_LABEL[$i][$r] . " " . $REAL[$i][$r] . "\" \\\n");
				$c=$c+1;

			}
			#fputs($file,"# SNMP section\n");
			#for ( $r=0; $r<count($REAL[$i]); $r++ ) {
			#	fputs($file,"echo $WWW$r > \$SNMPOUT-V$i-R$r\n");
			#}


			fputs($file,"\n");



		fclose($file);
		exec ("sudo chmod 777 /usr/local/bin/lvsgsp.dailyRS$i");
		}
	}

		// Now weekly

	for ( $i=1; $i<count($VIRTUAL); $i++) {
	echo " /usr/local/bin/lvsgsp.weeklyRS$i <br />";
	exec ("sudo chmod 777 /usr/local/bin/lvsgsp.weeklyRS$i");
		if ($file=fopen("/usr/local/bin/lvsgsp.weeklyRS$i","w")) {
			fputs($file,"#!/bin/bash\n");
			fputs($file,"# Lvsgsp cofiguration file generated bySCOP\n");
			fputs($file,"RRDTOOL=\"/usr/bin/rrdtool\"\n");
			fputs($file,"DB=\"/etc/scop/RS$i.rrd\"\n");
			fputs($file,"OUTPUT=\"/var/www/html/scop/stats/RS$i-weekly.gif\"\n");
			fputs($file,"LVSGSP=\"/usr/local/bin/lvsgsp\"\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				$string=$VIRTUAL[$i];
				$vport=$var = eregi_replace(":", " ", $string);
				$string=$REAL[$i][$r];
				$rport=$var = eregi_replace(":", " ", $string);

				fputs($file,"TMP=`\$LVSGSP -v $vport -r " . $rport .  "`\n");
				fputs($file,"WWW$r=`echo \$TMP | cut -d' ' -f1`\n");
			}

			fputs($file,"TIME=`date +%T`\n");
			fputs($file,"\$RRDTOOL update \$DB N:");
			fputs($file,"\$WWW0");
			for ( $r=1; $r<count($REAL[$i]); $r++ ) {
				fputs($file,":WWW$r");
			}
			fputs($file,"\n");
			fputs($file,"#Generate output graph\n");
			fputs($file,"\$RRDTOOL graph \$OUTPUT --start -604800 -w 550 -h 150 -v \"Connection Number\" \\\n ");
			fputs($file,"-t \"Loadbalancer.org connection tracking : Weekly report for $VIRTUAL_LABEL[$i] $VIRTUAL[$i]\" --alt-autoscale-max \\\n");
			fputs($file,"COMMENT:\"Current active connections - \$TIME\\n\" \\\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				fputs($file,"DEF:web$r=\$DB:www$r:AVERAGE \\\n");
			}
			$c=0;
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				If ($c==10) { $c=0 ;}
				fputs($file,"LINE1:web$r#$COLOUR[$c]:\"" . $REAL_LABEL[$i][$r] . " " . $REAL[$i][$r] . "\" \\\n");
				$c=$c+1;
			}

			fputs($file,"\n");



		fclose($file);
		exec ("sudo chmod 777 /usr/local/bin/lvsgsp.weeklyRS$i");
		}
	}

	// Now monthly

	for ( $i=1; $i<count($VIRTUAL); $i++) {
	echo " /usr/local/bin/lvsgsp.monthlyRS$i <br />";
	exec ("sudo chmod 777 /usr/local/bin/lvsgsp.monthlyRS$i");
		if ($file=fopen("/usr/local/bin/lvsgsp.monthlyRS$i","w")) {
			fputs($file,"#!/bin/bash\n");
			fputs($file,"# Lvsgsp cofiguration file generated bySCOP\n");
			fputs($file,"RRDTOOL=\"/usr/bin/rrdtool\"\n");
			fputs($file,"DB=\"/etc/scop/RS$i.rrd\"\n");
			fputs($file,"OUTPUT=\"/var/www/html/scop/stats/RS$i-monthly.gif\"\n");
			fputs($file,"LVSGSP=\"/usr/local/bin/lvsgsp\"\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				$string=$VIRTUAL[$i];
				$vport=$var = eregi_replace(":", " ", $string);
				$string=$REAL[$i][$r];
				$rport=$var = eregi_replace(":", " ", $string);

				fputs($file,"TMP=`\$LVSGSP -v $vport -r " . $rport .  "`\n");
				fputs($file,"WWW$r=`echo \$TMP | cut -d' ' -f1`\n");
			}

			fputs($file,"TIME=`date +%T`\n");
			fputs($file,"\$RRDTOOL update \$DB N:");
			fputs($file,"\$WWW0");
			for ( $r=1; $r<count($REAL[$i]); $r++ ) {
				fputs($file,":\$WWW$r");
			}
			fputs($file,"\n");
			fputs($file,"#Generate output graph\n");
			fputs($file,"\$RRDTOOL graph \$OUTPUT --start -18748800 -w 550 -h 150 -v \"Connection Number\" \\\n ");
			fputs($file,"-t \"Loadbalancer.org connection tracking : Monthly report for $VIRTUAL_LABEL[$i] $VIRTUAL[$i]\" --alt-autoscale-max \\\n");
			fputs($file,"COMMENT:\"Current active connections - \$TIME\\n\" \\\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				fputs($file,"DEF:web$r=\$DB:www$r:AVERAGE \\\n");
			}
			$c=0;
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				If ($c==10) { $c=0 ;}
				fputs($file,"LINE1:web$r#$COLOUR[$c]:\"" . $REAL_LABEL[$i][$r] . " " . $REAL[$i][$r] . "\" \\\n");
				$c=$c+1;
			}

			fputs($file,"\n");



		fclose($file);
		exec ("sudo chmod 777 /usr/local/bin/lvsgsp.monthlyRS$i");
		}
	}

	// Now yearly

	for ( $i=1; $i<count($VIRTUAL); $i++) {
	echo " /usr/local/bin/lvsgsp.yearlyRS$i <br />";
	exec ("sudo chmod 777 /usr/local/bin/lvsgsp.yearlyRS$i");
		if ($file=fopen("/usr/local/bin/lvsgsp.yearlyRS$i","w")) {
			fputs($file,"#!/bin/bash\n");
			fputs($file,"# Lvsgsp cofiguration file generated bySCOP\n");
			fputs($file,"RRDTOOL=\"/usr/bin/rrdtool\"\n");
			fputs($file,"DB=\"/etc/scop/RS$i.rrd\"\n");
			fputs($file,"OUTPUT=\"/var/www/html/scop/stats/RS$i-yearly.gif\"\n");
			fputs($file,"LVSGSP=\"/usr/local/bin/lvsgsp\"\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				$string=$VIRTUAL[$i];
				$vport=$var = eregi_replace(":", " ", $string);
				$string=$REAL[$i][$r];
				$rport=$var = eregi_replace(":", " ", $string);

				fputs($file,"TMP=`\$LVSGSP -v $vport -r " . $rport .  "`\n");
				fputs($file,"WWW$r=`echo \$TMP | cut -d' ' -f1`\n");
			}

			fputs($file,"TIME=`date +%T`\n");
			fputs($file,"\$RRDTOOL update \$DB N:");
			fputs($file,"\$WWW0");
			for ( $r=1; $r<count($REAL[$i]); $r++ ) {
				fputs($file,":\$WWW$r");
			}
			fputs($file,"\n");
			fputs($file,"#Generate output graph\n");
			fputs($file,"\$RRDTOOL graph \$OUTPUT --start -224985600 -w 550 -h 150 -v \"Connection Number\" \\\n ");
			fputs($file,"-t \"Loadbalancer.org connection tracking : Monthly report for for $VIRTUAL_LABEL[$i] $VIRTUAL[$i]\" --alt-autoscale-max \\\n");
			fputs($file,"COMMENT:\"Current active connections - \$TIME\\n\" \\\n");
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				fputs($file,"DEF:web$r=\$DB:www$r:AVERAGE \\\n");
			}
			$c=0;
			for ( $r=0; $r<count($REAL[$i]); $r++ ) {
				If ($c==10) { $c=0 ;}
				fputs($file,"LINE1:web$r#$COLOUR[$c]:\"" . $REAL_LABEL[$i][$r] . " " . $REAL[$i][$r] . "\" \\\n");
				$c=$c+1;
			}

			fputs($file,"\n");



		fclose($file);
		exec ("sudo chmod 777 /usr/local/bin/lvsgsp.yearlyRS$i");
		}
	}

	// Now create the batch files activated run by the crontab file...
	// First Daily
	//echo "<h2>Generate Crontab Scripts to update the graphs</h2>";
	echo "/etc/scop/graphsdaily <br />";
	`sudo touch /etc/scop/graphsdaily`;
	exec ("sudo chmod 777 /etc/scop/graphsdaily");
	if ($file=fopen("/etc/scop/graphsdaily","w")) {
		fputs($file,"#!/bin/bash\n");
		fputs($file,"# Daily Crontab File generated bySCOP\n");
		for ( $i=1; $i<count($VIRTUAL); $i++) {
			$string=$VIRTUAL[$i];
			$tok = strtok($string,":\n\t");
			$vip = $tok;
			$tok = strtok(":\n\t");
			$vport = $tok;
			fputs($file,"/usr/local/bin/lvsgsp.daily VS$i $vip $vport > /dev/null \n");
			fputs($file,"/usr/local/bin/lvsgsp.dailyRS$i > /dev/null \n");
			fputs($file,"\n");
		}
	fclose($file);
	}


	// Then Weekly

	echo "/etc/scop/graphsweekly <br />";
	`sudo touch /etc/scop/graphsweekly`;
	exec ("sudo chmod 777 /etc/scop/graphsweekly");
	if ($file=fopen("/etc/scop/graphsweekly","w")) {
		fputs($file,"#!/bin/bash\n");
		fputs($file,"# Weekly Crontab File generated bySCOP\n");
		for ( $i=1; $i<count($VIRTUAL); $i++) {
			$string=$VIRTUAL[$i];
			$tok = strtok($string,":\n\t");
			$vip = $tok;
			$tok = strtok(":\n\t");
			$vport = $tok;
			fputs($file,"/usr/local/bin/lvsgsp.weekly VS$i $vip $vport > /dev/null \n");
			fputs($file,"/usr/local/bin/lvsgsp.weeklyRS$i > /dev/null \n");
			fputs($file,"\n");
		}
	fclose($file);
	}

	// Then Monthly
	echo "/etc/scop/graphsmonthly <br />";
	`sudo touch /etc/scop/graphsmonthly`;
	exec ("sudo chmod 777 /etc/scop/graphsmonthly");
	if ($file=fopen("/etc/scop/graphsmonthly","w")) {
		fputs($file,"#!/bin/bash\n");
		fputs($file,"# Monthly Crontab File generated bySCOP\n");
		for ( $i=1; $i<count($VIRTUAL); $i++) {
			$string=$VIRTUAL[$i];
			$tok = strtok($string,":\n\t");
			$vip = $tok;
			$tok = strtok(":\n\t");
			$vport = $tok;
			fputs($file,"/usr/local/bin/lvsgsp.monthly VS$i $vip $vport > /dev/null \n");
			fputs($file,"/usr/local/bin/lvsgsp.monthlyRS$i > /dev/null \n");
			fputs($file,"\n");
		}
	fclose($file);
	}

	// Then Yearly
	echo "/etc/scop/graphsyearly <br />";
	`sudo touch /etc/scop/graphsyearly`;
	exec ("sudo chmod 777 /etc/scop/graphsyearly");
	if ($file=fopen("/etc/scop/graphsyearly","w")) {
		fputs($file,"#!/bin/bash\n");
		fputs($file,"# Monthly Crontab File generated bySCOP\n");
		for ( $i=1; $i<count($VIRTUAL); $i++) {
			$string=$VIRTUAL[$i];
			$tok = strtok($string,":\n\t");
			$vip = $tok;
			$tok = strtok(":\n\t");
			$vport = $tok;
			fputs($file,"/usr/local/bin/lvsgsp.yearly VS$i $vip $vport > /dev/null \n");
			fputs($file,"/usr/local/bin/lvsgsp.yearlyRS$i > /dev/null \n");
			fputs($file,"\n");
		}
	fclose($file);
	}








	// Now generate the charts.php file to display the stats
	//echo "<h2>Generate php script to view the stats</h2>";
	echo "/var/www/html/scop/stats/charts.php <br /></center>";
	exec ("sudo chmod 777 /var/www/html/scop/stats/charts.php");
	if ($file=fopen("/var/www/html/scop/stats/charts.php","w")) {
		$trans="14f";
		$a14f = "${$l.$trans}";
		$trans="5";
		$a5 = "${$l.$trans}";
		fputs($file,"<?include (\"../inc/header.inc\");?> <div id=\"contentArea\"><h1><a href=\"/scop/index.php?menu=reports&l=$l\">$a5</a> &gt; $a14f</h1><div class=\"border\">\n");



		//fputs($file,"NB. Whenever you make a change to the virtual or real server configurations you will need to re-generate the stats database.</br></br>\n");
		fputs($file,"<table align=\"center\" class=\"datasheet\" width=\"60%\"><th>VIP:port</th><th>Label</th><th>Daily </th><th>Weekly </th><th>Monthly </th><th>Yearly </th>\n");
			fputs($file,"<tr><td colspan=\"6\" class=\"sep2\"></td></tr>\n");

		for ( $i=1; $i<count($VIRTUAL); $i++) {

			fputs($file,"<tr><td><b><center>$VIRTUAL[$i]</center></b></td><td><i><center>$VIRTUAL_LABEL[$i]</center></i></td><td><center><a href=\"VS$i-daily.gif\" >Overview </br></a></center><center><a href=\"RS$i-daily.gif\" >Detail </a></center></td>\n");
			fputs($file,"<td><center><a href=\"VS$i-weekly.gif\" >Overview </br></a></center><center><a href=\"RS$i-weekly.gif\" >Detail </a></center></td>\n");
			fputs($file,"<td><center><a href=\"VS$i-monthly.gif\" >Overview </br></a></center><center><a href=\"RS$i-monthly.gif\" >Detail </a></center></td>\n");
			fputs($file,"<td><center><a href=\"VS$i-yearly.gif\" >Overview </br></a></center><center><a href=\"RS$i-yearly.gif\" >Detail </a></center></td>\n");

			fputs($file,"</tr>\n");
			fputs($file,"<tr><td colspan=\"6\" class=\"sep1\"></td></tr>\n");

			fputs($file,"\n");
		}

		fputs($file,"</table></center></br><?include (\"../inc/footer.inc\");?>\n");
		fputs($file,"\n");
		fputs($file,"</div><div class=\"bottom\"><span>-----</span></div></div>\n");

	fclose($file);
	}

	?>
</div><div class="bottom"><span>-----</span></div></div>
<?
	} // End of create databases



	if ($WRITEFILE==TRUE) {
		# open a new file
		write_config_file();
 }






}



include ("../inc/footer.inc");
?>


Return current item: SCOP Heartbeat Administration interface