RSS feed aggregator/combiner in PHP with Magpie RSS (v2)

March 3rd, 2010

I have recently upgraded the code to combine multiple RSS feeds, for the original version see this post.

To install, extract the following zip file to a directory where you want your combined feeds to be displayed, I use thydzik.com/combinedfeed as thydizk.com/feed is already used by Wordpress.

Edit index.php for your site, and make sure the temp directory has write permissions (mod 755). That should be it. Enjoy.

thydzik RSS feed aggregator v2.zip

Thanks to Magpie RSS and Feedcreator.

<?php
	$TMP_ROOT = "temp/"; //a atempory folder for storing the cached feeds, need to have write access (mod755)
	$DOMAIN_NAME = "http://thydzik.com/";
	$SITE_TITLE = "Travis Hydzik's blog feeds";
	$SITE_DESRIPTION = "A collection of Travis Hydzik's blog feeds";
	$SITE_AUTHOR = "Travis Hydzik";

	$FEEDS_ARRAY  = array( //the collection of urls linking to individual feeds
		"http://hydzik.com/feed/",
		"http://sonyaandtravis.com/feed",
		"http://thydzik.com/feed/"
	);

	$MAX_ITEMS = 10;
	$SHOW_FULL_FEED = FALSE;

	//stop editing from here onwards

	define('MAGPIE_DIR', '');
	define('MAGPIE_CACHE_DIR', $TMP_ROOT);

	//include magpie rss http://magpierss.sourceforge.net/
	@require_once(MAGPIE_DIR.'rss_fetch.inc');

	//include universal feed creator http://sourceforge.net/projects/feedcreator/
	@include(MAGPIE_DIR.'feedcreator.class.php');

	//create the basic rss feed
	$rss = new UniversalFeedCreator();
	$rss->useCached();
	$rss->title = $SITE_TITLE;
	$rss->description = $SITE_DESRIPTION;
	$rss->link = $DOMAIN_NAME;
	$rss->syndicationURL = curPageURL();

	//get all items is all feeds
	$total_temp = 0; //temp total number of posts in all rss feeds
	foreach ($FEEDS_ARRAY as $single_url) {
		$array_temp[$single_url]['page_title'] = url_grab_title($single_url); //grab the page title

		$rss_temp = fetch_rss($single_url);
		$items = array_slice($rss_temp->items, 0, $MAX_ITEMS);
		$array_temp[$single_url]['rss_data'] = $items;
		$total_temp += count($items);

		$array_temp[$single_url]['rss_pointer'] = 0;

		preg_match('@^(?:http://)?([^/]+)@i', $single_url, $matches);
		$array_temp[$single_url]['site_url'] = $matches[0];
	}

	while ($total_temp <> 0 && $MAX_ITEMS > 0){// loop while there are remaining posts to process
		$date_timestamp_temp = 0; //initialise to 0
		foreach ($FEEDS_ARRAY as $single_url) {
			$this_date_timestamp = $array_temp[$single_url]['rss_data'][$array_temp[$single_url]['rss_pointer']]['date_timestamp']; //get the date stamp of this post
			if ($this_date_timestamp > $date_timestamp_temp) { //if this date stamp is the newest, save where it came from
				$date_timestamp_temp = $this_date_timestamp; //update with this date stamp
				$temp_url = $single_url; //save the url feed
				$pointer_temp = $array_temp[$single_url]['rss_pointer']; //save the item number
			}
		}

		$total_temp --; //decrement total remaining posts to process
		$MAX_ITEMS --; //decrement number of posts to display
		$array_temp[$temp_url]['rss_pointer'] ++; //increment post index of used post rss

		//get the saved item
		$item = $array_temp[$temp_url]['rss_data'][$pointer_temp];

		//create the new item
		$item_new = new FeedItem();

		//add all the copied basics
		$item_new->title = $item['title'];
		$item_new->link = $item['link'];
		$item_new->date = $item['pubdate'];
		$item_new->author = $item['author'];
		$item_new->source = $temp_url;

		//to show full feed or blurb
		if ($SHOW_FULL_FEED) {
			$item_new->description = $item['content']['encoded'].'<p>Copyright &copy; <a href="'.$array_temp[$temp_url]['site_url'].'">'.$array_temp[$temp_url]['page_title'].'</a>. All Rights Reserved.</p>';
		} else {
			$item_new->description = $item['description']       .'<p>Copyright &copy; <a href="'.$array_temp[$temp_url]['site_url'].'">'.$array_temp[$temp_url]['page_title'].'</a>. All Rights Reserved.</p>';
		}

		$rss->addItem($item_new);
	}

	// a quick function the grab a pages title
	function url_grab_title($rss_url) {
  		$contents = file_get_contents($rss_url, TRUE, NULL, 0, 3072);
  		$contents = preg_replace("/(\n|\r)/", '', $contents);
		preg_match('/<title>(.*?)<\/title>/i', $contents, $matches);
		return $matches[1];
	}

	//get page url (for syndication), source http://www.webcheatsheet.com/PHP/get_current_page_url.php
	function curPageURL() {
		$pageURL = 'http';
		if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
		$pageURL .= "://";
		if ($_SERVER["SERVER_PORT"] != "80") {
			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
		} else {
			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		}
		return $pageURL;
	}

	// get your news items from other feed and display back
	$rss->saveFeed("RSS2.0", $TMP_ROOT."feed.xml");
?>
Bookmark and Share

Replace unorded list double arrows with bullets on default Kubrick theme

February 12th, 2010

A quick guide to how to replace right-pointing double angle quotation marks (») (U+00BB) with bullets (•) (U+2022).

Edit the following style.css in the wp-content\themes\default folder;

.entry ul li:before, #sidebar ul ul li:before {
	content: "\00BB \0020";
	}

to;

.entry ul li:before, #sidebar ul ul li:before {
	content: "\2022 \0020";
	}
Bookmark and Share

WordPress hacked – broken or blank refreshing admin/dashboard

February 12th, 2010

Recently, my Linux Go Daddy hosting servicing all three of my WordPress blogs were somehow accessed and malicious code inserted into every one of my php files.

The symptoms include;

  • A similar error in your RSS feed Warning: gzuncompress() [function.gzuncompress]: data error in /home/content/t/h/y/thydzik/html/blog/wp-includes/http.php on line 1818.
  • A broken Admin/Dashboard. This is due to the addition of the malicious script on the dynamic CSS files.
  • The Admin/Dashboard refreshes to a blank screen. This is due to the malicious script redirecting to other page.

What to look for;

  • The following code (truncated) inserted into all your php files;
<?php /**/ eval(base64_decode("aWYoZnVuY3Rpb25fZXhpc3RzKCdvYl...=="));?>
  • The following code when you view the source code in a browser;
<iframe src="http://iss9w8s89xx.org/in.php" width=1 height=1 frameborder=0></iframe>

What to do;

  • Change all your passwords.
  • Backup the ENTIRE site to local computer.
  • Cleanup all affected php files (it doesn’t seem to do anything to other file types). See below.
  • Re-upload your site.

Now to make things easier, I have created a VBS script that will automate the cleanup task. Place it in your local root director and run. A log file will be generated at C:\cleanUpWordPressPHP.txt listing the files it has cleaned.

Download the VBS script cleanUpWordPressPHP.vbs (right-click save-as)

Further information can be found on this Google support thread.

Bookmark and Share

Instructables – Turkish Delight and Button Purse

February 12th, 2010

Been a while since I have created an Instructable, the Turkish Delight was unpublished since 2008. Check them out.

Decorate a purse with colourful buttons
Decorate a purse with colourful buttons

Turkish Delight (Lokum) recipe
Turkish Delight (Lokum) recipe

Bookmark and Share

Heat problems with iStar BPN-350SAS 3×5.25″ to 5×3.5″ SATA Trayless Backplane

January 24th, 2010

Recently I posted about the use of an iStar BPN-350SAS in my RAID 6 array, well due to Australia’s extreme summer temperatures I have had a number of drives in the enclosure fail due to overheating.

Whilst I like the design and build of the BPN-350SAS there are some extreme flaws in the cooling design must likely due to implementation costs or interference with the units cosmetics.

Firstly, the 2x 60mm fans do not provide enough airflow; secondly, there are simply not enough paths for the air to flow. If you look inside the unit you will see 5 slits behind the PCB, and that is all there is for hot air exhaust. If you look at the front bezels, beneath the locking key hole plastic are 3 air vents, and this is all there is for the cool air intake.

Now, my solution has improved all off the above by first, removing the 60mm fans and installing 2x 80mm fans, these are connected via a molex connector. You can observe that 2x 80cm fans protrude 20mm on one side so it was necessary to install the protruding fan once the unit was installed into the case. Secondly, additional air holes on the back of the unit and on the top and under side of the unit to allow more air to circulate. I also removed the 5 springs that popped the drives out, but this was more to improve the backplane’s connection with the drives.

iStar BPN-350SAS modified - top air intake holes

iStar BPN-350SAS modified - top air intake holes and 80mm fan

iStar BPN-350SAS modified - botton air intake holes and 80mm fan

iStar BPN-350SAS modified - installation in case with 2 80mm fans

Bookmark and Share

Canon EFS 17-85mm IS stuck/locked zoom repair/disassembly

December 8th, 2009

It seems like this is a common problem with these lenses, the zoom gets stuck at 17mm with about 2mm of play (zoom movement). This problem is all due to a loose single screw on the inner lens assembly, sounds simple to fix, doesn’t it?

The challenge is trying to get to this single screw, which involves the separation of the lens into over 10 components, and the removal of about 20 small screws. Hopefully this guide will make the disassembly job a whole lot easier.

First, a reminder of what the lens looks like.

The stuck zoom lens

Turn the lens on its side with the connection contacts closest to you. There are 2 tiny Philips screws to remove.

Remove 2 screws holding the connection contacts

Balance the lens on its front with the metal lens screw lock ring visible. There are 4 small Philips screws to remove.

Metal lens screw lock

The metal ring can now be hinged apart. This next step is the most difficult. The inner black plastic ring is connected to the metal outer ring with 4 plastic clips in the inside. By pushing the clips towards the center, the black plastic ring can be removed from the top of the metal outer ring. Much care is needed due to the ribbon cable still being attached to the connection contacts allowing for a gap of roughly no more than 1cm.

Inner black ring and outer metal ring, clips visible

Once the inner black plastic ring is removed, the outer metal screw lock ring can be removed, exposing the PCB protected by a black plastic housing.

Both black and metal ring removed and PCB visible

Disconnect a single pressure ribbon cable attached to the inside of the black plastic housing which will then allow for its removal exposing the PCB.

Black plastic housing removed

Disconnect the 5 ribbon cables from the PCB. 2 are pressure connected, 2 with a hinged clip and 1 with a pressure clip. Unscrew a single Philips screw allowing the removal of the PCB.

Remove the 5 screws (circled in red) holding the outer black plastic ring allowing the remove of the black plastic ring. Then remove the 3 inner screws (circled in blue).

PCB removed

Turn the lens over and remove the rubber zoom grip. It can be removed by inserting a very thin screw driver under the rubber and working your way around.

Font of 17-85mm lens

Rubber zoom grip removed

With the rubber zoom grip removed, rotate the lens until you find a black rectangle sticker, peal this off to expose some contactors.

Black rectangle sticker removed exposing the contactors

With a Philip driver, unscrew the contactors. I actually performed this when reassembling the lens and slightly damaged them. It is better to remove them at the start to prevent this.

Contactors removed

There are 3 screws sitting on small metal tubes between a groove, finally remove these.

Screw in metal tubes within the groves

With these removed the inner lens portion can now be removed from the outer casing.

Outer casing removed from inner lens

You now have access to the problem screw(s) that need tightening. Once tightened, add some Loctite or nail-polish to stop the screws becoming loose again.

The final screws that need tightening

Some do’s and don’ts

  • don’t remove the front lens sticker or 3 screws behind it.
  • don’t remove the zoom sticker with m/ft increments.
  • don’t touch or disassemble any of the focusing ring!
  • do keep your UV filter on the lens, you can still remove the rubber grip with it on.
  • do make sure the focusing pin between the inner and outer len is in place.

References

Bookmark and Share

Pimsleur Mandarin Chinese Unit 1 Transcripts

October 27th, 2009

Due to a Notice of Copyright Infringement from Pimsleur, I have had to remove my transcripts, however due to the demand I have made available Taryn’s Transcripts (who’s site was also removed).

To download the transcripts as a zip file, enter your email address below and click submit. A download link will be sent to your inbox which is good for 5 minutes. Note: the file is 8mbs.

Leave a comment if there are any problems. I will eventually add all transcripts I have collected to the zip file.

Bookmark and Share

Dell PowerEdge SC430 with 8x WesternDigital 1TB drives in RAID-6

September 25th, 2009

Sometimes a man just wants to show of; this is one of those times.

My latest project was upgrading my full 2TB server (Adaptec 2410SA with 4x Seagate 750gb drives in RAID-5) to a 6TB server (Adaptec 3805 with 8x Western Digital 1TB drives in RAID-6).

Dell SC430 with installed iStar BPN-350SAS

Obviously, the Dell PowerEdge SC430 wasn’t designed for 9 drives (an extra for the OS) so it was quite challenging fitting it all on. It was made significantly easier by purchasing an iStar BPN-350SAS which allows for five 3.5″ drives to be squeezed into three 5.25″ bays. Plus it is tray-less, and looks very sleek. There was a significant problem in that the SC430 only supported two 5.12″ bays, after quite a bit of hacking the case up, I then realised that the motherboard was preventing the BPN-350SAS to fit in horizontally, with extreme luck and millimetre clearance, it did manage to fit in vertically, but with the extension of the P4 connector and two capacitors that were in the way. Refer to the following pictures.

Dell SC430 motherboard original

Dell SC430 motherboard modified

Dell SC430 showing motherboard clearance of iStar BPN-350SAS

The SC430 now had the two standard bottom hard disk drive cages and the five from the BPN-350SAS which meant I was still two drive spaces short. I removed the drive cage from a Dell Optiplex GX270, which I managed to luckily remove easily with a long stemmed drill to remove the rivets. I removed the SC430’s card fan, and riveted the GX270’s cage in place. This allowed me to still use rails for easy removal of drives. The SC430’s card fan was relocated as an exhaust fan to the back, mainly to stop BIOS from pausing on fan fault during boot-up.

Dell SC430 with new Optiplex GX270 HDD cage

Minor problems were; cable protrusion and the side panel not closing. This was fixed by using SATA power cables which had clip on connectors forming a natural right-angled connection, and also by carefully whittling the SATA cable connections so a tighter angle could be formed.

Dell SC430 cable management of 9 drives

Bookmark and Share