Free Android CakePHP GMaps Articles by Bali Web Design

October 28, 2010

How to remove generator meta tag wordpress

Filed under: php,wordpress — admin @ 10:13 pm

Starting from wordpress 2.5 and above, you cannot remove generated meta tag wordpress version through your template. On prior version, it is simple by comment the line for showing wordpress version on your template.

<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />

WordPress 2.5 and above, the version is moved into the core of the wordpress. So it will automatically generate metatag generate, such as

<meta name="generator" content="WordPress 3.0" />

If you want to remove this generated line, there are some ways :

  1. Login to administration wordpress page, and then go to Appearance > Themes, And then Editor. Open functions.php, Add this line before the closing ?> tag
    remove_action('wp_head', 'wp_generator');
  2. Or use this plugin. Install on plugins area.

Redirect with exit using cakephp

Filed under: cakephp,php — admin @ 8:38 am

If you run redirect function on cakephp 1.1, don’t forget to add exit() function after redirect sintax. This thing can make security hole that confusing you. The purpose of adding exit() function after redirect sintax is to avoid php running others code after redirect function.

$this->redirect('controller/action');
exit();

However cakephp 1.2 give you default exit after redirect. The complete sintax for redirect on cakephp 1.2 is

$this->redirect('controller/action', null, true);

which the third parameter define exit = true, means terminate the script. second parameter is for setting exit status, for example 404, etc. Defaultly you only need to write

$this->redirect('controller/action');

get referer url using cakephp

Filed under: cakephp,php — admin @ 8:08 am

Sometime we need to get the referer url that access a page or url on our website. It is easy to find referer url using cakephp framework. Inside your controller or cakephp class, you can get the referer url using this sintak

Controller::referer()

Referer url is the last page or url that accessed by the user before open current page or url.

How to log your website using cakephp

Filed under: cakephp,php — admin @ 7:50 am

Cakephp is a good framework, it is a rapid web development framework for building any type of website. As a framework, cakephp has many built in feature. One of cakephp feature is build in logging system. Developer can easily log their application using cakephp.

Log function that can be accessed through your controller easily. You can save or add new log into error log or debug log, or you can make new log file. All file will be placed inside CAKEPHP_FOLDER/app/tmp/logs folder

default sintax that added to CAKEPHP_FOLDER/app/tmp/logs/error.log

$this->log("error message log");

(more…)

October 13, 2010

Captcha component for cakephp using captcha.net

Filed under: cakephp,php — admin @ 8:32 pm

Captcha is a type of challenge-response to ensure that the user is really a person that the response is not generated by computer. We usually find captcha on any form input on a website such us contact us, feedback, registration and etc. The captcha is used to protect our site from spammer.

The popular captcha is recaptcha from captcha.net website. It is free for use. Their interface or design also really nice to put on your website. You can check their sample in http://www.captcha.net/. They support both image captcha and audio chaptca.

Since i work with cakephp framework, i need to integrate this captcha into my application. I would like to share my captcha component for you. It is a simple code and easy to integrate. Here are the step (more…)

October 7, 2010

How to set foreignKey for belongsTo cakephp without id

Filed under: cakephp,php — admin @ 2:45 am

Cakephp has a good ways for handling table relationship model using AppModel association structure. It is easy to create and set relation between two or more tables on your database. Cakephp has setting for one to one, one to many, many to many relationship.

I would like to tell you about setting foreignKey for one to many relationship in cakephp that the master table doesn’t have foreignKey id. On your model, the relationship for one to many that set on child table would look like this

<?php
	class CurrencyRate extends AppModel {
		var $belongsTo = array('Currency' => array(
			'className' => 'Currency',
			'foreignKey' => 'currency_id',
		));
	}

?>

(more…)