<?php

//session_save_path("./tmp") ;
session_start();

date_default_timezone_set('Europe/Warsaw');// PHP 5 >= 5.1.0 required by date functions

error_reporting(0);
ini_set('error_reporting', 0);
ini_set('display_startup_errors','0'); 
//display_startup_errors(0);

if (!isset($_SESSION['DEBUG'])) $_SESSION['DEBUG'] = 0;// set default value


if (file_exists(dirname(__FILE__)."/config/.config_".$_SERVER['SERVER_NAME'].".php")) {
	require(dirname(__FILE__)."/config/.config_".$_SERVER['SERVER_NAME'].".php");
}

if (file_exists(".config.php")) include(".config.php");
//require("../.config.php");

require("./superedit-SEF.php");

#Bzyk @ 2009-02-11 - dodatkowe funkcje dla BIALL-NET
if (file_exists("function2.php")) require("function2.php");

//STD INCLUDE 2010-01-14
require("superedit-logistyka.php");

SEF("M_DIST_CLAIM_DATE");
SEF("M_DIST_FILES");
SEF("K_OD_KOGO");
SEF("GORA");
SEF("WIEVTABLE");

if (file_exists("229dodaj_functions.php")) include("229dodaj_functions.php");


foreach ($_GET as $k => $v) {
	if (is_array($v)) continue;
	$_GET[$k] = addslashes($v);
}
foreach ($_POST as $k => $v) {
	if (is_array($v)) continue;
	$_POST[$k] = addslashes($v);
}

// register globals
$MENU_INIT = isset($_REQUEST['MENU_INIT'])? $_REQUEST['MENU_INIT'] : null;
$ARG1 = isset($_REQUEST['ARG1'])? $_REQUEST['ARG1'] : null;
$ARG1_VAL = isset($_REQUEST['ARG1_VAL'])? $_REQUEST['ARG1_VAL'] : null;


if (!isset($_REQUEST['HEADER_NOT_INIT']) || $_REQUEST['HEADER_NOT_INIT'] != 'YES') GORA();
if (!$_SESSION['AUTHORIZE_IP']) AUTHORIZE_IP($_SERVER['REMOTE_ADDR']);

AUTHORIZE_USER();
$_SESSION['USER_SESSION_LAST_ACTIVITY'] = time();// update procesy5.php logout time

SEF("TREE");
SEF("TREEJS");

if ($_SESSION['DEBUG']) echo "FUNCTION_INIT()";
DETECT_TABLE_COLUMN();// TODO: $thiss tworzone na podstawie 'CURRENT_MENU' ustawianej w MENU_INIT, teraz raczej zbedne wywolanie
SEF('FUNCTION_INIT');
FUNCTION_INIT();
if ($_SESSION['DEBUG']) echo "MENU_INIT()";
SEF('MENU');
SEF('MENU_INIT');
MENU_INIT();

DOL();
if ($_SESSION['DEBUG']){
	echo"<hr>_POST:\n<br><pre>";
	print_r($_POST);
	echo "<hr>_SESSION:\n<br>";
	print_r($_SESSION);
	echo"<hr>\n_GET:<br>\n";
	print_r($_GET);
	echo'</pre>';
}
