I would like some help in getting a code which can render all links in a webpage no follow. can any of you guys to a nofollow into this feed code <?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): Thanks in advance
Its an rss feed code. The thing is i want the links i generate to be nofollow. u can try this on any blank php file.
Too start with: You can't use include() with url's it can only be used with files which are hosted with your site. Secondly; i don't see why your defining the error_reporting() value within a variable, then recalling the function within the variable... But try this: <?php $file = 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=".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."&phpout=1"); //strip php tags so eval() can run... $file = str_replace("<?php", "", $file); $file = str_replace("?>", "", $file); //strip js so php can parse. $file = preg_replace('#<script[^>]*>.*?</script>#is','',$file); //change links to nofollow $file = str_replace(" target=_blank>", " target=_blank rel=\"nofollow\">", $file); eval($file); ?> PHP:
Parse error: syntax error, unexpected T_STRING in /home/reazun2/public_html/news.php(243) : eval()'d code on line 34
Woops, forgot to escape it. <?php $file = 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=".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."&phpout=1"); //strip php tags so eval() can run... $file = str_replace("<?php", "", $file); $file = str_replace("?>", "", $file); //strip js so php can parse. $file = preg_replace('#<script[^>]*>.*?</script>#is','',$file); eval($file); ?> PHP:
$content = file_get_content($url); $content = preg_replace('%<a\b%', '<a rel="nofollow"', $content); echo $content; PHP: @danx10 - He isn't trying to eval the code, he's just trying to output it to the browser. include WILL allow you to include a file from another server if your php config allows them, although its not recommended thats for sure. All that was wanted was to add the attribute rel="nofollow" to links (i'm assuming to stop search engines from using them for PR)
Since, he used include() I assumed he'd want to execute the code. Quote from php.net: Which is why i used file_get_contents().
That's fair enough, although PHP4 has been deprecated for a few years now so he shouldnt have it installed anywhere (and nor should any hosts although I believe yahoo still supports it!)
Guys i am very thank full for your help. I have tried the last code DanX10 Gave here. Its not showing an error but the code is still out putting dofollow links. Thanks Jay6390. $content = file_get_content($url); $content = preg_replace('%<a\b%', '<a rel="nofollow"', $content); echo $content; how should i add this part to DanX10's code. Please guide me. thanks
This should work: <?php $file = 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=".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."&phpout=1"); //strip php tags so eval() can run... $file = str_replace("<?php", "", $file); $file = str_replace("?>", "", $file); //strip js so php can parse. $file = preg_replace('#<script[^>]*>.*?</script>#is','',$file); $file = preg_replace('%<a\b%', '<a rel="nofollow"', $file); eval($file); ?> PHP:
I had just put that code. Parse error: syntax error, unexpected T_STRING in /home/reazun2/public_html/news.php(241) : eval()'d code on line 5 This is the error im getting.
$url = "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=".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."&phpout=1"; $content = str_replace('dofollow', 'nofollow', file_get_contents($url)); echo $content; PHP: