芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/mctv/web/index.php
. */ use Monolog\Logger; use Monolog\Processor\UidProcessor; use Psr\Container\ContainerInterface; use Slim\Views\TwigMiddleware; use Xibo\Factory\ContainerFactory; DEFINE('XIBO', true); define('PROJECT_ROOT', realpath(__DIR__ . '/..')); require PROJECT_ROOT . '/vendor/autoload.php'; // Enable/Disable logging if (\Xibo\Helper\Environment::isDevMode() || \Xibo\Helper\Environment::isForceDebugging()) { error_reporting(E_ALL); ini_set('display_errors', 1); } else { error_reporting(0); ini_set('display_errors', 0); } // Should we show the installer? if (!file_exists('settings.php')) { // Check to see if the install app is available if (file_exists(PROJECT_ROOT . '/web/install/index.php')) { header('Location: install/1'); exit(); } else { // We can't do anything here - no install app and no settings file. die('Not configured'); } } // Check that the cache folder if writeable - if it isn't we're in big trouble if (!is_writable(PROJECT_ROOT . '/cache')) { die('Installation Error: Cannot write files into the Cache Folder'); } // Create the container for dependency injection. try { $container = ContainerFactory::create(); } catch (Exception $e) { die($e->getMessage()); } // Configure Monolog $container->set('logger', function (ContainerInterface $container) { $logger = new Logger('WEB'); $uidProcessor = new UidProcessor(); // db $dbhandler = new \Xibo\Helper\DatabaseLogHandler(); $logger->pushProcessor($uidProcessor); $logger->pushHandler($dbhandler); return $logger; }); // Create a Slim application $app = \DI\Bridge\Slim\Bridge::create($container); $app->setBasePath($container->get('basePath')); // Config $container->get('configService'); $container->set('name', 'web'); // // Middleware (onion, outside inwards and then out again - i.e. the last one is first and last); // $app->add(new RKA\Middleware\IpAddress(true, [])); $app->add(new \Xibo\Middleware\Actions($app)); $app->add(new \Xibo\Middleware\Theme($app)); $app->add(new \Xibo\Middleware\CsrfGuard($app)); // Authentication $authentication = ($container->get('configService')->authentication != null) ? $container->get('configService')->authentication : (new \Xibo\Middleware\WebAuthentication()); $app->add($authentication->setDependencies($app)->addRoutes()); // Handle additional Middleware \Xibo\Middleware\State::setMiddleWare($app); // TODO reconfigure this and enable //$app->add(new Xibo\Middleware\HttpCache()); $app->add(new \Xibo\Middleware\State($app)); $app->add(new \Xibo\Middleware\Log($app)); $app->add(TwigMiddleware::createFromContainer($app)); $app->add(new \Xibo\Middleware\Storage($app)); $app->add(new \Xibo\Middleware\Xmr($app)); $app->addRoutingMiddleware(); // // End Middleware // // Add Error Middleware $app->addErrorMiddleware(false, true, true) ->setDefaultErrorHandler(\Xibo\Middleware\Handlers::webErrorHandler($container)); // All application routes require PROJECT_ROOT . '/lib/routes-web.php'; require PROJECT_ROOT . '/lib/routes.php'; // Run App try { $app->run(); } catch (Exception $e) { echo 'Fatal Error - sorry this shouldn\'t happen. '; echo '
' . $e->getMessage(); // Only output debug trace if we're configured to display errors if (ini_get('display_errors') == 1) { echo '
' . nl2br($e->getTraceAsString()) . '
'; } }