Tuesday, October 28, 2008

PHP: Always have Return on function

I had once experienced and almost freaked out locating a bug on my script, just to find out that it was just a no returning value or return on my function. The lesson I've learned here is to always use return inside functions even if it does not have to return something. This is a good programming practice to exercise. As much as possible use return();

Let me give some examples where the function will immediately return to the line from which it was called. Here are they:

(1) Use echo
function helloworld()
{
// scripts....
echo "hello World";
}


(2) Return boolean value (just if necessary)
function helloworld()
{
// scripts......

return true;
// or false
}


(3) if function will not return anything then just use return
function helloworld()
{
// scripts....
return;
}

Hope it helps everyone. Thanks and God Bless us all!!!!!

Wednesday, October 15, 2008

Installation of Bind and WMBind on Linux (A Draft)

INstallation of Bind (DNS Server) and WMBind

1.) Install first Bind
# yum install bind

2.) On CentOS 4.x there are default named.conf installed but not on CentOS 5.x

so for CentOS 5 either
a.) Copy the sample config from CentOS 4
b.) Copy the samples at /usr/share/bind/.... or locate name.conf.sample or sample folder

Firewall concern

Allow the ffg: ports

953 both udp and tcp
53 both udp and tcp


3.) Once the bind is installed, download and install Wmbind package
4.) make sure to read and follow what's on README on this package (espescially about the apache user)
a.) adding apache on group named
gpasswd -a apache named

5.) Enable mod rewrite on Apache by setting the following:

;From
AllowOverride None
;To
AllowOverride All

then restart apache

6.) Now see to it that named.conf and rndc.conf do have similar rndc-key values like as follows:

rndc.conf

key "rndc-key" {
algorithm hmac-md5;
secret "j2gS+6XTSeycPM8A+Fe5Tg==";
};

options {
default-key "rndc-key";
default-server 127.0.0.1;
default-port 953;
};

named.conf

key rndc-key {
algorithm hmac-md5;
secret "j2gS+6XTSeycPM8A+Fe5Tg==";
};

controls {
inet 127.0.0.1 allow { localhost; } keys { rndc-key; };
inet 192.168.2.3 port 953 allow { 192.168.2.0; } keys { rndc-key; };
};

Restart named by
/sbin/service named restart

also make sure that the rndc.conf and rndckeys are readable by group named where apache is a member.