<?php
/*======================================================================*\
|| #################################################################### ||
|| # EoT-Clan BC2 Server Stats                                        # ||
|| # ---------------------------------------------------------------- # ||
|| # Dieses Copyright darf nicht entfernt werden                      # ||
|| # This file may not be redistributed in whole or significant part. # ||
|| # -----------------BC2 Server Stats is a free Software-------------# ||
|| #                      http://eot-clan.net                         # ||
|| #################################################################### ||
\*======================================================================*/
 
  /*Ab hier nichts mehr ändern\\From here change anything*/     
/**/#########################################################################################################################################################
define('DS', DIRECTORY_SEPARATOR);
 
define('VERSION', '1.0.0.3');

/* Database connect */

$link = mysql_connect($host.':'.$sqlPort, $dbuser, $dbpw)
or die ("Can not connect to Database: " .mysql_error());
mysql_select_db($db);

/* Load Classes */

/**
 * Module added by Eichi (E-Mail: eichi@blubbbel.eu)
 */
function __autoload($sClass){
	$sDir = dirname(__FILE__);
	if ($sClass == 'xajax'){
		$sFile = dirname($sDir) . DS . 'js' . DS . 'xajax' . DS . 'xajax_core' . DS . 'xajax.inc.php';
		if (file_exists($sFile)){
			require_once $sFile;
		} else {
			exit('Fatal error in ' . __FILE__ . ' on line ' . __LINE__ . ': Could not find xajax library files. (' . $sFile . ')');
		}
	} else {
		$sFile = $sDir . DS . $sClass . '.php';
		if (file_exists($sFile)){
			require_once $sFile;
		} else {
			$sFile = $sDir . DS . $sClass . '.class.php';
			if (file_exists($sFile)){
				require_once $sFile;
			} else {
				exit('Fatal error in ' . __FILE__ . ' on line ' . __LINE__ . ': Could not load instantiated class ' . $sClass . ' in: ' . $sFile);
			}
		}
	}
}



function blaetterfunktion($seite,$maxseite,$url="",$anzahl=6,$get_name="page") {
   global $search;
   $anhang="?";
   if($anzahl%2 != 0) $anzahl++;

   $a = $seite-($anzahl/2);
   $b = 0;
   $blaetter = array();
   while($b <= $anzahl) {
      if($a > 0 AND $a <= $maxseite) {
         $blaetter[] = $a;
         $b++;
         }
      else if($a > $maxseite AND ($a-$anzahl-2)>=0) {
         $blaetter = array();
         $a -= ($anzahl+2);
         $b = 0;
       }
      else if($a > $maxseite AND ($a-$anzahl-2)<0) {
         break;
         }

      $a++;
      }
   $return = "";
   if(!in_array(1,$blaetter) AND count($blaetter) > 1) {
      if(!in_array(2,$blaetter)) $return .= "&nbsp;<a href=\"{$url}{$anhang}{$get_name}=1{$search}\">1</a>&nbsp;...";
      else $return .= "&nbsp;<a href=\"{$url}{$anhang}{$get_name}=1{$search}\">1</a>&nbsp;";
      }

   foreach($blaetter AS $blatt) {
      if($blatt == $seite) $return .= "&nbsp;<b>$blatt</b>&nbsp;";
      else $return .= "&nbsp;<a href=\"{$url}{$anhang}{$get_name}=$blatt{$search}\">$blatt</a>&nbsp;";
      }

   if(!in_array($maxseite,$blaetter) AND count($blaetter) > 1) {
      if(!in_array(($maxseite-1),$blaetter)) $return .= "...&nbsp;<a href=\"{$url}{$anhang}{$get_name}=$maxseite{$search}\">".server_gerneral_server_last."($maxseite)</a>&nbsp;";
      else $return .= "&nbsp;<a href=\"{$url}{$anhang}{$get_name}=$maxseite{$search}\">$maxseite</a>&nbsp;";
      }

   if(empty($return))
      return  "&nbsp;<b>1</b>&nbsp;";
   else
      return $return;
   }  
   
   
   
     
    if ($error_report == 1){
	 error_reporting(E_ALL);
}else{
	error_reporting(0);
}


$url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$url = parse_url($url, PHP_URL_PATH);
$url = (dirname($url));
$url = (explode('/', $url));


function db_query($q)
{
global $goodqueries, $badqueries, $totalqueries;
$x=mysql_query($q);
if($x===false) $badqueries++;
if($x!=false) $goodqueries++;
$totalqueries++;
return $x;
} 


$microtime = microtime(true);

$dir = "install";
if (!$directory = @opendir("./".$dir))  
$warning = "";
else
$warning = '<blink><font color=red>!!!WARNING!!!</font></blink> the install directory still exist. Please delete it.'; 

$ClanTag = explode(',', $ClanTag);