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, [...]
Posted on October 22nd, 2009 by Denie
Filed under: BASH, Linux, Scripting, Tutorials | No Comments »
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”;
?>
Posted on June 16th, 2009 by Denie
Filed under: PHP, Scripting | No Comments »
I found good examples for this.
- Quick HOWTO (from LinuxHomeNetworking.com) – download
- Sample IPTABLES Configuration (RedHat/CentOS) – download
Posted on February 23rd, 2009 by Denie
Filed under: Linux, Scripting, Tutorials | No Comments »
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.
Posted on February 20th, 2009 by Denie
Filed under: PHP, Scripting | No Comments »
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 [...]
Posted on January 19th, 2009 by Denie
Filed under: Linux, Scripting | No Comments »
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 [...]
Posted on December 18th, 2008 by Denie
Filed under: Internet, Scripting, Tutorials, Windows | No Comments »
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;
?>
Posted on December 17th, 2008 by Denie
Filed under: Scripting, Tutorials | No Comments »
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());
?>
Posted on December 17th, 2008 by Denie
Filed under: Scripting, Tutorials | No Comments »
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);
?>
Posted on December 17th, 2008 by Denie
Filed under: Scripting, Tutorials | No Comments »
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 [...]
Posted on November 14th, 2008 by Denie
Filed under: Linux, Scripting | No Comments »