<?php
error_reporting(0);
  /*
   *
	*******************************************************
	*				UWAGA! SKRYPT NIE JEST DARMOWY.								*
	*			DALSZE ROZPOWSZECHNIANIE BEZ ZGODY							*
	*	 FIRMY ITWORDS MARCIN SMYCZEK JEST ZABRONIONE.			*
	*******************************************************

	*******************************************************
	*	WWW.ITWORDS.PL		PRODUCENT OPROGRAMOWANIA					*
	*	NAZWA SKRYPTU:		WORDS CMS													*
	*	KONTAKT:					KONTAKT@ITWORDS.PL							 	*
	*******************************************************

	Copyright (c) 2014 ITWORDS. Wszelkie prawa zastrzeżone.
   *
   */

//**************************************************

// biblioteka smarty
require('libs/Smarty.class.php');

$smarty = new Smarty;

$smarty->template_dir = 'templates';
$smarty->compile_dir = 'templates_c';
$smarty->cache_dir = 'cache';
$smarty->config_dir = 'configs';


// Klasa Baza
require("class/core.class.php");

// Lang
require("class/lang/lang.php");

$DB = new Core($host,$dbname,$user,$pass);

// Funkcje
require("class/functions.php");

// biblioteki
require("modules/common.php");

if(isset($_GET['controller']) and isset($_GET['mID'])){
	$controller = strtolower($DB->GetOne("select mm.modules from ".MENU_TABLE." m join ".MODULES_TABLE." mm on mm.id=m.modulesID  where m.id=?",array($_GET['mID'])));
	if($_GET['controller']=='cookies')
		$controller=$_GET['controller'];
	
	if(empty($controller)){
		// echo "aaa";
		// $zzz=$DB->GetOne("select * from modules where id=?", arr);
		$controller=strtolower($DB->GetOne("select m.modules from ".MODULES_TABLE." m where m.id=?",array($_GET['mID'])));
	}
	// echo "<pre>";
	// print_R($_GET);
	// print_R($DB);
		// $controller=strtolower($DB->GetOne("select m.modules from ".MODULES_TABLE." m where id=?",($_GET['mID'])));
		
	if(!empty($controller)){
		if(file_exists('modules/'.$controller.'.php')){
			 include('modules/'.$controller.'.php');
		}
		else
		 include('modules/error.php');		
	}
	else{
		 include('modules/error.php');	
		 exit;
	}
	
}
else{
	include('modules/index.php');
}

?>
