Simple Web/Linux IP Address Lookup

If you’re going to be doing a lot of Geotargeting or IP Address Lookups, please take a feed instead which will preserve both our bandwidth and your bandwidth.
Simple GET
That said, there is an easy HTTP oriented API to locate IP addresses and Geocode them. If you don’t supply the “?ip=aa.bb.cc.dd” bit, [...]

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”;
?>

Linux Firewalls with IPTABLES (Good Tutorials)

I found good examples for this.
- Quick HOWTO (from LinuxHomeNetworking.com) – download
- Sample IPTABLES Configuration (RedHat/CentOS) – download

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.

Install APC for PHP on Linux

APC is the Alternative PHP Cache, which is a free, open, and robust framework for caching and optimizing PHP intermediate code. What this means is that APC reads your PHP files, parses them into a more efficient binary format and then caches them in memory so that each request for your PHP files and PHP [...]

IE ignores custom error pages

if you use php to create custom error pages (such as header(’HTTP/1.1 500 Internal Server Error’);) Internet Explorer ignores you custom page unless it is at least 512 (or sometimes 1024 bytes)
IE ignores custom error pages that are less than 512 (or from what i’ve read 1024) bytes.
just place this before any [...]

How to show image file that’s not accessible to public ?

You can use below script to show the image file for public access, but public don’t have direct access to the file itself. Because its located outside of the public folder.
<?php
/* Read local file from /home/bar */
$localfile = file_get_contents(”/home/userX/foo.jpg”);
echo $localfile;
?>

How to know ID number that inserted by the mysql insert query ?

Use below scripts :
mysql_insert_id() example
<?php
$link = mysql_connect(’localhost’, ‘mysql_user’, ‘mysql_password’);
if (!$link) {
die(’Could not connect: ’ . mysql_error());
}
mysql_select_db(’mydb’);
mysql_query(”INSERT INTO mytable (product) values (’kossu’)”);
printf(”Last inserted record has id %d\n”, mysql_insert_id());
?>

How to fetch data(s) using mysql_fetch_assoc ?

mysql_fetch_assoc — Fetch a result row as an associative array

<?php
$conn
= mysql_connect(”localhost”, “mysql_user”, “mysql_password”);
if (!
$conn) {
echo “Unable to connect to DB: ” . mysql_error();
exit;
}
if (!
mysql_select_db(”mydbname”)) {
echo “Unable to select mydbname: ” . mysql_error();
exit;
}
$sql = “SELECT id as userid, fullname, userstatus
FROM   sometable
WHERE  userstatus = 1″;
$result = mysql_query($sql);
if (!
$result) {
echo “Could not successfully run query ($sql) from DB: ” . mysql_error();
exit;
}
if (
mysql_num_rows($result) == 0) {
echo “No rows found, nothing to print so am exiting”;
exit;
}
// While a row of data exists, put that row in $row as an associative array
// Note: If you’re expecting just one row, no need to use a loop
// Note: If you put extract($row); inside the following loop, you’ll
//       then create $userid, $fullname, and $userstatus

while ($row = mysql_fetch_assoc($result)) {
echo $row["userid"];
echo $row["fullname"];
echo $row["userstatus"];
}
mysql_free_result($result);
?>

More about urlencode and urldecode

What you want is possible but it is considerably more work that it is practical to put in. Just say decode and let PHP do the calculations
Anyway, thanks for an interesting question. Researching it taught me about both how UTF-8 works and about URL encoding in general.
First, link to an explanation of URL [...]