Wednesday, December 2, 2009

Drupal SEO Optimisation - 5 Must Do Configurations


Saturday, November 14, 2009

Drupal upload path

To get where is the default path to upload file of the site:
example return: sites/


Other interesting discussion here:

Monday, November 9, 2009

drupal admin mysql has gone away!

Its such a hectic day.
I tried to clear the cache and i'm getting bunch of errors from mysql has gone away!
It turn out to be some very long query to update cache_update table and caused it to started to lost connection to db.. arg! I added a static variable to count the # of queries to database,, wow! 250+ queries! the front page itself about 110+queries!....

my here is my quick fix to the problem:
edit: drupal/includes/
function: _db_query
line #111, before mysql_query line.
(updated 10th nov: if ping is placed after mysql_query, db_effected_rows will always return -1, which causes lots of other issues)

try {
if (! mysql_ping($active_db))
throw new Exception("db closed!");
catch (Exception $e)
//attempt to reconnect
global $db_url;
$urlname = "default";
if (is_array($db_url)) {
$connect_url = array_key_exists($urlname, $db_url) ? $db_url[$urlname] : $db_url['default'];
else {
$connect_url = $db_url;

$active_db = db_connect($connect_url);

And these are my modules i've installed, while some are my custom modules:

Tuesday, October 20, 2009

apache web based monitoring

Ever wonder what is happening on your apache web server?
There are times when we found dead processes which doesnt seems to die off.
And it keeps accumulating and somehow reach its peak memory and dies off the server.
And you were spending many days of sleepless night trying to standby to restart the apache webserver every time it reaches its peak

Here is a solution:
Enable apache mod_status:
sudo a2enmod status
edit status.conf, and replace server-status with your secret url
sudo vi /etc/apache2/mods-available/status.conf

location server-status

restart apache:

apachectl restart

access your browser: or yoursecreturl

Sunday, October 18, 2009

drupal custom url / menu permission

Took me some time to figure this out.
If you ever one to have a url which is accessible by anyone,
you may either make a function to return true,
or you may set 'access callback' => '1'...

If it doesn't work, try go to administration > performance > resetting the cache.
The cache is always there, even with cache is off.

drupal access stages

Drupal is built with permission sets in mind.
User may have 1 or more roles.
Content may be limited based on content type, or up to single node level (1record).

When a user is viewing a node / page,
user will have to pass through access "access content".

Next, node may be limited based on content type in:

The type of access names can be declared in:

To overwrite permission, you may edit hook_access within the same node module,
or use hook_nodeapi

  • check for "access content"
  • trigger nodeapi.op = "load"
  • check for hook_access
  • running "hook_view"
  • trigger nodeapi.op = "view"
  • ...
Please advice me if I've missed out or made any mistake here.

Saturday, October 10, 2009

Open Source Rocks!

Who say open source isn't powerful for desktop?
It is enough for us to design this card :)
Tools: Gimp & Inkscape.
Purpose: To create awareness of skin disorder alternative cure

Thursday, October 8, 2009

Drupal Logging

Since drupal 6, they have replaced watchdog logging with dblog.
We are open sourcing one of our library for you to easily log onto the database log "watchdog" table.

* log to database
* @param string category
* @param string sLog
* @param string sType
* WATCHDOG_EMERG => t('emergency'),
WATCHDOG_ALERT => t('alert'),
WATCHDOG_CRITICAL => t('critical'),
WATCHDOG_ERROR => t('error'),
WATCHDOG_WARNING => t('warning'),
WATCHDOG_NOTICE => t('notice'),
WATCHDOG_INFO => t('info'),
WATCHDOG_DEBUG => t('debug'),
* @param array variables
function logger_log($sCategory, $sLog, $sType="info", $aVars=array())
switch ($sType)
case "emergency":
case "alert":
case "critical":
case "error":
case "err":
case "warning":
case "warn":
case "note":
case "notice":
case "info":
case "debug":
$iType = 999;//unknown

$aLog = array(
"user" => $GLOBALS["user"],
"type" => $sCategory,
"message" => $sLog,
"variables" => $aVars,
"severity" => $iType,
"request_uri" => $_SERVER["REQUEST_URI"],
"referer" => $_SERVER["HTTP_REFERER"],
"ip" => $_SERVER["REMOTE_ADDR"],
"timestamp" => time()


Tuesday, October 6, 2009

Planning on a CMS?

Developing a CMS with proper framework is not easy.
cox in php, u get nothing like dotnet framework has, unless we are taking up other framework to build from. But a lot of things to be considered when building a cms.
from user, roles n permissions, to modules, module access permissions, theming an templating, database layer, workflow of articles, sticky, search engine, tags, sections and categories and media of publishing(html, pdf, print). And all this has to be within MVC concept...

Good thing about using drupal is that it gives a lot of control to developer, without having to hack the core of drupal.
If we don't need to hack the drupal core, then can get security fixes easily.
Drupal has their team of security hacker do tests on codes of community contributed modules for flaws. Using drupal is like having team of unlimited n growing community to help build the portal, and someone to keep an eye watch on the updates and customise things based on user requirement.

Here are some good example of benefit of drupal:

The Drupal Advantage
* Most popular and most powerful open-source CMS
o huge install base
o massive, active development community
* Drupal is a CMS and an effective application framework
o clean, extensible code base
o many high-quality modules available for add-on capability
o keep custom, proprietary code to a minimum
o build highly functional custom modules to accomplish practically any task
* High performance
o built-in caching
o integrates easily with 3rd party caching mechanisms
o infinitely scalable
* SEO friendly right out of the box
o standards-compliant HTML/CSS
o capable of custom (HTML) page titles, meta descriptions
o customizable, friendly URLs
o permalinks
o simple Google Analytics integration (without writing or inserting code)
* Extremely well documented
* Mature, going into seventh major release
* Flexible, powerful theming engine separates content completely from presentation; a Drupal site's look-and-feel is limited only to the constraints of imagination and the modern web browser.
* Easy to install and support, runs on Windows or practically any AMP (Apache, mySQL, PHP) stack
* Notable Drupal Features and Selling Points
o Powerful taxonomy system for categorizing content
o User registration and profiles
o Role-based permission system
o Out-of-box RSS feeds
o Browser-based administration

Web sites running on Drupal include:
* The Onion,
* Fast Company,
* The Pulitzer Prizes,
* Churchill Downs,
* The Kentucky Derby, (built by Digett 2004 - 2008)
* Warner Brothers Records,
* AOL Corporate,
* Popular Science,
* thousands more, including virtually all those on Digett's portfolio page

More sites using drupal:

Thursday, October 1, 2009

new google document type: form

One of the latest cool thing google have made, online form!
User may do some kind of survey for their employees or students to do any kind of statistic analysts in google spread sheet.
The form allow user to add questions, group question by header, and even set if the question requires answer. Google is heading towards online database form.
This is quite cool, everyone say "aye!" Aye!!!

Friday, September 18, 2009

sendmail redirecting mail to outside

There are times when you host your mail on another server like google mail ..
To do so, you may set it in the configuration to set sendmail to redirect mails to outside instead of identifying it as local recipient.

in /etc/mail/
define(`LUSER_RELAY', `')dnl

Note: do not miss the 'dot' behind the domain.

then compile with m4 in /etc/mail
m4 >

restart sendmail service:
/etc/init.d/sendmail restart

testing it:
sendmail -v < /dev/null

check your email, and makesure to check your spam folder as this is going to be an empty email, and spam filtering doesn't like that ;)

Thursday, September 17, 2009

useful drupal module

Drupal creator has come out with their own drupal hosting service.
It seems that this list of modules would be helpful for most website to have a look into :)

Sunday, September 6, 2009

Which CMS is good?

Choice of CMS is pretty much dependent on the purpose of the website and what the users are familiar with.
Its in no doubt that Wordpress is much more user friendly, but its CMS capabilities is not strong. Wordpress is efficient enough for anyone who needs a blog or a normal website with commenting functionality. In designer point of view, it is easy to customise the design to suit websites appearance.

While a lot of people choose Joomla for its CMS features and has more complex usabilities compared to Wordpress. Some websites require more functionality such forums, calendar / event and better component add-on. There is high popularity among providers of websites to choose Joomla in Malaysia in in as their CMS platform.

In contrast, Drupal is more for developer / programmer. Its advance architecture allows most of modules / add-on to be developed without having to modify the core system of the CMS. In terms of components / features availabilities, you may find more add-on available free of charge compared to Joomla add-on.

In developer's point of view, Joomla community has been concentrating on maintaining existing infrastructure, whereby they are keeping a lot of old technology in order to have old compatibility with older version of the CMS. As of joomla version 1.5, they are lacking a lot of back-end administration component builder, forcing developers to hack the CMS core in order to achieve add-on for administration. Hacking the CMS core leads to maintenance update problem as security update cannot be patched without programmer's intervention.
Meanwhile, Drupal community has been actively developing a new platform version which is not compatible with older version of add-on, but maintains security patches for the previous version. The community also actively rewrites most of the core module to suit the new infrastructure changes and new technology changes. While security patches can be updated without much programmer intervention, it will be more cost efficient for maintenance.

Wordpress Pros
Simple to use - No need for modifications
Excellent for blogging or sharing thoughts in a sequential manner
Even the most elderly of users can get the hang of it quickly
Very user friendly
Easy direct update from administration
Wordpress Cons
Not developer friendly
The community seems to like to complain
Upgrades bring more bugs than fixes sometimes
Possible security issue as hacking core needs long term security maintenance

Joomla Pros
Friendly for all types of users - Designers, Developers and Administrators
Huge community is awesome for assisting with creation of websites
Has been rapidly growing and improving itself for the past three years
Joomla Cons
Still not user-friendly enough for everyone to understand
Not quite as powerful as Drupal, and can be a bit confusing for some to jump into
Possible security issue as hacking core needs long term security maintenance

Drupal Pros
Extremely developer friendly.
Strong community to help discern the dozens (hundreds) of functions and tags available.
Can be used to create some really awesome websites that can outperform a majority of other sites out there.
Low security maintenance as its unlikely the need to hack the core, therefore patching drupal is easy.
More search engine friendly as article URL can be defined as like static page without the need of using dynamic id in URL.
Drupal Cons
Not very designer and user-friendly. It's hard for someone with little code knowledge to make the leaps required to do the very cool things that Drupal is becoming known for.
Theming of Drupal has been a huge case of fail (until recently). Probably because it has been developers, not designers, that are making the themes.
Getting a Drupal website published could cost you more time, and thus more money, than Wordpress or Joomla.

There are no one CMS which will be best suit for all your need. Dependant on your requirements, it would be more time efficient to choose the CMS which you are familiar with and suits your feature requirements.
If you are looking for a simple blog or website with simple commenting and ranking of articles, you may choose Wordpress. If you are looking for more features like forums and calendar /event system without having to change any of the features, it would be best to be Joomla. While if you are planning to choose a very features pack or planning to customise features of the CMS, it would be best to use Drupal.

In business sense, budget CMS would be Wordpress and Joomla. While for corporation looking to customise their own company system and thinking into expanding the system as the corporation grow, it would be best to choose Drupal.

I find myself agreeing with Tim post @

Tuesday, September 1, 2009

drupal node form

There are times when we needed to create custom layout form design for your node.
In drupal, the theme it called to retrieve the form layout are:
1. [modulename]_node_form
2. node_form

//... return the array to declare node_form

Monday, August 10, 2009

how to recover mysql server root password?

If you have lost your mysql password for some "ding dong" reason, :P

here is how to recover them:
1. stop the mysqld service by: sudo /etc/init.d/mysqld stop
2. start: mysqld_safe --skip-grant-tables &
3. login without pwd: mysql -u root
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit
4. stop mysql: sudo /etc/init.d/mysqld stop
5. start mysqld: sudo /etc/init.d/mysqld start
6. try login via: mysql -u root -p (with yournew pwd)

Wednesday, August 5, 2009

Change Request

Its usual that under many circumstances, customer / client will change their mind or change their decision in tuning their software towards their objective.
Every change requirement shall have a "change request" document signed by customer/client.

A change request is a document containing a call for an adjustment of a system; it is of great importance in the change management process.


Every project shall have a well written requirement. One of the best requirement document design will be SRS.

Software Requirements Specifications (SRS)

Cover Page

Revisions Page

Table of Contents


1.1 Product Overview
1.2 Purpose
1.3 Scope
1.4 Reference
1.5 Definition And Abbreviation


2.1 External Interface Requirements
2.1.1 User Interfaces
2.1.2 Hardware Interfaces
2.1.3 Software Interfaces
2.1.4 Communications Protocols
2.1.5 Memory Constraints
2.1.6 Operation
2.1.7 Product function
2.1.8 Assumption and Dependency
2.2 Software Product Features
2.3 Software System Attributes
2.3.1 Reliability
2.3.2 Availability
2.3.3 Security
2.3.4 Maintainability
2.3.5 Portability
2.3.6 Performance
2.4 Database Requirements



Tuesday, June 23, 2009

wikimedia setup

Wiki media configuration tips:

Edit LocalSetting.php

How to setup only logged in user can edit / add post:

//only logged in user can edit
$wgGroupPermissions['*']['edit'] = false;
How to setup only admin can add user:
//only admin can create account...
$wgGroupPermissions['*']['createaccount'] = false;
How to enable upload for wiki media?
//find for $wgEnableUploads
$wgEnableUploads = true;
How to allow upload of other files:

$wgFileExtensions[] = "zip";
$wgFileExtensions[] = "gz";
$wgFileExtensions[] = "pdf";
$wgFileExtensions[] = "doc";
$wgFileExtensions[] = "xls";
$wgFileExtensions[] = "ppt";

But, upload will fail if you enable imagemagick, because it assume all your is image. Therefor, we will need to disable imagemagick:

$wgUseImageMagick = false;

Hope it helps ;)


Monday, June 22, 2009

drupal vs wordpress vs joomla

My findings:

  • very modular
  • able to reuse other module
  • allow theming overrides
  • drag n drop ordering of fields
  • allow custom fields
  • front end & back end having similar login and path
  • good interface
  • inserting folder as module make things simple
  • cutting edge - using tinymce3...
  • Complicated admin
  • Slow admin interface as 2 much form input in 1 screen

  • allow theming overrides
  • drag n drop ordering of fields
  • allow custom fields
  • nicest gui and friendliness among 3 cms
  • cutting edge technology - using wikimedia, tinymce3...
  • TODO

  • Clearly separate module, controller & view
  • allow theming overrides
  • support hooks

  • no custom field support
  • admin no hook support, therefore hacking core is unavoidable
  • some bad component design like jevents use their own templating, which is bad
  • inconsistant template - esp. between category & section
  • interface is like erp, not so good...
  • difficult to reuse other module functions
  • mootool 1.1 & tinymce2 legacy stuff!
  • component/module/plugin installation is tedious, need to pack and clear db if something went wrong