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:

http://www.youdomain.com/server-status 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:
hook_access

The type of access names can be declared in:
hook_perm


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

stages:
  • 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":
$iType = WATCHDOG_EMERG;
break;
case "alert":
$iType = WATCHDOG_ALERT;
break;
case "critical":
$iType = WATCHDOG_CRITICAL;
break;
case "error":
case "err":
$iType = WATCHDOG_ERROR;
break;
case "warning":
case "warn":
$iType = WATCHDOG_WARNING;
break;
case "note":
case "notice":
$iType = WATCHDOG_NOTICE;
break;
case "info":
$iType = WATCHDOG_INFO;
break;
case "debug":
$iType = WATCHDOG_DEBUG;
break;
default:
$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()
);

dblog_watchdog($aLog);
}

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:
http://www.youtube.com/watch?v=lzt-9vbXztI

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, http://www.theonion.com
* Fast Company, http://www.fastcompany.com
* The Pulitzer Prizes, http://www.pulitzer.org
* Churchill Downs, http://www.churchilldowns.com
* The Kentucky Derby, http://kentuckyderby.com (built by Digett 2004 - 2008)
* Warner Brothers Records, http://www.warnerbrosrecords.com
* AOL Corporate, http://corp.aol.com
* Popular Science, http://www.popsci.com
* thousands more, including virtually all those on Digett's portfolio page

More sites using drupal:
* http://www.avenuewebmedia.com/high-profile-sites-run-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!!!