<?php
define ("DATE_FORMAT", "d-m-Y, H:i");
define ("FORUM_STATUS_OPEN", 0);
define ("FORUM_STATUS_CLOSED", 1);
define ("FORUM_STATUS_MOVED", 2);
define ("FORUM_DEFAULT_TOPIC_LIMIT", 10);
define ("FORUM_AGE_LIMIT", 10);
define ("FORUM_PERMISSION_CAN_SEE", 0);
define ("FORUM_PERMISSION_CAN_SEE_TOPIC", 1);
define ("FORUM_PERMISSION_CAN_SEE_DELETE_MESSAGE", 2);
define ("FORUM_PERMISSION_CAN_SEARCH_FORUM", 3);
define ("FORUM_PERMISSION_CAN_DOWNLOAD_ATTACHMENT", 4);
define ("FORUM_PERMISSION_CAN_CREATE_TOPIC", 5);
define ("FORUM_PERMISSION_CAN_REPLY_OWN_TOPIC", 6);
define ("FORUM_PERMISSION_CAN_REPLY_OTHER_TOPIC", 7);
define ("FORUM_PERMISSION_CAN_UPLOAD_ATTACHMENT", 8);
define ("FORUM_PERMISSION_CAN_RATE_TOPIC", 9);
define ("FORUM_PERMISSION_CAN_EDIT_OWN_POST", 10);
define ("FORUM_PERMISSION_CAN_DELETE_OWN_POST", 11);
define ("FORUM_PERMISSION_CAN_MOVE_OWN_TOPIC", 12);
define ("FORUM_PERMISSION_CAN_CLOSE_OPEN_OWN_TOPIC", 13);
define ("FORUM_PERMISSION_CAN_DELETE_OWN_TOPIC", 14);
define ("FORUM_PERMISSION_CAN_DELETE_OTHER_POST", 15);
define ("FORUM_PERMISSION_CAN_EDIT_OTHER_POST", 16);
define ("FORUM_PERMISSIONS_CAN_OPEN_TOPIC", 17);
define ("FORUM_PERMISSIONS_CAN_CLOSE_TOPIC", 18);
define ("FORUM_PERMISSIONS_CAN_CHANGE_TOPICTYPE", 19);
define ("FORUM_PERMISSIONS_CAN_MOVE_TOPIC", 20);
define ("FORUM_PERMISSIONS_CAN_DELETE_TOPIC", 21);
define ("TOPIC_TYPE_NONE", 0);
define ("TOPIC_TYPE_STICKY", 1);
define ("TOPIC_TYPE_ANNOUNCE", 100);
define ("EXPIRE_MINUTE", time() + 60);
define ("EXPIRE_HOURS",  time() + 60*60);
define ("EXPIRE_DAY",    time() + 60*60*24);
define ("EXPIRE_MONTH",  time() + 60*60*24*30);
define ("EXPIRE_YEAR",   time() + 60*60*24*30*265);
define ("MAX_EDIT_PERIOD", 672); // Zeit in Stunden, in der der ein Beitrag editiert werden kann 672 = 1 Monat
define ("KOOBI_BOARD_NEWPOSTMAXAGE", "-2 weeks");

class Koobi_Smarty extends Smarty 
{
	function Koobi_Smarty($template_dir,$theme,$area,$row_lang_settings)
	{
		$url_prefix = ($_SERVER['SERVER_PORT']==443) ? 'https://' : 'http://';
		
		define('URL_PREFIX',$url_prefix);
		
		$path = $_SERVER['SCRIPT_NAME'];
		$path = explode('index',$path);
		$path_theme_abs = $path[0];
		$homelink = $url_prefix . $_SERVER['HTTP_HOST'] . str_replace('/index.php','',$_SERVER['PHP_SELF']);
		$cookiepath = str_replace('/index.php','',$_SERVER['PHP_SELF']);
		
		$res_css_path = $GLOBALS['db']->RowQuery("SELECT CSS_Theme FROM " . PREFIX . "_sektionen WHERE Id='" . $area . "'");
		$css_theme = (is_object($res_css_path) && $res_css_path->CSS_Theme != '' && is_dir(BASE_DIR . "/theme/{$theme}/css/" . $res_css_path->CSS_Theme)) ? $res_css_path->CSS_Theme : 'standard';
		
		if (stristr($_SERVER['HTTP_USER_AGENT'],"firefox")) $agent = "Firefox";
		elseif (stristr($_SERVER['HTTP_USER_AGENT'],"safari")) $agent = "Safari";
		elseif (stristr($_SERVER['HTTP_USER_AGENT'],"msie 7")) $agent = "IE7";
		elseif (stristr($_SERVER['HTTP_USER_AGENT'],"opera")) $agent = "Opera";
		elseif (stristr($_SERVER['HTTP_USER_AGENT'],"msie 6")) $agent = "IE6";
		else $agent = "UNKNOWN";
	
		define("AGENT", strtolower($agent));
		define("START_PATH", $path_theme_abs);
		define("AREA", $area);
		define("IMG_PATH", "theme/{$theme}/images");
		define("HOME_PATH", $homelink);
		define("BASE_PATH", $cookiepath);
		define("JSPATH", BASE_PATH . "/javascripts");
		define("BASE_PATH_START", BASE_PATH . "/theme/{$theme}/css/{$css_theme}");
		define("LC", $_SESSION['Langcode']);
		

		$this->compile_dir = BASE_DIR . "/compiled/{$area}";
		$this->cache_dir = BASE_DIR . "/compiled/{$area}";
		
		$this->assign('cookiepath', $cookiepath);
		$this->assign('textrandom', textrandom());
		$this->assign('browser', $agent);
		$this->assign('browser_s', strtolower($agent));
		$this->assign('maxattachment', MAXATTCHMENT);
		$this->assign('ugroup', $_SESSION['user_group']);
		$this->assign('lang_settings', $row_lang_settings);
		$this->assign('starter', 'index.php');
		$this->assign('use_seo', ($GLOBALS['settings']['use_seo']==1) ? 1 : 0 );
		$this->assign('startpath', $path_theme_abs);
		$this->assign('lang', $_SESSION['lang']);
		$this->assign('theme', $theme);
		$this->assign('area', $area);
		$this->assign('csspath', "theme/{$theme}/css/{$css_theme}");
		$this->assign('jspath', "javascripts");
		$this->assign('imgpath', "theme/{$theme}/images");
		$this->assign('imgpath_page', "theme/{$theme}/images/page/");
		$this->assign('imgpathshop', "theme/{$theme}/images/shop");
		$this->assign('imgpath_forums', "theme/{$theme}/images/forums/");
		$this->assign('base', BASE_DIR);
		$this->assign('show_price_images', 0);
		$this->assign('is_pro', (VERSION=='PRO') ? 1 : 0);
		$this->assign('incpath', BASE_DIR . "/theme/{$theme}");
		$this->assign('rss_newslink', "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?area={$area}&amp;p=newsarchive&amp;catid=" . (isset($_REQUEST['catid']) && !empty($_REQUEST['catid']) ? $_REQUEST['catid'] : "0") . "&amp;t=1&amp;mode=rss");
		$this->assign('homelink', $homelink);
		$this->assign('login', (isset($_SESSION['loggedin']) && ($_SESSION['loggedin']==1) ? 1 : 0));
		$this->assign('ugroup', $_SESSION['user_group']);
		
		$this->register_function('getonlinestatus', 'getonlinestatus');
		$this->register_function('newpn', 'newpn');
		$this->register_function('stats_user_forums', 'stats_user_forums');
		$this->register_function('userOnlineLinks', 'userOnlineLinks');
		$this->register_function('today_birthdays', 'today_birthdays');
		$this->register_function('numformat_detail', 'numformat_detail');
		$this->register_function('get_active', 'get_active');
		$this->register_function('permission', 'permission');
		$this->register_function('perm', 'perm');
		$this->register_function('copyright', 'print_copyright');
		$this->register_function('redir', 'redir');
		$this->register_function('print_redir', 'print_redir');
		$this->register_function('print_page_link', 'print_page_link');
		$this->register_function('fetchusername','fetchusername');
		
	}
}
?>