Adding Nofollow to RSS code (PHP)

Discussion in 'PHP' started by Andy_ameed, Jan 25, 2010.

  1. #1
    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?
     
    Andy_ameed, Jan 25, 2010 IP
  2. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    SmallPotatoes, Jan 25, 2010 IP
  3. Andy_ameed

    Andy_ameed Active Member

    Messages:
    129
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    unfortunately they do not provide a way around i had contacted them about this before.
     
    Andy_ameed, Jan 25, 2010 IP
  4. aquilax

    aquilax Member

    Messages:
    126
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #4
    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):
     
    aquilax, Jan 25, 2010 IP
  5. Andy_ameed

    Andy_ameed Active Member

    Messages:
    129
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #5
    Its not working. but no error is listed.
     
    Andy_ameed, Jan 25, 2010 IP
  6. aquilax

    aquilax Member

    Messages:
    126
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    33
    #6
    Ok just check what the include() is returning and modify it to suit your needs.
     
    aquilax, Jan 25, 2010 IP
  7. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #7
    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.
     
    Last edited: Jan 25, 2010
    SmallPotatoes, Jan 25, 2010 IP
  8. Andy_ameed

    Andy_ameed Active Member

    Messages:
    129
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #8
     	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.
     
    Andy_ameed, Jan 25, 2010 IP
  9. SmallPotatoes

    SmallPotatoes Peon

    Messages:
    1,321
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    0
    #9
    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.
     
    SmallPotatoes, Jan 25, 2010 IP
  10. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #10
    http://forums.digitalpoint.com/showpost.php?p=13366884&postcount=11
     
    danx10, Jan 25, 2010 IP