July 20 2013

Linux Default Gateway IP Address

Tagged Under :

In Windows Machine if want to check our IP Address or Gateway the easy method is use Command Prompt type ipconfig then it will lists down everything. But in LINUX it different.

In Linux, they call it ifconfig, open the terminal and type ifconfig it will lists down all the available network. But it didn’t print out the Gateway IP Address.

The easy way to print out Gateway IP Address command.
route -n | grep 'UG[ \t]' | awk '{print $2}'
Or, you can use others command to print out the Gateway.

July 20 2013

Protect PHP class file that must be include

Tagged Under : ,

Here we describe how we can protect our class file that calling with include function, but it was not secure and its have big risk. For the solution if we can make the file cannot execute or calling when it not include by PHP file.

Why we need it? because when someone try calling http://localhost/module/foo.class.php it will be successful and maybe some accident will happen here.

if( basename( __FILE__ ) == basename( $_SERVER['PHP_SELF'] ) ) exit();