Forum Moderators: open
I'm going to need whatever I do to display on every page, or possible just store a session or something, but there will need to be some type of lookup.
Thanks for any advice.
If there is a static list of just a few records (< 100), a flat file should do, which the application would read thru on every request. Modern operating systems do disk I/O cacheing, so a small file should stay in memory and access should be fast.
If you already have the data in a database, then use it. Lookup on an indexed column is fast even for more data.
You could try both and take timestamps before and after getting a hit or a miss and look at the results to judge about the performance impact of either solution.
Regards,
R.
One other issue could be manageability - how often is the look up list updated, who does it etc?
---
For the the fastest way to do this I would suggest not using a database at all but using plain php code and a string variable to check against.
***************************
* lookup.php
*
* Fill $lookup_list with a list of ip's which you want to check for
*
*
$loookup_list = "123.123.123.123 100.100.100.100 222.222.222.222 111.111.111.111";
$ip = $_SERVER["HTTP_CLIENT_IP"];
if (preg_match("/$ip/", $lookup_list)) {
$ip_found = 1;
} else {
$ip_found = -1;
}
Then at the top of each page you would have:
require_once('lookup.php');
and somewhere in your page you would have:
if $ip_found = 1 {
echo "IP matched so display something else";
} else {
echo "Display Adsense stuff here";
}
Working pretty good for now.