PHP Killer: Do not do this on your code

Unless you want/need to kill some time… do not do the following on your PHP code, or you will be banging your head against the wall:   1. Use trim() inside empty():   sample: if (!empty(trim($item))) { }   work around: $item = trim($item); if (!empty($item)) { }    … Continue reading

Kohana 3.2.6: Change Default Route

Let’s define a redirect module that will handle all requests that were not handled by any other controller. It will also be a good place to include a 404 page. modules/application/bootstrap.php Kohana::modules(array( . . ‘redirect’ => MODPATH . ‘redirect’, //Redirect module . . )); Route::set(‘default’, ‘(<request>)’, array( ‘request’ => ‘(.*)’,… Continue reading

Code:: css-message-box

I just started a Google Code hosted project since I’m always in need of pretty message boxes for my HTML things. Let me know if you want/can contribute to it. It’s currently licensed under GPL 2.0 Here’s the address:   Why: This seems to have been dead for a… Continue reading

Installing DropBox on Slackware 13.1 64-bit

Before you start, let's make sure you have gnome docutils installed: Get the package: Install GNOME Doc Utils (this part is borrowed from LinuxFromScratch book) ./configure –prefix=$(pkg-config –variable=prefix ORBit-2.0) –mandir=$(pkg-config –variable=prefix ORBit-2.0)/share/man make Test it make check and then install as root: make install switch to Dropbox installation folder… Continue reading

Kohana 3: Default Template [step 3]

Create the view for the default template: /modules/common/views/template/default/default.php   <!DOCTYPE html> <head> <title>Default template</title> </head> <body> <?php echo $content; ?> </body> </html>      

Kohana 3.1.x: Common controller [step 2]

Define parent controller:     <?php defined(‘SYSPATH’) or die(‘No direct script access.’); class Controller_Common_Content extends Controller_Template { public $template                = ”; public $template_name           = ‘default’; public $layout                  = ‘default’; public $save_auto_render        = null; public $content                 = ‘{Do something to generate content}’; public function __construct(Request $request, Response $response) { parent::__construct($request, $response);… Continue reading

Kohana 3.2.x: Master Template Controller [step 1]

Let's create a content module that will handle both static and dynamic content: First enable the module: modules/application/bootstrap.php Kohana::modules(array( . . 'content' => MODPATH . 'content', // Content module . . ));   Second, create the master template controller: modules/content/classes/controller/base/template.php template_name = Kohana::$config->load(''); $this->template = 'template/'.$this->template_name.'/index'; parent::before(); if ($this->auto_render) {… Continue reading

LAMP: Installing on Slackware 13.37 64-bit

Ongoing post:   1. Download Apache ( ) tar -xvjf httpd-2.2.21.tar.bz2 cd httpd-2.2.21 I like Slackware, but I also like the Apache layout installed in Debian distributions, so: ./configure –enable-layout=Debian–enable-module=most –enable-mods-shared=most –enable-ssl=shared make make install 2. PostgreSQL ./configure –with-perl –with-openssl gmake all gmake install     PHP ./configure –with-pgsql… Continue reading

(ve) Installing LAMP on Debian Squeeze – 64bit

aptitude update aptitude safe-upgrade aptitude install mysql-server mysql-client       NGINX aptitude install libpcre3-dev build-essential libssl-dev sudo cd /opt/ wget tar -xvzf nginx-1.0.8.tar.gz cd nginx-1.0.8 ./configure –prefix=/opt/nginx –user=nginx –group=nginx –with-http_ssl_module –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access_log –with-http_ssl_module –with-http_geoip_module –pid-path=/var/run/ nginx path prefix: “/opt/nginx” nginx binary file: “/opt/nginx/sbin/nginx” nginx configuration prefix:… Continue reading