[web-team] Bug on ....http://www.svlug.org/policies/list-policy.php

Rick Moen rick at linuxmafia.com
Thu Jul 10 00:09:04 PDT 2008


Quoting Mark Weisler (mark at weisler-saratoga-ca.us):

> If you go to ...http://www.svlug.org/policies/list-policy.php
> and then click on the banner, you will get a 404 Not Found.
> Not sure who will look into this...

So, I'm hoping Lisa will.  As a reminder, the header for all pages used
to be implemented using a server-side include.  Lisa re-implemented this 
concept in PHP, for her changeover.  (To my knowledge, that's the sole
purpose for which we're using PHP, as a glorified SSI replacement.)

There's a zero-length file called HOME in /var/www/svlug-main/ .  Inside
/var/www/svlug-main/header.php (the header "include" file), one finds this:

  <?php

  // This section of the code finds the maindir and homedir values
  // by searching for the file named HOME.  This allows us to find
  // the image directory as well as all necessary subdirectories.
  // This is necessary because this is an included file and has no
  // real sense of what the active directory may be when it is called.
  // At least, it may not know what directory REALITIVE TO the base
  // directory of the site (since the site may not start at the "/"
  // URL)

  $maindir = $_SERVER["DOCUMENT_ROOT"];
  $homedir = "/";
  $requestURI = $_SERVER["REQUEST_URI"];
  $requestPath = split("/", $requestURI);

  $i = -1;
  while(!file_exists($maindir."HOME") && $i++ < count($requestPath))
          {
          $path = $requestPath[$i];
          while (substr($path, 0, 1) == "/")
                  $path = substr($path, 1);
          while (substr($path, strlen($path) - 1, 1) == "/")
                  $path = substr($path, 0, strlen($path) - 1);
          if (strlen($path) < 1)
                  continue;
          $maindir .= $path."/";
          $homedir .= $path."/";
          }

  if (substr($homedir, strlen($homedir) - 1, 1) == "/")
          $homedir = substr($homedir, 0, strlen($homedir) - 1);
  if (substr($maindir, strlen($maindir) - 1, 1) == "/")
          $maindir = substr($maindir, 0, strlen($maindir) - 1);

  [...]

  <?phpif ($GLOBALS['homedir'] == "")        print "<a
  href='index.php'>";else        print "<a
  href='".$GLOBALS['homedir']."'>";?>

  [...]


I'm a bit tired out at the moment, and don't fully understand how that
logic is supposed to work.  In any event, the link _ought_ to resolve to 
"../index.php", but instead is resolving to "./index.php" (or such).
That is, clicking on the banner image is supposed to always take you to
the top of the site, http://www.svlug.org/index.php .


To be really picky, such a relative link should always, always, always
be to "./" or "../", and never to anything ending in index.html or
index.php, etc.   Why?  Because:

1.  Having some links go to http://www.example.com/, and others to
http://www.example.com/index.{html|shtml|php*} causes users' browser
caches to load twice for the same page content.  That's bad.

2.  Exposing to public HTML the specific filenames of directory index
files makes it likely that people will bookmark those URLs, which will
then break if/when you change to a different type of directory index
file.  E.g., people who bookmarked "http://www.svlug.org/index.shtml" 
got 404s the day Lisa removed index.shtml and replaced it with
index.php.  If they'd never seen anything but "http://www.svlug.org/",
they'd have bookmarked that, and the link would have remained unbroken.

I could fix that (I _think_) in Lisa's header.php file by replacing
"index.php" with "./" -- but figure I should check with her here, first.

The other problem, the problem of hyperlinking the banner to
non-existent page http://www.svlug.org/policies/index.php, I'm even more
reluctant to try to fix on my own.  Lisa?  (Thanks.)




More information about the web-team mailing list