HEX
Server: Apache/2.4.25 (Debian)
System: Linux server17 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64
User: web37 (1062)
PHP: 7.4.30
Disabled: show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, disk_total_space, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen
Upload Files
File: /var/www/web37/htdocs/topsex/admin/stats.php
<?php
############################################
### Top-XL - Statistiks stats.php 
############################################
/// 1. You are NOT entiteld to rent, lease, transfer, reproduce or distribute this Software.
/// 2. You are entiteld to adapt, and modify the Software to your need.
/// 3. You can use this Script on all of YOUR Domains.
/// 4. Any modification or removal to the links in the footer and member area shall terminate this license immediately .
/// 5. The Script has been tested on different Servers and found free of any notable errors by the author. The Author shall not in any case be liable for any special, incidental indirect or other similar damages arising from the use of this Script.
/// 6. Author: Simon Zehender - Contact: https://www.paddelberg.de
////////////////////////////////////////////
////////////////////////////////////////////
if ($scriptpath!=$_SERVER['DOCUMENT_ROOT'])
	{echo "Are you looking for something?";exit;}

$action = !empty ($_GET["action"]) ? safety ($_GET["action"]) : '';
$start = !empty ($_POST["start"]) && is_numeric ($_POST["start"]) ? safety ($_POST["start"]) : 0;
$sorter = !empty ($_GET["sorter"]) ? safety ($_GET["sorter"]) : '';
$show = !empty ($_GET["show"]) ? safety ($_GET["show"]) : '';
$what = !empty ($_GET["what"]) ? safety ($_GET["what"]) : '';

$entryspersite = !empty ($_GET["entryspersite"]) ? safety ($_GET["entryspersite"]) : '';
$entryspersite = !empty ($_POST["entryspersite"]) ? safety ($_POST["entryspersite"]) : $entryspersite;
$entryspersite = empty ($entryspersite) || !is_numeric($entryspersite) ? 25 : $entryspersite;

$sortid = "idasc";
$sortfecha = "fechaasc";
$sortip = "ipasc";
$sortin = "indesc";
$sortout = "outdesc";
$sortlang = "langasc";
$sortref = "refasc";
if ($sorter == "fechadesc")
	{$sqlholder = "ORDER BY fecha DESC";}
elseif ($sorter == "iddesc")
	{$sqlholder = "ORDER BY siteid DESC";}
elseif ($sorter == "idasc")
	{$sqlholder = "ORDER BY siteid ASC";$sortid = "iddesc";}
elseif ($sorter == "indesc")
	{$sqlholder = "ORDER BY validin DESC";$sortin = "inasc";}
elseif ($sorter == "inasc")
	{$sqlholder = "ORDER BY validin ASC";}
elseif ($sorter == "outdesc")
	{$sqlholder = "ORDER BY validout DESC";$sortout = "outasc";}
elseif ($sorter == "outasc")
	{$sqlholder = "ORDER BY validout ASC";}
elseif ($sorter == "ipdesc")
	{$sqlholder = "ORDER BY ip DESC";}
elseif ($sorter == "ipasc")
	{$sqlholder = "ORDER BY ip ASC";$sortip = "ipdesc";}
elseif ($sorter == "langdesc")
	{$sqlholder = "ORDER BY language DESC";}
elseif ($sorter == "langasc")
	{$sqlholder = "ORDER BY language ASC";$sortlang = "langdesc";}
elseif ($sorter == "refdesc")
	{$sqlholder = "ORDER BY referer DESC";}
elseif ($sorter == "refasc")
	{$sqlholder = "ORDER BY referer ASC";$sortref = "refdesc";}
else
	{
	$sqlholder = "ORDER BY fecha ASC";
	$sortfecha = "fechadesc";
	}

$main_content = '';
$menulast = '';
$menufirst = '';
$menu = '';

////////////////////////////////////////
/// dailystats current month
////////////////////////////////////////
if ($action=="dailystats")
	{
	if ($show == "lastmonth")
		{
		$month = date("m")-1;
		$thisyear = date("y");
		if ($month <=0)
			{$month = 12;$thisyear = $thisyear-1;}
		$siteheading = $text_dailystatslm." ";
		$backbutton = "lastmonthstats";
		}
	elseif ($show == "thismonth")
		{
		$month = date("m");
		$thisyear = date("y");
		$siteheading = $text_dailystatstm." ";
		$backbutton = "monthstats";
		}
	$daybegin = mktime(0,0,0,$month,$what,$thisyear); 
	$dayend = $daybegin+86400;
	$db -> query ("SELECT COUNT(id) as cnt FROM ".$topxl_hits_table."  WHERE timestamp>'".$daybegin."' and timestamp<'".$dayend."'"); 
	$row = $db -> fetch ();
	$allentrys = $row["cnt"];

	// the page-forward and backward links, and the pages to click on
	if ($allentrys > $entryspersite)
		{
		$max = $allentrys/$entryspersite;
		$max = ceil($max);
		$startfor = $start/$entryspersite;
		$startfor = ceil($startfor);
		if ($startfor <= 0)
			{$startfor = 0;}
		$endfor = $startfor+5;
		if ($endfor > $max)
			{$endfor = $max;}
		$thissite = $start/$entryspersite;
		$thissite = ceil($thissite);
		$lastsite = ($max-1)*$entryspersite;
		$nextback = ($startfor-1)*$entryspersite;
		$nextnext = ($startfor+1)*$entryspersite;
		$next = $start+$entryspersite;
		for($i = $startfor; $i < $endfor; $i++)
			{
			$nextsite = $i+1;
			if ($i == $thissite)
				{
				if ($i < $max-1)
					{
					$menulast .= "<a href=\"index.php?do=stats&action=dailystats&sorter=".$sorter."&start=".$lastsite."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_last."</b></a> ";
					$menu .= "<a href=\"index.php?do=stats&action=dailystats&start=".$nextnext."&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_next."</b></a> ";
					}
				if ($i > 0)
					{
					$menufirst .= "<a href=\"index.php?do=stats&action=dailystats&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_first."</b></a> ";
					$menu .= "<a href=\"index.php?do=stats&action=dailystats&start=".$nextback."&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_back."</b></a> ";
					}
				$menu .= "<strong>$thissite</strong> ";
				}
			if ($i < $max-1)
			{
			$menu .= "<a href=\"index.php?do=stats&action=dailystats&start=".$next."&entryspersite=".$entryspersite."&sorter=".$sorter."&what=".$what."&show=".$show."\"><b>".$nextsite."</b></a> ";}
			$next = $next+$entryspersite;
			}
		}

	$main_content .= "
	<table width=\"874\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
	<tr>
		<td height=\"35\" colspan=\"8\" class=\"heading\"  bgcolor=\"#FFFFFF\">".$siteheading." ".$what."</td>
	</tr>
	<form name=\"form1\" method=\"post\" action=\"index.php?do=stats&action=dailystats&sorter=".$sorter."&what=".$what."&show=".$show."\">
	<tr>
		<td height=\"28\" colspan=\"8\" bgcolor=\"#FFFFFF\" class=\"top\" style=\"padding:0px;\">
			<table width=\"872\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
				<tr>
					<td height=\"20\" width=\"448\" bgcolor=\"#FFFFFF\" align=\"left\" valign=\"middle\" class=\"top\" style=\"border-right:1px solid #CCCCCC;\">
					 ".$menu." ".$menufirst." ".$menulast."
					</td>
					<td width=\"80\" bgcolor=\"#FFFFFF\" align=\"center\" valign=\"middle\" class=\"top\" style=\"border-right:1px solid #CCCCCC;\">
					 <a href=\"index.php?do=stats&action=".$backbutton."\"><strong>".$text_mainsection."</strong></a>
					</td>
					<td width=\"350\" bgcolor=\"#FFFFFF\" align=\"center\" valign=\"middle\">
					<strong>".$text_show."</strong>
					".$text_from."
					<input type=\"text\" name=\"start\" value=\"$start\" style=\"width:30px;height:16px;\"> --- 
					<input type=\"text\" name=\"entryspersite\" value=\"".$entryspersite."\" style=\"width:30px;height:16px;\"> <strong>".$text_persite."</strong> 
					<input name=\"submit\" type=\"submit\" class=\"submitbuton\" value=\"".$text_submit."\" style=\"width:80px;height:22px;\"> 
					</td>
				</tr>
			</table>
		</td>
	</tr>
	</form>
	<tr>	
		<td width=\"75\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystats&entryspersite=".$entryspersite."&sorter=".$sortfecha."&what=".$what."&show=".$show."";
		if ($sorter == "fechadesc" or $sorter == "fechaasc" or $sorter == "")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_time."</a>
		</td>
		<td width=\"60\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystats&entryspersite=".$entryspersite."&sorter=".$sortid."&what=".$what."&show=".$show."";
		if ($sorter == "iddesc" or $sorter == "idasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_siteid."</a>
		</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystats&entryspersite=".$entryspersite."&sorter=".$sortin."&what=".$what."&show=".$show."";
		if ($sorter == "indesc" or $sorter == "inasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_in."</a>
		</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystats&entryspersite=".$entryspersite."&sorter=".$sortout."&what=".$what."&show=".$show."";
		if ($sorter == "outdesc" or $sorter == "outasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_out."</a>
		</td>
		<td width=\"135\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystats&entryspersite=".$entryspersite."&sorter=".$sortip."&what=".$what."&show=".$show."";
		if ($sorter == "ipdesc" or $sorter == "ipasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_adminsignupip."</a>
		</td>
		<td width=\"85\" bgcolor=\"#E4E4E4\" align=\"center\">Browser</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystats&entryspersite=".$entryspersite."&sorter=".$sortlang."&what=".$what."&show=".$show."";
		if ($sorter == "langdesc" or $sorter == "langasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_lang."</a>
		</td>
		<td width=\"316\" bgcolor=\"#E4E4E4\">
		<a href=\"index.php?do=stats&action=dailystats&entryspersite=".$entryspersite."&sorter=".$sortref."&what=".$what."&show=".$show."";
		if ($sorter == "refdesc" or $sorter == "refasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_referer."</a>
		</td>
	</tr>";
	
	$rowmarker = 0;
	$db -> query ("SELECT * FROM ".$topxl_hits_table." WHERE timestamp>'".$daybegin."' and timestamp<'".$dayend."' ".$sqlholder." LIMIT ".$start.",".$entryspersite); 
	while($dailystatsgetrow = $db -> fetch ())
		{
		$siteid = $dailystatsgetrow['siteid'];
		$fecha = substr($dailystatsgetrow['fecha'], 11, 19);
		$ip = $dailystatsgetrow['ip'];
		$referer = $dailystatsgetrow['referer'];
		$language = substr($dailystatsgetrow['language'], 0, 2);
		$browser = $dailystatsgetrow['browser'];
		$browserreal = $browser;
		$browser = useragent($browser);
		$in = $dailystatsgetrow['validin'];
		$out = $dailystatsgetrow['validout'];
		if ($in == "no-kekssperre")
			{$in = "X-C";}
		if ($in == "no-ipblock-nokeks")
			{$in = "X-IP";}
		if ($in == "yes")
			{$in = "YES";}
		if ($out == "no-kekssperre")
			{$out = "X-C";}
		elseif ($out == "no-ipblock-nokeks")
			{$out = "X-IP";}
		elseif ($out == "yes")
			{$out = "YES";}
		$rowmarker++;
		if ($rowmarker == 2)
			{
			$tdbgcolor = "bgcolor=\"#F7F7F7\"";
			$rowmarker = 0;
			}
		else
			{$tdbgcolor = "bgcolor=\"#FFFFFF\"";}
		$main_content .= "
		<tr>
			<td ".$tdbgcolor." nowrap align=\"center\">".$fecha."</td>
			<td ".$tdbgcolor." align=\"right\">".$siteid."</td>
			<td ".$tdbgcolor." align=\"right\">".$in."</td>
			<td ".$tdbgcolor." align=\"right\">".$out."</td>
			<td ".$tdbgcolor." align=\"right\">".$ip."</td>
			<td ".$tdbgcolor." align=\"center\"><span title=\"".$browserreal."\">".$browser."</span></td>
			<td ".$tdbgcolor." align=\"center\">".$language."</td>
			<td ".$tdbgcolor." nowrap><div id=\"Layer1\" style=\"position:relativ; width:300px; height:22px; z-index:1; overflow: hidden;\"><a href=\"".$referer."\" target=\"_blank\" title=\"".$referer."\">".$referer."</a></div></td>
		</tr>
		";
		}

	$main_content .= "
		<tr>
			<td  bgcolor=\"#FFFFFF\" colspan=\"9\" height=\"28\"><strong>".$text_legend."</strong></td>
		</tr>
		<tr>
			<td  bgcolor=\"#FFFFFF\" colspan=\"9\" class=\"small\">
			<strong>X-C:</strong> ".$text_exp_xc."<br>
			<strong>X-IP:</strong> ".$text_exp_xip."<br>
			<strong>I.Ex:</strong> ".$text_exp_iex."<br>
			</td>
		</tr>
	</table>";

	////template
	if(!file_exists($file))
	{echo "The template ".$file." does not exist."; exit;}
	$fp1 = fopen($file,"r");  
	$zeile = fread ($fp1, filesize ($file));
	include("template.php");
	echo $zeile;
	exit;
	}

////////////////////////////////////
/// Current and last month stats
////////////////////////////////////

if ($action=="monthstats" or $action=="lastmonthstats")
	{
	if ($action=="lastmonthstats")
		{
		$month = date("m")-1;
		$thisyear = date("y");
		if ($month <=0)
			{
			$month = 12;
			$thisyear = $thisyear-1;
			}
		$thismonthdate = mktime(0,0,0,$month,1,$thisyear);
		$day = date("t",$thismonthdate);
		$siteheading = $text_lastmonthstats;
		$show = "lastmonth";
		}

	else
		{
		$day = date("d");
		$month = date("m");
		$thisyear = date("y"); 
		$siteheading = $textthismonthstats;
		$show = "thismonth";
		$thismonthdate = mktime(0,0,0,$month,1,$thisyear);
		}

	$weekdayget = $thismonthdate;
	$dateget = date("m-d",$thismonthdate);

	//// Html to display on the site
	$main_content .= "
	<table width=\"874\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
	<tr>
		<td height=\"35\" colspan=\"8\" class=\"heading\"  bgcolor=\"#FFFFFF\">".$siteheading."</td>
	</tr>
	<tr>
		<td width=\"20\" bgcolor=\"#E4E4E4\">&nbsp;</td>
		<td width=\"50\" bgcolor=\"#E4E4E4\">".$text_weekday."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\">".$text_date."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">".$text_hitin."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">".$text_hitout."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">".$text_ratio."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\"></td>
		<td width=\"501\" bgcolor=\"#E4E4E4\"></td>
	</tr>";

	$rowmarker = 0;
	for ($i= 1; $i<=$day; $i++) 
		{
		$rowmarker++;

		if ($rowmarker == 2)
			{
			$tdbgcolor = "bgcolor=\"#F7F7F7\"";
			$rowmarker = 0;
			}

		else
			{$tdbgcolor = "bgcolor=\"#FFFFFF\"";}

		$weekday = date("D", $weekdayget);
		$daybegin = $weekdayget;
		$yearget = date("y", $weekdayget);
		$monthget = date("m", $weekdayget);
		$dayget = date("d", $weekdayget);
		$daybegin = mktime(0,0,0,$monthget,$dayget,$yearget);
		$dayend = $daybegin+86400;

		$db -> query("SELECT count(validin) AS insumme FROM ".$topxl_hits_table." WHERE validin='yes' and timestamp>'$daybegin' and timestamp<'$dayend'"); 
		$countmonthinsrow = $db -> fetch ();
		$monthhitsin = $countmonthinsrow['insumme'];

		$db -> query("SELECT count(validout) AS outsumme FROM ".$topxl_hits_table." WHERE validout='yes' and timestamp>'$daybegin' and timestamp<'$dayend'"); 
		$countmonthoutsrow = $db -> fetch ();
		$monthhitsout = $countmonthoutsrow['outsumme'];

		if (!empty ($monthhitsin) && !empty ($$monthhitsout))
			{
			$ratiodayinout = $monthhitsout/$monthhitsin;
			$ratiodayinout = substr($ratiodayinout, 0, 4);
			}

		else 
			{$ratiodayinout = 1;}	
		
		$main_content .= "
		<tr>
			<td height=\"20\" ".$tdbgcolor.">".$i."</td>
			<td ".$tdbgcolor.">".$weekday."</td>
			<td ".$tdbgcolor." align=\"center\">".$dateget."</td>
			<td ".$tdbgcolor." align=\"right\">".$monthhitsin."</td>
			<td ".$tdbgcolor." align=\"right\">".$monthhitsout."</td>
			<td ".$tdbgcolor." align=\"center\">1/".$ratiodayinout."</td>
			<td ".$tdbgcolor." align=\"center\"><a href=\"index.php?do=stats&action=dailystats&what=".$i."&show=".$show."\">".$text_view."</a></td>
			<td ".$tdbgcolor."></td>
		</tr>";

		$dateget++;
		$weekdayget = $weekdayget+86400;
		unset($ratiodayinout);
		}

	$main_content .= "
	</table>";

	////template
	if(!file_exists($file))
		{echo "The template ".$file." does not exist."; exit;}
	$fp1 = fopen($file,"r");  
	$zeile = fread ($fp1, filesize ($file));
	include("template.php");
	echo $zeile;
	exit;
	}

////////////////////////////////////
//// Dailystats blockes by cookie
////////////////////////////////////

if ($action=="dailystatsbc")
	{
	if ($show == "lastmonthstatsbc")
		{
		$month = date("m")-1;
		$thisyear = date("y");
		if ($month <=0)
			{$month = 12;$thisyear = $thisyear-1;}
		$siteheading = $text_dailystatslmbc." ";
		$backbutton = "lastmonthstatsbc";
		}

	elseif ($show == "monthstatsbc")
		{
		$month = date("m");
		$thisyear = date("y");
		$siteheading = $text_dailystatstmbc." ";
		$backbutton = "monthstatsbc";
		}

	$daybegin = mktime(0,0,0,$month,$what,$thisyear); 
	$dayend = $daybegin+86400;
	$db -> query ("SELECT siteid FROM ".$topxl_hits_table." WHERE timestamp>='".$daybegin."' and timestamp<'".$dayend."' and (validin='no-kekssperre' or validout='no-kekssperre')"); 

	// the page-forward and backward links, and the pages to click on
	if ($db -> numRows () > $entryspersite)
		{
		$max = $allentrys / $entryspersite;
		$max = ceil($max);
		$startfor = $start/$entryspersite;
		$startfor = ceil($startfor);
		if ($startfor <= 0)
			{$startfor = 0;}
		$endfor = $startfor+5;
		if ($endfor > $max)
			{$endfor = $max;}
		$thissite = $start/$entryspersite;
		$thissite = ceil($thissite);
		$lastsite = ($max-1)*$entryspersite;
		$nextback = ($startfor-1)*$entryspersite;
		$nextnext = ($startfor+1)*$entryspersite;
		$next = $start+$entryspersite;

		for($i = $startfor; $i < $endfor; $i++)
			{
			$nextsite = $i+1;
			if ($i == $thissite)
				{
				if ($i < $max-1)
					{
					$menulast .= "<a href=\"index.php?do=stats&action=dailystatsbc&sorter=".$sorter."&start=".$entryspersite."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_last."</b></a> ";
					$menu .= "<a href=\"index.php?do=stats&action=dailystatsbc&start=".$nextnext."&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_next."</b></a> ";
					}
				if ($i > 0)
					{
					$menufirst .= "<a href=\"index.php?do=stats&action=dailystatsbc&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_first."</b></a> ";
					$menu .= "<a href=\"index.php?do=stats&action=dailystatsbc&start=".$nextback."&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_back."</b></a> ";
					}
				$menu .= "<strong>".$thissite."</strong> ";
				}
			if ($i < $max-1)
				{$menu .= "<a href=\"index.php?do=stats&action=dailystatsbc&start=".$next."&entryspersite=".$entryspersite."&sorter=".$sorter."&what=".$what."&show=".$show."\"><b>".$nextsite."</b></a> ";}

			$next = $next+$entryspersite;
			}
		}

	$main_content .= "
	<table width=\"874\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
	<tr>
		<td height=\"35\" colspan=\"8\" class=\"heading\"  bgcolor=\"#FFFFFF\">".$siteheading." ".$what."</td>
	</tr>
	<form name=\"form1\" method=\"post\" action=\"index.php?do=stats&action=dailystatsbc&sorter=".$sorter."&what=".$what."&show=".$show."\">
	<tr>
		<td height=\"28\" colspan=\"8\" bgcolor=\"#FFFFFF\" class=\"top\" style=\"padding:0px;\">
			<table width=\"872\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
				<tr>
					<td height=\"20\" width=\"448\" bgcolor=\"#FFFFFF\" align=\"left\" valign=\"middle\" class=\"top\" style=\"border-right:1px solid #CCCCCC;\">
					 ".$menu." ".$menufirst." ".$menulast."
					</td>
					<td width=\"80\" bgcolor=\"#FFFFFF\" align=\"center\" valign=\"middle\" class=\"top\" style=\"border-right:1px solid #CCCCCC;\">
					 <a href=\"index.php?do=stats&action=$backbutton\"><strong>".$text_mainsection."</strong></a>
					</td>
					<td width=\"350\" bgcolor=\"#FFFFFF\" align=\"center\" valign=\"middle\">
					<strong>".$text_show."</strong>
					".$text_from."
					<input type=\"text\" name=\"start\" value=\"$start\" style=\"width:30px;height:16px;\"> --- 
					<input type=\"text\" name=\"entryspersite\" value=\"".$entryspersite."\" style=\"width:30px;height:16px;\"> <strong>".$text_persite."</strong> 
					<input name=\"submit\" type=\"submit\" class=\"submitbuton\" value=\"".$text_submit."\" style=\"width:80px;height:22px;\"> 
					</td>
				</tr>
			</table>
		</td>
	</tr>
	</form>
	<tr>	
		<td width=\"75\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystatsbc&entryspersite=".$entryspersite."&sorter=$sortfecha&what=".$what."&show=".$show."";
		if ($sorter == "fechadesc" or $sorter == "fechaasc" or $sorter == "")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_time."</a>
		</td>
		<td width=\"60\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystatsbc&entryspersite=".$entryspersite."&sorter=".$sortid."&what=".$what."&show=".$show."";
		if ($sorter == "iddesc" or $sorter == "idasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_siteid."</a>
		</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystatsbc&entryspersite=".$entryspersite."&sorter=".$sortin."&what=".$what."&show=".$show."";
		if ($sorter == "indesc" or $sorter == "inasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_in."</a>
		</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystatsbc&entryspersite=".$entryspersite."&sorter=".$sortout."&what=".$what."&show=".$show."";
		if ($sorter == "outdesc" or $sorter == "outasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_out."</a>
		</td>
		<td width=\"135\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystatsbc&entryspersite=".$entryspersite."&sorter=".$sortip."&what=".$what."&show=".$show."";
		if ($sorter == "ipdesc" or $sorter == "ipasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_adminsignupip."</a>
		</td>
		<td width=\"85\" bgcolor=\"#E4E4E4\" align=\"center\">Browser</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystatsbc&entryspersite=".$entryspersite."&sorter=".$sortlang."&what=".$what."&show=".$show."";
		if ($sorter == "langdesc" or $sorter == "langasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_lang."</a>
		</td>
		<td width=\"316\" bgcolor=\"#E4E4E4\">
		<a href=\"index.php?do=stats&action=dailystatsbc&entryspersite=".$entryspersite."&sorter=".$sortref."&what=".$what."&show=".$show."";
		if ($sorter == "refdesc" or $sorter == "refasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_referer."</a>
		</td>
	</tr>";

	$rowmarker = 0;
	$db -> query ("SELECT * FROM ".$topxl_hits_table." WHERE timestamp>'$daybegin' and timestamp<'".$dayend."' and (validin='no-kekssperre' or validout='no-kekssperre') ".$sqlholder." LIMIT ".$start.",".$entryspersite); 
	while($dailystatsgetrow = $db -> fetch ())
		{
		$siteid = $dailystatsgetrow['siteid'];
		$fecha = substr($dailystatsgetrow['fecha'], 11, 19);
		$ip = $dailystatsgetrow['ip'];
		$referer = $dailystatsgetrow['referer'];
		$language = substr($dailystatsgetrow['language'], 0, 2);
		$browser = $dailystatsgetrow['browser'];
		$browserreal = $browser;
		$browser = useragent($browser);
		$in = $dailystatsgetrow['validin'];
		$out = $dailystatsgetrow['validout'];

		if ($in == "no-kekssperre")
			{$in = "X-C";}

		if ($out == "no-kekssperre")
			{$out = "X-C";}

		$rowmarker++;

		if ($rowmarker == 2)
			{$tdbgcolor = "bgcolor=\"#F7F7F7\"";$rowmarker = 0;}
		else
			{$tdbgcolor = "bgcolor=\"#FFFFFF\"";}

		$main_content .= "
		<tr>
			<td ".$tdbgcolor." nowrap align=\"center\">".$fecha."</td>
			<td ".$tdbgcolor." align=\"right\">".$siteid."</td>
			<td ".$tdbgcolor." align=\"right\">".$in."</td>
			<td ".$tdbgcolor." align=\"right\">".$out."</td>
			<td ".$tdbgcolor." align=\"right\">".$ip."</td>
			<td ".$tdbgcolor." align=\"center\"><span title=\"$browserreal\">".$browser."</span></td>
			<td ".$tdbgcolor." align=\"center\">".$language."</td>
			<td ".$tdbgcolor." nowrap><div id=\"Layer1\" style=\"position:relativ; width:300px; height:22px; z-index:1; overflow: hidden;\"><a href=\"".$referer."\" target=\"_blank\" title=\"$referer\">".$referer."</a></div></td>
		</tr>";
		}

	$main_content .= "
		<tr>
			<td  bgcolor=\"#FFFFFF\" colspan=\"9\" height=\"28\"><strong>".$text_legend."</strong></td>
		</tr>
		<tr>
			<td  bgcolor=\"#FFFFFF\" colspan=\"9\" class=\"small\">
			<strong>X-C:</strong> ".$text_exp_xc."<br>
			<strong>I.Ex:</strong> ".$text_exp_iex."<br>
			</td>
		</tr>
	</table>";

	////template
	if(!file_exists($file))
		{echo "The template ".$file." does not exist."; exit;}
	$fp1 = fopen($file,"r");  
	$zeile = fread ($fp1, filesize ($file));
	include("template.php");
	echo $zeile;
	exit;
	}
	
////////////////////////////////////////
///  this and last month stats blocked cookies
////////////////////////////////////////

if ($action=="monthstatsbc" or $action=="lastmonthstatsbc")
	{
	if ($action=="lastmonthstatsbc")
		{
		$month = date("m")-1;
		$thisyear = date("y");
		if ($month <=0)
			{
			$month = 12;
			$thisyear = $thisyear-1;
			}
		$thismonthdate = mktime(0,0,0,$month,1,$thisyear);
		$day = date("t",$thismonthdate);
		$siteheading = $text_lmbc;
		$show = "lastmonthstatsbc";
		}

	else
		{
		$day = date("d");
		$month = date("m");
		$thisyear = date("y");
		$siteheading = $text_tmbc;
		$show = "monthstatsbc";
		$thismonthdate = mktime(0,0,0,$month,1,$thisyear);
		}

	$weekdayget = $thismonthdate;
	$dateget = date("m-d",$thismonthdate);

	//// Html to display on the site
	$main_content .= "
	<table width=\"874\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
	<tr>
		<td height=\"35\" colspan=\"7\" class=\"heading\"  bgcolor=\"#FFFFFF\">".$siteheading."</td>
	</tr>
	<tr>
		<td width=\"20\" bgcolor=\"#E4E4E4\">&nbsp;</td>
		<td width=\"50\" bgcolor=\"#E4E4E4\">".$text_weekday."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\">".$text_date."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">".$text_bcin."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">".$text_bcout."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\"></td>
		<td width=\"567\" bgcolor=\"#E4E4E4\"></td>
	</tr>";

	$rowmarker = 0;
	for ($i= 1; $i<=$day; $i++) 
		{
		$rowmarker++;

		if ($rowmarker == 2)
			{
			$tdbgcolor = "bgcolor=\"#F7F7F7\"";
			$rowmarker = 0;
			}
		else
			{$tdbgcolor = "bgcolor=\"#FFFFFF\"";}

		$weekday = date("D", $weekdayget);
		$weekday = date("D", $weekdayget);
		$daybegin = $weekdayget;
		$yearget = date("y", $weekdayget);
		$monthget = date("m", $weekdayget);
		$dayget = date("d", $weekdayget);
		$daybegin = mktime(0,0,0,$monthget,$dayget,$yearget);
		$dayend = $daybegin+86400;

		$db -> query ("SELECT count(validin) AS insumme FROM ".$topxl_hits_table." WHERE validin='no-kekssperre' and timestamp>'".$daybegin."' and timestamp<'".$dayend."'"); 
		$countmonthinsrow = $db -> fetch ();
		$monthhitsin = $countmonthinsrow['insumme'];

		$db -> query ("SELECT count(validout) AS outsumme FROM ".$topxl_hits_table." WHERE validout='no-kekssperre' and timestamp>'".$daybegin."' and timestamp<'".$dayend."'"); 
		$countmonthoutsrow = $db -> fetch ();
		$monthhitsout = $countmonthoutsrow['outsumme'];

		$main_content .= "
		<tr>
			<td height=\"20\" ".$tdbgcolor.">".$i."</td>
			<td ".$tdbgcolor.">".$weekday."</td>
			<td ".$tdbgcolor." align=\"center\">".$dateget."</td>
			<td ".$tdbgcolor." align=\"right\">".$monthhitsin."</td>
			<td ".$tdbgcolor." align=\"right\">".$monthhitsout."</td>
			<td ".$tdbgcolor." align=\"center\"><a href=\"index.php?do=stats&action=dailystatsbc&what=".$i."&show=".$show."\">$text_view</a></td>
			<td ".$tdbgcolor."></td>
		</tr>";
		$dateget++;
		$weekdayget = $weekdayget+86400;
		}

	$main_content .= "
	</table>";

	////template
	if(!file_exists($file))
		{echo "The template ".$file." does not exist."; exit;}
	$fp1 = fopen($file,"r");  
	$zeile = fread ($fp1, filesize ($file));
	include("template.php");
	echo $zeile;
	exit;
	}	

////////////////////////////////////
//// Dailystats blockes by ip
////////////////////////////////////

if ($action=="dailystatsbip")
	{
	if ($show == "lastmonthstatsbip")
		{
		$month = date("m")-1;
		$thisyear = date("y");
		if ($month <=0)
			{
			$month = 12;
			$thisyear = $thisyear-1;
			}
		$siteheading = $text_dailystatsbiplm." ";
		$backbutton = "lastmonthstatsbip";
		}

	elseif ($show == "monthstatsbip")
		{
		$month = date("m");
		$thisyear = date("y");
		$siteheading = $text_dailystatsbiptm." ";
		$backbutton = "monthstatsbip";
		}

	$daybegin = mktime(0,0,0,$month,$what,$thisyear); 
	$dayend = $daybegin+86400;
	$db -> query ("SELECT COUNT(id) as cnt FROM ".$topxl_hits_table."  WHERE timestamp>'".$daybegin."' and timestamp<'".$dayend."' and (validin='no-ipblock-nokeks' or validout='no-ipblock-nokeks')"); 
	$row = $db -> fetch ();
	$allentrys = $row["cnt"];

	// the page-forward and backward links, and the pages to click on
	if ($allentrys > $entryspersite)
		{
		$max = $allentrys/$entryspersite;
		$max = ceil($max);
		$startfor = $start/$entryspersite;
		$startfor = ceil($startfor);
		if ($startfor <= 0)
			{$startfor = 0;}
		$endfor = $startfor+5;
		if ($endfor > $max)
			{$endfor = $max;}
		$thissite = $start/$entryspersite;
		$thissite = ceil($thissite);
		$lastsite = ($max-1)*$entryspersite;
		$nextback = ($startfor-1)*$entryspersite;
		$nextnext = ($startfor+1)*$entryspersite;
		$next = $start+$entryspersite;
		$menulast = '';
		$menufirst = '';
		$menu = '';

		for($i = $startfor; $i < $endfor; $i++)
			{
			$nextsite = $i+1;
			if ($i == $thissite)
				{
				if ($i < $max-1)
					{
					$menulast .= "<a href=\"index.php?do=stats&action=dailystatsbip&sorter=".$sorter."&start=".$entryspersite."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_last."</b></a> ";
					$menu .= "<a href=\"index.php?do=stats&action=dailystatsbip&start=".$nextnext."&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_next."</b></a> ";
					}
				if ($i > 0)
					{
					$menufirst .= "<a href=\"index.php?do=stats&action=dailystatsbip&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_first."</b></a> ";
					$menu .= "<a href=\"index.php?do=stats&action=dailystatsbip&start=".$nextback."&sorter=".$sorter."&entryspersite=".$entryspersite."&what=".$what."&show=".$show."\"><b>".$text_back."</b></a> ";
					}
				$menu .= "<strong>".$thissite."</strong> ";
				}
			if ($i < $max-1)
				{$menu .= "<a href=\"index.php?do=stats&action=dailystatsbip&start=".$next."&entryspersite=".$entryspersite."&sorter=".$sorter."&what=".$what."&show=".$show."\"><b>".$nextsite."</b></a> ";}
			
			$next = $next+$entryspersite;
			}
		}

	$main_content .= "
	<table width=\"874\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
	<tr>
		<td height=\"35\" colspan=\"8\" class=\"heading\"  bgcolor=\"#FFFFFF\">".$siteheading." ".$what."</td>
	</tr>
	<form name=\"form1\" method=\"post\" action=\"index.php?do=stats&action=dailystatsbip&sorter=".$sorter."&what=".$what."&show=".$show."\">
	<tr>
		<td height=\"28\" colspan=\"8\" bgcolor=\"#FFFFFF\" class=\"top\" style=\"padding:0px;\">
			<table width=\"872\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
				<tr>
					<td height=\"20\" width=\"448\" bgcolor=\"#FFFFFF\" align=\"left\" valign=\"middle\" class=\"top\" style=\"border-right:1px solid #CCCCCC;\">
					 ".$menu." ".$menufirst." ".$menulast."
					</td>
					<td width=\"80\" bgcolor=\"#FFFFFF\" align=\"center\" valign=\"middle\" class=\"top\" style=\"border-right:1px solid #CCCCCC;\">
					 <a href=\"index.php?do=stats&action=$backbutton\"><strong>".$text_mainsection."</strong></a>
					</td>
					<td width=\"350\" bgcolor=\"#FFFFFF\" align=\"center\" valign=\"middle\">
					<strong>".$text_show."</strong>
					$text_from
					<input type=\"text\" name=\"start\" value=\"$start\" style=\"width:30px;height:16px;\"> --- 
					<input type=\"text\" name=\"entryspersite\" value=\"".$entryspersite."\" style=\"width:30px;height:16px;\"> <strong>".$text_persite."</strong> 
					<input name=\"submit\" type=\"submit\" class=\"submitbuton\" value=\"".$text_submit."\" style=\"width:80px;height:22px;\"> 
					</td>
				</tr>
			</table>
		</td>
	</tr>
	</form>
	<tr>	
		<td width=\"75\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystatsbip&entryspersite=".$entryspersite."&sorter=".$sortfecha."&what=".$what."&show=".$show."";
		if ($sorter == "fechadesc" or $sorter == "fechaasc" or $sorter == "")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_time."</a>
		</td>
		<td width=\"60\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystatsbip&entryspersite=".$entryspersite."&sorter=".$sortid."&what=".$what."&show=".$show."";
		if ($sorter == "iddesc" or $sorter == "idasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_siteid."</a>
		</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystatsbip&entryspersite=".$entryspersite."&sorter=".$sortin."&what=".$what."&show=".$show."";
		if ($sorter == "indesc" or $sorter == "inasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_in."</a>
		</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">
		<a href=\"index.php?do=stats&action=dailystatsbip&entryspersite=".$entryspersite."&sorter=".$sortout."&what=".$what."&show=".$show."";
		if ($sorter == "outdesc" or $sorter == "outasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_out."</a>
		</td>
		<td width=\"135\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystatsbip&entryspersite=".$entryspersite."&sorter=".$sortip."&what=".$what."&show=".$show."";
		if ($sorter == "ipdesc" or $sorter == "ipasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_adminsignupip."</a>
		</td>
		<td width=\"85\" bgcolor=\"#E4E4E4\" align=\"center\">Browser</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\">
		<a href=\"index.php?do=stats&action=dailystatsbip&entryspersite=".$entryspersite."&sorter=".$sortlang."&what=".$what."&show=".$show."";
		if ($sorter == "langdesc" or $sorter == "langasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_lang."</a>
		</td>
		<td width=\"316\" bgcolor=\"#E4E4E4\">
		<a href=\"index.php?do=stats&action=dailystatsbip&entryspersite=".$entryspersite."&sorter=".$sortref."&what=".$what."&show=".$show."";
		if ($sorter == "refdesc" or $sorter == "refasc")
			{$main_content .= "&start=".$start;}
		$main_content .= "\">".$text_referer."</a>
		</td>
	</tr>";

	$rowmarker = 0;

	$db -> query ("SELECT * FROM ".$topxl_hits_table." WHERE timestamp>'".$daybegin."' and timestamp<'".$dayend."' and (validin='no-ipblock-nokeks' or validout='no-ipblock-nokeks') ".$sqlholder." LIMIT ".$start.",".$entryspersite); 
	while($dailystatsgetrow = $db -> fetch ())
		{
		$siteid = $dailystatsgetrow['siteid'];
		$fecha = substr($dailystatsgetrow['fecha'], 11, 19);
		$ip = $dailystatsgetrow['ip'];
		$referer = $dailystatsgetrow['referer'];
		$language = substr($dailystatsgetrow['language'], 0, 2);
		$browser = useragent($dailystatsgetrow['browser']);
		$browserreal = $browser;
		$in = $dailystatsgetrow['validin'];
		$out = $dailystatsgetrow['validout'];

		if ($in == "no-ipblock-nokeks")
			{$in = "X-IP";}

		elseif ($out == "no-ipblock-nokeks")
			{$out = "X-IP";}

		$rowmarker++;

		if ($rowmarker == 2)
			{
			$tdbgcolor = "bgcolor=\"#F7F7F7\"";
			$rowmarker = 0;
			}
	
		else
			{$tdbgcolor = "bgcolor=\"#FFFFFF\"";}

		$main_content .= "
		<tr>
			<td ".$tdbgcolor." nowrap align=\"center\">".$fecha."</td>
			<td ".$tdbgcolor." align=\"right\">".$siteid."</td>
			<td ".$tdbgcolor." align=\"right\">".$in."</td>
			<td ".$tdbgcolor." align=\"right\">".$out."</td>
			<td ".$tdbgcolor." align=\"right\">".$ip."</td>
			<td ".$tdbgcolor." align=\"center\"><span title=\"".$browserreal."\">".$browser."</span></td>
			<td ".$tdbgcolor." align=\"center\">".$language."</td>
			<td ".$tdbgcolor." nowrap><div id=\"Layer1\" style=\"position:relativ; width:300px; height:22px; z-index:1; overflow: hidden;\"><a href=\"".$referer."\" target=\"_blank\" title=\"".$referer."\">".$referer."</a></div></td>
		</tr>";
		}

	$main_content .= "
	<tr>
		<td  bgcolor=\"#FFFFFF\" colspan=\"9\" height=\"28\"><strong>".$text_legend."</strong></td>
	</tr>
	<tr>
		<td  bgcolor=\"#FFFFFF\" colspan=\"9\" class=\"small\">
		<strong>X-IP:</strong> ".$text_exp_xip."<br>
		<strong>I.Ex:</strong> ".$text_exp_iex."<br>
		</td>
	</tr>
	</table>";

	////template
	if(!file_exists($file))
		{echo "The template ".$file." does not exist."; exit;}
	$fp1 = fopen($file,"r");  
	$zeile = fread ($fp1, filesize ($file));
	include("template.php");
	echo $zeile;
	exit;
	}

////////////////////////////////////////
/// this and lats month stats blocked ip
////////////////////////////////////////

if ($action=="monthstatsbip" or $action=="lastmonthstatsbip")
	{
	if ($action=="lastmonthstatsbip")
		{
		$month = date("m")-1;
		$thisyear = date("y");
		if ($month <=0)
			{
			$month = 12;
			$thisyear = $thisyear-1;
			}
		$thismonthdate = mktime(0,0,0,$month,1,$thisyear);
		$day = date("t",$thismonthdate);
		$siteheading = $text_lmbip;
		$show = "lastmonthstatsbip";
		}

	else
		{
		$day = date("d");
		$month = date("m");
		$thisyear = date("y");
		$siteheading = $text_tmbip;
		$show = "monthstatsbip";
		$thismonthdate = mktime(0,0,0,$month,1,$thisyear);
		}

	$weekdayget = $thismonthdate;
	$dateget = date("m-d",$thismonthdate);

	//// Html to display on the site
	$main_content .= "
	<table width=\"874\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
	<tr>
		<td height=\"35\" colspan=\"7\" class=\"heading\"  bgcolor=\"#FFFFFF\">".$siteheading."</td>
	</tr>
	<tr>
		<td width=\"20\" bgcolor=\"#E4E4E4\">&nbsp;</td>
		<td width=\"50\" bgcolor=\"#E4E4E4\">".$text_weekday."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\">".$text_date."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">".$text_bcipin."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"right\">".$text_bcipout."</td>
		<td width=\"65\" bgcolor=\"#E4E4E4\" align=\"center\"></td>
		<td width=\"567\" bgcolor=\"#E4E4E4\"></td>
	</tr>";

	$rowmarker = 0;
	for ($i= 1; $i<=$day; $i++) 
		{
		$rowmarker++;
		if ($rowmarker == 2)
			{
			$tdbgcolor = "bgcolor=\"#F7F7F7\"";
			$rowmarker = 0;
			}

		else
			{$tdbgcolor = "bgcolor=\"#FFFFFF\"";}

		$weekday = date("D", $weekdayget);
		$weekday = date("D", $weekdayget);
		$daybegin = $weekdayget;
		$yearget = date("y", $weekdayget);
		$monthget = date("m", $weekdayget);
		$dayget = date("d", $weekdayget);
		$daybegin = mktime(0,0,0,$monthget,$dayget,$yearget);
		$dayend = $daybegin+86400;

		$db -> query ("SELECT count(validin) AS insumme FROM ".$topxl_hits_table." WHERE validin='no-ipblock-nokeks' and timestamp>'".$daybegin."' and timestamp<'".$dayend."'"); 
		$countmonthinsrow = $db -> fetch ();
		$monthhitsin = $countmonthinsrow['insumme'];

		$db -> query ("SELECT count(validout) AS outsumme FROM ".$topxl_hits_table." WHERE validout='no-ipblock-nokeks' and timestamp>'".$daybegin."' and timestamp<'".$dayend."'"); 
		$countmonthoutsrow = $db -> fetch ();
		$monthhitsout = $countmonthoutsrow['outsumme'];	

		$main_content .= "
		<tr>
			<td height=\"20\" ".$tdbgcolor."".$i."</td>
			<td ".$tdbgcolor.">".$weekday."</td>
			<td ".$tdbgcolor." align=\"center\">".$dateget."</td>
			<td ".$tdbgcolor." align=\"right\">".$monthhitsin."</td>
			<td ".$tdbgcolor." align=\"right\">".$monthhitsout."</td>
			<td ".$tdbgcolor." align=\"center\"><a href=\"index.php?do=stats&action=dailystatsbip&what=".$i."&show=".$show."\">".$text_view."</a></td>
			<td ".$tdbgcolor."></td>
		</tr>";

		$dateget++;
		$weekdayget = $weekdayget+86400;
		}

	$main_content .= "
	</table>";

	////template
	if(!file_exists($file))
	{echo "The template ".$file." does not exist."; exit;}
	$fp1 = fopen($file,"r");  
	$zeile = fread ($fp1, filesize ($file));
	include("template.php");
	echo $zeile;
	exit;
	}	

////////////////////////////////////////
/// normaler aufruf do=stats
////////////////////////////////////////

//// get hits today
$thisdaydate = mktime(0,0,0,date("m"),date("d"),date("Y"));
$todayhitin = get_stats_overview("validin","validin='yes' and timestamp >= '".$thisdaydate."'",$topxl_hits_table,$db);
$todayhitout = get_stats_overview("validout","validout='yes' and timestamp >= '".$thisdaydate."'",$topxl_hits_table,$db);
$ratiotodayinout=get_ratio($todayhitin,$todayhitout);

//// get hits yestertoday
$yesterdaydate = mktime(0, 0, 0, date("m"),date("d")-1,date("Y")); 
$yesterdayhitin = get_stats_overview("validin","validin='yes' and timestamp <= '".$thisdaydate."' and timestamp >= '".$yesterdaydate."'",$topxl_hits_table,$db);
$yesterdayhitout = get_stats_overview("validout","validout='yes' and timestamp <= '".$thisdaydate."' and timestamp >= '".$yesterdaydate."'",$topxl_hits_table,$db);
$ratioyesterdayinout=get_ratio($yesterdayhitin,$yesterdayhitout);

//// get hits this week
$thisweektime = strtotime("last Monday");
$thisweekhitsin=get_stats_overview("validin","validin='yes' and timestamp>'".$thisweektime."'",$topxl_hits_table,$db);
$thisweekhitsout=get_stats_overview("validout","validout='yes' and timestamp>'".$thisweektime."'",$topxl_hits_table,$db);
$ratiothisweekinout=get_ratio($thisweekhitsin,$thisweekhitsout);

//// get hits last week
$lastweektime = strtotime("last Monday -1 week");
$lastweekhitsin = get_stats_overview("validin","validin='yes' and timestamp<'".$thisweektime."' and timestamp>'".$lastweektime."'",$topxl_hits_table,$db);
$lastweekhitsout = get_stats_overview("validout","validout='yes' and timestamp<'".$thisweektime."' and timestamp>'".$lastweektime."'",$topxl_hits_table,$db);
$ratiolastweekinout=get_ratio($lastweekhitsin,$lastweekhitsout);

//// get hits this month
$thismonthdate = mktime(0, 0, 0, date("m"),1,date("Y"));
$monthhitsin = get_stats_overview("validin","validin='yes' and timestamp>'".$thismonthdate."'",$topxl_hits_table,$db);
$monthhitsout = get_stats_overview("validout","validout='yes' and timestamp>'".$thismonthdate."'",$topxl_hits_table,$db);
$ratiomonthinout=get_ratio($monthhitsin,$monthhitsout);

//// get hits last month
$lastmonthdate = mktime(0, 0, 0, date("m")-1,1,date("Y"));
$lastmonthhitsin = get_stats_overview("validin","validin='yes' and timestamp>'".$lastmonthdate."' and timestamp<'".$thismonthdate."'",$topxl_hits_table,$db);
$lastmonthhitsout = get_stats_overview("validout","validout='yes' and timestamp>'".$lastmonthdate."' and timestamp<'".$thismonthdate."'",$topxl_hits_table,$db);
$ratiolastmonthinout=get_ratio($lastmonthhitsin,$lastmonthhitsout);

//// Hits since last reset
$thistimehitin = get_stats_overview("validin","validin='yes' and timestamp >= '".$config['lastreset']."'",$topxl_hits_table,$db);
$thistimehitout = get_stats_overview("validout","validout='yes' and timestamp >= '".$config['lastreset']."'",$topxl_hits_table,$db);
$ratiothismonthinout=get_ratio($thistimehitin,$thistimehitout);

//// get hits last period
$lastperiodresetti = $config['lastreset']-$config['lastresettime'];
$hitinlastperiod = get_stats_overview("validin","validin='yes' and timestamp<'".$config['lastreset']."' and timestamp>'".$lastperiodresetti."'",$topxl_hits_table,$db);
$hitoutlastperiod = get_stats_overview("validout","validout='yes' and timestamp<'".$config['lastreset']."' and timestamp>'".$lastperiodresetti."'",$topxl_hits_table,$db);
$ratiomlatsperiodinout=get_ratio($hitinlastperiod,$hitoutlastperiod);

//// get hits total
$db -> query ("SELECT sum(hitintotal) AS insumme,sum(hitouttotal) AS outsumme FROM ".$topxl_user_table." WHERE active='yes'"); 
$counthitsrow = $db -> fetch ();
$allhitsin = $counthitsrow['insumme'];
$allhitsout = $counthitsrow['outsumme'];
$ratiomallinout=get_ratio($allhitsin,$allhitsout);

//// Get by cookie blocked hits
//// Get by cookie blocked hits today
$bctodayhitin = get_stats_overview("validin","validin='no-kekssperre' and timestamp >= '".$thisdaydate."'",$topxl_hits_table,$db);	
$bctodayhitout=get_stats_overview("validout","validout='no-kekssperre' and timestamp >= '".$thisdaydate."'",$topxl_hits_table,$db);

//// Get by cookie blocked hits yestertoday
$bcyesterdayhitin = get_stats_overview("validin","validin='no-kekssperre' and timestamp <= '".$thisdaydate."' and timestamp >= '".$yesterdaydate."'",$topxl_hits_table,$db);
$bcyesterdayhitout = get_stats_overview("validout","validout='no-kekssperre' and timestamp <= '".$thisdaydate."' and timestamp >= '".$yesterdaydate."'",$topxl_hits_table,$db);	

//// Get by cookie blocked hits this week
$bcthisweekhitsin = get_stats_overview("validin","validin='no-kekssperre' and timestamp>'".$thisweektime."'",$topxl_hits_table,$db);
$bcthisweekhitsout = get_stats_overview("validout","validout='no-kekssperre' and timestamp>'".$thisweektime."'",$topxl_hits_table,$db);

//// Get by cookie blocked hits last week
$bclastweekhitsin = get_stats_overview("validin","validin='no-kekssperre' and timestamp<'".$thisweektime."' and timestamp>'".$lastweektime."'",$topxl_hits_table,$db);
$bclastweekhitsout = get_stats_overview("validout","validout='no-kekssperre' and timestamp<'".$thisweektime."' and timestamp>'".$lastweektime."'",$topxl_hits_table,$db);

//// Get by cookie blocked hits this month
$bcmonthhitsin = get_stats_overview("validin","validin='no-kekssperre' and timestamp>'".$thismonthdate."'",$topxl_hits_table,$db);
$bcmonthhitsout = get_stats_overview("validout","validout='no-kekssperre' and timestamp>'".$thismonthdate."'",$topxl_hits_table,$db);

//// Get by cookie blocked hits last month
$lastbcmonthhitsin = get_stats_overview("validin","validin='no-kekssperre' and timestamp>'".$lastmonthdate."' and timestamp<'".$thismonthdate."'",$topxl_hits_table,$db);
$lastbcmonthhitsout = get_stats_overview("validout","validout='no-kekssperre' and timestamp>'".$lastmonthdate."' and timestamp<'".$thismonthdate."'",$topxl_hits_table,$db);

//// Get by cookie blocked hits this period
$bcthistimehitin = get_stats_overview("validin","validin='no-kekssperre' and timestamp >= '".$config['lastreset']."'",$topxl_hits_table,$db);
$bcthistimehitout = get_stats_overview("validout","validout='no-kekssperre' and timestamp >= '".$config['lastreset']."'",$topxl_hits_table,$db);

//// Get by cookie blocked hits last period
$hitinbclatsperiod = get_stats_overview("validin","validin='no-kekssperre' and timestamp<'".$config['lastreset']."' and timestamp>'".$lastperiodresetti."'",$topxl_hits_table,$db);
$hitoutbclatsperiod = get_stats_overview("validout","validout='no-kekssperre' and timestamp<'".$config['lastreset']."' and timestamp>'".$lastperiodresetti."'",$topxl_hits_table,$db);
//// Get by cookie blocked hits total
$bcallhitsin = get_stats_overview("validin","validin='no-kekssperre'",$topxl_hits_table,$db);
$bcallhitsout = get_stats_overview("validout","validout='no-kekssperre'",$topxl_hits_table,$db);
//// Get by ip blocked hits
//// Get by ip blocked hits from today (users which deleted cookie but have the same ip)
$biptodayhitin = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp >= '".$thisdaydate."'",$topxl_hits_table,$db);
$biptodayhitout = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp >= '".$thisdaydate."'",$topxl_hits_table,$db);

//// Get by ip blocked hits from yesterday (users which deleted cookie but have the same ip)
$bipyesterdayhitin = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp <= '".$thisdaydate."' and timestamp >= '".$yesterdaydate."'",$topxl_hits_table,$db);
$bipyesterdayhitout = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp <= '".$thisdaydate."' and timestamp >= '".$yesterdaydate."'",$topxl_hits_table,$db);

//// Get by ip blocked hits from this week
$bipthisweekhitsin = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp>'".$thisweektime."'",$topxl_hits_table,$db);
$bipthisweekhitsout = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp>'".$thisweektime."'",$topxl_hits_table,$db);

//// Get by ip blocked hits from last week
$biplastweekhitsin = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp<'".$thisweektime."' and timestamp>'".$lastweektime."'",$topxl_hits_table,$db);
$biplastweekhitsout = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp<'".$thisweektime."' and timestamp>'".$lastweektime."'",$topxl_hits_table,$db);

//// Get by ip blocked hits from this month
$bipmonthhitsin = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp>'".$thismonthdate."'",$topxl_hits_table,$db);
$bipmonthhitsout = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp>'".$thismonthdate."'",$topxl_hits_table,$db);

//// Get by ip blocked hits from last month
$lastbipmonthhitsin = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp>'".$lastmonthdate."' and timestamp<'".$thismonthdate."'",$topxl_hits_table,$db);
$lastbipmonthhitsout = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp>'".$lastmonthdate."' and timestamp<'".$thismonthdate."'",$topxl_hits_table,$db);

//// Get by ip blocked hits since last reset
$bipthistimehitin = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp >= '".$config['lastreset']."'",$topxl_hits_table,$db);
$bipthistimehitout = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp >= '".$config['lastreset']."'",$topxl_hits_table,$db);

//// Get by ip blocked hits from last period
$hitinbiplatsperiod = get_stats_overview("validin","validin='no-ipblock-nokeks' and timestamp<'".$config['lastreset']."' and timestamp>'".$lastperiodresetti."'",$topxl_hits_table,$db);
$hitoutbiplatsperiod = get_stats_overview("validout","validout='no-ipblock-nokeks' and timestamp<'".$config['lastreset']."' and timestamp>'".$lastperiodresetti."'",$topxl_hits_table,$db);

//// Get all by ip blocked hits
$bipallhitsin = get_stats_overview("validin","validin='no-ipblock-nokeks'",$topxl_hits_table,$db);
$bipallhitsout = get_stats_overview("validout","validout='no-ipblock-nokeks'",$topxl_hits_table,$db);

//// Html to display on the site
$main_content .= "
<table width=\"874\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"#CCCCCC\">
	<tr>
		<td height=\"35\" colspan=\"9\" bgcolor=\"#FFFFFF\" class=\"top\"><strong class=\"heading\">".$text_stats."</strong></td>
	</tr>
	<tr>
		<td width=\"150\" bgcolor=\"#FFFFFF\"></td>
		<td width=\"65\" bgcolor=\"#FFFFFF\" align=\"right\">".$text_validin2."</td>
		<td width=\"65\" bgcolor=\"#FFFFFF\" align=\"right\">".$text_validout2."</td>
		<td width=\"65\" bgcolor=\"#FFFFFF\" align=\"center\">".$text_ratiobeetween."</td>
		<td width=\"65\" bgcolor=\"#FFFFFF\" align=\"right\">".$text_bcin."</td>
		<td width=\"65\" bgcolor=\"#FFFFFF\" align=\"right\">".$text_bcout."</td>
		<td width=\"65\" bgcolor=\"#FFFFFF\" align=\"right\">".$text_bcipin."</td>
		<td width=\"65\" bgcolor=\"#FFFFFF\" align=\"right\">".$text_bcipout."</td>
		<td width=\"258\" bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitstoday."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$todayhitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$todayhitout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiotodayinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bctodayhitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bctodayhitout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$biptodayhitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$biptodayhitout."</td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitsyesterday."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$yesterdayhitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$yesterdayhitout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratioyesterdayinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcyesterdayhitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcyesterdayhitout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipyesterdayhitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipyesterdayhitout."</td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitsthisweek."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$thisweekhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$thisweekhitsout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiothisweekinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcthisweekhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcthisweekhitsout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipthisweekhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipthisweekhitsout."</td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitalastweek."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$lastweekhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$lastweekhitsout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiolastweekinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bclastweekhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bclastweekhitsout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$biplastweekhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$biplastweekhitsout."</td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitsthismonts."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=monthstats\">".$monthhitsin."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=monthstats\">".$monthhitsout."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiomonthinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=monthstatsbc\">".$bcmonthhitsin."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=monthstatsbc\">".$bcmonthhitsout."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=monthstatsbip\">".$bipmonthhitsin."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=monthstatsbip\">".$bipmonthhitsout."</a></td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitslastmonth."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=lastmonthstats\">".$lastmonthhitsin."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=lastmonthstats\">".$lastmonthhitsout."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiolastmonthinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=lastmonthstatsbc\">".$lastbcmonthhitsin."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=lastmonthstatsbc\">".$lastbcmonthhitsout."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=lastmonthstatsbip\">".$lastbipmonthhitsin."</a></td>
		<td bgcolor=\"#FFFFFF\" align=\"right\"><a href=\"index.php?do=stats&action=lastmonthstatsbip\">".$lastbipmonthhitsout."</a></td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitssincereset."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$thistimehitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$thistimehitout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiothismonthinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcthistimehitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcthistimehitout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipthistimehitin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipthistimehitout."</td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitslastperiod."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$hitinlastperiod."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$hitoutlastperiod."</td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiomlatsperiodinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$hitinbclatsperiod."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$hitoutbclatsperiod."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$hitinbiplatsperiod."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$hitoutbiplatsperiod."</td>

		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td bgcolor=\"#FFFFFF\">".$text_hitstotal."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$allhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$allhitsout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"center\">1/".$ratiomallinout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcallhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bcallhitsout."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipallhitsin."</td>
		<td bgcolor=\"#FFFFFF\" align=\"right\">".$bipallhitsout."</td>
		<td bgcolor=\"#FFFFFF\"></td>
	</tr>
	<tr>
		<td  bgcolor=\"#FFFFFF\" colspan=\"9\" height=\"28\"><strong>".$text_legend."</strong></td>
	</tr>
	<tr>
		<td  bgcolor=\"#FFFFFF\" colspan=\"9\" class=\"small\">
		<strong>".$text_validin2." / ".$text_validout2.":</strong> ".$text_allvalidhits."<br>
		<strong>".$text_ratiobeetween.":</strong> ".$text_exp_ratiobeetween."<br>
		<strong>".$text_bcin." / ".$text_bcout.":</strong> ".$text_allhitsblockevcooki."<br>
		<strong>".$text_bcipin." / ".$text_bcipout.":</strong> ".$text_allhitsblockipexp."<br>
		</td>
	</tr>
</table>";

/// Template 
if(!file_exists($file))
	{echo "The template ".$file." does not exist."; exit;}
$fp1 = fopen($file,"r");  
$zeile = fread ($fp1, filesize ($file));
include("template.php");
echo $zeile;
exit;
?>