I am having a problem that has me tearing my hair out.
I have a lot of stores on my site that have affiliate links. I have integrated it into my forum that if someone posts a link to one of those stores it will redirect through my affiliate link before going back to the original page posted.
It all works just great except for one glitch.
Posting just one link in a post goes great.
If more than one link is in a post, it only redirects through the first link listed.
I need help getting all links to be recognized individually and redirecting correctly.
Here is a sample post:
http://www.flamingoworld.com/forum/showflat.php?Cat=&Board=freebie&Number=2331
All completely different urls, but all redirect to the first one posted.
Would like it to process the first url and continue on to do all urls until it runs out of urls to process.
When you view the properties for each link, the "txt=" part is always the same as the first link. The "to=" is the posted link.
The "txt=" should be the same as the "to="
The "txt=" is the final landing page where people want to go, so they both need to be the same, as in the first listed link.
I am sure you are all confused by now! lol
But the thing is, the redirecting isn't going through and doing all the links, only the first one.
I am just getting so frustrated, I feel I know this forum code so well from working on this, but I am stumped.
The problem only exists if the urls are in the same post. The redirect works great when using just one link in one post.
Just need to figure out how to get the redirect to recognize and process more than one link in a post.
If I can get this figured out the script will work perfect.
Here is the part of the code causing the problem:
eregi("[[:alnum:].,-_?+~%#/&=]*</a>",$Body,$reg3);
$txt = $reg3[0];
$txt = eregi_replace("</a>"," ",$txt);
$txt = eregi_replace(">","",$txt);
$txt = trim($txt);
$txt = str_replace("&","|.|",$txt);
if(strpos($Body,"href='")){
$Body = str_replace("href='","href='../redirect.php?txt=$txt&to=",$Body);
}elseif(strpos($Body,"href=\"")){
$Body = str_replace("href=\"","href=\"../redirect.php?txt=$txt&to=",$Body);
}elseif(strpos($Body,"href=")){
$Body = str_replace("href=","href=../redirect.php?txt=$txt&to=",$Body);
}
$postrow[$i]['Body'] = $Body;
Thanks!
Connie