Forums / Cotonti / Support / How to limit RSS feed output

Prevent content theft

foxhound
#1 2012-05-23 11:56

I have found many people use the RSS feed of my Genoa website. I am of course very happy with that however, this has a downside.
There are websites out there who are fully streaming my content without really doing their best to indicate the content is from my website and what is even worse they stream this content into their Facebook and Twitter accounts so they get followers and readers for my content without them doing any work themselves.

I don't want to remove the RSS feed all together since hundres of people use it, I just want to limit output. I have been going through the rss.php but have not found any reference where the max number of characters to be outputted can be added.
I noticed other CMS'es have an option to set max character output of their RSS feeds but to my knowledge thats not the case for the default Cotonti RSS feed?

Anyone here knows how I can make it so the RSS feed outputs like (for example) 60 characters and than automatically generates a "read the full article here" (linking to my website) to direct the readers to my website?

This way even if those sites keep streaming my RSS feed to their social sites their readers will soon be annoyed enough to have to go from site to site to read the fulll article they will instead follow/register on my own social sites, right? smiley

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kingsley
#2 2012-05-23 12:36

maybe take a look at the RSS in Siena? That one can be limited to a certain amount of characters, so maybe you can copy/extract it from there..

Trustmaster
#3 2012-05-23 12:52

In rss.php line 400 find

return $text;

and replace it with

return mb_substr($text, 0, 60)."<br /><span class=\"readmore\"><a href=\"".$pag_pageurl."\">".$L['ReadMore']."</a></span>";
May the Source be with you!
foxhound
#4 2012-05-23 14:58

@Kingsley
I was not aware of that (not using Sienna yet except a few preparations for new sites), thx for the tip.

@Trustmaster
Excellent, thanks for that code. I have added it to the RSS, now I need to wait till those sites update to see what content they are now showing to be sure its working :)

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kingsley
#5 2012-05-23 16:20

As usual, trustmaster beats me with his knowledge :P (like that was difficult :D)

Trustmaster
#6 2012-05-23 16:43

@Kingsley

I don't really exprect everyone to be a PHP coder here, so nevermind.

@foxhound

You can check how it's doing immediately by browsing http://example.com/rss.php

May the Source be with you!
Kingsley
#7 2012-05-23 17:29

I know, just kidding around :)

foxhound
#8 2012-05-25 08:48
#34394 Trustmaster:
@foxhound

You can check how it's doing immediately by browsing http://example.com/rss.php

Yes, I understood that and I did view my changes there. I was just interest to see what would happen on those sites.
And yes, everything works but to be honest I am not really happy with how my RSS feed is now looking. Its a bit messy, have a look at it here:
http://www.armaholic.com/rss.php

Due to limitting the number of characters the text in the RSS is cut of in a very ugly way. That was the intention indeed but right now I am trying to find some more ways to protect my content.
So I was thinking, instead of limitting the content I wanted to remove the images from the RSS so sites using my RSS wont look so nice with their pictureless articles.
I searched around on the net and saw many people prevent images to show in their RSS by adding some rules to their CSS but I guess since this is a pure PHP RSS that wont work.
But I found a function which I am now trying to use but it is actually stopping any output from the RSS when I add it.
This is the function I found ( http://bavotasan.com/2011/a-better-way-to-remove-images-from-a-wordpress-post/ ), I changed it a bit hoping it would work in the genoa RSS:

// custom function to remove pics from the RSS
function remove_images( $text ) {
   $postOutput = preg_replace('/<img[^>]+./','', $text);
   return $postOutput;
}
add_filter( 'sed_parse', 'remove_images', 100 );


And its very possible I am doing something stupid here but yeah ........... PHP is not mine, I am just trying wink

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Trustmaster
#9 2012-05-25 09:20

The most radical solution would be stripping all tags and then limiting the output to 60 characters:

return mb_substr(strip_tags($text), 0, 60)."<br /><span class=\"readmore\"><a href=\"".$pag_pageurl."\">".$L['ReadMore']."</a></span>";
May the Source be with you!
foxhound
#10 2012-05-31 12:29

Thanks for that code Trustmaster!
I added something extra to it to allow certain html codes just so the RSS output would not look idiotic or so non-apealing RSS readers would just end the RSS readers. This is the code I use now:

return mb_substr(strip_tags($text, '<strong><a><i><ul><ol><center><br><img>'), 0, 700)." ........... <br /><br /><span class=\"readmore\"><a href=\"".$pag_pageurl."\">".'Read the full article on Armaholic'."</a></span><hr style=\"size:5px;\">";


 

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kingsley
#11 2012-05-31 16:20

No shit, Armaholic is ur site? Cooolll.. :) Me play too..