Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 07-03-2007, 10:32 AM   #1
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
coders.. the ultimate convert relative links to absolute links?

Do you know how? Share a php function.. convert relative links to absolute.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-03-2007, 10:33 AM   #2
geeknik
l337 h4x0r!#%
 
geeknik's Avatar
 
Industry Role:
Join Date: Feb 2005
Location: OKC, OK, USA
Posts: 8,364
Try this one:

Quote:
function absolute_url($txt, $base_url){
$needles = array('href="', 'src="', 'background="');
$new_txt = '';
if(substr($base_url,-1) != '/') $base_url .= '/';
$new_base_url = $base_url;
$base_url_parts = parse_url($base_url);

foreach($needles as $needle){
while($pos = strpos($txt, $needle)){
$pos += strlen($needle);
if(substr($txt,$pos,7) != 'http://' && substr($txt,$pos,8) != 'https://' && substr($txt,$pos,6) != 'ftp://' && substr($txt,$pos,9) != 'mailto://'){
if(substr($txt,$pos,1) == '/') $new_base_url = $base_url_parts['scheme'].'://'.$base_url_parts['host'];
$new_txt .= substr($txt,0,$pos).$new_base_url;
} else {
$new_txt .= substr($txt,0,$pos);
}
$txt = substr($txt,$pos);
}
$txt = $new_txt.$txt;
$new_txt = '';
}
return $txt;
}
$txt is your HTML code where you want to convert your relative links.
__________________
hacker 4 hire.
geeknik is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-03-2007, 10:37 AM   #3
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
will test it.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-03-2007, 10:45 AM   #4
geeknik
l337 h4x0r!#%
 
geeknik's Avatar
 
Industry Role:
Join Date: Feb 2005
Location: OKC, OK, USA
Posts: 8,364
I'll keep looking.
__________________
hacker 4 hire.
geeknik is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-03-2007, 11:27 AM   #5
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
Quote:
Originally Posted by geeknik View Post
Try this one:



$txt is your HTML code where you want to convert your relative links.
substr?! you can do it with probably one line of preg_match_replace....

anyway, if you wanna invest a few bucks, hit me up (icq: 33375924) I can probably cook something up...
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 07-03-2007, 11:30 AM   #6
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
Quote:
Originally Posted by woj View Post
substr?! you can do it with probably one line of preg_match_replace....

anyway, if you wanna invest a few bucks, hit me up (icq: 33375924) I can probably cook something up...
was mostly looking for a better function than I was already using. It has to account for the '../../blah.jpg' type links too, etc.. I have it working but it's not "pretty" yet.
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.