Monthly Archives: July 2012

How to use Invision’s BBCode

Using Invision’s BBCode isn’t straight forward. Chances are that you need to invoke the BBCode parser if you want to create a plugin or hook for Invision Powered Board. Here’s the rough code to do so, with $topics being the array containing all the topics from the database to be parsed:

<?php

$classToLoadComposite = IPSLib::loadLibrary( IPS_ROOT_PATH . "sources/classes/editor/composite.php", "classes_editor_composite" );
$editor = new $classToLoadComposite();
#$editor->setAllowHtml( 1 );
//-----------------------------------------
// Return the data
//-----------------------------------------
foreach ($topics as &$topic) {
    $topic["formattedPost"] = $editor->process($topic["post"]);
    IPSText::getTextClass("bbcode")->parsing_section = "topics";
    IPSText::getTextClass("bbcode")->parse_smilies = TRUE;
    IPSText::getTextClass("bbcode")->parse_bbcode = TRUE;
    IPSText::getTextClass("bbcode")->parse_html = FALSE;
    IPSText::getTextClass("bbcode")->parse_nl2br = TRUE;
    IPSText::getTextClass("bbcode")->bypass_badwords = FALSE;
    $topic["formattedPost"] = IPSText::getTextClass("bbcode")->preDisplayParse( $topic["formattedPost"] );
}
?>

For the parsing_section, you should put a value that corresponds to the editor section. In my case, I need it to ‘topics’. To get the full list, you may need to look up Invision Powered Board’s source code which I cannot provide.

I wrote this down more as a personal note and I hope it benefits you as it did for me. If you have any questions, feel free to post and I can attempt answering.

Reading on Amazon Kindle

I can’t recommend Amazon Kindle enough if you’re an avid reader. I got mine delivered over from the US to Singapore through a proxy courier. I think I used comGateway.

Since then I bought numerous books from the US shop without trouble, it all get delivered to my Kindle. I haven’t encountered phone verification of any sort.

The question I get most from people is what is it that don’t work in Singapore. Well, the 3G internet on the Kindle can only access Wikipedia and Amazon websites unfortunately. Other than that everything works fine.

I have been using Kindle for Mac more often lately:

Kindle for Mac.

It’s a lot easier to search through the annotations in the desktop application.

How to install PHP GeoIP in Ubuntu

This instructions will install GeoIP over Ubuntu. It is tested over Ubuntu 12.04 LTS.

I assume you already have PEAR/PECL available. I am using the CentOS’s stock PHP. First you need to update your channels:

kahwee:~ kahwee$ sudo pear update-channels
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date

Continue reading “How to install PHP GeoIP in Ubuntu” »

How to automate GeoIP updates on Linux

This works for Ubuntu, Debian and CentOS distributions. You need a valid license key from MaxMind. This is available as a subscription at a nominal fee.

If you have installed GeoIP successfully, you should have the geoipupdate program. If you don’t, you need the run the following.

Install over Ubuntu or Debian:

sudo apt-get install geoip-bin geoip-database libgeoip-dev

Install over CentOS:

sudo yum install re2c geoip geoip-data geoip-devel

Both libgeoip-dev and geoip-devel are required for compiling PHP’s GeoIP.

Once you run geoipupdate the first time, it tells you about a missing GeoIP file.

root@gladlycode:~# geoipupdate 
Error opening GeoIP Configuration file /etc/GeoIP.conf

Now you copy over from the default file:

mv /etc/GeoIP.conf.default /etc/GeoIP.conf

If you now run geoipupdate, you get the following:

MD5 Digest of installed database is f5c2f7eed9331dcaa99b7a6b4633b684
Invalid UserID

Continue reading “How to automate GeoIP updates on Linux” »

How to install APC in Ubuntu 12.04

This installation is through PEAR. You can install it in other methods too. This has installed APC 3.1.9 for me over Ubuntu 12.04 LTS.

sudo apt-get install build-essential libpcre3-dev php5-dev
sudo pear update-channels
sudo pecl install apc

Continue reading “How to install APC in Ubuntu 12.04” »