Page 1 of 1

include

Posted: Tue Mar 01, 2005 8:09 am
by asta123
Hi,
I need help.
When I use <frameset> I can open diferent pages from diferent web servers. Something like:

<frameset rows="64,*">
<frame name="banner" target="contents">
<frameset cols="150,*">
<frame name="contents" target="main" src="content.html">
<frame name="main" src="http://www.omnitel.lt">
</frameset>
....

I don't want use frameset.
How can I make similar with phpscript?

This work bad:
<? include "head.inc";
include "http://www.omnitel.lt";
include "end.inc";
?>
Where is my mistake?

Posted: Tue Mar 01, 2005 8:18 am
by CoderGoblin
It could be that html://www.omnitel.lt does not exist. (may be http://www.omnitel.It/index.php" at a guess).

You may also need to check the configuration settings...

The manual states....

If "URL fopen wrappers" are enabled in PHP (which they are in the default configuration), you can specify the file to be included using a URL (via HTTP or other supported wrapper - see Appendix L for a list of protocols) instead of a local pathname. If the target server interprets the target file as PHP code, variables may be passed to the included file using a URL request string as used with HTTP GET. This is not strictly speaking the same thing as including the file and having it inherit the parent file's variable scope; the script is actually being run on the remote server and the result is then being included into the local script.

Warning

Windows versions of PHP prior to PHP 4.3.0 do not support accessing remote files via this function, even if allow_url_fopen is enabled.

This means that include is not the best thing. Look into readfile

Posted: Tue Mar 01, 2005 8:42 am
by asta123
I know manual. My script work, but not how I expect.
When i try adress http://www.omnitel.lt/?m3_lt$205592_206051 from Internet explorer, page is O.K.
When I try open this page from my file.php, page is not correct.
<? include "http://www.omnitel.lt/?m3_lt$205592_206051"; ?> - include without pictures, menu scripts, css files. Links on that opened page work not correct.

I need "result page" from remote server, not "text" from page.

Posted: Tue Mar 01, 2005 8:58 am
by feyd
you will have to fetch the page's contents, parse it such that the information comes from their server again.. make sure you have permission to do this as well.

Posted: Tue Mar 01, 2005 9:11 am
by CoderGoblin
The reason I emboldened part of the text was to highlight this problem. As Feyd has said you will to get the text and potentially parse the paths etc as it is likely they are not set to be the full URL. You cannot get the script itself using the url as this would be a security problem.

Posted: Tue Mar 01, 2005 9:39 am
by asta123
How can I fetch? Have I use function fopen?
I try this function.
.....

I stay with <frameset>. I need to show pages from another web servers.

Write phpscript it is to dificult for my. I am beginner in php.

Posted: Tue Mar 01, 2005 10:12 am
by guest
I Have Been Having The Same Problems With One Of My Scripts

Posted: Tue Mar 01, 2005 11:04 am
by CoderGoblin
In general you cannot access a php script from another site. All you can get is the HTML content. If you were able to get the script you could also get other details such as database passwords etc.

The solution is for the file on the required url to set full pathnames rather than relative ones. e.g

Code: Select all

<img src="http://www.site.com/img/myimage.jpg">
rather than

Code: Select all

<img src="img/myimage.jpg">
The same with links.

To add information, you would then only need to strip out the body of the text (storing any necessary css/javascript file links included within the <head> block which you would then need to also include in your head block).

All other alternatives require close cooperation with the target url creators. An example being an XML Feed etc.