note 29202 rejected from function.include by jsheets
| From: | jsheets@php.net | Date: | Thu, 06 Feb 2003 03:07:39 +0000 |
| Subject: | note 29202 rejected from function.include by jsheets | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-43493@lists.php.net to get a copy of this message | ||
---------PROBLEM---------
Returning a load instruction to the browser that shows a frame containing two files results in an
error, or not loading the images that are in that page (lots of you have problems with it as
I've understood from my mailbox;-)
---------REPRODUCTION---------
- Create a script that uses
Include("framepage")
where framepage AND sourcefiles are in another directory then the script is. You'll see that
neither the pages are loaded, nor the images on it!
---------EXPLANATION---------
- Using Include() for a file that is a frame-source (ie, loads two other HTML-pages) results in
loading that framepage, but -not- the sourcefiles (fe. src="test.htm").
- The errordocuments are loaded instead, because the browser cannot locate the sourcefiles.
- Though the framepage was loaded correctly, the errorlog shows that the sourcepages were tried for
in the directory were the PHP script resides
---------WHY IT'S HANDY TO KNOW---------
- Creating a script that translates id's to pages in hyperlinks, thus enabling you to create a
pretty good protected memberarea in a simple yet effective way:
Create a getpage.php file, add hyperlinks to your HTML documents saying
"getpage.php?id=1234" and have the getpage script resolve the id 1234 to an url like
"/memberarea/docs/nl/x/y/info.htm".
Now, whenever a user clicks on the link, the browser sends the request getpage?... and gets the
expected page.
(off course, before returning the page, the script checks authorization first, but I've left it
out for clear understanding of the problem).
---------TRIED SOLUTIONS---------
- Include(...) results in not being able to find pages or images!
- Header("Location:...), same result
- Changing (chdir) to the source directory...same result
---------REASON FOR THIS BEHAVIOR---------
- PHP Engine, and that was completely new for me, RESETS the cwd (current working directory) to the
ORIGINAL location where the script resides (in this case getpage.php), immediately after ending
execution of that script!
---------SOLUTION----------
(after 2 hours trying every possibility!)
echo
'<META HTTP-EQUIV="Refresh"
Content="0;
URL= /dir/dir/dir/dir/file.htm ' ">' ;
---------Warnings---------
- This should be on one line off course, just to ensure it's clear in this message
- ENSURE a leading slash!
- Set the location to the location to the base of the hosting server (that is, the actual root!)
---------------------------------------------
Good luck!
Peter