<?php
/*
// ===========================================================================
// Core {core.php}
// ===========================================================================
*/

if (version_compare(PHP_VERSION, '5.3.0', '<')) {
    die('<b>Error</b>: PHP 5.3 required, using version: ' . PHP_VERSION . "\n");
}

if (file_exists("DEBUG.txt") && filesize("DEBUG.txt"))
{
	error_reporting(-1);
}

spl_autoload_register(function ($class) {
	$script = str_replace('\\', '/', dirname(__FILE__) . '/../class/' . strtolower($class) . '.php');
	if (file_exists($script))
	{
		require_once($script);
	}
});

if (!ini_get('default_charset')) 
{
	ini_set('default_charset', 'utf-8');
}

/**
 * Escape string or array for SQL using single quotes
 *
 * @param object $object String or array
 * @param string $quote Optional quote character
 */
function Q($object, $quote = "'")
{
	if (is_array($object))
	{
		foreach ($object as $key => $value)
		{
			$object[$key] = $quote . str_replace($quote, $quote . $quote, $value) . $quote;
		}
		return $object;
	}
	return $quote . str_replace($quote, $quote . $quote, $object) . $quote;
}
