Location: PHPKode > projects > pkZoos Website > index.php
<?php
	if(version_compare(phpversion(), '4.1.0', '<'))
	{
		die('need php version 4.1.0 or higher.');
	}





	/* */

	define('PK_MAGIC', 1);





	/* */

	define('PK_VERSION', '0.1.16');
	define('PK_DATE', '19.01.2006');





	/* */

	error_reporting(E_ALL);





	/* */

    if(ini_get('register_globals'))
    {
        if(isset($_COOKIE) && is_array($_COOKIE))
            foreach($_COOKIE as $key => $value)
                if(isset($$key))
	                unset($$key);

        if(isset($_ENV) && is_array($_ENV))
            foreach($_ENV as $key => $value)
                if(isset($$key))
	                unset($$key);

        if(isset($_FILES) && is_array($_FILES))
            foreach($_FILES as $key => $value)
                if(isset($$key))
                	unset($$key);

        if(isset($_GET) && is_array($_GET))
            foreach($_GET as $key => $value)
                if(isset($$key))
	                unset($$key);

        if(isset($_POST) && is_array($_POST))
            foreach($_POST as $key => $value)
                if(isset($$key))
	                unset($$key);

        if(isset($_SESSION) && is_array($_SESSION))
            foreach($_SESSION as $key => $value)
                if(isset($$key))
	                unset($$key);

        if(isset($_REQUEST) && is_array($_REQUEST))
            foreach($_REQUEST as $key => $value)
                if(isset($$key))
	                unset($$key);
    }





    /* */

    set_magic_quotes_runtime(0);





	/* */

    if(@get_magic_quotes_gpc())
    {
        if(isset($_COOKIE) && is_array($_COOKIE))
            foreach($_COOKIE as $key => $value)
                if(is_string($value))
                    $_COOKIE[$key] = stripslashes($value);

        if(isset($_GET) && is_array($_GET))
            foreach($_GET as $key => $value)
                if(is_string($value))
                    $_GET[$key] = stripslashes($value);

        if(isset($_POST) && is_array($_POST))
            foreach($_POST as $key => $value)
                if(is_string($value))
                    $_POST[$key] = stripslashes($value);
    }





	/* */

	require_once(dirname(__FILE__) . '/config/config.php');

	if(!defined('PK_INSTALLED'))
	{
		header('Location: install.php');
		exit;
	}





	/* */

	require_once(dirname(__FILE__) . '/includes/db/' . $db_type . '.php');

	define('CATS_TABLE',           $table_prefix.'cats');
	define('CATS_PASSWORDS_TABLE', $table_prefix.'cats_passwords');
	define('HEADS_TABLE',          $table_prefix.'heads');
	define('MODS_TABLE',           $table_prefix.'mods');
	define('POSTS_TABLE',          $table_prefix.'posts');
	define('TOPICS_TABLE',         $table_prefix.'topics');
	define('TOPICS_TRACK_TABLE',   $table_prefix.'topics_track');
	define('CONFIG_TABLE',         $table_prefix.'config');
	define('LANGS_TABLE',          $table_prefix.'langs');
	define('SEARCHES_TABLE',       $table_prefix.'searches');
	define('SESSIONS_TABLE',       $table_prefix.'sessions');
	define('STYLES_TABLE',         $table_prefix.'styles');
	define('USERS_TABLE',          $table_prefix.'users');

	$db = new DB();

	if(!$db->connect($db_server, $db_port, $db_name, $db_user, $db_password))
	{
		die('cannot connect to database.');
	}





	/* */

	require_once(dirname(__FILE__) . '/includes/functions.php');
	require_once(dirname(__FILE__) . '/includes/config.php');

	config_load();





	/* */

	define('CURRENT_TIME', time());
	define('DATE_TODAY', make_date(CURRENT_TIME));
	define('DATE_YESTERDAY', make_date(CURRENT_TIME - (60 * 60 * 24)));
	define('CLIENT_IP', $_SERVER['REMOTE_ADDR']);





	/* */

	require_once($config['script_path'] . 'includes/template.php');

	$tpl = new TPL();





	/* */

	require_once($config['script_path'] . 'includes/error.php');
	require_once($config['script_path'] . 'includes/session.php');
	require_once($config['script_path'] . 'includes/user.php');
	require_once($config['script_path'] . 'includes/lang.php');
	require_once($config['script_path'] . 'includes/style.php');
	require_once($config['script_path'] . 'includes/mail.php');
	require_once($config['script_path'] . 'includes/compression.php');

	user_login();
	//session_begin();
	lang_load();
	style_load();
	error_clear();









	/* */

	set_last_online_time($user['id'], CURRENT_TIME);





	/* */

	$tpl->add_vars
	(
        array
        (
        	'PK_VERSION' => html_escape(PK_VERSION),
        	'PK_DATE' => html_escape(PK_DATE),
        	'DATE_TODAY' => html_escape(DATE_TODAY),
        	'SITE_NAME' => html_escape($config['site_name']),
        	'SITE_CHARSET' => html_escape($lang['charset']),
        	'SITE_LANGUAGE' => html_escape($lang['name']),
        	'PAGE_TITLE' => '',
        	'ONLINE_USERS' => get_online_users(),
        	'ONLINE_GUESTS' => get_online_guests(),
        	'URL_BASE' => html_escape(base_url()),
        	'URL_STYLE' => html_escape($config['style_url']),
        	'URL_INDEX' => html_escape(make_url('', array())),
        	'URL_NEWS' => html_escape(make_url('news', array())),
        	'URL_NEWS_CAT' => html_escape(make_url('cat', array('cat_id' => $config['news_cat_id']))),
        	'URL_BOARD' => html_escape(make_url('board', array())),
        	'URL_REGISTER' => html_escape(make_url('register', array())),
        	'URL_LOGIN' => html_escape(make_url('register', array('action' => 'login'))),
        	'URL_SEND_PASSWORD' => html_escape(make_url('register', array('action' => 'send_password'))),
        	'URL_LOGOUT' => html_escape(make_url('register', array('action' => 'logout'))),
        	'URL_USERS' => html_escape(make_url('users', array())),
			'URL_ALL_USERS' => html_escape(make_url('users', array('mode' => 'all'))),
			'URL_ONLINE_USERS' => html_escape(make_url('users', array('mode' => 'online'))),
			'URL_SEARCH' => html_escape(make_url('search', array())),
			'URL_SEARCH_USER' => html_escape(make_url('search', array('action' => 'search_user'))),
			'URL_SEARCH_POST' => html_escape(make_url('search', array('action' => 'search_post'))),
			'URL_SEARCH_TOPIC' => html_escape(make_url('search', array('action' => 'search_topic')))
        )
	);





	/* */

	$actions = array
	(
		'board'    => array('script' => $config['script_path'] . 'board.php', 'tpl' => 'board.html'),
		'cat'      => array('script' => $config['script_path'] . 'cat.php', 'tpl' => 'cat.html'),
		'news'     => array('script' => $config['script_path'] . 'news.php', 'tpl' => 'news.html'),
		'register' => array('script' => $config['script_path'] . 'register.php', 'tpl' => 'register.html'),
		'search'   => array('script' => $config['script_path'] . 'search.php', 'tpl' => 'search.html'),
		'topic'    => array('script' => $config['script_path'] . 'topic.php', 'tpl' => 'topic.html'),
		'user'     => array('script' => $config['script_path'] . 'user.php', 'tpl' => 'user.html'),
		'users'    => array('script' => $config['script_path'] . 'users.php', 'tpl' => 'users.html')
	);

	if(!isset($_GET['view']))
	{
		$_GET['view'] = $config['view_default'];
	}

	if(!isset($actions[$_GET['view']]))
	{
		$_GET['view'] = $config['view_default'];
	}

	require_once($actions[$_GET['view']]['script']);

	compression_begin();

	$tpl->filename($actions[$_GET['view']]['tpl']);
	$tpl->display();

	compression_end();
?>
Return current item: pkZoos Website