Tag Archives: PHP

Installing PHP and Apache module under /home

Let’s say you have your own Apache 2 setup in your home directory, and you want to build and install PHP as well, and set it up as an Apache module without root privileges (e.g. if you want to use a different PHP version than the one installed globally).

You may run into problems such as PHP’s configure script not detecting apxs2 (and thus not building an Apache module). Continue reading

Wikipedia Watchlist RSS

Wikipedia’s Watchlist has a RSS feed, which is a nice way to keep track changes on your watched articles. However, the RSS feed doesn’t seem to conform to the RSS standard, and confuses some feedreaders – notably, Opera M2.

Here’s a simple PHP script, which you can place on your website, that’ll fix the RSS feed. You’ll need to give it the URL to your RSS feed (which you can get by subscribing to your watchlist), since it contains your secret API key.

$rss_url = 'http://en.wikipedia.org/w/api.php'
	. '?action=feedwatchlist'
	. '&allrev=allrev'
	. '&hours=72'
	. '&wlowner=YOUR_USERNAME_HERE'
	. '&wltoken=YOUR_API_KEY_HERE'
	. '&feedformat=rss';
$feed = `wget -q -O - '$rss_url'`;
$rows = explode("\n", $feed);
header('Content-type: application/rss+xml');
foreach ($rows as $row)
	if (strpos($row, '<item>')!==false)
		$alldata = '';
	if (strpos($row, '<guid>')!==false)
	$alldata .= $row;
	if (strpos($row, '</item>')!==false)
		$row = '<guid isPermaLink="false">' 
			. md5($alldata) 
			. "</guid>\n"
			. $row;
	echo $row . "\n";