linux fixes (it's opposite day)

This commit is contained in:
flash 2016-02-20 12:20:58 +01:00
parent 3d4f1c3187
commit b977c8422b
4 changed files with 28 additions and 33 deletions

View file

@ -8,29 +8,22 @@
; but must EXCLUDE the .php file extension. (I recommend sticking with the bundled mysql library)
driver = mysql
; Use a Unix system socket (if the library supports it), doesn't work on Windows servers.
unixsocket = false
; URI to SQL server (usually localhost or 127.0.0.1) or in the case that you're using Unix sockets
; the path to the socket.
host = localhost
; Port for the SQL server, ignored if Unix sockets are used. Should be 3306.
port = 3306
; Username used to authenticate with the SQL server
username = sakura
; Password for the same purpose
password = "password"
; Database (not table) name used.
database = sakura
; Table prefix used.
prefix = sakura_
[dsn]
host=localhost
port=3306
dbname=sakura
; Data files relative to the root directory
[data]
; JSON file containing ISO 3166 country codes

View file

@ -1,7 +1,7 @@
<?php
/**
* Holds the configuration manager.
*
*
* @package Sakura
*/
@ -9,7 +9,7 @@ namespace Sakura;
/**
* Handles both the local and database stored configuration sides of Sakura.
*
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
@ -17,21 +17,21 @@ class Config
{
/**
* Container for the parsed local configuration.
*
*
* @var array
*/
private static $local = [];
/**
* Cache for the configuration stored in the database.
*
*
* @var array
*/
private static $database = [];
/**
* Initialiser, parses the local configuration.
*
*
* @param string $local Path to the configuration file.
*/
public static function init($local)
@ -59,10 +59,10 @@ class Config
/**
* Get a value from the local configuration file.
*
*
* @param string $key Configuration section.
* @param string $subkey Configuration key.
*
*
* @return array|string Configuration value.
*/
public static function local($key, $subkey = null)
@ -88,13 +88,13 @@ class Config
/**
* Get a configuration value from the database.
*
*
* @param string $key Configuration key.
* @param bool $returnNull Unused value, only exists to prevent explosions.
*
* @param string $default Value that gets used when the value doesn't exist.
*
* @return string Configuration value.
*/
public static function get($key, $returnNull = false)
public static function get($key, $default = null)
{
// Check if the key that we're looking for exists
if (array_key_exists($key, self::$database)) {
@ -112,12 +112,11 @@ class Config
}
}
// Then return the value
trigger_error(
'Unable to get configuration value "' . $key . '"',
E_USER_ERROR
);
return null;
// If we fell all the way down here set the bundled default value
Config::set($key, $default);
// And then return default that value
return $default;
}
public static function set($key, $value)

View file

@ -1,7 +1,7 @@
<?php
/**
* Holds the serve command controller.
*
*
* @package Sakura
*/
@ -18,6 +18,6 @@ class ServeCommand extends Command
public function execute()
{
exec(PHP_BINDIR . '\php -S localhost:8000 -t ' . addslashes(ROOT . 'public/') . ' ' . addslashes(ROOT . 'server.php'));
exec(PHP_BINDIR . '/php -S localhost:8000 -t ' . addslashes(ROOT . 'public/') . ' ' . addslashes(ROOT . 'server.php'));
}
}

View file

@ -37,11 +37,14 @@ if (!@include_once ROOT . 'vendor/autoload.php') {
// Setup the autoloader
spl_autoload_register(function ($className) {
// Replace \ with /
$className = str_replace('\\', '/', $className);
// Create a throwaway count variable
$i = 1;
// Replace the sakura namespace with the libraries directory
$className = str_replace('Sakura\\', 'libraries/', $className, $i);
$className = str_replace('Sakura/', 'libraries/', $className, $i);
// Require the file
require_once ROOT . $className . '.php';