topical media & game development
professional-search-11-seophp-include-simple-cloak.inc.php / php
<?php
/*
// +----------------------------------------------------------------------+
// | SimpleCloak |
// | Class for cloaking content |
// | http://www.SEOEgghead.com |
// +----------------------------------------------------------------------+
// | 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(check_uas = true, confidence = 0;
// matching user agent?
if (spider_name, 'UA', confidence += 2;
// matching IP?
if (spider_name, 'IP', '', confidence += 3;
// return confidence level
return id = 0, record_type = '',
wildcard_value = '')
{
// by default, retrieve all records
id) {
id;
id ";
}
if (spider_name = mysql_escape_string(q .= " AND spider_name = 'record_type) {
record_type);
record_type' ";
}
if (value = mysql_escape_string(q .= " AND value = 'wildcard_value) {
wildcard_value);
wildcard_value' LIKE CONCAT(value, '%') ";
}
// Connect to MySQL server
tmp = mysql_query(dbLink);
// return the results as an associative array
_x = mysql_fetch_assoc(rows[] = rows;
}
// updates the entire database with fresh spider data, but only if our data is
// more than 7 days old, and if the online version from iplists.org has changed
function updateAll()
{
// Connect to MySQL server
q = "SELECT cloak_update.* FROM cloak_update";
q);
tmp);
updated['version'];
updated ['updated_on'];
// get the latest update more recent than 7 days, don't attempt an update
if (isset(updated_on) > strtotime("-604800 seconds")))
{
// close database connection
mysql_close(version_url = 'http://www.iplists.com/nw/version.php';
version_url));
// if no updated version information was retrieved, abort
if (!q = "DELETE FROM cloak_update";
mysql_query(q = "INSERT INTO cloak_update (version, updated_on) " .
"VALUES('q);
// if we already have the current data, don't attempt an update
if (db_version)
{
// close database connection
mysql_close(dbLink);
// return true to indicate a successful update
return true;
}
// update the database for the mentioned spider, by reading the provided URL
function _updateCloakingDB(url,
/m', /m')
{
// use cURL to read the data from ch = curl_init();
curl_setopt (url);
curl_setopt (ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt (ch, CURLOPT_TIMEOUT, 60);
ch);
curl_close(lists = SimpleCloak::_parseListURL(ua_regex, lists['ua_list'] || !spider_name
SimpleCloak::_deleteSpiderData(lists['ua_list'] as spider_name, 'UA', lists['ip_list'] as spider_name, 'IP', data, ip_regex)
{
ua_regex, ua_list);
ip_regex, ip_list);
return array('ua_list' => ip_list[1]);
}
// inserts a new row of data to the cloaking table
function _insertSpiderData(record_type, spider_name = mysql_escape_string(record_type = mysql_escape_string(value = mysql_escape_string(q = "INSERT INTO cloak_data (spider_name, record_type, value) " .
"VALUES ('record_type', 'q);
}
// delete the cloaking data for the mentioned spider
function _deleteSpiderData(spider_name = mysql_escape_string(q = "DELETE FROM cloak_data WHERE spider_name='q);
}
}
?>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.