コード例 #1
0
ファイル: rest.php プロジェクト: JoniJnm/dokify2
error_reporting(E_ALL);
header('Access-Control-Allow-Origin: *');
require __DIR__ . '/includes/init.php';
register_shutdown_function(function () {
    $last_error = error_get_last();
    if ($last_error && in_array($last_error['type'], array(E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR))) {
        //delete cache headers. If there is a 500 the output shouldn't be cached
        header('Cache-Control: no-store, no-cache, must-revalidate', true);
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT', true);
        \JNMFW\classes\databases\DBFactory::rollbackAllConnections();
    }
    $request = \JNMFW\classes\Request::getInstance();
    $request->setStrictMode(false);
    $controllerName = $request->getCmd('controller');
    $task = $request->getCmd('task');
    HTimer::end('Request', $controllerName . '::' . $task);
});
HTimer::init('Request');
$request = \JNMFW\classes\Request::getInstance();
$controllerName = $request->getCmd('controller');
$task = $request->getCmd('task');
HLog::verbose('Request init ' . $controllerName . '::' . $task);
$controllerName = '\\dokify2\\controllers\\' . \ucfirst($controllerName) . "Controller";
if (!\class_exists($controllerName)) {
    HServer::sendNotFound("Controller {$controllerName} not found");
}
$controller = new $controllerName();
if (!\is_callable(array($controller, $task))) {
    HServer::sendNotFound("Method {$task} not found");
}
$controller->{$task}();
コード例 #2
0
ファイル: init.php プロジェクト: JoniJnm/dokify2
});
$logfile = Config::PHP_LOG_FILE;
if ($logfile) {
    if (substr($logfile, 0, 1) != '/') {
        $logfile = dirname(__DIR__) . '/' . $logfile;
    }
    ini_set("error_log", $logfile);
}
$logfile = Config::LOG_FILE;
if ($logfile) {
    if (substr($logfile, 0, 1) != '/') {
        $logfile = dirname(__DIR__) . '/' . $logfile;
    }
    HLog::setFile($logfile);
}
HLog::setLevel(Config::LOG_LEVEL);
\JNMFW\helpers\HLang::init('ES', 'ES', 'dokify2\\langs');
$driver = new MySQLiDriver(Config::DB_SERVER, Config::DB_USER, Config::DB_PASSWORD, Config::DB_NAME);
$driver->setPrefix(Config::DB_PREFIX);
DBFactory::registerDefaultInstance($driver);
if (CacheXCache::isEnabled()) {
    $cache = CacheManager::getInstance();
    $cache->setLocalCache(new CacheXCache());
}
function loadJNMFW()
{
    // cargar librería JNMFW
    // puede estar en una subcarpeta,
    // en la superior o ya incluida en el php.ini
    if (stripos(get_include_path(), 'jnmfw')) {
        return;