<?php
include("clickmeconfig.php");
$url = $_GET['url'];
if ($_GET['show'] == "header")  {
echo"
<html>
<head>
<title>$SITETITLE</title>
<style>
* {
font-family: Arial, Helvetica, sans-serif; 
font-size:12px;
font-weight:bold;
text-decoration:none;
color: $frametext;
background-color: $framebackground;
}
</style>
<BASE TARGET=\"_top\">
</head>
<BODY BGCOLOR=\"#B51109\">
&nbsp;<span class=\"bigwhite-noul\">
<a href=\"$BASEURL\" target=\"_parent\">Return to $SITETITLE</a> | <a href=\"$url\">Remove Frame</a>
</span>
</body>
</html>
" ;
} else {
function error ($error_message) {
	echo $error_message."<BR>";
	exit;
}
if (! file_exists($COUNT_FILE))
	error("Can't find file, check '\$COUNT_FILE' var...");
if ((! $url) || (! preg_match("/http:/", $url))) error ("<h1>ClickMe Error</h1><font face=\"Verdana\" size=\"2\" color=\"red\">Invalid url, you should use the script like this: <a href=\"http://$SERVER_NAME$PHP_SELF?http://www.ki4bbo.org/\">http://$SERVER_NAME$PHP_SELF?http://www.ki4bbo.org/</a></font>");
$file_arry = file($COUNT_FILE);        
while (list($key, $val) = each($file_arry)) {
	if ($val != "") {
		list($file_url, $nb) = preg_split("/\t|\n/", $val);
		if ($file_url == $url) { 
			$nb++; $file_arry[$key] = "$file_url\t$nb\n"; $find = 1;
		}
	}
}
$today = date("d/m/y h:i A");   //JAM

$file = join ("", $file_arry);
if (! $find) $file .= "$today $url\t1\n";   //JAM- add $today
$fp = fopen("$COUNT_FILE", "w");
flock($fp, 1);
fputs($fp, $file);                                                     
flock($fp, 3);
fclose($fp);
if ($showframe == "true") {
echo ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>'.$SITETITLE.' - '.$url.'</title>
</head>

<frameset rows="*,1" frameborder="0" framespacing="0" border="0">
	<frame src="'.$url.'"  name="outside site" id="outsidesite" />
	<frame src="out.php?show=header&url='.$url.'" marginheight="1" />

</frameset>
<noframes>
Click here to continue: <a href="'.$url.'">'.$url.'</a>
</noframes>
</html>');
} else {
header("Location: $url");
} 
}
?>