Archive for June, 2008

wordpress relative url

Monday, June 30th, 2008

edit wp-includes/functions.php

function get_option( $setting ) {
	global $wpdb;

	if (in_array($setting, array('siteurl', 'home'))) {
		if (ereg('(wp-includes)', $_SERVER['PHP_SELF'], $r)) {
			return ('http://'.$_SERVER['SERVER_NAME'].(
					$_SERVER['PHP_SELF'], 0,
					strpos($_SERVER['PHP_SELF'], $r[0])
		} else if (ereg('wp-admin', $_SERVER['PHP_SELF'])) {
			return 'http://'.$_SERVER['SERVER_NAME']
			. dirname(dirname($_SERVER['PHP_SELF']));
		} else {
				if (file_exists($_SERVER_SCRIPT_FILENAME.'/wp-content')) {
				if ($_SERVER_SCRIPT_FILENAME == '.') break;
			return 'http://'.$_SERVER['SERVER_NAME'].$_SERVER_PHP_SELF;

Blizzard Announces Diablo 3

Monday, June 30th, 2008

After a week long tease by Blizzard, Diablo 3 has just been announced in Paris. The splash screen has been updated at their homepage.

Install Adobe Acrobat Reader 8.1.2 on Ubuntu 8.04

Monday, June 30th, 2008
$ sudo wget \
-O /etc/apt/sources.list.d/medibuntu.list
$ sudo apt-get update
$ sudo apt-get install medibuntu-keyring
$ sudo apt-get update
$ sudo apt-get install acroread

PDT: PHP Development Tools for Eclipse Platform

Friday, June 27th, 2008

The PDT project provides a PHP Development Tools framework for the Eclipse platform. This project encompasses all development components necessary to develop PHP and facilitate extensibility. It leverages the existing Web Tools Project in providing developers with PHP capabilities.

Project Principles:
* Intuitive and easy to learn
* Seamless integration with the Web Tools project
* Adherence to Eclipse standards
* Extensibility
* Continuous support of PHP developments


Friday, June 27th, 2008

phpDocumentor tags are very similar to tags for the JavaDoc tool for Sun’s Java Programming Language. Tags are only parsed if they are the first thing on a new line of a DocBlock. You may use the @ character freely throughout documents as long as it does not begin a new line. An example:

* tags demonstration
* @author this tag is parsed, but this @version tag is ignored
* @version 1.0 this version tag is parsed

Web site blocking techniques

Wednesday, June 25th, 2008

To deploy the web-site blocking mechanism in Squid, add the following entries to your Squid configuration file (in my system, it’s called squid.conf and it’s located in the /etc/squid directory):

acl bad url_regex “/etc/squid/squid-block.acl”
http_access deny bad

The file /etc/squid/squid-block.acl contains web sites or words you want to block. You can name the file whatever you like. If a site has the URL or word listed in squid-block.acl file, it won’t be accesible to your users. The entries below are found in squid-block.acl file used by my clients:

With the squid-block.acl file in action, internet users cannot access the following sites:

* Sites that have addresses ending with
* Sites that have addresses ending with
* Sites containing the word “sex” in its pages

You should beware that by blocking sites containing the word “sex”, you will also block sites such as Middlesex University, Sussex University, etc. To resolve this problem, you can put those sites in a special file called squid-noblock.acl:


Javascript: Get URL Variables

Tuesday, June 24th, 2008
<script type="text/javascript">
// Read a page's GET URL variables and return them as an associative array.
function getUrlVars() {
  var vars = [], hash;
  var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
  for(var i = 0; i < hashes.length; i++) {
    hash = hashes[i].split('=');
    vars[hash[0]] = hash[1];
  return vars;
// Example for URL
var hash = getUrlVars();
// alert(hash['hello']); // prints 'bonjour'
// alert(hash['goodevening']); // prints 'bonsoir'

Reset Wordpress Password

Wednesday, June 18th, 2008

update wp_users set user_pass = md5(’admin’) where user_login = ‘admin’;

Javascript String Search

Tuesday, June 17th, 2008

This method is used to search for a match between a regular expression and the specified string. If a match is found, the search method returns the index of the regular expression within the string. If no match is found, a value of -1 is returned.

The first example of code below uses the search method to look for a match between the regular expression ‘rExp’ and the characters in the ‘myString’ string object and displays the resulting value in the browser. In the second example, removing the ‘i’ (ignore case) flag from the regular expression causes the value of the search to be returned as -1

myString = new String(”Go to”)
rExp = /;
results =


myString = new String(”Go to”)
rExp = /;
results =


Fixing ffmpeg on Ubuntu

Tuesday, June 17th, 2008

For a litany of legal reasons, ffmpeg does not come with all of the necessary things enabled for you to encode video for the iPod Video by default. Therefore, we need to build it from source and install some other libraries and programs, as well. Make sure you have multiverse and universe enabled.

sudo apt-get remove ffmpeg
sudo apt-get install liba52-dev libdts-dev libgsm1-dev libvorbis-dev  libxvidcore4 \
libxvidcore-dev libdc1394-dev libfaac-dev liblame-dev libx264-dev libfaad2-dev libtheora-dev \
libsdl1.2-dev libmpeg4ip-dev
tar jxvf ffmpeg-export-snapshot.tar.bz2
cd ffmpeg-export-*
./configure --prefix=/usr/local --disable-debug --enable-shared --enable-gpl --enable-postproc \
--enable-swscale --enable-pthreads --enable-x11grab --enable-liba52 --enable-libdc1394 \
--enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libtheora \
--enable-libvorbis --enable-libx264 --enable-libxvid
sudo make install

Trying to compile ffmpeg from svn gives the following error:
libavcodec/libx264.c: In function ‘X264_init’:
libavcodec/libx264.c:224: error: ‘X264_ME_TESA’ undeclared (first use in this…

Solved. Installing these two packages: