Thursday, March 11, 2010

Wordpress hack tips - Add tags to static pages

I did a lot of wordpress plugin jobs recently. But sometimes clients are not satisfied with what plugins can do. for example there is a client of mine want add tags to any static pages, just like wordpress posts did.

Actually it's very easy to do this(as well as to create a plugin for this).
just paste following lines to page_attributes_meta_bos function in meta-boxes.php:

<h5>Tags</h5>
<div>
<input type="text" name="tags_input" class="tags-input" id="tags-input" size="30" tabindex="3" value="<?php echo get_tags_to_edit( $post->ID ); ?>" />
</div>

Tuesday, March 2, 2010

The most easy way to install geoip php extension note

在网上找了一堆安装geo ip模块的方法,各种方法都很麻烦。现在本尊(无量牛逼最三三尊)来整理一个最简单的安装方法如下。

1.install GEOIP C Library
http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.6.tar.gz
./configure
make
sudo make install

2.Install GEOIP PHP Extension
sudo pecl install geoip

3.Following message from step2, for example:
Build process completed successfully
Installing '/usr/local/lib/php/20060613/geoip.so'
install ok: channel://pecl.php.net/geoip-1.0.7
configuration option "php_ini" is not set to php.ini location
You should add "extension=geoip.so" to php.ini

4.Install GeoIP database
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gzip -d GeoIP.dat.gz
sudo cp GeoIP.dat /usr/local/share/GeoIP/
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
sudo cp GeoLiteCity.dat /usr/local/share/GeoIP/GeoLiteCity.dat
sudo mv /usr/local/share/GeoIP/GeoLiteCity.dat /usr/local/share/GeoIP/GeoIPCity.dat

5.test
<?php print_r(geoip_record_by_name('125.63.166.38'));