I got to thinking about the code that figures out APPLICATION_ROOT, et al.
I think I
have a slightly better four lines:

        define("SERVER_NAME", $SERVER_NAME);
        define("SCRIPT_NAME", basename(__FILE__));
        define("APPLICATION_ROOT", ereg_replace("([^/\\]*)$", "",
dirname(__FILE__)));
        define("EXTERNAL_PATH", dirname($SCRIPT_NAME) . "/");

I wish I could get rid of the ereg_replace, but I can't think of one that
will
fit on one line.  So, given either "C:\inetpub\wwwroot" or "/www/htdocs" we
need to chop off the last path.  Can't use strrpos() because you don't know
if you're
looking for / or \.

I did think of using a function like this:

        /*
        ** Function: parent
        ** Input: STRING path
        ** Output: STRING
        ** Description: given a path, returns the parent path
        */
        function parent($path)
        {
                $i = strlen($path) - 1;
                while(($i >= 0) AND ($path[$i] != "/") AND ($path[$i] != "/"))
                {
                        $i--;
                }

                if($i > 0)
                {
                        return(substr($path, 0, $i));
                }
                else
                {
                        return("/");
                }
        }

But all the clutter isn't worth it.

Anyway, I'll be committing this to CVS in a few seconds...

Leon



------------------------------------------------------------
To subscribe:    [EMAIL PROTECTED]
To unsubscribe:  [EMAIL PROTECTED]
Site:            http://www.working-dogs.com/freetrade/
Problems?:       [EMAIL PROTECTED]

Reply via email to