Archive for March, 2006

counterize patch 2: excluding users, the first step

Posted in WordPress on March 31st, 2006 by Johan Huysmans – 1 Comment

Adding a counter on your site is great. But if you want to get the real number of visitors you may not count your own pagehits.
In the counterize plugin is an excludelist where you can add your own ip. But I’m always on different locations and what if someone else from the same network visits your website… it doesn’t get counted.

I know 1 thing… If I visit my blog, I’m already logged in (he remembers my login). So what I made is an extra check before the page-hit get logged. If I’m logged in, it doesn’t need to be counted.

Adding these simple lines does the trick (added them at line 631)

# let's check it is a logged in user.
# If he's logged in, we don't count him.
if ($checkval == 0) {
     global $user_ID;
     get_currentuserinfo();
     if('' == $user_ID)
     $checkval=0;
} else {
     $checkval=1;
}

This is hard coded, but I will add an option to the admin webinterface of counterize that can enable or disable this option and maybe add an textfield so you can decide which user doesn’t need to be logged.

Enjoy ! You can find the patchfile here.

counterize patch

Posted in WordPress on March 29th, 2006 by Johan Huysmans – Be the first to comment

I have been using counterize for a while. This is a wordpress plugin that counts the page-hits of your blog. It comes with a nice admin interface containing detailed information.

This plugin is designed to be located directly in the wp-plugins directory together with its images. I wanted to have all files of the counterize plugin located in the counterize directory (a subdirectory of plugins), so i needed to change the paths of the images and links to the .php file in the counterize.php.

It isn’t a lot of work to update all the paths, there are only 8 instances that needs to be changed located on line 135, 188, 240, 678, 731, 790, 853 and 1224. For the lazy guys that have version 0.50 of counterize I created a patch file, you can find that file here.

Here is a manual for applying that patch:

$ cd /path/to/wp-content/plugins/
$ mkdir counterize
$ mv counterize.php counterize_blue.png counterize_green.png counterize_red.png counterize_yellow.png counterize
$ patch counterize/counterize.php /path/to/downloaded/patch1

168.254.0.0 route

Posted in Linux SysAdmin on March 17th, 2006 by Johan Huysmans – Be the first to comment

Ever noticed there exists a route for the 168.254.0.0 network in your route table?

[root@raskas ~]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.0        *               255.255.0.0     U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
default         gw              0.0.0.0         UG    0      0        0 eth0

This is the network used by windows when there is no dhcp server available. Technologies behind this are Zeroconf (Zero Configuration Networking) and APIPA (Automatic Private IP Addressing).

But on a linux server, or even desktop, we don’t want to see that route.

We can manually remove this route by

[root@raskas ~]# route del -net 169.254.0.0/16

but after a network reboot the route will be back.

The route can be permanently removed by adding following line in /etc/sysconfig/network

NOZEROCONF=yes

note: tested on redhat based distros

backup script

Posted in Backup on March 10th, 2006 by Johan Huysmans – Be the first to comment

Since several weeks I’m working with backups.

I created a script that dumps databases. It currently only supports mysql, ldap and postgresql. The script is not difficult, it just uses the dump program of the database and writes that to a file.

I created an other script that does the real backup. It uses rsync to copy the data to the other host, together with ssh. With some simple commands over ssh it will keep a history. It also will create a daily incremental backup linked to the weekly full backup.

http://www.raskas.be/blog/scripts/database-backup/ will bring you to the information about the database script.

http://www.raskas.be/blog/scripts/full-backup/ will bring you to the information about the backup script.

I made those script available online so everybody can use and improve those scripts. If you improved the script, please let me know, maybe I will update my scripts with your modifications.