<?php 
ob_start();
session_start();
//error_reporting(E_ALL ^ E_NOTICE );
error_reporting(E_ERROR | E_PARSE);

/* WEBSITE INFORMATION */

$basepath=$_SERVER['DOCUMENT_ROOT'];
include($basepath.'/admin/includes/config.php'); 
include($basepath.'/admin/includes/function.php'); 


if((stripos($_SERVER['REQUEST_URI'],'admin') && $adminPage !== 'login') || $adminLogged) {
	$referer=$_SERVER['REQUEST_URI'];

	if($_SESSION["zalogowany"]==1) {	
			

		include($basepath.'/admin/templates/header.php'); 
		
		$max_results = $settings['adminResults'];
		if(!isset($_GET['page']) || $_GET[page] == '' || !is_numeric($_GET[page])) {
			$page = 1;
		} else {
			$page = $_GET['page'];
		}
		$from = (($page * $max_results) - $max_results);	
			
		
	} else {
		header("Location: $basehttp/admin/index.php?referer={$referer}"); 
		exit();
	}
	
} else {
		
		// lang
		if($enabledLang){
			if(isset($_GET['lang'])) {		
				$lang=$_GET['lang'];			
				setcookie('lang',$lang,time()+(3600*24*365));		
			}		
			elseif (isset($_COOKIE['lang'])){
				$lang=$_COOKIE['lang'];
			} else {
				$lang='pl';
			}
			
			$countLang=mysql_num_rows(mysql_query("SELECT * FROM  lang  WHERE `lang`='$lang'")); 
			if($countLang==0){
				die("BLAD: Nieprawidlowy jezyk !");
			} 
			$resultL=mysql_query("SELECT * FROM translate_name n, translate_text t WHERE n.id=t.word AND t.lang='$lang'");
			while($rowL = mysql_fetch_array($resultL)) {
				$GLOBALS['translate'][$rowL['nazwa']] = $rowL['text'];
			}
			
		}
		// eof lang

}

?>