include

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
asta123
Forum Newbie
Posts: 3
Joined: Tue Mar 01, 2005 7:43 am
Location: Lithuania

include

Post 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?
Last edited by asta123 on Tue Mar 01, 2005 8:54 am, edited 1 time in total.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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
asta123
Forum Newbie
Posts: 3
Joined: Tue Mar 01, 2005 7:43 am
Location: Lithuania

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
asta123
Forum Newbie
Posts: 3
Joined: Tue Mar 01, 2005 7:43 am
Location: Lithuania

Post 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.
guest
Forum Commoner
Posts: 25
Joined: Sat Nov 22, 2003 11:50 pm

Post by guest »

I Have Been Having The Same Problems With One Of My Scripts
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Post Reply