Combine Two WordPress RSS feed into a single Feed

If you have two blogs installed on same domain, you may want to combine two blogs feed into one blog feed. It will provide few benefits:

a) Ease of feed management

b) More readers

c) Better feed stats and much more

Required tools

=> MagpieRSS rss parser for php (download link)

=> FeedCreator lets you easily create RSS 0.91, 1.0 or 2.0, ATOM 0.3 and OPML 1.0 feeds with PHP (download link).

Download required tools

Download required tools to your desktop and upload to your server in myfeed directory using ftp / sftp client. Following instructions assumes that you have a shell access to server:
mkdir myfeed
cd myfeed
wget http://internap.dl.sourceforge.net/sourceforge/magpierss/magpierss-0.72.tar.gz
tar -zxvf magpierss-0.72.tar.gz
cp magpierss-0.72/*.inc .
mv magpierss-0.72/extlib/ .
rm -rf magpierss-0.72*
wget http://www.bitfolge.de/download/feedcreator_172.zip
unzip feedcreator_172.zip
rm *.zip *.txt

Create rss.php script

Now you have all required tools, just create rss.php script :

<?php
$TMP_ROOT = "/tmp";
$DOMAIN_NAME = "http://theos.in/";
$SITE_TITLE = "Your Site / blog Title";
$SITE_DESRIPTION = "Your Site / blog Description";
$SITE_AUTHOR = "Vivek";
$SITE_LOG_URL = $DOMAIN_NAME."logo.jpg";
$RSS_DIR = "/home/lighttpd/theos.in/http";
 
define('MAGPIE_DIR', $RSS_DIR.'/myfeed/');
define('MAGPIE_CACHE_DIR', $TMP_ROOT.'/rsscache');
 
/* include required files */
@require_once(MAGPIE_DIR.'rss_fetch.inc');
@include(MAGPIE_DIR.'feedcreator.class.php');
 
/* Set RSS properties */
$rss = new UniversalFeedCreator();
$rss->useCached();
$rss->title = $SITE_TITLE;
$rss->description = $SITE_DESRIPTION;
$rss->link = $DOMAIN_NAME;
$rss->syndicationURL = $DOMAIN_NAME."/rss/rss.php";
 
/* Set Image properties */
$image = new FeedImage();
$image->title = $SITE_TITLE. " Logo";
$image->url = $SITE_LOG_URL;
$image->link = $DOMAIN_NAME;
$image->description = "Feed provided by ". $SITE_TITLE. ". Click to visit.";
$rss->image = $image;
 
/**************************************************************
showSummery() - Fetch and build new feed
$url = Feed url
$num = Show the most recent posts (default = 10 )
$showfullfeed = true or false, for each article, show full text or summary (default false / summary text)
***************************************************************/
function showSummery($url,$num=10,$showfullfeed=false){
global $rss, $DOMAIN_NAME, $SITE_AUTHOR, $SITE_TITLE;
$num_items = $num;
@$rss1 = fetch_rss( $url );
if ( $rss1 )
{
        $items = array_slice($rss1->items, 0, $num_items);
        foreach ($items as $item)
        {
                $href = $item['link'];
                $title = $item['title'];
                if ( ! $showfullfeed ) {
                        $desc = $item['description'];
                }else{
                        $desc =  $item['content']['encoded'];
                }
                $desc .=  '<p>Copyright &copy; <a href="'.$DOMAIN_NAME.'">'.$SITE_TITLE.'</a>.  All Rights Reserved.</p>';
                $pdate = $item['pubdate'];
                $item = new FeedItem();
                $item->title = $title;
                $item->link = $href;
                $item->description = $desc;
                $item->date = $pdate;
                $item->source = $DOMAIN_NAME;
                $item->author = $SITE_AUTHOR;
                $rss->addItem($item);
        }
}
else
{
   echo "Error: Cannot fetch feed url - ".$url;
}
} // end showSummery()
//***************************************************************/
// Add your feed below:
// showSummery("http://path-to/url/feed",number-of-rss-items,false)
//****************************************************************/
showSummery("http://theos.in/feed/");
showSummery("https://www.cyberciti.biz/tips/feed/");
showSummery("https://www.cyberciti.biz/faq/feed/",5,false);
 
// get your news items from other feed and display back
$rss->saveFeed("RSS1.0", $TMP_ROOT."/rsscache/feed.xml");
?>

Customize script

Set temporary directory to cache rss feed, web server must be able to write to this directory.
$TMP_ROOT = "/tmp";
Set path to rss directory:
$RSS_DIR = "/home/lighttpd/theos.in/http";
Set your domain name, site title, description and author name:
$DOMAIN_NAME = "http://theos.in/";
$SITE_TITLE = "Your Site / blog Title";
$SITE_DESRIPTION = "Your Site / blog Description";
$SITE_AUTHOR = "Vivek";

Finally, set logo file name (replace logo.jpg with actual logo file name):
$SITE_LOG_URL = $DOMAIN_NAME."logo.jpg";

showSummery() function

showSummery($url,$num=10,$showfullfeed=false) fetch remote feed url and build new feed. It accept following arguments:

  • $url = Feed url
  • $num = Show the most recent posts (default = 10 )
  • $showfullfeed = true or false, for each article, show full text or summary (default false )

To combine two RSS feed http://theos.in/blog1/feed/ and http://theos.in/blog2/feed/, call showSummery():
showSummery("http://theos.in/blog1/feed/");
showSummery("http://theos.in/blog2/feed/");
showSummery("http://other-my-blog.com/feed/",5,true); // full feed

Test it

Open a web browser and type url http://your-domain.com/myfeed/rss.php

Download all files and required tools

=> You can download rss.php and required tools here (all GPL licensed except FeedCreator which is under LGPL)

Other tools – Yahoo Pipes

You can use 3rd party service such as Yahoo Pipes, which is an interactive feed aggregator and manipulator. Personally, I like to keep more control on my feed, hence I wrote this script.

How to: Find out domain expiration date

My friend recently lost her domain name as she forgot to renew it. Now there is no way she can get back the domain name. So how do you find out domain expiration date?

There are 3 simple ways:

By checking the public WHOIS database

Visit whois service here and enter your domain name. You can also use your domain registrar whois service to find out information.

By logging into your domain service providers account

Login to your domain registrar account and list expiring domain. Make sure you set all domains to auto renewal. Finally, make sure your credit card / payment information is upto date to avoid delays.

By using automated shell scripts for Linux /UNIX / Mac OS X

You can grab modified shell script that run as a cron job from your own Mac OS X / Unix computer. This script checks to see if a domain has expired. It can be run in interactive and batch mode, and provides facilities to alarm (email) if a domain is about to expire in advance.

Free Windows Software

If anyone has any information about free domain remainder utility for Windows XP / Vista, please add them in the comments.

Most domain register provides a series of reminder emails to you as the domain name approaches its expiry date. Make sure you whitelist those email address. If domain names are quite important register them for 5-10 years and lock all domain names.

Javascript tutorial step by step – A beginners guide

Javascript is a scripting language based on the concept of prototype-based programming. The language is best known for its use in websites as client-side JavaScript. JavaScript was originally developed by Brendan Eich of Netscape under the name Mocha, later LiveScript, and finally renamed to JavaScript.

JavaScript is a prototype-based scripting language with a syntax loosely based on C. Like C, the language has no input or output constructs of its own.

Why should a webpage author use JavaScript in addition to HTML?

* Javascript adds user interactivity.
* Javascript enhances visual displays.
* Javascript allows client-side user form validation.
* Javascript provides more seamless integration with user plug-ins.
* Javascript allows access to some system information that HTML does not.

Why would you want to learn to program in JavaScript when there are so many canned scripts available for cutting and pasting into your own pages. Here are a few good reasons:
* Sometimes you want to customize a canned program to make it unique.
* Some functions that you want to accomplish have not been written yet.
* Many scripts are browser-centric (notably MSIE) or out of date.
* JavaScript is cross-platform. You can write programs that work on Windows, MacIntosh and Linux systems.
* Application users do not have to bother with downloading a JavaScript application, they just access your webpage. And version control is simple as there is one active version — the one on your website.
* The JavaScript language syntax is similar to that of C and Java so it makes a great starting point on a programming career.
* No proprietary development system is required. A simple editor is all that you need to write Javascript code. A browser is all that is needed to run JavaScript.
* JavaScript code is open source and freely available.

This guide try to answer all of the above questions and it will teach javascript step by step.

Windows XP – Batch file script to copy all files

This is a small script I use to copy file quickly from source to destination. This script should work under Windows XP, 2000, 2003, 98/95 etc.

Syntax
Script accept two command line argument as follows:
mycopy.bat {source} {destination}

Where,
mycopy.bat – This script copies files and directories, including subdirectories using Windows xcopy program. You must pass following two arguments/parameters
source – Use to specify the location and names of the file/directory you want to copy.
destination – Use to specify the destination of the files you want to copy.

How do I use this script?

For example copy all *.doc file from C:\DATA to \\SERVER\BACKUP directory, you need to execute script as follows:
Cd c:\data

mycopy.bat *.doc \\SERVER\BACKUP

OR copy all files from c:\data to z:\

mycopy.bat c:\data\** z:\

mycopy.bat source code

@rem BATCH FILE
@echo off
if "%1" == "" goto error1
if "%2" == "" goto error2
@rem * Copy from source to destination including subdirs and hidden
@rem * File
xcopy "%1" "%2" /S /E /H
goto endofprogram
:error1
echo You must provide source
echo Syntax:
echo %0 source destination
goto endofprogram
:error2
echo You must provide destination
echo Syntax:
echo %0 source destination
goto endofprogram
:endofprogram

Where,

  • Line # 03 and 04 make sure we pass the command line argument.
  • Line # 08 – If both command line arguments (source and destination) are provided it will copy files using XCOPY program.