<?
// SCOP administration software.
// Copyright (C) 2002 Loadbalancer.org Limited
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include ("../inc/header.inc");
include ("../inc/functions.inc");
?>
<?
L7parse_config_file();
global $L7vnum,$L7rnum,$v,$r,$action,$subaction,$L7DELETEVIRTUAL,$L7VIRTUAL,$L7VIRTUAL_LABEL,$L7REAL,$L7REAL_LABEL,$L7VIRTUAL_COOKIE,$L7REAL_WEIGHT,$L7VIRTUAL_MODE,$L7VIRTUAL_FALLBACK,$L7VIRTUAL_PERSIST;
$L7DELETEVIRTUAL=NULL;
$trans="107";
$t107 = "${$l.$trans}";
# Modify Real Server Section
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
// 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>
<?
//echo "<h2>Add a real server to <b>Virtual Server $v</b> ..</h2>";
$trans="7bb";
$ars = "${$l.$trans}";
$trans="3";
$a3 = "${$l.$trans}";
?>
<div id="contentArea">
<h1><a href="/scop/index.php?menu=editconf&l=<?=$l?>"><?=$a3?></a> > <? echo "$ars $t107"; ?></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 "<FORM method=\"post\" action=\"haproxy.php?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 "</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> > <? echo"$txt $t107"; ?></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 "<FORM method=\"post\" action=\"haproxy.php?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=\"". $L7REAL_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=\"". $L7REAL[$v][$r] . "\"></td></tr>";
?><td colspan="3" class="sep1"></td><?
echo "<tr><th>$a39 </th><td><INPUT type=\"text\" size=5 name=\"newweight\" value=\"" . $L7REAL_WEIGHT[$v][$r] . "\"></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($L7REAL[$v]);
if (!$exists) {
If ( strstr($newreal,":") && !strstr($newreal,"IP") ) {
$r = $_POST['r'];
$label = $_POST['label'];
$label = str_replace(" ","_",$label);
$L7WRITEFILE=TRUE;
SCOP_log("Config : New L7real server added $label.");
$r = count($L7REAL[$v]);
$L7REAL[$v][$r]=$newreal;
$L7REAL_WEIGHT[$v][$r]=$newweight;
$L7REAL_LABEL[$v][$r]=$label;
$L7rnum++;
} 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);
$r = $_POST['r'];
$label = $_POST['label'];
$label = str_replace(" ","_",$label);
$L7WRITEFILE=TRUE;
SCOP_log("Config : Real Server $label changed.");
$L7REAL[$v][$r]=$newreal;
$L7REAL_WEIGHT[$v][$r]=$newweight;
$L7REAL_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") {
$L7WRITEFILE=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.");
}
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> > <? echo "$txt $t107"; ?></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}";
for ( $i=1; $i<count($L7VIRTUAL); $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>$L7VIRTUAL_LABEL[$i]</i></td><td>($L7VIRTUAL[$i])</td><td>";
echo "[ <a href=\"haproxy.php?action=modreal&subaction=add&v=$i&t=$t\" class=\"action\">$ars</a> ]</td></tr>";
for ( $b=count($L7REAL[$i])-1; $b>-1; $b--) {
$x=$b+1;
?><tr><td colspan="5" class="sep1"></td></tr><?
echo "<tr><td> RIP $x </td><td><i>" . $L7REAL_LABEL[$i][$b] . " </i></td><td><b>" . $L7REAL[$i][$b] . "</b></td>";
echo "<td><i>" . $L7REAL_WEIGHT[$i][$b] . "</i></td><td>[ <a href=\"haproxy.php?action=modreal&subaction=modify&v=$i&r=$b&t=$t\" class=\"action\"> $mod </a> ]";
echo "</td><td>[ <a href=\"haproxy.php?action=modreal&subaction=remove&v=$i&r=$b\" class=\"action\" onclick=\"return areyousure('Are you sure you want to remove the real server ? (" . $L7REAL[$i][$b] . ")')\"> $del </a> ]</td>";
}
//echo "</table>";
//echo "<a href=\"haproxy.php?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=\"haproxy.php?action=modvirtual&t=$t\" class=\"action\">$mvs</a> ]";
echo "</td></tr></table>";
?></div>
<div class="bottom"><span>-----</span></div>
</div>
<?
}
}
# Now the modify Virtual Server Section....
if ($action=="modvirtual") {
if ($subaction=="remove") {
$L7WRITEFILE=TRUE;
$L7DELETEVIRTUAL=$v;
SCOP_log("Config : L7Virtual Server removed.");
}
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> > <? echo"$a7aa $t107"; ?></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;
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");
document.addvirt.virt.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");
document.addvirt.virt.select();
return false
}
var virt = document.addvirt.fallback.value;
var stringtotest = document.addvirt.fallback.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 ("Fallback is not a valid IPAddress:Port");
document.addvirt.fallback.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");
document.addvirt.fallback.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=\"haproxy.php?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 class=\"altLine\"><th>Mode </th>";
echo "<td><select name=\"mode\">";
echo "<OPTION VALUE=\"http\" ";
echo ">http";
echo "<OPTION VALUE=\"tcp\" ";
echo "selected=\"true\"";
echo ">tcp";
echo "</select></td></tr>";
?><td colspan="3" class="sep1"><?
echo "<tr><th>Fallback </th><td> <INPUT type=\"text\" size=20 name=\"fallback\" value=\"127.0.0.1:80\"></td></tr>";
?><td colspan="3" class="sep1"><?
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") {
$virt = $_POST['virt'];
$persist = $_POST['persist'];
$label = $_POST['label'];
$addphys = $_POST['addphys'];
$portno = $_POST['portno'];
$mode = $_POST['mode'];
$fallback = $_POST['fallback'];
$label = str_replace(" ","_",$label);
if (strlen($label)==0) {$label="VIP_$L7vnum";}
# Check for valid virt:port or fwmark
#$exists = VIP_Exists($virt);
#$vipcount = count($VIRTUAL);
if (!$exists) {
If ( strstr($virt,":") OR strlen($virt)<=4 ) {
$L7WRITEFILE=TRUE;
//echo "<p>The virtual server has now been added.</p>";
SCOP_log("Config : Virtual server $label added.");
$L7vnum++;
$L7rnum=0;
$L7VIRTUAL[$L7vnum]=$virt;
$L7VIRTUAL_LABEL[$L7vnum]=$label;
$L7VIRTUAL_MODE[$L7vnum]=$mode;
$L7VIRTUAL_FALLBACK[$L7vnum]=$fallback;
if ($persist=="yes" ) {
$L7VIRTUAL_COOKIE[$L7vnum]="SERVERID insert nocache indirect";
}
// Now check if we need to add the physical VIP to haresources
if ($demo=="FALSE") {
$ip = Get_ip($virt);
if ($addphys=="yes" && strlen($virt)>4) {
add_physical_vip($ip);
}
}
}
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
var fall = document.editvirt.fallback.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.fallback.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.fallback.select();
return false
}
}
var virt = document.editvirt.virt.value;
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");
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> > <? echo"$txt $t107"; ?></h1>
<div class="border">
<?
echo "<FORM method=\"post\" name=\"editvirt\" action=\"haproxy.php?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="22";
$persistent = "${$l.$trans}";
echo "<tr><th>$a21</th><td> <INPUT type=\"text\" size=20 name=\"label\" value=\"$L7VIRTUAL_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=\"$L7VIRTUAL[$v]\"></td><td>";
echo " ";
// draw_portlist();
#helpitem("5-1-2");
echo "<tr><th>$persistent </th>";
echo "<td><select name=\"persist\">";
echo "<OPTION VALUE=\"yes\" ";
if (strlen($L7VIRTUAL_COOKIE[$v])>=1){echo "selected=\"true\"";}
echo ">yes";
echo "<OPTION VALUE=\"no\" ";
if (strlen($L7VIRTUAL_COOKIE[$v])<=1){echo "selected=\"true\"";}
echo ">no";
echo "</select></td></tr>";
?><td colspan="3" class="sep1"><?
echo "<tr class=\"altLine\"><th>Mode </th>";
echo "<td><select name=\"mode\">";
echo "<OPTION VALUE=\"http\" ";
if ($L7VIRTUAL_MODE[$v]=="http"){echo "selected=\"true\"";}
echo ">http";
echo "<OPTION VALUE=\"tcp\" ";
if ($L7VIRTUAL_MODE[$v]=="tcp"){echo "selected=\"true\"";}
echo ">tcp";
echo "</select></td></tr>";
?><td colspan="3" class="sep1"><?
echo "<tr><th>Fallback </th><td> <INPUT type=\"text\" size=20 name=\"fallback\" value=\"$L7VIRTUAL_FALLBACK[$v]\"></td></tr>";
?><td colspan="3" class="sep1"><?
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'];
$mode = $_POST['mode'];
$fallback = $_POST['fallback'];
$persist = $_POST['persist'];
$persisttime = $_POST['persisttime'];
$label = str_replace(" ","_",$label);
if (strlen($label)==0) {$label="VIP_$v";}
$thevirtport = Get_port($virt);
$thefallport = Get_port($fall);
$thevirtip = Get_ip($virt);
if (strlen($fallback<=1)) {
$fallback="127.0.0.1:80";
}
$L7WRITEFILE=TRUE;
SCOP_log("Config : L7Virtual server $label modified.");
//If a VIP has been modified need to check haresources to see if we need to add it.
add_physical_vip($thevirtip);
$L7VIRTUAL[$v]=$virt;
$L7VIRTUAL_LABEL[$v]=$label;
$L7VIRTUAL_MODE[$v]=$mode;
$L7VIRTUAL_PERSIST[$v]=$persist;
$L7VIRTUAL_FALLBACK[$v]=$fallback;
$L7VIRTUAL_COOKIE[$v]="";
if ($persist=="yes") {
if ($mode=="http"){
$L7VIRTUAL_COOKIE[$v]="SERVERID insert nocache indirect";
} else {
$L7VIRTUAL_COOKIE[$v]="source";
}
}
}
//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> > <? echo"$txt $t107"; ?></h1>
<div class="border">
<?
$trans="7b";
$mlrs = "${$l.$trans}";
$trans="7aa";
$anvs = "${$l.$trans}";
$trans="19";
$mod = "${$l.$trans}";
$trans="20";
$del = "${$l.$trans}";
?><table border="0" class="datagrid" align="center">
<tr><td colspan="3" style="text-align:left;">
<?
echo "[ <a href=\"haproxy.php?action=modvirtual&subaction=add&t=$t\" class=\"action\">$anvs</a> ] ";
echo "[ <a href=\"haproxy.php?action=modreal&t=$t\" class=\"action\">$mlrs</a> ]</td></tr>";
for ( $i=1; $i<count($L7VIRTUAL); $i++) {
if ($L7DELETEVIRTUAL<>$i) {
echo "<tr><td>VIP<b>$i</b> <i>$L7VIRTUAL_LABEL[$i]</i></td>";
echo "<td><b>$L7VIRTUAL[$i]</b></td>";
echo "<td style=\"text-align:right\">[ <a href=\"haproxy.php?action=modvirtual&subaction=edit&v=$i&t=$t\" class=\"action\"> $mod </a> ]</td> ";
echo "<td style=\"text-align:right\">[ <a href=\"haproxy.php?action=modvirtual&subaction=remove&v=$i&t=$t\" class=\"action\" onclick=\"return areyousure('Are you sure you want to remove the virtual server? ($L7VIRTUAL[$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>
<?
} //end of ifaction=modvirtual
if ($L7WRITEFILE==TRUE){
L7write_config_file();
}
?>
<?
include ("../inc/footer.inc");
?>