r3146 - maintenance->trunk sync of changesets 3143~3145
authorDenis Ovsienko <infrastation@yandex.ru>
Thu, 1 Oct 2009 12:42:46 +0000 (12:42 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Thu, 1 Oct 2009 12:42:46 +0000 (12:42 +0000)
ChangeLog
inc/code.php
inc/functions.php
inc/init.php
inc/interface.php
inc/ophandlers.php
install.php
popup.php
process.php
upgrade.php

index 1aa7d3c6b9f3981e88fdfe5f40bbd217f8d6de82..e07cd07508891c349f816cc00048bcf1ed7260d6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 0.17.6
        bugfix: PHP warning
        bugfix: escaping of a newly created IPv4 network name (ticket:292)
+       bugfix: generate URLs more friendly for reverse proxies (ticket:246)
 0.17.5 2009-09-16
        bugfix: corrected reference counters in tag tree
        bugfix: "cn" autotag was not generated for objects
index 67c85ee50dd8d522c3a9d098c115cf316743a515..d96a2d6a02919b764766174b589b90b265abf54a 100644 (file)
@@ -1034,8 +1034,7 @@ function locateSyntaxError ($stack)
 
 function refRCLineno ($ln)
 {
-       global $root;
-       return "<a href='${root}?page=perms&tab=default#line${ln}'>line ${ln}</a>";
+       return "<a href='index.php?page=perms&tab=default#line${ln}'>line ${ln}</a>";
 }
 
 function getRackCodeWarnings ()
index 6f8d0c217a992332f87f8dde10159ce6c5ffbcde..1f53394edb58fc512cc460302268dd37e32cb8e9 100644 (file)
@@ -1373,8 +1373,8 @@ function validTagName ($s, $allow_autotag = FALSE)
 
 function redirectUser ($p, $t)
 {
-       global $page, $root;
-       $l = "{$root}?page=${p}&tab=${t}";
+       global $page;
+       $l = "index.php?page=${p}&tab=${t}";
        if (isset ($page[$p]['bypass']) and isset ($_REQUEST[$page[$p]['bypass']]))
                $l .= '&' . $page[$p]['bypass'] . '=' . $_REQUEST[$page[$p]['bypass']];
        header ("Location: " . $l);
@@ -1806,8 +1806,6 @@ function formatTimestamp ($timestamp) {
 // prepend cutting button to each of them.
 function serializeFileLinks ($links, $scissors = FALSE)
 {
-       global $root;
-
        $comma = '';
        $ret = '';
        foreach ($links as $link_id => $li)
@@ -1839,7 +1837,7 @@ function serializeFileLinks ($links, $scissors = FALSE)
                        $ret .= "<a href='" . makeHrefProcess(array('op'=>'unlinkFile', 'link_id'=>$link_id)) . "'";
                        $ret .= getImageHREF ('cut') . '</a> ';
                }
-               $ret .= sprintf("<a href='%s?%s%s'>%s</a>", $root, $params, $li['entity_id'], $li['name']);
+               $ret .= sprintf("<a href='index.php?%s%s'>%s</a>", $params, $li['entity_id'], $li['name']);
                $comma = '<br>';
        }
        return $ret;
@@ -1888,13 +1886,8 @@ function ip_long2quad ($quad)
 
 function makeHref($params = array())
 {
-       global $head_revision, $numeric_revision, $root;
-       $ret = $root.'?';
+       $ret = 'index.php?';
        $first = true;
-       if (!isset($params['r']) and ($numeric_revision != $head_revision))
-       {
-               $params['r'] = $numeric_revision;
-       }
        foreach($params as $key=>$value)
        {
                if (!$first)
@@ -1907,14 +1900,9 @@ function makeHref($params = array())
 
 function makeHrefProcess($params = array())
 {
-       global $head_revision, $numeric_revision, $root, $pageno, $tabno;
-       $ret = $root.'process.php'.'?';
+       global $pageno, $tabno;
+       $ret = 'process.php?';
        $first = true;
-       if ($numeric_revision != $head_revision)
-       {
-               error_log("Can't make a process link when not in head revision");
-               die();
-       }
        if (!isset($params['page']))
                $params['page'] = $pageno;
        if (!isset($params['tab']))
@@ -1931,13 +1919,7 @@ function makeHrefProcess($params = array())
 
 function makeHrefForHelper ($helper_name, $params = array())
 {
-       global $head_revision, $numeric_revision, $root;
-       $ret = $root.'popup.php'.'?helper='.$helper_name;
-       if ($numeric_revision != $head_revision)
-       {
-               error_log("Can't make a process link when not in head revision");
-               die();
-       }
+       $ret = 'popup.php?helper=' . $helper_name;
        foreach($params as $key=>$value)
                $ret .= '&'.urlencode($key).'='.urlencode($value);
        return $ret;
index e5c87b1c66c3f7ffb427c59a7f76a581bff87f38..2ea253a8e5bb1a5f6b4ca828080f3be03ad89758 100644 (file)
@@ -9,19 +9,6 @@
 *
 */
 
-// "Note that when using ISAPI with IIS, the value will be 'off' if the
-// request was not made through the HTTPS protocol."
-$root = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') ? 'http://' : 'https://';
-$root .= isset ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']=='80'?'':$_SERVER['SERVER_PORT']));
-// "Since PHP 4.3.0, you will often get a slash or a dot back from
-// dirname() in situations where the older functionality would have given
-// you the empty string."
-// "On Windows, both slash (/) and backslash (\) are used as directory
-// separator character."
-$root .= strtr (dirname ($_SERVER['PHP_SELF']), '\\', '/');
-if (substr ($root, -1) != '/')
-       $root .= '/';
-
 // This is the first thing we need to do.
 require_once 'inc/exceptions.php';
 require_once 'inc/config.php';
@@ -56,7 +43,7 @@ else
        (
                "Database connection parameters are read from inc/secret.php file, " .
                "which cannot be found.\nYou probably need to complete the installation " .
-               "procedure by following <a href='${root}install.php'>this link</a>.",
+               "procedure by following <a href='install.php'>this link</a>.",
                __FILE__
        );
        exit (1);
@@ -107,7 +94,7 @@ if ($dbver != CODE_VERSION)
                'just upgraded to version ' . CODE_VERSION . ', while the '.
                'database version is ' . $dbver . '. No user will be ' .
                'either authenticated or shown any page until the upgrade is ' .
-               "finished. Follow <a href='${root}upgrade.php'>this link</a> and " .
+               "finished. Follow <a href='upgrade.php'>this link</a> and " .
                'authenticate as administrator to finish the upgrade.</p>';
        exit (1);
 }
@@ -198,7 +185,7 @@ if (isset ($_REQUEST['tab']))
 elseif (basename($_SERVER['PHP_SELF']) == 'index.php' and getConfigVar ('SHOW_LAST_TAB') == 'yes' and isset ($_SESSION['RTLT'][$pageno]))
 {
        $tabno = $_SESSION['RTLT'][$pageno];
-       $url = "${root}?page=$pageno&tab=$tabno";
+       $url = "index.php?page=$pageno&tab=$tabno";
        foreach ($_GET as $name=>$value)
        {
                if ($name == 'page' or $name == 'tab') continue;
index 7ba29898944be8fd1df74aedf0b919ffca96fda8..875eaae28a79c8e3397aaf29d3a2ca3dad3572f8 100644 (file)
@@ -2746,15 +2746,14 @@ function renderAddMultipleObjectsForm ()
 
 function printGreeting ()
 {
-       global $root, $remote_username, $remote_displayname;
-       echo "Hello, <a href='${root}?page=myaccount&tab=default'>${remote_displayname}</a>. This is RackTables " .
+       global $remote_username, $remote_displayname;
+       echo "Hello, <a href='index.php?page=myaccount&tab=default'>${remote_displayname}</a>. This is RackTables " .
                CODE_VERSION .
-               ". Click <a href='${root}?logout'>here</a> to logout.";
+               ". Click <a href='index.php?logout'>here</a> to logout.";
 }
 
 function renderSearchResults ()
 {
-       global $root;
        $terms = trim ($_REQUEST['q']);
        if (!strlen ($terms))
        {
@@ -2858,19 +2857,19 @@ function renderSearchResults ()
                        case 'ipv4addressbydq':
                                $parentnet = getIPv4AddressNetworkId ($record);
                                if ($parentnet !== NULL)
-                                       echo "<script language='Javascript'>document.location='${root}?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record}';//</script>";
+                                       echo "<script language='Javascript'>document.location='index.php?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record}';//</script>";
                                else
-                                       echo "<script language='Javascript'>document.location='${root}?page=ipaddress&ip=${record}';//</script>";
+                                       echo "<script language='Javascript'>document.location='index.php?page=ipaddress&ip=${record}';//</script>";
                                break;
                        case 'ipv4addressbydescr':
                                $parentnet = getIPv4AddressNetworkId ($record['ip']);
                                if ($parentnet !== NULL)
-                                       echo "<script language='Javascript'>document.location='${root}?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record['ip']}';//</script>";
+                                       echo "<script language='Javascript'>document.location='index.php?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${record['ip']}';//</script>";
                                else
-                                       echo "<script language='Javascript'>document.location='${root}?page=ipaddress&ip=${record['ip']}';//</script>";
+                                       echo "<script language='Javascript'>document.location='index.php?page=ipaddress&ip=${record['ip']}';//</script>";
                                break;
                        case 'ipv4network':
-                               echo "<script language='Javascript'>document.location='${root}?page=ipv4net";
+                               echo "<script language='Javascript'>document.location='index.php?page=ipv4net";
                                echo "&id=${record['id']}";
                                echo "';//</script>";
                                break;
@@ -2879,22 +2878,22 @@ function renderSearchResults ()
                                        $hl = '&hl_port_id=' . key ($record['by_port']);
                                else
                                        $hl = '';
-                               echo "<script language='Javascript'>document.location='${root}?page=object&object_id=${record['id']}${hl}';//</script>";
+                               echo "<script language='Javascript'>document.location='index.php?page=object&object_id=${record['id']}${hl}';//</script>";
                                break;
                        case 'ipv4rspool':
-                               echo "<script language='Javascript'>document.location='${root}?page=ipv4rspool&pool_id=${record['id']}';//</script>";
+                               echo "<script language='Javascript'>document.location='index.php?page=ipv4rspool&pool_id=${record['id']}';//</script>";
                                break;
                        case 'ipv4vs':
-                               echo "<script language='Javascript'>document.location='${root}?page=ipv4vs&vs_id=${record['id']}';//</script>";
+                               echo "<script language='Javascript'>document.location='index.php?page=ipv4vs&vs_id=${record['id']}';//</script>";
                                break;
                        case 'user':
-                               echo "<script language='Javascript'>document.location='${root}?page=user&user_id=${record['user_id']}';//</script>";
+                               echo "<script language='Javascript'>document.location='index.php?page=user&user_id=${record['user_id']}';//</script>";
                                break;
                        case 'file':
-                               echo "<script language='Javascript'>document.location='${root}?page=file&file_id=${record['id']}';//</script>";
+                               echo "<script language='Javascript'>document.location='index.php?page=file&file_id=${record['id']}';//</script>";
                                break;
                        case 'rack':
-                               echo "<script language='Javascript'>document.location='${root}?page=rack&rack_id=${record['id']}';//</script>";
+                               echo "<script language='Javascript'>document.location='index.php?page=rack&rack_id=${record['id']}';//</script>";
                                break;
                }
                return;
@@ -2908,7 +2907,7 @@ function renderSearchResults ()
                        switch ($where)
                        {
                                case 'object':
-                                       startPortlet ("<a href='${root}?page=depot'>Objects</a>");
+                                       startPortlet ("<a href='index.php?page=depot'>Objects</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
                                        echo '<tr><th>what</th><th>why</th></tr>';
                                        foreach ($what as $obj)
@@ -2977,7 +2976,7 @@ function renderSearchResults ()
                                        finishPortlet();
                                        break;
                                case 'ipv4network':
-                                       startPortlet ("<a href='${root}?page=ipv4space'>IPv4 networks</a>");
+                                       startPortlet ("<a href='index.php?page=ipv4space'>IPv4 networks</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
                                        foreach ($what as $cell)
                                        {
@@ -2999,9 +2998,9 @@ function renderSearchResults ()
                                                echo "<tr class=row_${order}><td class=tdleft>";
                                                $parentnet = getIPv4AddressNetworkId ($addr['ip']);
                                                if ($parentnet !== NULL)
-                                                       echo "<a href='${root}?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${addr['ip']}'>${addr['ip']}</a></td>";
+                                                       echo "<a href='index.php?page=ipv4net&tab=default&id=${parentnet}&hl_ipv4_addr=${addr['ip']}'>${addr['ip']}</a></td>";
                                                else
-                                                       echo "<a href='${root}?page=ipaddress&ip=${addr['ip']}'>${addr['ip']}</a></td>";
+                                                       echo "<a href='index.php?page=ipaddress&ip=${addr['ip']}'>${addr['ip']}</a></td>";
                                                echo "<td class=tdleft>${addr['name']}</td></tr>";
                                                $order = $nextorder[$order];
                                        }
@@ -3009,7 +3008,7 @@ function renderSearchResults ()
                                        finishPortlet();
                                        break;
                                case 'ipv4rspool':
-                                       startPortlet ("<a href='${root}?page=ipv4rsplist'>RS pools</a>");
+                                       startPortlet ("<a href='index.php?page=ipv4rsplist'>RS pools</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
                                        foreach ($what as $cell)
                                        {
@@ -3022,7 +3021,7 @@ function renderSearchResults ()
                                        finishPortlet();
                                        break;
                                case 'ipv4vs':
-                                       startPortlet ("<a href='${root}?page=ipv4vslist'>Virtual services</a>");
+                                       startPortlet ("<a href='index.php?page=ipv4vslist'>Virtual services</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
                                        foreach ($what as $cell)
                                        {
@@ -3035,7 +3034,7 @@ function renderSearchResults ()
                                        finishPortlet();
                                        break;
                                case 'user':
-                                       startPortlet ("<a href='${root}?page=userlist'>Users</a>");
+                                       startPortlet ("<a href='index.php?page=userlist'>Users</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
                                        foreach ($what as $item)
                                        {
@@ -3048,7 +3047,7 @@ function renderSearchResults ()
                                        finishPortlet();
                                        break;
                                case 'file':
-                                       startPortlet ("<a href='${root}?page=files'>Files</a>");
+                                       startPortlet ("<a href='index.php?page=files'>Files</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
                                        foreach ($what as $cell)
                                        {
@@ -3061,7 +3060,7 @@ function renderSearchResults ()
                                        finishPortlet();
                                        break;
                                case 'rack':
-                                       startPortlet ("<a href='${root}?page=rackspace'>Racks</a>");
+                                       startPortlet ("<a href='index.php?page=rackspace'>Racks</a>");
                                        echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
                                        foreach ($what as $cell)
                                        {
@@ -3217,11 +3216,11 @@ function renderPortOIFCompatEditor()
 // but use some proper abstract function later.
 function renderConfigMainpage ()
 {
-       global $pageno, $page, $root;
+       global $pageno, $page;
        echo '<ul>';
        foreach ($page as $cpageno => $cpage)
                if (isset ($cpage['parent']) and $cpage['parent'] == $pageno)
-                       echo "<li><a href='${root}?page=${cpageno}'>" . $cpage['title'] . "</li>\n";
+                       echo "<li><a href='index.php?page=${cpageno}'>" . $cpage['title'] . "</li>\n";
        echo '</ul>';
 }
 
@@ -3543,14 +3542,14 @@ function printImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
 
 function getImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
 {
-       global $root, $image;
+       global $image;
        if (!isset ($image[$tag]))
                $tag = 'error';
        $img = $image[$tag];
        if ($do_input == TRUE)
                return
                        "<input type=image name=submit class=icon " .
-                       "src='${root}${img['path']}' " .
+                       "src='${img['path']}' " .
                        "border=0 " .
                        ($tabindex ? "tabindex=${tabindex}" : '') .
                        (!strlen ($title) ? '' : " title='${title}'") . // JT: Add title to input hrefs too
@@ -3558,7 +3557,7 @@ function getImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
        else
                return
                        "<img " .
-                       "src='${root}${img['path']}' " .
+                       "src='${img['path']}' " .
                        "width=${img['width']} " .
                        "height=${img['height']} " .
                        "border=0 " .
@@ -3569,8 +3568,7 @@ function getImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
 // This function returns URL for favourite icon.
 function getFaviconURL ()
 {
-       global $root;
-       return $root . 'pix/racktables.ico';
+       return 'pix/racktables.ico';
 }
 
 function renderSystemReports ()
@@ -3713,7 +3711,7 @@ function renderReports ($what)
 
 function renderTagStats ()
 {
-       global $taglist, $root;
+       global $taglist;
        echo '<table border=1><tr><th>tag</th><th>total</th><th>objects</th><th>IPv4 nets</th><th>racks</th>';
        echo '<th>IPv4 VS</th><th>IPv4 RS pools</th><th>users</th><th>files</th></tr>';
        $pagebyrealm = array
@@ -3736,7 +3734,7 @@ function renderTagStats ()
                                echo '&nbsp;';
                        else
                        {
-                               echo "<a href='${root}?page=" . $pagebyrealm[$realm] . "&cft[]=${taginfo['id']}'>";
+                               echo "<a href='index.php?page=" . $pagebyrealm[$realm] . "&cft[]=${taginfo['id']}'>";
                                echo $taginfo['refcnt'][$realm] . '</a>';
                        }
                        echo '</td>';
@@ -4079,9 +4077,8 @@ function renderVirtualService ($vsid)
 
 function renderProgressBar ($percentage = 0, $theme = '')
 {
-       global $root;
        $done = ((int) ($percentage * 100));
-       echo "<img width=100 height=10 border=0 title='${done}%' src='${root}render_image.php?img=progressbar&done=${done}";
+       echo "<img width=100 height=10 border=0 title='${done}%' src='render_image.php?img=progressbar&done=${done}";
        echo (!strlen ($theme) ? '' : "&theme=${theme}") . "'>";
 }
 
@@ -5228,7 +5225,7 @@ function renderAccessDenied ()
        echo "<link rel=stylesheet type='text/css' href=pi.css />\n";
        echo "<link rel=icon href='" . getFaviconURL() . "' type='image/x-icon' />";
        echo "</head><body>";
-       global $root, $pageno, $tabno,
+       global $pageno, $tabno,
                $user_given_tags,
                $target_given_tags,
                $auto_tags,
@@ -5252,7 +5249,7 @@ function renderAccessDenied ()
        echo serializeTags ($auto_tags) . "&nbsp;</td></tr>\n";
        echo "<tr><th width='50%' class=tdright>Requested page:</th><td class=tdleft>${pageno}</td></tr>\n";
        echo "<tr><th width='50%' class=tdright>Requested tab:</th><td class=tdleft>${tabno}</td></tr>\n";
-       echo "<tr><td colspan=2 align=center>Click <a href='${root}?logout'>here</a> to logout.</td></tr>\n";
+       echo "<tr><td colspan=2 align=center>Click <a href='index.php?logout'>here</a> to logout.</td></tr>\n";
        echo "</table>\n";
        echo "</body></html>";
        die;
@@ -5270,7 +5267,7 @@ function renderMyAccount ()
 // File-related functions
 function renderFile ($file_id)
 {
-       global $nextorder, $aac, $root;
+       global $nextorder, $aac;
        $file = spotEntity ('file', $file_id);
        if ($file == NULL)
        {
@@ -5287,7 +5284,7 @@ function renderFile ($file_id)
        echo "<tr><th width='50%' class=tdright>Size:</th><td class=tdleft>";
        if (isolatedPermission ('file', 'download', $file))
        {
-               echo "<a href='${root}download.php?file_id=${file_id}'>";
+               echo "<a href='download.php?file_id=${file_id}'>";
                printImageHREF ('download', 'Download file');
                echo '</a>&nbsp;';
        }
@@ -5362,8 +5359,7 @@ function renderFileReuploader ()
 
 function renderFileDownloader ($file_id)
 {
-       global $root;
-       echo "<br><center><a target='_blank' href='${root}download.php?file_id=${file_id}&asattach=1'>";
+       echo "<br><center><a target='_blank' href='download.php?file_id=${file_id}&asattach=1'>";
        printImageHREF ('DOWNLOAD');
        echo '</a></center>';
 }
@@ -5536,9 +5532,9 @@ function renderFilesForEntity ($entity_id)
 // Use special encoding for upload forms
 function printOpFormIntro ($opname, $extra = array(), $upload = FALSE)
 {
-       global $root, $pageno, $tabno, $page;
+       global $pageno, $tabno, $page;
 
-       echo "<form method=post name=${opname} action='${root}process.php?page=${pageno}&tab=${tabno}&op=${opname}'";
+       echo "<form method=post name=${opname} action='process.php?page=${pageno}&tab=${tabno}&op=${opname}'";
        if ($upload)
                echo " enctype='multipart/form-data'";
        echo ">";
@@ -5594,7 +5590,6 @@ function printRoutersTD ($rlist, $as_cell = 'yes')
 // Same as for routers, but produce two TD cells to lay the content out better.
 function printIPv4NetInfoTDs ($netinfo, $tdclass = 'tdleft', $indent = 0, $symbol = 'spacer', $symbolurl = '')
 {
-       global $root;
        if ($symbol == 'spacer')
        {
                $indent++;
@@ -5610,7 +5605,7 @@ function printIPv4NetInfoTDs ($netinfo, $tdclass = 'tdleft', $indent = 0, $symbo
                        echo '</a>';
        }
        if (isset ($netinfo['id']))
-               echo "<a href='${root}?page=ipv4net&id=${netinfo['id']}'>";
+               echo "<a href='index.php?page=ipv4net&id=${netinfo['id']}'>";
        echo "${netinfo['ip']}/${netinfo['mask']}";
        if (isset ($netinfo['id']))
                echo '</a>';
@@ -5634,21 +5629,20 @@ function printIPv4NetInfoTDs ($netinfo, $tdclass = 'tdleft', $indent = 0, $symbo
        {
                echo niftyString ($netinfo['name']);
                if (count ($netinfo['etags']))
-                       echo '<br><small>' . serializeTags ($netinfo['etags'], "${root}?page=ipv4space&tab=default&") . '</small>';
+                       echo '<br><small>' . serializeTags ($netinfo['etags'], "index.php?page=ipv4space&tab=default&") . '</small>';
        }
        echo "</td>";
 }
 
 function renderCell ($cell)
 {
-       global $root;
        switch ($cell['realm'])
        {
        case 'user':
                echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
                printImageHREF ('USER');
                echo '</td>';
-               echo "<td><a href='${root}?page=user&user_id=${cell['user_id']}'>${cell['user_name']}</a></td></tr>";
+               echo "<td><a href='index.php?page=user&user_id=${cell['user_id']}'>${cell['user_name']}</a></td></tr>";
                if (strlen ($cell['user_realname']))
                        echo "<tr><td><strong>" . niftyString ($cell['user_realname']) . "</strong></td></tr>";
                else
@@ -5676,7 +5670,7 @@ function renderCell ($cell)
                                break;
                }
                echo "</td><td>";
-               printf ("<a href='${root}?page=file&file_id=%s'><strong>%s</strong></a>", $cell['id'], niftyString ($cell['name']));
+               printf ("<a href='index.php?page=file&file_id=%s'><strong>%s</strong></a>", $cell['id'], niftyString ($cell['name']));
                echo "</td><td rowspan=3 valign=top>";
                if (isset ($cell['links']) and count ($cell['links']))
                        printf ("<small>%s</small>", serializeFileLinks ($cell['links']));
@@ -5685,7 +5679,7 @@ function renderCell ($cell)
                echo '</td></tr><tr><td>';
                if (isolatedPermission ('file', 'download', $cell))
                {
-                       echo "<a href='${root}download.php?file_id=${cell['id']}'>";
+                       echo "<a href='download.php?file_id=${cell['id']}'>";
                        printImageHREF ('download', 'Download file');
                        echo '</a>&nbsp;';
                }
@@ -5696,7 +5690,7 @@ function renderCell ($cell)
                echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
                printImageHREF ('VS');
                echo "</td><td>";
-               echo "<a href='${root}?page=ipv4vs&vs_id=${cell['id']}'>";
+               echo "<a href='index.php?page=ipv4vs&vs_id=${cell['id']}'>";
                echo $cell['dname'] . "</a></td></tr><tr><td>";
                echo $cell['name'] . '</td></tr><tr><td>';
                echo count ($cell['etags']) ? ("<small>" . serializeTags ($cell['etags']) . "</small>") : '&nbsp;';
@@ -5704,7 +5698,7 @@ function renderCell ($cell)
                break;
        case 'ipv4rspool':
                echo "<table class='slbcell vscell'><tr><td>";
-               echo "<a href='${root}?page=ipv4rspool&pool_id=${cell['id']}'>";
+               echo "<a href='index.php?page=ipv4rspool&pool_id=${cell['id']}'>";
                echo !strlen ($cell['name']) ? "ANONYMOUS pool [${cell['id']}]" : niftyString ($cell['name']);
                echo "</a></td></tr><tr><td>";
                printImageHREF ('RS pool');
@@ -5718,7 +5712,7 @@ function renderCell ($cell)
                echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>";
                printImageHREF ('NET');
                echo '</td>';
-               echo "<td><a href='${root}?page=ipv4net&id=${cell['id']}'>${cell['ip']}/${cell['mask']}</a></td></tr>";
+               echo "<td><a href='index.php?page=ipv4net&id=${cell['id']}'>${cell['ip']}/${cell['mask']}</a></td></tr>";
                if (strlen ($cell['name']))
                        echo "<tr><td><strong>" . niftyString ($cell['name']) . "</strong></td></tr>";
                else
@@ -5734,7 +5728,7 @@ function renderCell ($cell)
                echo "<img border=0 width=${thumbwidth} height=${thumbheight} title='${cell['height']} units' ";
                echo "src='render_image.php?img=minirack&rack_id=${cell['id']}'>";
                echo "</td><td>";
-               printf ("<a href='${root}?page=rack&rack_id=%s'><strong>%s</strong></a>", $cell['id'], niftyString ($cell['name']));
+               printf ("<a href='index.php?page=rack&rack_id=%s'><strong>%s</strong></a>", $cell['id'], niftyString ($cell['name']));
                echo "</td></tr><tr><td>";
                echo niftyString ($cell['comment']);
                echo "</td></tr><tr><td>";
@@ -5745,7 +5739,7 @@ function renderCell ($cell)
                echo "<table class='slbcell vscell'><tr><td rowspan=2 width='5%'>";
                printImageHREF ('OBJECT');
                echo '</td>';
-               echo "<td><a href='${root}?page=object&object_id=${cell['id']}'>";
+               echo "<td><a href='index.php?page=object&object_id=${cell['id']}'>";
                echo "<strong>" . niftyString ($cell['dname']) . "</strong></a></td></tr>";
                echo '<td>';
                echo count ($cell['etags']) ? ("<small>" . serializeTags ($cell['etags']) . "</small>") : '&nbsp;';
@@ -5759,10 +5753,9 @@ function renderCell ($cell)
 
 function renderLBCell ($object_id)
 {
-       global $root;
        $oi = spotEntity ('object', $object_id);
        echo "<table class=slbcell><tr><td>";
-       echo "<a href='${root}?page=object&object_id=${object_id}'>${oi['dname']}</a>";
+       echo "<a href='index.php?page=object&object_id=${object_id}'>${oi['dname']}</a>";
        echo "</td></tr><tr><td>";
        printImageHREF ('LB');
        echo "</td></tr><tr><td>";
@@ -5773,12 +5766,11 @@ function renderLBCell ($object_id)
 
 function renderRouterCell ($dottedquad, $ifname, $cell)
 {
-       global $root;
        echo "<table class=slbcell><tr><td rowspan=3>${dottedquad}";
        if (strlen ($ifname))
                echo '@' . $ifname;
        echo "</td>";
-       echo "<td><a href='${root}?page=object&object_id=${cell['id']}&hl_ipv4_addr=${dottedquad}'><strong>${cell['dname']}</strong></a></td>";
+       echo "<td><a href='index.php?page=object&object_id=${cell['id']}&hl_ipv4_addr=${dottedquad}'><strong>${cell['dname']}</strong></a></td>";
        echo "</td></tr><tr><td>";
        printImageHREF ('router');
        echo "</td></tr><tr><td>";
@@ -5791,7 +5783,6 @@ function renderRouterCell ($dottedquad, $ifname, $cell)
 // if a preview cannot be shown
 function getFilePreviewCode ($file)
 {
-       global $root;
        $ret = '';
        switch ($file['type'])
        {
@@ -5813,8 +5804,8 @@ function getFilePreviewCode ($file)
                                $resampled = TRUE;
                        }
                        if ($resampled)
-                               $ret .= "<a href='${root}download.php?file_id=${file['id']}&asattach=no'>";
-                       $ret .= "<img width=${width} height=${height} src='${root}render_image.php?img=preview&file_id=${file['id']}'>";
+                               $ret .= "<a href='download.php?file_id=${file['id']}&asattach=no'>";
+                       $ret .= "<img width=${width} height=${height} src='render_image.php?img=preview&file_id=${file['id']}'>";
                        if ($resampled)
                                $ret .= '</a><br>(click to zoom)';
                        break;
@@ -5871,7 +5862,7 @@ function showPathAndSearch ($pageno)
                }
                return $path;
        }
-       global $root, $page;
+       global $page;
        // Path.
        echo "<td class=activemenuitem width='99%'>" . getConfigVar ('enterprise');
        $path = getPath ($pageno);
@@ -5885,7 +5876,7 @@ function showPathAndSearch ($pageno)
                        );
                else
                        $title = dynamic_title_decoder ($no);
-               echo ": <a href='${root}?page=${no}&tab=default";
+               echo ": <a href='index.php?page=${no}&tab=default";
                foreach ($title['params'] as $param_name => $param_value)
                        echo "&${param_name}=${param_value}";
                echo "'>" . $title['name'] . "</a>";
@@ -5893,7 +5884,7 @@ function showPathAndSearch ($pageno)
        echo "</td>";
        // Search form.
        echo "<td><table border=0 cellpadding=0 cellspacing=0><tr><td>Search:</td>";
-       echo "<form name=search method=get action='${root}'><td>";
+       echo "<form name=search method=get><td>";
        echo '<input type=hidden name=page value=search>';
        // This input will be the first, if we don't add ports or addresses.
        echo "<input type=text name=q size=20 tabindex=1000></td></form></tr></table></td>";
@@ -5910,7 +5901,7 @@ function getTitle ($pageno)
 
 function showTabs ($pageno, $tabno)
 {
-       global $tab, $root, $page, $trigger;
+       global $tab, $page, $trigger;
        if (!isset ($tab[$pageno]['default']))
                return;
        echo "<td><div class=greynavbar><ul id=foldertab style='margin-bottom: 0px; padding-top: 10px;'>";
@@ -5927,7 +5918,7 @@ function showTabs ($pageno, $tabno)
                if ($tabidx == $tabno)
                       $tabclass = 'current'; // override any class for an an active selection
                echo "<li><a class=${tabclass}";
-               echo " href='${root}?page=${pageno}&tab=${tabidx}";
+               echo " href='index.php?page=${pageno}&tab=${tabidx}";
                if (isset ($page[$pageno]['bypass']) and isset ($_REQUEST[$page[$pageno]['bypass']]))
                {
                        $bpname = $page[$pageno]['bypass'];
index 90a5336f76ce0e99873739d003cef54106cf5bd9..54b4d0a8ec2c759881a9a7e7a805c349bdcae232 100644 (file)
@@ -9,12 +9,12 @@ $msgcode = array();
 
 function buildWideRedirectURL ($log, $nextpage = NULL, $nexttab = NULL, $moreArgs = array())
 {
-       global $root, $page, $pageno, $tabno;
+       global $page, $pageno, $tabno;
        if ($nextpage === NULL)
                $nextpage = $pageno;
        if ($nexttab === NULL)
                $nexttab = $tabno;
-       $url = "${root}?page=${nextpage}&tab=${nexttab}";
+       $url = "index.php?page=${nextpage}&tab=${nexttab}";
        if (isset ($page[$nextpage]['bypass']))
                $url .= '&' . $page[$nextpage]['bypass'] . '=' . $_REQUEST[$page[$nextpage]['bypass']];
 
index f680f7ce20bae5b4779bff9daa871435ffc45854..0a349192fb765128998a72b152c613067b3a9d05 100644 (file)
@@ -20,8 +20,17 @@ else
 if ($step > count ($stepfunc))
 {
        require 'inc/init.php';
-       global $root;
-       header ("Location: " . $root);
+       $root = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') ? 'http://' : 'https://';
+       $root .= isset ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']=='80'?'':$_SERVER['SERVER_PORT']));
+       // "Since PHP 4.3.0, you will often get a slash or a dot back from
+       // dirname() in situations where the older functionality would have given
+       // you the empty string."
+       // "On Windows, both slash (/) and backslash (\) are used as directory
+       // separator character."
+       $root .= strtr (dirname ($_SERVER['PHP_SELF']), '\\', '/');
+       if (substr ($root, -1) != '/')
+               $root .= '/';
+       header ("Location: ${root}");
        exit;
 }
 $title = "RackTables installation: step ${step} of " . count ($stepfunc);
index 2ed057dea87d81876f775eaf4cc47b2d2c8d69ce..d9ea06fd42dde0ba31999ff1dc7f2327732075ec 100644 (file)
--- a/popup.php
+++ b/popup.php
@@ -39,7 +39,7 @@
                        echo '</select><br><br>';
                        echo "<input type='submit' value='Proceed' onclick='".
                        "if (getElementById(\"ports\").value != \"\") {".
-                       "       opener.location=\"${root}process.php?page=object&tab=ports&op=linkPort&object_id=$object_id&port_id=$port_id&port_name=$port_name&remote_port_name=\"+getElementById(\"remote_port_name\").value+\"&remote_object_name=\"+getElementById(\"remote_object_name\").value+\"&remote_port_id=\"+getElementById(\"ports\").value; ".
+                       "       opener.location=\"process.php?page=object&tab=ports&op=linkPort&object_id=$object_id&port_id=$port_id&port_name=$port_name&remote_port_name=\"+getElementById(\"remote_port_name\").value+\"&remote_object_name=\"+getElementById(\"remote_object_name\").value+\"&remote_port_id=\"+getElementById(\"ports\").value; ".
                        "       window.close();}'>";
                        echo '</form></div>';
                        break;
index baa6ca88c3337e0ea7603d171d8076381df996f0..b2e8a7faafb579a023450ffdd71677491e16c4b0 100644 (file)
@@ -12,7 +12,6 @@ if ($op == 'addFile' && !isset($_FILES['file']['error'])) {
        showError ("File upload error, it's size probably exceeds upload_max_filesize directive in php.ini");
        die;
 }
-redirectIfNecessary();
 fixContext();
 
 if (!isset ($ophandler[$pageno][$tabno][$op]))
index 9f2b26173e8404d5c89f09ca5a68fb898387a274..d90c20a359f9a3d259c34f8a613a014281a63644 100644 (file)
@@ -445,16 +445,9 @@ CREATE TABLE `PortInterfaceCompat` (
 //
 // ******************************************************************
 
-$root = (empty($_SERVER['HTTPS']) or $_SERVER['HTTPS'] == 'off') ? 'http://' : 'https://';
-$root .= isset ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'].($_SERVER['SERVER_PORT']=='80'?'':$_SERVER['SERVER_PORT']));
-$root .= strtr (dirname ($_SERVER['PHP_SELF']), '\\', '/');
-if (substr ($root, -1) != '/')
-       $root .= '/';
-
 // a clone of showError() to drop dependency on interface.php
 function showFailure ($info = '', $location = 'N/A')
 {
-       global $root;
        if (preg_match ('/\.php$/', $location))
                $location = basename ($location);
        elseif ($location != 'N/A')
@@ -562,7 +555,7 @@ else
                        if (isset ($relnotes[$batchid]))
                                echo "<tr><th>Release notes for ${batchid}</th><td>" . $relnotes[$batchid] . "</td></tr>\n";
                }
-               echo "<tr><th>Summary</th><td>Upgrade complete, it is Ok to <a href='${root}'>enter</a> the system.</td></tr>\n";
+               echo "<tr><th>Summary</th><td>Upgrade complete, it is Ok to <a href='index.php'>enter</a> the system.</td></tr>\n";
        }
 }
 echo '</table>';