Skip to main content


If you are lazy to update your website, there's an alternative to it. It is called RSS feeder. With it, you have no need to update your website with latest news from other sites. If the sites provide RSS, you can feed your website with their news with RSS feeder and it's done automatically. But before that, you should know how to setup one. There are many RSS feeders in the market and I personally use MagPieRSS.

Add RSS feeds to your Web site using MagpieRSS
Syndication of material from other sites is a good way to get fresh content on your site. As visitors arrive at your site they can see a teaser for the syndicated content and a link to the publisher. If they are interested in an item they can follow the link to the original location. You can add syndicated content to your site using the Really Simple Syndication (RSS) protocol and a bit of PHP code in the form of an application called MagpieRSS. Here's how.

MagpieRSS is an RSS parser written in PHP. It supports RSS 0.9 and 1.0, with some RSS 2.0 support. MagpieRSS is a simple object-oriented backend which includes automatic caching of parsed RSS to reduce load on external Web sites. To use MagpieRSS on your Web site you will need PHP 4.2.0 (or greater) with XML (expat) support or PHP5 with libxml2 support. Download MagpieRSS. Extract the four main files (,,, and and the directory extlib and copy them to a directory named magpierss in the document root (where your web pages are stored) on your Web server.

Next, decide where the syndicated content will go on your site. If you want the content to appear on your front page then most likely you need to edit index.php. If you only have an index.html (not .php) then rename it to index.php as now you are adding some PHP code to it. Edit the file and add the following line at the top:


To actually fetch and parse the RSS add a call to fetch_rss() in your web page replacing the URL with the URL of the content you are syndicating.This function will return an array ($rss) that contains the syndicated content as an array of syndicated items along with some publisher information, such as the the name of the publisher (which is stored in $rss->channel['title']) and an optional description of the publisher (e.g. "The Online Newspaper for Linux and Open Source") which can be found in $rss->channel['description']. There is also $rss->channel['link'] which contains a general link to the publisher.The syndicated items can be accessed via $rss->items. A simple loop can be used to transverse the items one at a time:

foreach ($rss->items as $item)
// Your code here

Each item contains a title, link and description. $item['title'] contains the title of the article or story, $item['link'] is the link to the original and $item['description'] is the description of the story which is often the introduction paragraph or some sort of summary. To display a simple list of syndicated items use the following code:

foreach ($rss->items as $item) {
$href= $item['link'];
$title = $item['title'];
$desc = $item['description'];
echo "$title";
echo $desc;

Of course, the output is simple HTML, but from here you should be able to expand the code to suit the style and design of your site.

In the 0.91 version of the RSS specification the title is restricted to 100 characters and the description to 500. However there are no length limits in RSS 0.92 and greater. This can cause a problem for your Web site. Keeping a consistent look and feel to your Web site is important. If syndicated items are displayed too freely your site may start to look out-of-joint. Imagine you have similar code to the above listing news items in a side bar. What will happen if the description of a particular item is several thousand characters long? Or what if there was 50 items being syndicated?

Length validation is an important aspect to putting syndicated items on your site. To limit the number of items displayed, the easiest thing to do is slice the resulting array into a smaller chunk. After calling fetch_rss(), but before any processing, add the following line: $items = array_slice($rss->items, 0, 10); Which will shrink the array to contain only the first 10 items. Now the foreach loop can be run without any worries.

To validate the length of the description use the strlen() function:

if (strlen($desc) >= 80)
$desc = substr($desc,0,79)."...";

Here the description is shortened to be less than 80 characters with ... at the end to show that there is more text available. If you have shortened the description you might what to offer a link to the full syndicated text rather than a link to the original. That way users remain on your site longer. The full version of the syndicated item would then contain the link to the original. To do this you will need a script called something like readmore.php which uses MagpieRSS to display the full text as the main item on the web page along with your normal navigation, side bars and advertising. The parameters to the readmore.php would be the URL of the RSS feed and the item number you wish to display. One thing to watch is that some descriptions contain HTML as well as plain text. Blindly chopping the string could cause the string to be cut half way through a tag. Smart chopping is needed but that is beyond the scope of this article. However a crude solution is to use the PHP function strip_tags() which will remove all the HTML tags from the string. The full text version of the item displayed by the readmore.php can leave the tags intact.

To speed up your Web site and save unnecessary traffic for the publishers web server it is important to set up caching. MagpieRSS has built-in automatic caching. With caching MagpieRSS will only fetch and parse RSS feeds when the cache is too old.

To enable caching add the following lines to your script:

define('MAGPIE_CACHE_ON', 1);

By default MagpieRSS will cache items for one hour. This can be overridden using:

define('MAGPIE_CACHE_AGE', 1800);

Where 1800 is the number of seconds to cache objects (e.g. 30 minutes, 60*30).

MagpieRSS makes it easy to add syndicated content to your Web site, with only a small time investment you can improve the content of your site. Remember "content is king."

Thanks to Gary Sims for this article.
Source :


Popular posts from this blog

mplayer-gui error : Error in skin config file

After installing mplayer-gui package, I can't start it.

$ gmplayer MPlayer 1.1-4.8 (C) 2000-2012 MPlayer Team mplayer: could not connect to socket mplayer: No such file or directory Failed to open LIRC support. You will not be able to use your remote control. Error in skin config file on line 6: PNG read error in /usr/share/mplayer/skins/default/main Config file processing error with skin 'default'
After googling a bit, I found out that it was due to the png files in dir /usr/share/mplayer/skins/default. This is the default skin directory. To fix this error, I have to install ImageMagick package because I want to use the convert program to convert all of the png files to format png24. Thus, cd /usr/share/mplayer/skins/default; for FILE in *.png ; do sudo convert $FILE -define png:format=png24 $FILE ; done
Rerun gmplayer and all should be fine.
Have fun!
UPDATE (02-10-2017)

It doesn't work on Ubuntu 16.04 (xenial) but there's a workaround here.

You can update your syst…

Transparent proxy with squid 2.6

I have upgraded my squid from 2.5 STABLE13 to 2.6 STABLE18. Transparent proxy is setup differently in this version. You need this directives in squid.conf (usually in /etc or /usr/local/etc or /usr/local/squid/etc, check with your distro).

acl our_networks src
http_access allow our_networks
http_port transparent
always_direct allow all

where is your proxy server IP address.

If you have flushed your iptables, create new rule:

iptables -t nat -A PREROUTING -i eth0 -p tcp –dport 80 -j REDIRECT –to-port 3128

where 3128 is the port where squid is running.

postfix - mailbox size limit and message size limit

postfix is my MTA of choice. I use it for my mailserver because its simplicity , security and sendmail-compatible (the widely used smtp in the world but not as secure). It is also extensible by plugging other servers for various purposes (antispam, antivirus,database etc).

I had one problem with file attachment larger than 10MB. Users couldn't send it although I have setup squirrelmail (SM) to be able to attach files summed up more than 20MB and I had modified php settings as per here. The problem was not in SM setting. It was postfix. By default, attachment size that can be sent by postfix is 10MB ~ 10240000 byte. How did I know it? I looked in log file (for my system it is in /var/log/mail/errors. For other system, the file to look is /var/log/maillog). The line looked like this:

Feb 26 16:30:53 webmail postfix/sendmail[30775]: fatal: Message file too big

Open /etc/postfix/ with a text editor of choice and find message_size_limit directive an…