=============================================
Use at your own risk and please do not ask any questions
=============================================
=============================================
File ae-common.php
=============================================
| $date $time EST | $ipaddress | $QueryString | $ServerRequest | $agent | $referer | $HostName |");
$MAX_Retries = 1;
$CurlTimeOut = 10;
$TOKEN="D33U9QUBB1LUSJ";
$ID="celticstones";
$AdSense= false;
$CSS = "ae.css";
$JS = "ae.js";
$AWSRoot = "xml-us.amznxslt.com";
// webservices.amazon.com xml-na.amznxslt.com xml.amazon.com xml-us.amznxslt.com xml-de.amznxslt.com xml-fr.amznxslt.com xml-ca.amznxslt.com xml-jp.amznxslt.com xml-uk.amznxslt.com
//$AWSRoot = "207.171.163.113";
if (strstr($QueryString, "&banner")) $XSL='http://www.celtic-one-design.com/amazon-services/banner6.xsl';
elseif (strstr($QueryString, "&mybottomstore")) $XSL='http://www.celtic-one-design.com/amazon-services/php-mybottomstore.xsl';
else $XSL='http://www.celtic-one-design.com/php/ae.xsl';
// $XSL="http://216.193.252.111/~celtic3/amazon-services/banner6.xsl";
function send_file($file)
{
global $SENDtime;
$SENDtime = getmicrotime();
if($fp = @fopen($file, 'rb'))
{
@ob_start('_gzipCompress');
//@fpassthru($fp); old code
$Data = '';
while( (!feof($fp)) && (connection_status()==0) )
{
$Data = $Data . fread($fp, 1024*2);
}
echo $Data;
while (@ob_end_flush());
}
@fclose($fp);
$SENDtime = round((getmicrotime() - $SENDtime), 4);
return((connection_status()==0) and !connection_aborted());
}
function FetchURL($URL, $TIMEOUT)
{
global $CurlTime, $StatusCode, $CurlStatus;
$Curl = curl_init();
curl_setopt($Curl, CURLOPT_URL, $URL);
curl_setopt($Curl, CURLOPT_TIMEOUT, $TIMEOUT);
curl_setopt($Curl, CURLOPT_CONNECTTIMEOUT, $TIMEOUT);
curl_setopt($Curl, CURLOPT_HEADER, 0);
curl_setopt($Curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($Curl, CURLOPT_MAXREDIRS, 5);
curl_setopt($Curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($Curl, CURLOPT_USERAGENT, "-COD~Zilla- Zon PHP/XSLT Explorer gzip (celticone at msn.com)");
curl_setopt($Curl, CURLOPT_REFERER, "http://www.celtic-one-design.com/amazon-web-services/amazon-php-xslt.htm");
curl_setopt($Curl, CURLOPT_ENCODING , "gzip");
$Data = curl_exec($Curl);
$CurlTime = $CurlTime + round(curl_getinfo($Curl, CURLINFO_TOTAL_TIME), 4);
$StatusCode = curl_getinfo($Curl, CURLINFO_HTTP_CODE);
$CurlStatus = curl_errno($Curl) . " - " . curl_error($Curl);
curl_close($Curl);
return $Data;
}
function _gzipCompress($buffer,$mode=5)
{
$buffer2=ob_gzhandler($buffer,$mode);
if (strlen($buffer2)>1) $buffer=$buffer2;
header('Content-Length: '.strlen($buffer));
return $buffer;
}
function GetAWSAddress($domain)
{
global $LogRoot;
$AWSIPAddress = $LogRoot . "AWSIPAddress" . ".txt";
if(@file_exists($AWSIPAddress))
{
$TmpTime = time() - @filemtime($AWSIPAddress); //
if ($TmpTime < 30*60) return trim(@file_get_contents($AWSIPAddress));
else @unlink($AWSIPAddress);
}
$IP = gethostbyname($domain);
if($f = @fopen($AWSIPAddress, "w+"))
{
$LockAttempt = 0;
while ((false === @flock($f, LOCK_EX)) && $LockAttempt < 5)
{
usleep(100000);
$LockAttempt++;
}
@fwrite($f, $IP);
}
@flock($f, LOCK_UN);
@fclose ($f);
return $IP;
}
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function deldir($dir, $days)
{
$handle = opendir($dir); //
$MaxCacheTime = $days * 24 * 60 * 60;
$Count = 0;
while (false!==($FolderOrFile = readdir($handle))) //
{
if(!is_dir($dir . $FolderOrFile) && $FolderOrFile != "." && $FolderOrFile != ".." && $FolderOrFile != ".htaccess")
{
$TmpTime = time() - filemtime($dir . $FolderOrFile); //
if ($TmpTime > $MaxCacheTime)
{
unlink($dir . $FolderOrFile); //
$Count++;
}
}
}
closedir($handle);
return $Count;
}
function RejectCall($message)
{
global $HostRoot, $CacheRoot, $ImageRoot, $LogRoot, $CleanCache, $RejectLog;
header("HTTP/1.1 410 Error : Gone");
header("X-Powered-By: -COD~Zilla-", true);
header("Content-Length: 0", true);
//header ("Shit List: You Made It", true);
$message = $message . " <-\n";
$OpenRejectionLog = @fopen($RejectLog, "a+");
if ($OpenRejectionLog) @fwrite($OpenRejectionLog, $message);
@fclose($OpenRejectionLog);
// Might as well get the bastards to clean up my cache while they are wasting my bandwidth
if(!file_exists($CleanCache))
{
set_time_limit(30);
$TmpTime = time() - @filemtime("awslock/.");
if ($TmpTime > 0) @rmdir("awslock");
$A = "IP Files:" . deldir($HostRoot, 2) . "\n";
$A = $A . "Cache Files:" . deldir($CacheRoot, 1) . "\n";
$A = $A . "Image Files:" . deldir($ImageRoot, 1) . "\n";
$A = $A . "Log Files:" . deldir($LogRoot, 3) . "\n";
if($F = @fopen($CleanCache, "a+")) @fwrite($F, $A);
@fclose($F);
}
die();
}
function log_it()
{
global $locked, $BotCall, $Error, $ErrorLog, $BotLog, $Log, $time_start, $date, $time, $ipaddress, $fetchtime, $QueryString, $CachedOrFetched, $Retries, $AWSstatus, $agent, $referer, $fetch, $LastModified, $ClientLastModified, $HostName, $Status, $DNSLOOKUPtime, $HOSTLOOKUPtime, $LOCKtime, $CurlTime, $SENDtime;
if($locked)
{
$TmpTime = time() - @filemtime("awslock/.");
if ($TmpTime > 0) @rmdir("awslock");
}
$fetchtime = round(getmicrotime() - $time_start, 4);
if($Status == "Unknown")
{
if((connection_status()==0) and !connection_aborted()) $Status = "Sent";
else $Status = "Aborted";
}
$message = "-> | $date $time EST | $ipaddress | $fetchtime | $QueryString | $CachedOrFetched | $Retries | $AWSstatus Host Lookup: $HOSTLOOKUPtime AWS Lookup: $DNSLOOKUPtime Lock Time: $LOCKtime Curl Time: $CurlTime Send Time: $SENDtime | $agent | $referer |";
if ($Error) // Log the Error Call
{
$message = $message . " $fetch | $Status | <-\n";
if($Openerrorlog = @fopen($ErrorLog, "a+")) @fwrite($Openerrorlog, "$message");
@fclose($Openerrorlog);
}
elseif($BotCall) // Log the agent in the botlog
{
$message = $message . " $LastModified | $ClientLastModified | $Status | <-\n";
if($Openbotlog = @fopen($BotLog, "a+")) @fwrite($Openbotlog, "$message");
@fclose($Openbotlog);
}
else // Log the GOOD AWS Call
{
if (!eregi("&banner", $QueryString) && !eregi("&mybottomstore", $QueryString))
{
$message = $message . " $LastModified | $ClientLastModified | $HostName | $Status | <-\n";
if($Openlog = @fopen($Log, "a+")) @fwrite($Openlog, "$message");
@fclose($Openlog);
}
}
exit(0);
}
?>
=============================================
File fetch.php
=============================================
| $date $time EST | $ipaddress | $QueryString | $ServerRequest | $agent | $referer |");
$locked = false;
register_shutdown_function('log_it');
header("X-Powered-By: -COD~Zilla-", true);
$MaxCacheTime = 7*24*60*60;
$XpireTime = 7*24*60*60;
$BackTimeStampFile = 1*24*60*60 - ((3*60) + 22);
$FileName = urlencode($QueryString);
$CacheFileStub = md5($FileName);
$CacheFile = $CacheRoot . $CacheFileStub . ".html";
$AWSstatus = "OK";
$Status = "Unknown";
$Error = false;
$Recieved = 0;
$Retries = 0;
$CachedOrFetched = "304";
if((@file_exists($CacheFile)) && (($TmpTime=time())-@filemtime($CacheFile) < $MaxCacheTime)) // Seven Day Cache Rule -1 Day
{
$Filetime = @filemtime($CacheFile) - $BackTimeStampFile;
$Xpire = $Filetime + $XpireTime + $BackTimeStampFile;
$LastModified = gmdate("D, d M Y H:i:s", $Filetime) . " GMT";
$Etag = '"'. md5($LastModified . $CacheFile) . '"';
header("Last-Modified: $LastModified", true);
header("ETag: $Etag", true);
if(strstr($ClientLastModified, $LastModified) || strstr($ClientEtag, $Etag))
{
header("Content-Length: 0", true);
header("HTTP/1.1 304 Not Modified", true);
}
else
{
header("Content-Type: text/html", true);
header("Cache-Control: private, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Expires: " . gmdate('D, d M Y H:i:s', $Xpire) . " GMT");
if(send_file($CacheFile)) $Status = "Sent";
else $Status = "Aborted";
$CachedOrFetched="CACHED";
}
}
else
{
$fetch = '/onca/xml3?t=' . $ID . '&dev-t=' . $TOKEN . '&' . $QueryString . '&type=heavy&locale=us&f=' . $XSL . '&date=' . urlencode($date) . '&time=' . urlencode($time) . urlencode(" EST");
if(strstr($QueryString, "page=") && !preg_match("/browse/", $QueryString)) $fetch = $fetch . '&sort=relevancerank';
if($AdSense) $fetch = $fetch . '&AdSense=true';
$fetch = $fetch . '&CSS=' . $CSS . '&JS=' . $JS;
$DNSLOOKUPstarttime = getmicrotime(); // this is placed here to take advantage of the file lock
$fetch = 'http://' . GetAWSAddress($AWSRoot) . $fetch;
$DNSLOOKUPtime = $DNSLOOKUPtime + round((getmicrotime() - $DNSLOOKUPstarttime), 4);
set_time_limit(30);
$AWSstatus = "";
$CachedOrFetched = "FETCHED";
$Fetched = false;
$Retry = false;
$Delay = 1;
do
{
if ($Retry)
{
sleep ($Delay);
$Retries++;
$Delay *= 2;
}
$Fetched = false;
$Retry = false;
$locked = false;
$LockAttempt = 0;
$Temp = getmicrotime();
while(!$locked && ($LockAttempt < 6))
{
if(@mkdir("awslock",0777)) $locked = true;
else
{
$LockAttempt++;
$TmpTime = time() - @filemtime("awslock/.");
if ($TmpTime > 0) @rmdir("awslock");
else usleep(200000);
}
}
$LOCKtime = $LOCKtime + round((getmicrotime() - $Temp), 4);
$Data = FetchURL($fetch, $CurlTimeOut);
if($locked)
{
$TmpTime = time() - @filemtime("awslock/.");
if ($TmpTime > 0) @rmdir("awslock");
}
$locked = false;
if ($StatusCode != 200)
{
$AWSstatus = "Error: HTTP: $StatusCode :" . $CurlStatus;
if ($Retries < $MAX_Retries) $Retry = true;
else $Error = true;
}
else
{
$Fetched = true;
$AWSstatus = "CURL OK";
$Recieved = strlen($Data); // Data is in $Data
$AWSstatus = $AWSstatus . " Recieved: $Recieved";
$Error = false;
$DoCache = true;
$DoDisplay = true;
$Output=explode("\n", $Data);
if(preg_match("/xml version/i", $Output[0]))
{
if ($Retries < $MAX_Retries) $Retry = true;
else
{
$AWSstatus = $AWSstatus . " " . strip_tags("Error: $Output[0]:$Output[1]");
$Error = true;
$DoDisplay = false;
$DoCache = false;
$Header="503";
}
}
elseif($Recieved < 100)
{
if ($Retries < $MAX_Retries) $Retry = true;
else
{
$AWSstatus = $AWSstatus . " Error: Blank Page";
$Error = true;
$DoDisplay = false;
$DoCache = false;
$Header="503";
}
}
elseif(!preg_match("/celtic-one/i", $Data))
{
if ($Retries < $MAX_Retries) $Retry = true;
else
{
$AWSstatus = $AWSstatus . " Error: Redirection";
$Error = true;
$DoDisplay = false;
$DoCache = false;
$Header="503";
}
}
}
} while ($Retry);
// Filter out nonsense
$Data = preg_replace("/src=.http:\/\/images.amazon.com.+?jpg./i", "#", $Data);
if(preg_match('/AvailabilityNode/', $Data))
{
$AWSstatus = $AWSstatus . " Error: Availability Node Missing";
$Error = true;
$DoCache = false;
}
if(preg_match("/errorbox/i", $Data)) // Bad Search No Need To Cache
{
$Error = true;
$DoCache = false;
$Header="404";
if(preg_match("/no exact matches/i", $Data)) $AWSstatus = $AWSstatus . " Error: Bad Search";
elseif(preg_match("/valid asin/i", $Data)) $AWSstatus = $AWSstatus . " Error: Invalid Asin";
elseif(preg_match("/this asin cannot be accessed using amazon/i", $Data)) $AWSstatus = $AWSstatus . " Error: Third Party Product";
else $AWSstatus = $AWSstatus . " Error: Unknown Search Error";
}
if ($Fetched)
{
header("Cache-Control: post-check=0, pre-check=0", false);
if ($Error)
{
header("Cache-Control: no-store, no-cache, must-revalidate", false);
if ($Header == "503")
{
header("HTTP/1.1 503 Error : Service Unavailable", true);
header("Content-Length: 0", true);
}
elseif ($Header == "404")
{
header("HTTP/1.1 404 Error : Not Found", true);
}
}
if ($DoDisplay)
{
header("Content-Type: text/html", true);
if (!$Error) header("Cache-Control: private, must-revalidate");
if($DoCache)
{
$handle = @fopen("$CacheFile", "wb"); //Write the good data to cache
@fwrite($handle, $Data);
@fclose($handle);
$Filetime = @filemtime($CacheFile) - $BackTimeStampFile;
$Xpire = $Filetime + $XpireTime + $BackTimeStampFile;
$LastModified = gmdate("D, d M Y H:i:s", $Filetime) . " GMT";
$Etag = '"'. md5($LastModified . $FileName) . '"';
header("Last-Modified: $LastModified", true);
header("ETag: $Etag", true);
header("Expires: " . gmdate('D, d M Y H:i:s', $Xpire) . " GMT");
}
$SENDtime = getmicrotime();
ob_start('_gzipCompress');
echo $Data;
while (@ob_end_flush());
$SENDtime = round((getmicrotime() - $SENDtime), 4);
if((connection_status()==0) and !connection_aborted()) $Status = "Sent";
else $Status = "Aborted";
}
}
else
{
$Error = true;
header ("Connection: close", true);
if(@file_exists($CacheFile)) // If AWS is down and cache file is outdated - use it anyway
{
$Filetime = @filemtime($CacheFile) - $BackTimeStampFile;
$Xpire = $Filetime + $XpireTime + $BackTimeStampFile;
$LastModified = gmdate("D, d M Y H:i:s", $Filetime) . " GMT";
$Etag = '"'. md5($LastModified . $FileName) . '"';
header("Content-Type: text/html", true);
header("Cache-Control: private, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Last-Modified: $LastModified", true);
header("ETag: $Etag", true);
header("Expires: " . gmdate('D, d M Y H:i:s', $Xpire) . " GMT");
if(send_file($CacheFile)) $Status = "Sent";
else $Status = "Aborted";
$CachedOrFetched="Fallback Cached";
$AWSstatus = "Fallback Cached Due To " . $AWSstatus;
}
// If AWS is down due to 503s - Redirect - Maybe it will work?
elseif(($StatusCode == 503 || preg_match("/timed out|connect failed/", $CurlStatus)) && !$BotCall)
{
$CachedOrFetched="Redirected To AWS";
$AWSstatus = "Temporary Redirect Fallback Due To " . $AWSstatus;
header("HTTP/1.1 307 Temporary Redirect", true);
header("Location: $fetch");
header("Content-Length: 0", true);
}
else
{
header("HTTP/1.1 503 Error : Service Unavailable", true);
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Length: 0", true);
}
}
}
exit(0);
//header("Connection: Keep-Alive", true);
//header ("Connection: close", true);
//header ("Keep-Alive: timeout=30, max=149", true);
?>
=============================================
File get-image.php
=============================================
| $date $time EST | $ipaddress | $QueryString | $ServerRequest | $agent | $referer |");
$Cache = false;
$fetch = 'http://images.amazon.com/images/P/' . $QueryString;
$FileName = $QueryString;
$ImageFile = $ImageRoot . $FileName ;
if($Cache) $HTTP_ImageFile = 'http://www.celtic-one-design.com/php/image-cache/' . $FileName;
else $HTTP_ImageFile = $fetch;
$HTTP_AlternateImageFile ='http://www.celtic-one-design.com/php/no-img-lg.gif';
if(!@file_exists($ImageFile) && $Cache)
{
$FetchError = false;
$Retry = false;
$Delay = 1;
$Retries = 0;
set_time_limit(30);
do
{
if ($Retry)
{
sleep ($Delay);
$Retries++;
$Delay *= 2;
}
$Retry = false;
$Data = FetchURL($fetch, $CurlTimeOut);
if ($StatusCode != 200)
{
if ($Retries < $MAX_Retries) $Retry = true;
else $FetchError = true;
}
} while ($Retry);
if ($StatusCode == 200 && (strlen($Data) <= 1000)) $FetchError = true;
if ($FetchError) $HTTP_ImageFile = $HTTP_AlternateImageFile;
else
{
$fp = @fopen("$ImageFile", "wb");
@fwrite($fp, $Data);
@fclose($fp);
}
}
header("HTTP/1.1 302 Found", true);
header("Content-Length: 0", true);
header("Location: $HTTP_ImageFile");
header("Cache-Control: private");
header("X-Powered-By: -COD~Zilla-", true);
die();
?>
=============================================
File click.php
=============================================
| $date $time EST | $ipaddress | $QueryString | <-\n";
if($Openlog = @fopen($clicklog, "a+")) @fwrite($Openlog, "$message");
@fclose ($Openlog);
?>
=============================================
File compress.php
=============================================
| $date $time EST | $ipaddress | $QueryString | $ServerRequest | $agent | $referer |");
register_shutdown_function('Compress_log_it');
header("X-Powered-By: -COD~Zilla-", true);
$Status = "304";
$CompressFile = "//home/celtic3/public_html/php/" . $QueryString;
if(@file_exists($CompressFile))
{
$Filetime = @filemtime($CompressFile);
$LastModified = gmdate("D, d M Y H:i:s", $Filetime) . " GMT";
$Etag = '"'. md5($LastModified . urlencode($QueryString)) . '"';
header("Last-Modified: $LastModified", true);
header("ETag: $Etag", true);
if(strstr($ClientLastModified, $LastModified) || strstr($ClientEtag, $Etag))
{
header("Content-Length: 0", true);
header("HTTP/1.1 304 Not Modified", true);
}
else
{
if(strstr($QueryString, ".css"))
{
header("Content-Type: text/css", true);
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 24*60*60) . ' GMT');
}
elseif(strstr($QueryString, ".js"))
{
//header("Content-Type: application/x-javascript", true);
header("Content-Type: text/javascript", true);
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 60*60) . ' GMT');
}
elseif(strstr($QueryString, ".xsl"))
{
header("Content-Type: text/xml", true);
header("Expires: " . gmdate('D, d M Y H:i:s', time() + 24*60*60) . ' GMT');
}
else header("Content-Type: text/plain", true);
header("Cache-Control: private, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
if(send_file($CompressFile)) $Status = "Sent";
else $Status = "Aborted";
}
}
exit(0);
function Compress_log_it()
{
global $CompressLog, $date, $time, $ipaddress, $QueryString, $Status, $agent, $referer, $LastModified, $ClientLastModified;
$message = "-> | $date $time EST | $ipaddress | $QueryString | $Status | $agent | <-\n";
if($Openlog = @fopen($CompressLog, "a+")) @fwrite($Openlog, "$message");
@fclose($Openlog);
}
?>
=============================================
File redirect.php
=============================================
|$date $time EST|$ipaddress|$QueryString|$ServerRequest|$agent|$referer|");
$message = "-> | $date $time EST | $ipaddress | $Redirect | <-\n";
if($Openlog = @fopen($clicklog, "a+")) @fwrite($Openlog, "$message");
@fclose ($Openlog);
header("X-Powered-By: -COD~Zilla-", true);
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-Length: 0", true);
header("HTTP/1.1 307 Temporary Redirect", true);
header("Location: $Redirect");
header ("Connection: close", true);
?>
=============================================
File ae.xsl
=============================================
Special Discount! Your price: List price:
Please modify your search and try again.
The price is so low that Jeff Bezos will not allow it to be displayed on this site! To see Jeff's price, click the order button.
Your price:
THAT'S
Platforms:
Tracks
Features:
Related Categories
Product Review
Customer Reviews











| ' sc+='zonEXPLORERIn Association With Amazon.com' sc+=' | |
| ' sc+='' sc+=' | ' sc+='' sc+='' sc+=' |
| '
if(ZonTools || ZonRecommends) sc+=' '
if (ZonTools)
{
sc+='Your Amazon Cart';
if (AddToWishList) sc+='Your Amazon Wish List';
}
if (ZonRecommends)
{
sc+='New Releases'
sc+='Coming Soon'
sc+='Gift Ideas'
sc+='Early Adopters'
}
if(ZonTools || ZonRecommends) sc+=' '
sc+=' | |
Prices and product availability are subject to change. Price is accurate as of ' + DATE + ' at ' + TIME + '
Any price displayed on the Amazon website at the time of purchase will govern the sale of this product.
Privacy Policy' sc+=' | My Amazon Wishlist' sc+=' | Feedback' sc+=' | Use zonExplorer Search Form At Your Site
' document.write(sc) sc=''; } function order(Asin,Title,IsMedia,Available) { sc=''; if(AddToCart && Available == "true") { sc+=''; sc+='