Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-02-2003, 02:56 PM   PM User | #1
x_goose_x
Regular Coder

 
Join Date: Jun 2002
Location: Montreal, Canada
Posts: 644
Thanks: 0
Thanked 0 Times in 0 Posts
x_goose_x is an unknown quantity at this point
Grabbing remote page, links/imgs don't work..

When you include a page from another php page on a different domain all the images and links are relative, so none f them work. Is there any way to fix this aside from writting a script that searches for common references (src=,href=,...). Because If I do that, javascripts urls will be much harder. Is there a way to get the file with absolute paths?
x_goose_x is offline   Reply With Quote
Old 04-02-2003, 04:41 PM   PM User | #2
bored
New Coder

 
Join Date: Jan 2003
Location: Tulsa, OK
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
bored is an unknown quantity at this point
When files are included the source targets are originating from the folder that the script that includes the file is in. Example, say you have the main script in /fun and the include in /fun/includes.

In the included script you have to set all of the non-absolute links to show as if the script was in the /fun folder. so if your images folder is /images the image links in the main script as well as the unclude have to be images/file.ext.

You're probably setting the images like ../images/file.ext in the include file. Or so thats what it seems.

Let me know if that helped.
bored is offline   Reply With Quote
Old 04-02-2003, 05:35 PM   PM User | #3
Ökii
Regular Coder

 
Join Date: Jun 2002
Location: UK
Posts: 577
Thanks: 0
Thanked 0 Times in 0 Posts
Ökii is an unknown quantity at this point
if you had to add "http://domain.whatever/folder/folder before each image that didn't have that, you'd need some form of clever regex.

a sneaky (and also untested) workaround it to sling a <base href=" at the top of their included output - that should ignore hrefs and srcs that start http and just effect the rest.

echo '<base href="' .substr($file,0,strrpos('/',$file)). '">';

couldn't remember which way the strrpos accepts its parameters either.
__________________
Ökii - formerly pootergeist
teckis - take your time and it'll save you time.
Ökii is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:37 PM.


Advertisement
Log in to turn off these ads.