Re: listing root directory



Greetings, Dan Gelder.
In reply to Your message dated Sunday, January 27, 2008, 05:08:15,

no, that just turns
/home/.machine/user/site.com/work/january/phpstuff/includer.php
into
/home/.machine/user/site.com/work/january/phpstuff/

and you can read my post to understand why that brings me no closer
than before.

What I need to know, I guess, is a way to get the official root folder
so I have
/home/.machine/user/site.com/

And then I can match the strings?? Can't say how to solve it yet.

Wouldn't $_SERVER["SCRIPT_NAME"] do what you are looking for? Don't use
$_SERVER["PHP_SELF"] because that can contain so-called "additional path
information" that users could be adding to the script's URL in some
circumstances (/january/phpstuff/includer.php/extra/stuff) and which,
incidentally, makes $_SERVER["PHP_SELF"] a value that should not be
trusted. Mind you, perhaps it's better to regard all of $SERVER as
untrusted just to err on the side of caution.

Sebastian Lisken

I know not to trust $_SERVER too far, but it doesn't matter, because I
am interested in finding the *included file*'s location, not the base
script. IE:

------
------ folder1/file1.php:
------

echo "Here is an image from another folder:";
include '/folder2/file2.php';

------
------ folder2/file2.php:
------

function getGlobalPrefix()
{
//this is what I need to write:
//it takes the data in __FILE__ and somehow turns that into 'http://
mySite.com/folder2/'
}
echo "<img src='" . getGlobalPrefix() . "/myGreatImage.gif'>";

------

OK, does it make sense now?? :-)

You has an advice but don't get it right.

$dir = dirname(__FILE__); // current script location
if(stripos($_SERVER['DOCUMENT_ROOT'], $dir) === 0)
{
$dir = substr($dir, strlen($_SERVER['DOCUMENT_ROOT']));
echo("<img src=\"{$dir}/image_in_the_same_location_as_script\"/>");
}


--
Sincerely Yours, AnrDaemon <anrdaemon@xxxxxxxxxxx>

.



Relevant Pages

  • Re: Error handling in vbscript.
    ... Here is my standard schpeal on VBS error handling. ... The Err object appears to be somewhat incorrectly documented in the MS VBS ... look back along the call stack to the global script, ...
    (microsoft.public.scripting.vbscript)
  • Re: ADSI scripting "risks"
    ... Bulk updates do have an element of risk and you should exercise caution when making large updates to the directory service. ... He is even more cautious, and wants us to modify the script to apply the changes to smaller chunks of accounts, evaluate the results to see if it has caused any "problems" for AD. ...
    (microsoft.public.scripting.vbscript)
  • Re: PHP file download counter
    ... This will log the request to a flat file then redirect the ... // Class SimpleRedirectLog ... $err = false; ... Write a script that supplies the file download with the correct mime type ...
    (comp.lang.php)
  • Re: setting an environment variable to the current IP
    ... Set WshEnv = WshShell.Environment ... If Err 0 Then ... for each IPConfig in IPConfigSet ... I have enough vbs to have been able to see what the script does, ...
    (microsoft.public.scripting.vbscript)
  • Re: Can I break out of vbScript by causing error..... let me explain
    ... Call SubA() ... wscript.echo "Err after SubA", err.number, err.description, err.source ... Call SubB() ... So, if I really don't care if he script kicks out an error, I should ...
    (microsoft.public.scripting.vbscript)