The code below is a RSS feed code which out put 10 URLS. All these urls are Dofollow. <?php $olderror_reporting =error_reporting(0); include ("http://rssfeedreader.com/rss3/rss.php?url=http%3A%2F%2Ffeeds.reuters.com%2Freuters%2FUSVideoTopNews&newpage=1&chead=&atl=&desc=&owncss=1&eleminate=&auth=&dts=&width=300&max=10&tlen=0&rnd=1&bt=3&bs=Double&nmb=&ntb=&naf=&nst=&nwd=0&nht=0&dlen=0&lstyle=-1&lc=Blue&bg=White&bc=Gray&spc=&ims=&tc=&ts=11&tfont=Verdana,+Arial,+Sans-serif&rf=".$HTTP_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_VARS['PHP_SELF']."&phpout=1"); error_reporting($olderror_reporting); ?> Code (markup): Can anyone add the Nofollow to this PHP code. or is it possible?
The feed is being generated by rssfeedreader.com. The best thing to do is check their documentation to see if they offer an easy way to do it. Otherwise you could post-process the returned feed with regular expressions, but that's a more fragile solution.
Why don't you try something like that. I'm not sure if it will work <?php $olderror_reporting =error_reporting(0); $text = file_get_contents("http://rssfeedreader.com/rss3/rss.php?url=http%3A%2F%2Ffeeds.reuters.com%2Freuters%2FUSVideoTopNews&newpage=1&chead=&atl=&desc=&owncss=1&eleminate=&auth=&dts=&width=300&max=10&tlen=0&rnd=1&bt=3&bs=Double&nmb=&ntb=&naf=&nst=&nwd=0&nht=0&dlen=0&lstyle=-1&lc=Blue&bg=White&bc=Gray&spc=&ims=&tc=&ts=11&tfont=Verdana,+Arial,+Sans-serif&rf=".$HTTP_SERVER_VARS['SERVER_NAME'].$HTTP_SERVER_VARS['PHP_SELF']."&phpout=1"); $text = string_replace(' href=', ' rel="nofollow" href=', $text); eval($text); error_reporting($olderror_reporting); ?> Code (markup):
Try replacing: $text = string_replace(' href=', ' rel="nofollow" href=', $text); eval($text); PHP: with $text = str_replace(' href=', ' rel=\"nofollow\" href=', $text); echo $text; PHP: By the way, never use eval() unless you have personal direct knowledge that the string you are passing to it is, and always will be, safe. That is not the case here since it comes from an outside source. The backslashes are required since the RSS link generator thing is creating Javascript.
Haiti focuses on health and housing "; $arnews[0] .= " "; $arnews[1]="Ethiopian plane crashes ex-Beirut "; $arnews[1] .= " "; $arnews[2]="Quake survivor recovers in hospital "; $arnews[2] .= " "; $arnews[3]="Afghanistan elections postponed "; $arnews[3] .= " "; $arnews[4]=""Basterds" big SAG winner "; $arnews[4] .= " "; $arnews[5]="WHO news conference in Haiti "; $arnews[5] .= " "; $arnews[6]="Quake survivor rescued "; $arnews[6] .= " "; $arnews[7]="Bin Laden tape claims plane attack "; $arnews[7] .= " "; $arnews[8]="Thousands of monks bless Rajapaksa "; $arnews[8] .= " "; $arnews[9]="Haiti's poorest struggling "; $arnews[9] .= " "; if ($rnd) { shuffle($arnews); } while (list(, $value) = each ($arnews)) { print ($value); print (" "); } print(" ");print("RSS to HTML");print(" Increased Web Site Traffic");print(" "); ?> Code (markup): what i have quoted above is the out put when the eval is replaced. The links are output, but as we can see the codes before it is the problem. Guys anyways thanks a lot trying.
I looked more closely at the output from rssfeedreader. It produces PHP code which does require eval() or include(). Therefore I think it's a very bad idea to use it. Maybe someone else can help you further but I cannot in good conscience.