Simple Check IP with PHP

You can use below simple PHP scripting to check IP address
<?php
if(!empty($_SERVER["HTTP_X_FORWARDED_FOR"])){
echo “<title>”.$_SERVER["HTTP_X_FORWARDED_FOR"].” via “.$_SERVER["REMOTE_ADDR"].”</title>\n\n”;
echo “Your IP: “.$_SERVER["HTTP_X_FORWARDED_FOR"] . “<br />\n”;
echo “Proxy IP: “.$_SERVER["REMOTE_ADDR"] . “<br />\n”;
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}else{
echo “<title>”.$_SERVER["REMOTE_ADDR"].”</title>\n\n”;
echo “Your IP: “.$_SERVER["REMOTE_ADDR"] . “<br />\n”;
$ip = $_SERVER["REMOTE_ADDR"];
}
echo “Date Time: ” . date(”Y-m-d H:i:s”) . “<br />\n”;
?>

Mixing PHP and SSI

This information is ONLY relevant to PHP4 and Apache 1.3. (BUT possible can be work also in PHP 5.x and Apache 2.x ) We historically used PHP for all our web work. We have decided to migrate to ruby for lots of reasons for all our new web development but we still have lots of [...]

PHP configuration inside httpd.conf

How to set PHP error notice hidden in httpd.conf (vhost):

<VirtualHost *:80>

php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off

</VirtualHost>

How to set individual php.ini in httpd.conf (vhost):

<VirtualHost *:80>

PHPIniDir ‘/path/to/php/conf/php-foo.ini’

</VirtualHost>

How to set individual PHPError.log in httpd.conf (vhost):

<VirtualHost *:80>

php_flag [...]

Compiling PHP 5.2.x / cannot find -lltdl

When compiling PHP from source, some of the CentOS users reported that they getting errors like below:

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status

What you need to do, is just follow the below steps.

Verify that the libtool and libtool-ltdl packages are installed.
Symlink libltdl.so to libltdl.so.x.x.x

If libtool and libtool-ltdl already exist, you may go [...]

How to protect your website using simple PHP scripts

Just put below on your top line of the scripts :
$ips = array(”127.0.0.1″,”aaa.bbb.ccc”,”xxx.yyy.zzz”);
$userip = $_SERVER['REMOTE_ADDR'];
foreach ($ips as $ip) {
if (!preg_match(”/$ip/i”, $userip)) {
echo “Access Denied!”;
exit;
}
}
Notes:
$ips is the allowed IP address range
Other way, you can use .htaccess to protect directories/files.