public static function init()
 {
     if (!self::$app) {
         $config = Autoload::load('App\\config');
         self::$app = new self($config);
         Autoload::init();
         $modules = self::app()->getConfig('Modules');
         foreach ($modules as $item) {
             $module = 'Modules/' . $item;
             Autoload::load($module, 1);
         }
         Session::init();
         Router::init();
     }
 }
Ejemplo n.º 2
0
#!/usr/bin/php
<?php 
include dirname(__DIR__) . '/framework/init.php';
Autoload::init(array(LIBS, EXTERNAL, FRAMEWORK_LIBS, FRAMEWORK_EXTERNAL), CACHE);
Config::parse('define.ini', true);
Cache::$base_prefix = Config::get('cache', 'prefix');
function clear_dir($dir)
{
    if (!file_exists($dir)) {
        return;
    }
    foreach (glob($dir . '/*') as $file) {
        unlink($file);
    }
}
$file = array_shift($argv);
$set = array_shift($argv);
if (empty($set)) {
    die('Set needed' . "\n");
}
$set = Database::get_full_row('set', 'id = ?', $set);
if (empty($set)) {
    die('Incorrect set' . "\n");
}
if (!$set['grabbed']) {
    Grabber::get_set($set['id']);
}
$folder = IMAGES . SL . 'import';
if (!file_exists($folder . SL . $set['id']) || !is_dir($folder . SL . $set['id'])) {
    die('No import folder' . "\n");
}
Ejemplo n.º 3
0
        if (!self::$instance) {
            self::$instance = new self();
        }
        return self::$instance;
    }
    /**
     * Registrar.
     *
     * @return void
     */
    public function register()
    {
        spl_autoload_register(function ($name) {
            // fix root
            if ($name[0] != '\\') {
                $name = '\\' . $name;
            }
            // only couch files
            if (1 !== strpos($name, __NAMESPACE__)) {
                return;
            }
            // prepare file name & path
            $name = substr($name, 1 + strlen(__NAMESPACE__));
            $file = sprintf('%s/%s.php', __DIR__, str_replace('\\', '/', $name));
            require $file;
        });
    }
}
// auto-init for including
return Autoload::init();
Ejemplo n.º 4
0
<?php

require_once 'engine/utils.php';
require_once 'engine/autoload.php';
Autoload::init('config/autoload.php');
use App\Config, App\Request, App\User, App\Route, App\View, App\Timer, App\Debug, App\Mysql, App\Response;
try {
    Config::load('config/settings.php');
    Config::applyHostSettings('config/hosts.php');
    Mysql::setHost(Config::get('dbConnection'));
    Timer::start();
    User::startSession();
    Request::parse();
    Route::add(['/dumper' => 'dumper', '/module' => 'module', '/login' => 'login', '/tasks' => 'page', '/profile' => 'page', '/projects' => 'page', '/workspace' => 'page', '/404' => 'error', '/' => 'page']);
    Route::go();
    Timer::showExecutionTime();
    Mysql::showResources();
    Response::out();
} catch (\Exception $e) {
    Debug::showException($e);
}
Ejemplo n.º 5
0
<?php

// Require Loader
if (file_exists("app/libraries/Autoload.php")) {
    require_once "app/libraries/Autoload.php";
}
// Initialize all requires classes
Autoload::init();
// To avoid triggering a PHP notice, we can't use array elements that do not exists
if (!isset($_GET['url'])) {
    $_GET['url'] = '/';
}
$router = new Router($_GET['url']);
$router->setDefaultController('HomeController');
$router->setDefaultAction('index');
$router->parse();
$controller = $router->getController();
$action = $router->getAction();
$arguments = $router->getArguments();
$controllerClass = Controller::factory($controller);
$actionName = $action;
// This is the key part, we call a method that has a name stored in $stored
$controllerClass->{$actionName}($arguments);
Ejemplo n.º 6
0
            include_once $library;
            return true;
        }
        return false;
    }
    protected static function search_lib($name)
    {
        foreach (self::$directories as $directory) {
            if (file_exists($directory . SL . $name)) {
                return $directory . SL . $name;
            }
        }
        return false;
    }
}
Autoload::init(array(ROOT_DIR . SL . 'libs', ENGINE . SL . 'external'));
function autoload_old($class_name)
{
    $class = ROOT_DIR . SL . 'libs' . SL . str_replace('__', SL, $class_name) . '.php';
    if (file_exists($class)) {
        include_once $class;
        return true;
    }
    $class = ROOT_DIR . SL . 'engine' . SL . str_replace('__', SL, $class_name) . '.php';
    if (file_exists($class)) {
        include_once $class;
        return true;
    }
    if (!preg_match('/^Read_/i', $class_name) && !preg_match('/^Api_/i', $class_name)) {
        if (_TYPE_ == 'index') {
            include_once TEMPLATE_DIR . SL . '404' . SL . 'fatal.php';
Ejemplo n.º 7
0
<?php

/// logic unrelated to a specific request
/** @file */
#Tool, used by config
require_once $_ENV['systemFolder'] . 'tool/Tool.php';
#used by autoloader
require_once $_ENV['systemFolder'] . 'tool/Arrays.php';
require_once $_ENV['systemFolder'] . 'tool/Hook.php';
require_once $_ENV['systemFolder'] . 'tool/CommonTraits.php';
#Config setting
require_once $_ENV['systemFolder'] . 'tool/Config.php';
Config::init();
#Autoloader
require_once $_ENV['systemFolder'] . 'tool/Autoload.php';
$autoload = Autoload::init(null, $_ENV['autoloadIncludes']);
spl_autoload_register(array($autoload, 'auto'));
#composer autload
if (is_file($_ENV['composerFolder'] . 'autoload.php')) {
    require_once $_ENV['composerFolder'] . 'autoload.php';
}
set_error_handler($_ENV['errorHandler'], $_ENV['errorsHandled']);
set_exception_handler($_ENV['exceptionHandler']);
Config::loadUserFiles($_ENV['preRoute']);
#pre session request handling; for file serving and such.
require_once $_ENV['systemFolder'] . 'tool/control/Route.php';
\control\Route::handle($_SERVER['REQUEST_URI']);