public function __construct() { if (isset(self::$current)) { throw new ConstructionException('Cannot construct more than one instance of singleton class Scout.'); } $this->_parse_url(); self::$current = $this; #$user = new user(); #Gbl::store('user',$user); Gbl::store('subdomain', $this->_parse_subdomain()); }
require_once SMARTY_CLASS_PATH . '/SmartyBC.class.php'; $smarty = new SmartyBC(); $smarty->template_dir = TEMPLATE_PATH; $smarty->compile_dir = SMARTY_TEMPLATE_C_PATH; $smarty->config_dir = SMARTY_CONFIGS_PATH; $smarty->cache_dir = SMARTY_CACHE_PATH; $smarty->assign('site_url', SITE_URL); $smarty->assign('template_url', TEMPLATE_URL); if (MODE == 'staging') { $smarty->caching = 0; $smarty->cache_lifetime = 0; } Gbl::store('template_engine', $smarty); # create the system log, used for most logging $system_log = new Log(SYSTEM_LOG_PATH, LOG_LEVEL_ALL); Gbl::store('system_log', $system_log); # authentication types -- auth module define('AUTH_SITE', 0); # cleaner types -- used by the Cleaner module. define('CTYPE_ARRAY', 0); define('CTYPE_REGEX', 1); define('CTYPE_INT', 2); define('CTYPE_ID', 3); define('CTYPE_POS_NUMERIC', 4); define('CTYPE_BOOL', 5); define('CTYPE_POS_INT', 6); # auth params define('AUTH_COOKIE', 'auth'); define('AUTH_COOKIE_EXPIRE', 24 * 60 * 60); define('AUTH_COOKIE_DOMAIN', DOMAIN); define('DEFAULT_MINER_FEE', 1000);
<? /** * Database.php * shorthand functions to make coding quicker * * copyright 2015 zcor */ $db = mysqli_connect(DBSERVER, DBUSER, DBPASS, DBPRIMARY) or die(file_get_contents("install.html")); Gbl::store('db',$db); if (!$db) { die('Could not connect: ' . mysql_error()); } function query($query) { try { $return = mysqli_query(Gbl::get('db'), $query); if(mysqli_error(Gbl::get('db'))) { throw new Exception('Query error '.mysqli_error(Gbl::get('db'))); } } catch (Exception $e) { Gbl::get('system_log')->write(LOG_LEVEL_ERROR, 'Fatal query error: ' . $e->getMessage()); if(MODE == 'staging') { echo $e->getMessage(); echo "\n<br>\n" . $query; } die("404"); } return($return);