|
Posted by Jerry Stuckle on 05/13/07 14:41
Alan Jones wrote:
> On 12 May 2007 19:51:19 -0700, ZeldorBlat <zeldorblat@gmail.com>
> wrote:
>
>>> First of all, thank you very much for clueing me in on this area of
>>> programming. Without your help, I would still be very lost, but is
>>> there a way to make basename, or a similar function, simply return
>>> the filename of the parent page; the page the include is in? Thanks
>>> again, I really appreciate any help I can get.
>> Yes -- look at the following URL:
>>
>> <http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server>
>>
>> and try the various variables available to see what they return.
>
> I went thru that page last night and the most promising seemed to
> be 'REQUEST_URI', which is supposed to output, "The URI which was
> given in order to access this page; for instance, '/index.html'."
>
> However, both...
>
> echo ($_SERVER['REQUEST_URI']);
>
> and...
>
> echo basename($_SERVER['REQUEST_URI']);
>
> ...returned the name of the file it is in, the include 'child' file,
> and not the actual page URL accessed; /index.php. I need the
> include script to know if it is being run within index.php.
>
> Again, thanks for racking your brain on this with me. I'm at a
> total loss... :(
>
> BTW, might you or anyone be able to help with understanding
> 'open_basedir restriction'? I received the following error when
> trying to use the link() function...
>
> link ("/index.php","/index_body.php");
>
> Warning: link(): open_basedir restriction in effect.
> File(/index.php) is not within the allowed path(s):
> (/home/httpd/vhosts/jalanjones.com/httpdocs:/tmp) in
> /home/httpd/vhosts/jalanjones.com/httpdocs/index_body.php on line 46
>
> Thanks :)
Alan,
$_SERVER['REQUEST_URI'] does give the uri used to fetch the page. I'm
not sure what you mean by 'child' file. Are you using frames? Maybe if
you post the code you're using (including that in the 'parent' and
'child' pages) it will be more clear.
And as Schraalhans indicated, commands which relate to the underlying
filesystem (i.e. link, fopen, include, etc.) reference the file system
directly. So if you use absolute paths (beginning with '/'), it is the
root directory of the file system. But your host has limited you so all
you can access are files in /hom/httpd/vhosts/jalanjones.com/httpdocs
and /tmp.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|