<?php

// Configuration for myChess
// `````````````````````````
// This file is require_once'd by most PHP pages.

define('LANGUAGE',			'en_GB');
define('DB_PATH',			'../games.db');
define('APP_NAME',			'myChess');
define('APP_EMAIL_FROM',	'mail@myChess.local');
define('RSS_EMAIL',     	'rss@myChess.local');
define('RSS_ITEMCOUNT',		8);
define('HISTORY_COUNT',		5);
define('DEFAULT_BOARD',		'r|n|b|q|k|b|n|r|p|p|p|p|p|p|p|p|||||||||||||||||||||||||||||||||P|P|P|P|P|P|P|P|R|N|B|Q|K|B|N|R');
define('DEFAULT_TZONE',		'Pacific/Auckland');
define('DEFAULT_THEME',		0);

// Constants
// `````````

require_once 'lang-'.LANGUAGE.'.php';

define('PLAYER_W',      	1); // Uppercase pieces
define('PLAYER_B',      	2); // Lowercase pieces
define('PLAYER_S',      	3);
define('HOME_ADDRESS',		'?p=home');


// Helper functions
// ````````````````

function redirect($url) {
	header('Location: '.$url);
	die();
}

function main_url() {
	return 'http://'.
		$_SERVER['HTTP_HOST'].dirname($_SERVER['SCRIPT_NAME']).'/index.php';
}

function dieWithError($message = E_INVREQ) {
	$_SESSION['info'] = $message;
	redirect(HOME_ADDRESS);
}
