Changed all directory pointers in FuzeWorks to use the directories defined in FuzeWorks\Core.

The index file has been removed as well. This file has been replaced with the FuzeWorks\Configurator class. The configurator prepares FuzeWorks and loads it when requested. This allows for more flexible startups.
This commit is contained in:
Abel Hoogeveen 2016-07-07 17:48:09 +02:00
parent 5d19a1c4dc
commit b0f73d5537
21 changed files with 357 additions and 166 deletions

View File

@ -50,6 +50,7 @@ release:
name: "${CI_BUILD_NAME}_${CI_BUILD_REF_NAME}"
paths:
- build/
expire_in: 3 weeks
cache:
key: "$CI_BUILD_REF/$CI_BUILD_REF_NAME"
paths:

View File

@ -35,6 +35,7 @@ use FuzeWorks\Config;
use FuzeWorks\ConfigException;
use FuzeWorks\Database;
use FuzeWorks\DatabaseException;
use FuzeWorks\Core;
/**
* Initialize the database
@ -144,11 +145,11 @@ function &DB($params = '', $query_builder_override = NULL)
$query_builder = $active_record;
}
require_once('Core'.DS.'Database'.DS.'DB_driver.php');
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_driver.php');
if ( ! isset($query_builder) OR $query_builder === TRUE)
{
require_once('Core'.DS.'Database'.DS.'DB_query_builder.php');
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_query_builder.php');
if ( ! class_exists('FW_DB', FALSE))
{
/**
@ -171,7 +172,7 @@ function &DB($params = '', $query_builder_override = NULL)
}
// Load the DB driver
$driver_file = 'Core'.DS.'Database'.DS.'drivers/'.$params['dbdriver'].DS.$params['dbdriver'].'_driver.php';
$driver_file = Core::$coreDir . DS . 'Database'.DS.'drivers/'.$params['dbdriver'].DS.$params['dbdriver'].'_driver.php';
if (!file_exists($driver_file))
{
@ -187,7 +188,7 @@ function &DB($params = '', $query_builder_override = NULL)
// Check for a subdriver
if ( ! empty($DB->subdriver))
{
$driver_file = 'Core'.DS.'Database'.DS.'drivers'.DS.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
$driver_file = Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$DB->dbdriver.'/subdrivers/'.$DB->dbdriver.'_'.$DB->subdriver.'_driver.php';
if (file_exists($driver_file))
{

View File

@ -35,6 +35,7 @@ use FuzeWorks\Logger;
use FuzeWorks\DatabaseException;
use FuzeWorks\Utf8;
use FuzeWorks\Language;
use FuzeWorks\Core;
/**
* Database Driver Class
@ -764,8 +765,8 @@ abstract class FW_DB_driver {
if ( ! class_exists($driver, FALSE))
{
require_once('Core'.DS.'Database'.DS.'DB_result.php');
require_once('Core'.DS.'database'.DS.'drivers'.DS.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_result.php');
require_once(Core::$coreDir . DS . 'database'.DS.'drivers'.DS.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
}
return $driver;
@ -1690,7 +1691,7 @@ abstract class FW_DB_driver {
{
if ( ! class_exists('FW_DB_Cache', FALSE))
{
require_once('Core'.DS.'Database'.DS.'DB_cache.php');
require_once(Core::$coreDir . DS . 'Database'.DS.'DB_cache.php');
}
elseif (is_object($this->CACHE))
{
@ -1771,7 +1772,7 @@ abstract class FW_DB_driver {
$call['file'] = str_replace('\\', '/', $call['file']);
}
if (strpos($call['file'], 'Core'.DS.'Database') === FALSE && strpos($call['class'], 'Loader') === FALSE)
if (strpos($call['file'], Core::$coreDir . DS . 'Database') === FALSE && strpos($call['class'], 'Loader') === FALSE)
{
// Found it - use a relative path for safety
$message[] = 'Filename: '.str_replace(array('Application', 'Core'), '', $call['file']);

View File

@ -32,6 +32,7 @@
namespace FuzeWorks\Library;
use FuzeWorks\Factory;
use FuzeWorks\Core;
/**
* FuzeWorks File Caching Class
@ -75,7 +76,7 @@ class FW_Cache_file extends FW_Driver {
$this->factory->helpers->load('file');
$path = $this->factory->config->get('cache')->cache_file_path;
$this->_cache_path = ($path === '') ? 'Application'.DS.'Cache/' : $path;
$this->_cache_path = ($path === '') ? Core::$appDir . DS . 'Cache/' : $path;
}
// ------------------------------------------------------------------------

View File

@ -35,6 +35,7 @@ use FuzeWorks\Config;
use FuzeWorks\Logger;
use FuzeWorks\LibraryException;
use FuzeWorks\Factory;
use FuzeWorks\Core;
use ReflectionObject;
/**
@ -132,7 +133,7 @@ class FW_Driver_Library {
if (file_exists($file))
{
// Yes - require base class from BASEPATH
$basepath = 'Core'.DS.'Libraries'.DS.$clean_class.DS.'drivers'.DS.$clean_class.'_'.$child.'.php';
$basepath = Core::$coreDir . DS. 'Libraries'.DS.$clean_class.DS.'drivers'.DS.$clean_class.'_'.$child.'.php';
if ( ! file_exists($basepath))
{
$msg = 'Unable to load the requested class: FW_'.$child_name;

View File

@ -59,7 +59,7 @@ class Config
*
* @var array Array of paths where helpers can be found
*/
protected $configPaths = array('Application'.DS.'Config');
protected $configPaths = array();
/**
* Temporary variable to remain compatible with old FuzeWorks code
@ -69,6 +69,11 @@ class Config
*/
protected static $factory;
public function __construct()
{
$this->configPaths[] = Core::$appDir . DS. 'Config';
}
/**
* Retrieve a config file object
*
@ -115,10 +120,11 @@ class Config
foreach ($configPaths as $directory)
{
// If file exists, load it and break the loop
if (file_exists($directory . DS . 'config.'.$configName.'.php'))
$file = $directory . DS . 'config.'.$configName.'.php';
if (file_exists($file))
{
// Load object
return new ConfigORM($directory . DS . 'config.'.$configName.'.php');
return new ConfigORM($file);
break;
}
}

View File

@ -0,0 +1,179 @@
<?php
/**
* FuzeWorks.
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2015 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
*
* @link http://fuzeworks.techfuze.net
* @since Version 0.0.1
*
* @version Version 0.0.1
*/
namespace FuzeWorks;
/**
* Class Configurator.
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
*/
class Configurator
{
protected $parameters;
const COOKIE_SECRET = 'fuzeworks-debug';
public function __construct()
{
$this->parameters = $this->getDefaultParameters();
}
/**
* @return array
*/
protected function getDefaultParameters()
{
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$last = end($trace);
$debugMode = static::detectDebugMode();
return [
'appDir' => isset($trace[1]['file']) ? dirname($trace[1]['file']) : NULL,
'wwwDir' => isset($last['file']) ? dirname($last['file']) : NULL,
'debugMode' => $debugMode,
'productionMode' => !$debugMode,
'consoleMode' => PHP_SAPI === 'cli',
];
}
/**
* @param string error log directory
* @param string administrator email
* @return void
*/
public function enableDebugger($logDirectory = NULL, $email = NULL)
{
Tracy\Debugger::$strictMode = TRUE;
Tracy\Debugger::enable(!$this->parameters['debugMode'], $logDirectory, $email);
Nette\Bridges\Framework\TracyBridge::initialize();
}
/**
* Sets the default timezone.
* @return self
*/
public function setTimeZone($timezone)
{
date_default_timezone_set($timezone);
@ini_set('date.timezone', $timezone); // @ - function may be disabled
return $this;
}
/**
* Adds new parameters. The %params% will be expanded.
* @return self
*/
public function addParameters(array $params)
{
$this->parameters = DI\Config\Helpers::merge($params, $this->parameters);
return $this;
}
/**
* Sets path to temporary directory.
* @return self
*/
public function setTempDirectory($path)
{
$this->parameters['tempDir'] = $path;
return $this;
}
/**
* @return bool
*/
public function isDebugMode()
{
return $this->parameters['debugMode'];
}
/**
* Set parameter %debugMode%.
* @param bool|string|array
* @return self
*/
public function setDebugMode($value)
{
if (is_string($value) || is_array($value)) {
$value = static::detectDebugMode($value);
} elseif (!is_bool($value)) {
throw new Nette\InvalidArgumentException(sprintf('Value must be either a string, array, or boolean, %s given.', gettype($value)));
}
$this->parameters['debugMode'] = $value;
$this->parameters['productionMode'] = !$this->parameters['debugMode']; // compatibility
return $this;
}
/**
* Detects debug mode by IP address.
* @param string|array IP addresses or computer names whitelist detection
* @return bool
*/
public static function detectDebugMode($list = NULL)
{
$addr = isset($_SERVER['REMOTE_ADDR'])
? $_SERVER['REMOTE_ADDR']
: php_uname('n');
$secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET])
? $_COOKIE[self::COOKIE_SECRET]
: NULL;
$list = is_string($list)
? preg_split('#[,\s]+#', $list)
: (array) $list;
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$list[] = '127.0.0.1';
$list[] = '::1';
}
return in_array($addr, $list, TRUE) || in_array("$secret@$addr", $list, TRUE);
}
public function createContainer()
{
// First set all the directories
Core::$appDir = $this->parameters['appDir'];
Core::$wwwDir = $this->parameters['wwwDir'];
// Then set debug mode
if ($this->parameters['debugMode'])
{
define('ENVIRONMENT', 'DEVELOPMENT');
}
else
{
define('ENVIRONMENT', 'PRODUCTION');
}
// Then load the framework
Core::init();
}
}

View File

@ -49,11 +49,6 @@ class Core
*/
public static $version = '0.0.1';
/**
* @var bool Whether the files has been loaded
*/
private static $loaded = false;
/**
* Working directory of the Framework.
*
@ -63,6 +58,12 @@ class Core
*/
public static $cwd;
public static $appDir;
public static $wwwDir;
public static $coreDir;
/**
* Initializes the core.
*
@ -70,9 +71,12 @@ class Core
*/
public static function init()
{
// Set the CWD for usage in the shutdown function+
// Set the CWD for usage in the shutdown function
self::$cwd = getcwd();
// Set the core dir for when the loading of classes is required
self::$coreDir = dirname(__DIR__);
// If the environment is not yet defined, use production settings
if (!defined('ENVIRONMENT'))
{
@ -90,7 +94,7 @@ class Core
register_shutdown_function(array('\FuzeWorks\Core', 'shutdown'));
// Load core functionality
self::loadStartupFiles();
new Factory();
// Load the config file of the FuzeWorks core
$config = Config::get('core');
@ -110,61 +114,15 @@ class Core
);
}
// Load Composer
if ($config->enable_composer) {
$file = ($config->composer_autoloader != '' ? $config->composer_autoloader : 'vendor/autoload.php');
self::loadComposer($file);
}
// And fire the coreStartEvent
$event = Events::fireEvent('coreStartEvent');
if ($event->isCancelled()) {
return true;
}
}
/**
* Load all the files of the FuzeWorks Framework.
*/
private static function loadStartupFiles()
{
if (self::$loaded) {
return;
}
// Load core abstracts
include_once 'Core/System/class.factory.php';
include_once 'Core/System/class.exceptions.php';
include_once 'Core/System/class.abstract.event.php';
// Load the core classes
include_once 'Core/System/class.config.php';
include_once 'Core/System/class.abstract.configOrmAbstract.php';
include_once 'Core/System/class.configOrm.php';
include_once 'Core/System/class.abstract.eventPriority.php';
include_once 'Core/System/class.events.php';
include_once 'Core/System/class.logger.php';
include_once 'Core/System/class.abstract.model.php';
include_once 'Core/System/class.models.php';
include_once 'Core/System/class.layout.php';
include_once 'Core/System/class.abstract.controllerabstract.php';
include_once 'Core/System/class.router.php';
include_once 'Core/System/class.abstract.module.php';
include_once 'Core/System/class.modules.php';
include_once 'Core/System/class.libraries.php';
include_once 'Core/System/class.helpers.php';
include_once 'Core/System/class.database.php';
include_once 'Core/System/class.language.php';
include_once 'Core/System/class.utf8.php';
include_once 'Core/System/class.uri.php';
include_once 'Core/System/class.security.php';
include_once 'Core/System/class.input.php';
include_once 'Core/System/class.output.php';
// Load the core classes
new Factory();
self::$loaded = true;
// And initialize multiple classes
Layout::init();
Language::init();
}
/**
@ -189,27 +147,6 @@ class Core
}
}
/**
* Load composer if it is present.
*
* @param string directory of composer autoload file (optional)
*
* @return bool true on success, false on failure
*/
private static function loadComposer($file = 'vendor/autoload.php')
{
if (file_exists($file)) {
include $file;
Logger::log('Loaded Composer');
Logger::loadComposer();
return true;
}
Logger::log('Failed to load Composer. File \''.$file.'\' not found');
return false;
}
/**
* Checks whether the current running version of PHP is equal to the input string.
*

View File

@ -93,7 +93,7 @@ class Database
return $reference = self::$defaultDB;
}
require_once ('Core'.DS.'Database'.DS.'DB.php');
require_once (Core::$coreDir . DS . 'Database'.DS.'DB.php');
if ($newInstance)
{
@ -131,12 +131,12 @@ class Database
$database =& self::$defaultDB;
}
require_once ('Core'.DS.'Database'.DS.'DB_forge.php');
require_once('Core'.DS.'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_forge.php');
require_once (Core::$coreDir . DS . 'Database'.DS.'DB_forge.php');
require_once(Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_forge.php');
if ( ! empty($database->subdriver))
{
$driver_path = 'Core'.DS.'Database'.DS.'drivers'.DS.$database->dbdriver.DS.'subdrivers'.DS.$database->dbdriver.'_'.$database->subdriver.'_forge.php';
$driver_path = Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$database->dbdriver.DS.'subdrivers'.DS.$database->dbdriver.'_'.$database->subdriver.'_forge.php';
if (file_exists($driver_path))
{
require_once($driver_path);
@ -185,8 +185,8 @@ class Database
$database = & self::$defaultDB;
}
require_once ('Core'.DS.'Database'.DS.'DB_utility.php');
require_once('Core'.DS.'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_utility.php');
require_once (Core::$coreDir . DS . 'Database'.DS.'DB_utility.php');
require_once(Core::$coreDir . DS . 'Database'.DS.'drivers'.DS.$database->dbdriver.DS.$database->dbdriver.'_utility.php');
$class = 'FW_DB_'.$database->dbdriver.'_utility';
if ($newInstance)

View File

@ -157,7 +157,7 @@ class Events
$eventName = $input;
if (!class_exists($eventClass)) {
// Check if the file even exists
$file = 'Core/Events/event.'.$eventName.'.php';
$file = Core::$coreDir . DS . 'Events' . DS . 'event.'.$eventName.'.php';
if (file_exists($file)) {
// Load the file
$eventClass = "\FuzeWorks\Event\\".$eventClass;

View File

@ -68,7 +68,15 @@ class Helpers
*
* @var array Array of paths where helpers can be found
*/
protected $helperPaths = array('Application'.DS.'Helpers', 'Core'.DS.'Helpers');
protected $helperPaths = array();
public function __construct()
{
$this->helperPath = [
Core::$appDir . DS . 'Helpers',
Core::$coreDir . DS . 'Helpers'
];
}
/**
* Load a helper.
@ -111,7 +119,7 @@ class Helpers
// If an extension is loaded there needs to be a base helper
if ($extendedHelperLoaded)
{
$baseHelper = 'Core'.DS.'Helpers'.$helperName.'.php';
$baseHelper = Core::$coreDir . DS . 'Helpers' . DS . $helperName.'.php';
if (!file_exists($baseHelper))
{
throw new HelperException("Could not load helper. Base Helper not found while Extension loaded", 1);

View File

@ -62,7 +62,7 @@ class Language
* Paths where the class can find translations
* @var array
*/
protected static $languagePaths = array('Application'.DS.'Language');
protected static $languagePaths = array();
/**
* The current language array
@ -76,6 +76,11 @@ class Language
*/
protected static $is_loaded = array();
public static function init()
{
self::$languagePaths[] = Core::$appDir . DS . 'Language';
}
/**
* Retrieve a language file and return the language array
*
@ -115,7 +120,7 @@ class Language
$lang = array();
// Load the base file, so any others found can override it
$basepath = 'Core'.DS.'Language'.DS.$idiom.DS.$langfile;
$basepath = Core::$coreDir . DS. 'Language'.DS.$idiom.DS.$langfile;
if (($found = file_exists($basepath)) === TRUE)
{
$lang = array_merge($lang, (array) include($basepath));

View File

@ -43,6 +43,7 @@ use FuzeWorks\TemplateEngine\TemplateEngine;
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
* @todo Make Object, remove static stuff
*/
class Layout
{
@ -58,7 +59,7 @@ class Layout
*
* @var string
*/
public static $directory = 'Application/Views';
public static $directory;
/**
* All assigned currently assigned to the template.
@ -95,6 +96,11 @@ class Layout
*/
private static $current_engine;
public static function init()
{
self::$directory = Core::$appDir . DS .'Views';
}
/**
* Retrieve a template file using a string and a directory and immediatly parse it to the output class.
*
@ -521,7 +527,7 @@ class Layout
self::$current_engine = null;
self::$assigned_variables = array();
self::$directory = 'Application/Views';
self::$directory = Core::$appDir . DS . 'Views';
Logger::log('Reset the layout manager to its default state');
}
}

View File

@ -74,7 +74,7 @@ class Libraries
*
* @var array Library paths
*/
protected $libraryPaths = array('Core'.DS.'Libraries', 'Application'.DS.'Libraries');
protected $libraryPaths = array();
/**
* Array of all the loaded library objects
@ -89,6 +89,8 @@ class Libraries
public function __construct()
{
$this->factory = Factory::getInstance();
$this->libraryPaths[] = Core::$coreDir . DS . 'Libraries';
$this->libraryPaths[] = Core::$appDir . DS . 'Libraries';
}
/**
@ -135,7 +137,7 @@ class Libraries
// Load the driver class if it is not yet loaded
if ( ! class_exists('FuzeWorks\FW_Driver_Library', false))
{
require_once('Core'.DS.'Libraries'.DS.'Driver.php');
require_once(Core::$coreDir . DS . 'Libraries'.DS.'Driver.php');
}
// And then load and return the library
@ -177,7 +179,7 @@ class Libraries
$class = ucfirst($class);
// Is the library a core library, then load a core library
if (file_exists('Core'.DS.'Libraries'.DS.$subdir.$class.'.php'))
if (file_exists(Core::$coreDir . DS . 'Libraries'.DS.$subdir.$class.'.php'))
{
// Load base library
return $this->loadCoreLibrary($class, $subdir, $parameters, $directories, $newInstance);
@ -239,7 +241,7 @@ class Libraries
}
// Remove the core directory from the checklist
if (in_array('Core'.DS.'Libraries', $directories))
if (in_array(Core::$coreDir . DS . 'Libraries', $directories))
{
array_shift($directories);
}
@ -267,7 +269,7 @@ class Libraries
}
// Second base; if no base class is found in the app folder, load it from the core folder
include_once('Core'.DS.'Libraries'.DS.$subdir.$class.'.php');
include_once(Core::$coreDir . DS . 'Libraries'.DS.$subdir.$class.'.php');
// Now let's check for extensions
$subclass = $this->factory->config->getConfig('main')->application_prefix . $class;
@ -325,7 +327,7 @@ class Libraries
foreach ($directories as $directory)
{
// Skip the core directory
if ($directory === 'Core'.DS.'Libraries')
if ($directory === Core::$coreDir . DS . 'Libraries')
{
continue;
}

View File

@ -152,11 +152,11 @@ class Logger {
{
if (ENVIRONMENT === 'DEVELOPMENT')
{
Debugger::enable(Debugger::DEVELOPMENT, realpath('Application'.DS.'Logs'));
Debugger::enable(Debugger::DEVELOPMENT, realpath(Core::$appDir . DS . 'Logs'));
}
else
{
Debugger::enable(Debugger::PRODUCTION, realpath('Application'.DS.'Logs'));
Debugger::enable(Debugger::PRODUCTION, realpath(Core::$appDir . DS . 'Logs'));
}
self::$useTracy = true;
}
@ -279,15 +279,15 @@ class Logger {
Layout::reset();
Layout::assign('Logs', self::$Logs);
Layout::view(self::$logger_template, 'Core'.DS.'Views', true);
Layout::view(self::$logger_template, Core::$coreDir . DS . 'Views', true);
}
public static function logToFile()
{
Layout::reset();
Layout::assign('Logs', self::$Logs);
$contents = Layout::get('logger_cli', 'Core'.DS.'Views');
$file = 'Application'.DS.'Logs'.DS.'log_latest.php';
$contents = Layout::get('logger_cli', Core::$coreDir . DS . 'Views');
$file = Core::$appDir . 'Logs'.DS.'log_latest.php';
if (is_writable($file))
{
file_put_contents($file, '<?php ' . $contents);

View File

@ -69,10 +69,10 @@ class Models
{
// Model load event
$event = Events::fireEvent('modelLoadEvent', $name, $directory);
$directory = ($event->directory === null ? 'Application/Models' : $event->directory);
$directory = ($event->directory === null ? Core::$appDir . DS . 'Models' : $event->directory);
$name = ($event->model === null ? $name : $event->model);
$file = $directory.'/model.'.$name.'.php';
$file = $directory.DS.'model.'.$name.'.php';
if (isset(self::$model_types[$name])) {
Logger::log('Loading Model: '.get_class(self::$model_types[$name]), get_class(self::$model_types[$name]));
self::$models_array[$name] = self::$model_types[$name];

View File

@ -92,7 +92,7 @@ class Modules
public static function get($name)
{
// Where the modules are
$path = 'Modules/';
$path = Core::$appDir . DS . 'Modules/';
// Check if the requested module is registered
if (isset(self::$register[$name])) {
@ -413,7 +413,7 @@ class Modules
Logger::newLevel('Loading Module Headers', 'Core');
// Get all the module directories
$dir = 'Modules/';
$dir = Core::$appDir . DS . 'Modules/';
$mod_dirs = array();
$mod_dirs = array_values(array_diff(scandir($dir), array('..', '.')));

View File

@ -505,8 +505,8 @@ class Router
// Construct file paths and classes
$class = '\Application\Controller\\'.ucfirst($controller);
$directory = 'Application/Controller/';
$file = $directory . 'controller.'.$controller.'.php';
$directory = Core::$appDir . DS . 'Controller';
$file = $directory . DS .'controller.'.$controller.'.php';
$event = Events::fireEvent('routerLoadControllerEvent',
$file,

View File

@ -51,8 +51,6 @@ if (!function_exists('getColoredString'))
}
}
$mask = "|%5s |%-90s | %10s |\n";
$id = 1;

View File

@ -0,0 +1,89 @@
<?php
/**
* FuzeWorks.
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2015 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
*
* @link http://fuzeworks.techfuze.net
* @since Version 0.0.1
*
* @version Version 0.0.1
*/
namespace FuzeWorks;
/**
* Class Configurator.
*
* @author Abel Hoogeveen <abel@techfuze.net>
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
*/
class Configurator
{
protected $parameters;
public function __construct()
{
$this->parameters = $this->getDefaultParameters();
}
/**
* @return array
*/
protected function getDefaultParameters()
{
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$last = end($trace);
$debugMode = static::detectDebugMode();
return [
'appDir' => isset($trace[1]['file']) ? dirname($trace[1]['file']) : NULL,
'wwwDir' => isset($last['file']) ? dirname($last['file']) : NULL,
'debugMode' => $debugMode,
'productionMode' => !$debugMode,
'consoleMode' => PHP_SAPI === 'cli',
];
}
/**
* Detects debug mode by IP address.
* @param string|array IP addresses or computer names whitelist detection
* @return bool
*/
public static function detectDebugMode($list = NULL)
{
$addr = isset($_SERVER['REMOTE_ADDR'])
? $_SERVER['REMOTE_ADDR']
: php_uname('n');
$secret = isset($_COOKIE[self::COOKIE_SECRET]) && is_string($_COOKIE[self::COOKIE_SECRET])
? $_COOKIE[self::COOKIE_SECRET]
: NULL;
$list = is_string($list)
? preg_split('#[,\s]+#', $list)
: (array) $list;
if (!isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$list[] = '127.0.0.1';
$list[] = '::1';
}
return in_array($addr, $list, TRUE) || in_array("$secret@$addr", $list, TRUE);
}
}

View File

@ -1,44 +0,0 @@
<?php
/**
* FuzeWorks.
*
* The FuzeWorks MVC PHP FrameWork
*
* Copyright (C) 2015 TechFuze
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author TechFuze
* @copyright Copyright (c) 2013 - 2016, Techfuze. (http://techfuze.net)
* @copyright Copyright (c) 1996 - 2015, Free Software Foundation, Inc. (http://www.fsf.org/)
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 License
*
* @link http://fuzeworks.techfuze.net
* @since Version 0.0.1
*
* @version Version 0.0.1
*/
use FuzeWorks\Core;
use FuzeWorks\Factory;
define('ENVIRONMENT', 'PRODUCTION');
// Include framework
require_once dirname(__FILE__).'/Core/System/class.core.php';
// Load it
Core::init();
$router = Factory::getInstance()->router;
$router->route();