JavaScript Editor Ajax software     Free javascripts 



Main Page

// | Copyright (c) 2005-2006 Jaimie Sirovich and Cristian Darie |
// +
-------------------------------------------------------------
+
*/
// load configuration file
require_once(‘config.inc.php’);
class SimpleCloak
{
// returns the confidence level
function isSpider($spider_name = ‘’, $check_uas = true, $check_ips = true)
{
// default confidence level to 0
$confidence = 0;
// matching user agent?
if ($check_uas)
if (SimpleCloak::_get(0, $spider_name, ‘UA’, $_SERVER[‘HTTP_USER_AGENT’]))
$confidence += 2;
// matching IP?
if ($check_ips)
if (SimpleCloak::_get(0, $spider_name, ‘IP’, ‘’, $_SERVER[‘REMOTE_ADDR’]))
$confidence += 3;
// return confidence level
return $confidence;
}
// retrieve cloaking data filtered by the supplied parameters
function _get($id = 0, $spider_name = ‘’, $record_type = ‘’,
$value = ‘’, $wildcard_value = ‘’)
{
// by default, retrieve all records
$q = “ SELECT cloak_data.* FROM cloak_data WHERE TRUE “;
// add filters
if ($id) {
$id = (int) $id;
$q .= “ AND id = $id “;
}
if ($spider_name) {
$spider_name = mysql_escape_string($spider_name);
$q .= “ AND spider_name = ‘$spider_name’ “;
}
if ($record_type) {
$record_type = mysql_escape_string($record_type);
$q .= “ AND record_type = ‘$record_type’ “;
}
if ($value) {
$value = mysql_escape_string($value);
$q .= “ AND value = ‘$value’ “;
}
226
Chapter 11: Cloaking, Geo-Targeting, and IP Delivery
c11.qxd:c11 11:01 226


JavaScript Editor Ajax software     Free javascripts