r1601 + move apply_macros() and lf_wrap() to a more appropriate location
authorDenis Ovsienko <infrastation@yandex.ru>
Wed, 23 Jan 2008 16:06:51 +0000 (16:06 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Wed, 23 Jan 2008 16:06:51 +0000 (16:06 +0000)
+ fix renderLVSConfig() once more for an even better LFs

inc/functions.php
inc/interface.php

index 3022288e9e9a2d25d613d62cd45048bed8e63724..3e038f00694d742dcc2774a5ac22adc0d5db4868 100644 (file)
@@ -1126,4 +1126,22 @@ function getObjectCount ($rackData)
        return count ($objects);
 }
 
+// Perform substitutions and return resulting string
+function apply_macros ($macros, $subject)
+{
+       $ret = $subject;
+       foreach ($macros as $search => $replace)
+               $ret = str_replace ($search, $replace, $ret);
+       return $ret;
+}
+
+// Make sure the string is always wrapped with LF characters
+function lf_wrap ($str)
+{
+       $ret = trim ($str, "\r\n");
+       if (!empty ($ret))
+               $ret .= "\n";
+       return $ret;
+}
+
 ?>
index 16569c4248021381296274bd8cb7fc710c886706..3da9a95de085b14486edf11af091f52a28e9a198 100644 (file)
@@ -3643,24 +3643,6 @@ Dictionary edit page in Configuration section.
 <?php
 }
 
-// Perform substitutions and return resulting string
-function apply_macros ($macros, $subject)
-{
-       $ret = $subject;
-       foreach ($macros as $search => $replace)
-               $ret = str_replace ($search, $replace, $ret);
-       return $ret;
-}
-
-// Make sure the string is always wrapped with LF characters
-function lf_wrap ($str)
-{
-       $ret = trim ($str, "\r\n");
-       if (!empty ($ret))
-               $ret .= "\n";
-       return $ret;
-}
-
 function renderLVSConfig ($object_id = 0)
 {
        global $pageno, $tabno;
@@ -3688,21 +3670,21 @@ function renderLVSConfig ($object_id = 0)
                        '%VNAME%' =>  $vsinfo['vs_name'],
                        '%RSPOOLNAME%' => $vsinfo['pool_name']
                );
-               $vsconfig = apply_macros
+               $newconfig .=  "virtual_server ${vsinfo['vip']} ${vsinfo['vport']} {\n";
+               $newconfig .=  "\tprotocol ${vsinfo['proto']}\n";
+               $newconfig .= apply_macros
                (
                        $macros,
                        lf_wrap ($vsinfo['vs_vsconfig']) .
                        lf_wrap ($vsinfo['lb_vsconfig']) .
                        lf_wrap ($vsinfo['pool_vsconfig'])
                );
-               $newconfig .=  "virtual_server ${vsinfo['vip']} ${vsinfo['vport']} {\n";
-               $newconfig .=  "\tprotocol ${vsinfo['proto']}\n";
-               $newconfig .=  "${vsconfig}\n";
                foreach ($vsinfo['rslist'] as $rs)
                {
                        $macros['%RSIP%'] = $rs['rsip'];
                        $macros['%RSPORT%'] = $rs['rsport'];
-                       $rsconfig = apply_macros
+                       $newconfig .=  "\treal_server ${rs['rsip']} ${rs['rsport']} {\n";
+                       $newconfig .= apply_macros
                        (
                                $macros,
                                lf_wrap ($vsinfo['vs_rsconfig']) .
@@ -3710,8 +3692,6 @@ function renderLVSConfig ($object_id = 0)
                                lf_wrap ($vsinfo['pool_rsconfig']) .
                                lf_wrap ($rs['rs_rsconfig'])
                        );
-                       $newconfig .=  "\treal_server ${rs['rsip']} ${rs['rsport']} {\n";
-                       $newconfig .=  "\t${rsconfig}\n";
                        $newconfig .=  "\t}\n";
                }
                $newconfig .=  "}\n\n\n";