bunch of fuckery taken straight from sockhub

This commit is contained in:
flash 2015-03-08 05:57:30 +01:00
parent 1d0f78d59f
commit 416a3ff88f
3 changed files with 73 additions and 2 deletions

View file

@ -0,0 +1,66 @@
<?php
/*
* Configuration Management
*/
namespace Flashii;
class Configuration {
public static $_LCNF;
public static $_DCNF;
// Constructor
public static function init($local) {
// Store $local in $_LCNF
if(is_array($local))
self::$_LCNF = $local;
else
die('<h1>Failed to initialise configuration.</h1>');
}
// Initialise Database configuration values.
// Different from __construct as that is called before the database connection is initially
// established
public static function initDB() {
$_DATA = Database::fetch('config', true);
$_DBCN = array();
foreach($_DATA as $_CONF)
$_DBCN[$_CONF[0]] = $_CONF[1];
self::$_DCNF = $_DBCN;
}
// Get values from the configuration on the file system
public static function getLocalConfig($key, $subkey = null) {
if(array_key_exists($key, self::$_LCNF)) {
if($subkey)
return self::$_LCNF[$key][$subkey];
else
return self::$_LCNF[$key];
} else
return null;
}
// Dynamically set local configuration values, does not update the configuration file
public static function setLocalConfig($key, $subkey, $value) {
if($subkey) {
if(!isset(self::$_LCNF[$key])) {
self::$_LCNF[$key] = array();
}
self::$_LCNF[$key][$subkey] = $value;
} else {
self::$_LCNF[$key] = $value;
}
}
// Get values from the configuration in the database
public static function getConfig($key) {
if(array_key_exists($key, self::$_DCNF))
return self::$_DCNF[$key];
else
return null;
}
}

View file

@ -25,3 +25,8 @@ $fiiConf['urls']['system'] = 'sys.iihsalf.net';
$fiiConf['etc']['localPath'] = '/var/www/flashii.net/';
$fiiConf['etc']['templatesPath'] = $fiiConf['etc']['localPath'] .'_sakura/templates/';
$fiiConf['etc']['design'] = 'yuuno';
// Administrator details
$fiiConf['admin']['name'] = 'Flashwave';
$fiiConf['admin']['twitter'] = '_flashii';
$fiiConf['admin']['statuspage'] = 'status.flashii.net';

View file

@ -10,9 +10,9 @@ require_once('/var/www/flashii.net/_sakura/sakura.php');
$flashii->initTwig();
// Add page specific things
$renderData['page'] = array_merge($renderData['page'], [
$renderData['page'] = [
'title' => 'Flashii Dev'
]);
];
// Print page contents
print $flashii->twig->render('main/index.tpl', $renderData);