$full_class = "WebAPL\\" . $Extension; $full_class::__init(); class_alias($full_class, $Extension); } }); Event::listen('APL.modules.load', function () { Event::fire('APL.core.load'); Event::fire('APL.core.prepare'); Module::where('enabled', '1')->get()->each(function ($module) { ClassLoader::addDirectories(app_path() . '/modules/' . $module->extension . '/'); ClassLoader::load($module->extension); Modules::addInstance($module->extension); }); }); $clear_cache = FALSE; Event::listen(['eloquent.sav*', 'eloquent.upd*', 'eloquent.del*', 'eloquent.creat*'], function () use(&$clear_cache) { $clear_cache = TRUE; }); App::shutdown(function () use(&$clear_cache) { if ($clear_cache) { File::deleteDirectory($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/cache/'); @unlink($_SERVER['DOCUMENT_ROOT'] . '/apps/frontend/storage/meta/services.json'); Cache::flush(); } }); App::before(function () { }); App::down(function () { return Response::make("Be right back!", 503); }); require app_path() . '/filters.php';
} function cbURL($articleId) { return 'http://www.cnbeta.com/articles/' . $articleId . '.htm'; } function postWeiboBySAE($content) { return file_get_contents('http://cnbeta1.sinaapp.com/post_weibo.php?cnbeta1=true&text=' . urlencode($content)); } function replaceImgURL($content) { return str_replace('static.cnbetacdn.com', 'cnbeta1.sinaapp.com', $content); } # App shutdown App::shutdown(function () { Cacher::close(); }); # Constants const ARTICLE_CACHE_TIME = 1814400; // 3600 * 24 * 21, 21 days const ARTICLE_REFRESH_TIME = 300; // 5min const ARTICLE_RECENT_DAY = 2; // article in 1 day is 'recent' # For cache keys const ARTICLE_CACHE_KEY_PREFIX = 'A:'; const UPTODATE_KEY_PREFIX = 'U:'; const LATEST_ARTICLE_ID_KEY = 'LatestArticle'; const INDEX_CACHE_KEY = 'IndexData'; const FEED_CACHE_KEY = 'FeedData'; # Index Page
<?php require 'vendor/autoload.php'; use Symfony\Component\HttpFoundation\Request; define('BASEDIR', __DIR__ . '/'); define('APPDIR', BASEDIR . 'app/'); define('SYSDIR', BASEDIR . 'system/'); define('VENDORDIR', BASEDIR . 'vendor/'); define('VIEWSDIR', APPDIR . 'views/'); // define set of local environments $environments = array('local' => array('localhost')); // Enable powerful debugger for local only. if (in_array($_SERVER['HTTP_HOST'], $environments['local'])) { require SYSDIR . 'php_error.php'; $options = array('enable_saving' => false, 'snippet_num_lines' => 10); \php_error\reportErrors($options); } // start running the application require SYSDIR . 'app.php'; $app = new App(Request::createFromGlobals()); $app->start(); $app->router->run(); $app->shutdown();