Phalcon Framework 3.2.2

Phalcon\Mvc\Dispatcher\Exception: Post not found

/var/www/peopleread/data/www/peopleread.net/app/modules/News/Controller/IndexController.php (29)
#0News\Controller\IndexController->postAction(1204875-spacex-launches-15th-mission-of-the-year-on-previously-flown-rocket-booster)
#1Phalcon\Dispatcher->callActionMethod(Object(News\Controller\IndexController), postAction, Array([slug] => 1204875-spacex-launches-15th-mission-of-the-year-on-previously-flown-rocket-booster))
#2Phalcon\Dispatcher->_dispatch()
#3Phalcon\Dispatcher->dispatch()
/var/www/peopleread/data/www/peopleread.net/app/Bootstrap.php (459)
<?php
 
namespace ITD;
/**
 * Class Bootstrap
 * @package ITD
 */
class Bootstrap
{
 
    public function run()
    {
 
        require_once APPLICATION_PATH . '/vendor/misc.php'; // temp function
        $di = new \Phalcon\DI\FactoryDefault();
        // Config
        $this->setConfig($di);
        // Registry
        $this->setRegistry($di);
        // Loader
        $this->setLoader($di);
        // Database
        $this->setDb($di);
        // URL
        $this->setUrl($di, true);
        // Cache
        $this->initCache($di);
        // CMS
        $this->setCmsConfig($di);
        // View
        $this->initView($di);
        // Application
        $this->setApplication($di);
        // Events Manager, Dispatcher
        $this->initEventManager($di);
        // Session
        $this->setSession($di);
        //Request
        $this->setRequest($di);
        //Acl
        $this->setAcl($di);
        //Services, Flash helper
        $this->setServices($di);
        // JS Assets
        $this->initAssetsManager($di);
        // Routing
        $this->setRouting($di);
        if(!$this->isAdminPanel($di)){
            // News site subdomain
            $this->setCountry($di);
        }
        // Database shard
        //$this->setDbCluster($di);
 
        // Main dispatching process
        $this->dispatch($di);
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setConfig($di)
    {
        require_once APPLICATION_PATH . '/modules/Cms/Config.php';
        $config = \Cms\Config::get();
        $di->set('config', $config);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setRegistry($di)
    {
        $registry = new \Phalcon\Registry();
        $di->set('registry', $registry);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setLoader($di)
    {
        $loader = new \Phalcon\Loader();
        $loader->registerNamespaces($di->get('config')->loader->namespaces->toArray());
        $loader->registerDirs([APPLICATION_PATH . "/plugins/"]);
        $loader->register();
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setCountry($di)
    {
      $url = $di->get('url');
        $country = new \News\Repository\Country($di);
    $host = $di->get('request')->getHttpHost();
    $url->setBaseUri("https://".$host."/");
        $di->set('country', $country);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setDb($di)
    {
        $config = $di->get('config');
        $db = new \Phalcon\Db\Adapter\Pdo\Mysql([
            "host" => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname" => $config->database->dbname,
            "charset" => $config->database->charset,
        ]);
        $di->set('db', $db);
        return $di;
    }
 
    private function setDbCluster($di)
    {
        $country_code = $di->get('country')->getCountryCode();
        $country = \News\Model\Country::find("code = $country_code");
        $dbNodeConfig = $country->getDbConfig();
        p($dbNodeConfig);
        $dbPost = new \Phalcon\Db\Adapter\Pdo\Mysql($dbNodeConfig);
        $di->set('dbPost', $dbPost);
        return $di;
    }
 
    /**
     * @param $di
     * @param bool $cdn
     * @return mixed
     */
    private function setUrl($di, $cdn = false)
    {
        $config = $di->get('config');
        $url = new \Phalcon\Mvc\Url();
        $url->setBasePath($config->base_path);
        $url->setBaseUri("https://" . BASE_HOST . "/");
        // Статические ресурсы проходят через CDN, тоже в базу в настройки
        if ($cdn)
            $url->setStaticBaseUri('https://cdn.' . BASE_HOST . '/');
        $di->set('url', $url);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setCmsConfig($di)
    {
        $config = $di->get('config');
        $registry = $di->get('registry');
        $cmsModel = new \Cms\Model\Configuration();
        $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setApplication($di)
    {
        $config = $di->get('config');
        $application = new \Phalcon\Mvc\Application();
        $application->registerModules($config->modules->toArray());
        $di->set('application', $application);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setSession($di)
    {
        session_set_cookie_params(0, '/', '.' . BASE_HOST);
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        $di->set('session', $session);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setRequest($di)
    {
        $request = new \Phalcon\Http\Request();
        $di->set('request', $request);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setAcl($di)
    {
        $acl = new \Application\Acl\DefaultAcl();
        $di->set('acl', $acl);
        return $di;
    }
 
    private function setServices($di)
    {
 
        //breadcrumbs
        $crumbs = new \Application\Breadcrumbs\Breadcrumbs();
        $di->set('crumbs', $crumbs);
 
        //file manager
        $fm = new \FileManager\FM();
        $di->set('fm', $fm);
 
        // Flash helper
        $flash = new \Phalcon\Flash\Session([
            'error' => 'alert alert-warning alert-dismissable',
            'success' => 'alert alert-success',
            'notice' => 'alert alert-info',
            'warning' => 'alert alert-warning',
        ]);
        $di->set('flash', $flash);
        $di->set('helper', new \Application\Mvc\Helper());
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setRouting($di)
    {
        $config = $di->get('config');
        $application = $di->get('application');
 
        $core = new \Cms\Main($application->getModules());
        $di->set('core', $core);
 
        $this->initRouting($application, $di);
        $application->setDI($di);
        return $di;
    }
 
    /**
     * @param $application
     * @param $di
     */
    private function initRouting($application, $di)
    {
        $router = new \Application\Mvc\Router\DefaultRouter();
        $router->setDi($di);
        foreach ($application->getModules() as $module) {
            $routesClassName = str_replace('Module', 'Routes', $module['className']);
            if (class_exists($routesClassName)) {
                $routesClass = new $routesClassName();
                $router = $routesClass->init($router);
            }
            $initClassName = str_replace('Module', 'Init', $module['className']);
            if (class_exists($initClassName)) {
                $init = new $initClassName();
                if (method_exists($init, "setMenu")) {
                    $init->setMenu();
                }
            }
        }
        $di->set('router', $router);
    }
 
    /**
     * @param $di
     */
    private function initAssetsManager($di)
    {
        $config = $di->get('config');
 
        $assetsManager = new \Application\Assets\Manager();
        $js_collection = $assetsManager->collection('js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/js/main.js')
            ->setTargetUri('assets/js/main.js')
            ->join(true);
        /*if ($config->assets->js) {
            foreach ($config->assets->js as $js) {
                $js_collection->addJs(ROOT . '/' . $js);
            }
        }*/
 
 
        $di->set('assets', $assetsManager);
    }
 
    private function initEventManager($di)
    {
        $eventsManager = new \Phalcon\Events\Manager();
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
        $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \ITD\Plugin\CheckPoint($di->get('request'));
            new \ITD\Plugin\Localization($dispatcher);
            new \ITD\Plugin\AdminLocalization($di->get('config'));
            new \ITD\Plugin\Acl($di->get('acl'), $dispatcher, $di->get('view'));
            new \ITD\Plugin\MobileDetect($di->get('session'), $di->get('view'), $di->get('request'));
            //отдельно переводы для стран
            if(!$this->isAdminPanel($di)) {
                new \Cms\Repository\Localization($di);
            }
        });
 
        $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
            new \ITD\Plugin\Title($di);
        });
 
        // Profiler
        $registry = $di->get('registry');
        if ($registry->cms['PROFILER']) {
            $profiler = new \Phalcon\Db\Profiler();
            $di->set('profiler', $profiler);
 
            $eventsManager->attach('db', function ($event, $db) use ($profiler) {
                if ($event->getType() == 'beforeQuery') {
                    $profiler->startProfile($db->getSQLStatement());
                }
                if ($event->getType() == 'afterQuery') {
                    $profiler->stopProfile();
                }
            });
        }
 
        $db = $di->get('db');
        $db->setEventsManager($eventsManager);
        $dispatcher->setEventsManager($eventsManager);
        $di->set('dispatcher', $dispatcher);
 
 
    }
 
    private function initView($di)
    {
        $config = $di->get('config');
        $registry = $di->get('registry');
        $url = $di->get('router')->getRewriteUri();
 
        $view = new \Phalcon\Mvc\View();
        define('TEMPLATE_ID', $registry->cms['TEMPLATE_ID']);
 
        define('MAIN_VIEW_PATH', '../../../views/templates/' . TEMPLATE_ID . '/views');
        define('MAIN_VIEW_PATH_ADMIN', '../../../views/admin/');
        $adminPanel = (strpos($url, '/admin') !== false) ? true : false;
        if ($adminPanel) {
            $view->setMainView(MAIN_VIEW_PATH_ADMIN . 'index');
            $view->setPartialsDir(MAIN_VIEW_PATH_ADMIN . 'partials/');
        } else {
            $view->setMainView(MAIN_VIEW_PATH . '/index');
            $view->setLayoutsDir(MAIN_VIEW_PATH . '/layouts/');
            $view->setLayout('index');
            $view->setPartialsDir(MAIN_VIEW_PATH . '/partials/');
        }
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/cache/volt/']);
        $volt->initCompiler();
 
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt" => $volt,
            ".phtml" => $phtml,
            ".php" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
 
 
        $ajax = $di->get('request')->getQuery('_ajax');
        if ($ajax) {
            $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
        }
        $di->set('view', $view);
 
        return $view;
    }
 
    private function initCache($di)
    {
        $config = $di->get('config');
 
        $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
            "lifetime" => 60,
            "prefix" => HOST_HASH,
        ]);
 
        $cache = null;
        switch ($config->cache) {
            case 'file':
                $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
                    "cacheDir" => __DIR__ . "/cache/backend/",
                ]);
                break;
            case 'memcache':
                $cache = new \Phalcon\Cache\Backend\Memcache(
                    $cacheFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                break;
        }
        $di->set('cache', $cache, true);
        $di->set('modelsCache', $cache, true);
 
        \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
        $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
        $di->set('modelsMetadata', $modelsMetadata);
    }
 
    private function dispatch($di)
    {
        $router = $di['router'];
        $router->handle();
        $view = $di['view'];
        $dispatcher = $di['dispatcher'];
        $response = $di['response'];
        $dispatcher->setModuleName($router->getModuleName());
        $dispatcher->setControllerName($router->getControllerName());
        $dispatcher->setActionName($router->getActionName());
        $dispatcher->setParams($router->getParams());
 
        $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
        $ModuleClassName = $moduleName . '\Module';
        if (class_exists($ModuleClassName)) {
            $module = new $ModuleClassName;
            $module->registerAutoloaders();
            $module->registerServices($di);
        }
 
        $view->start();
 
        $registry = $di['registry'];
        if ($registry->cms['DEBUG_MODE']) {
            $debug = new \Phalcon\Debug();
            $debug->listen();
            $dispatcher->dispatch();
        } else {
            try {
                $dispatcher->dispatch();
            } catch (\Phalcon\Exception $e) {
                // Errors catching
 
                $view->setViewsDir(__DIR__ . '/modules/Index/views/');
                $view->setPartialsDir('');
                $view->e = $e;
 
                if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
                    $response->setHeader(404, 'Not Found');
                    $view->partial('error/error404');
                } else {
                    $response->setHeader(503, 'Service Unavailable');
                    $view->partial('error/error503');
                }
                $response->sendHeaders();
                echo $response->getContent();
 
                return;
 
            }
        }
 
        $view->render(
            $dispatcher->getControllerName(),
            $dispatcher->getActionName(),
            $dispatcher->getParams()
        );
 
        $view->finish();
 
        $response = $di['response'];
 
        // AJAX
        $request = $di['request'];
        $_ajax = $request->getQuery('_ajax');
        if ($_ajax) {
            $contents = $view->getContent();
 
            $return = new \stdClass();
            $return->html = $contents;
            $return->title = $di->get('helper')->title()->get();
            $return->success = true;
 
            if ($view->bodyClass) {
                $return->bodyClass = $view->bodyClass;
            }
 
            $headers = $response->getHeaders()->toArray();
            if (isset($headers[404]) || isset($headers[503])) {
                $return->success = false;
            }
            $response->setContentType('application/json', 'UTF-8');
            $response->setContent(json_encode($return));
        } else {
            $response->setContent($view->getContent());
        }
 
        $response->sendHeaders();
 
        echo $response->getContent();
    }
 
 
    public function isAdminPanel($di)
    {
        $url = $di->get('router')->getRewriteUri();
        $adminPanel = (strpos($url, '/admin') !== false) ? true : false;
        return $adminPanel;
    }
 
}
#4ITD\Bootstrap->dispatch(Object(Phalcon\Di\FactoryDefault))
/var/www/peopleread/data/www/peopleread.net/app/Bootstrap.php (56)
<?php
 
namespace ITD;
/**
 * Class Bootstrap
 * @package ITD
 */
class Bootstrap
{
 
    public function run()
    {
 
        require_once APPLICATION_PATH . '/vendor/misc.php'; // temp function
        $di = new \Phalcon\DI\FactoryDefault();
        // Config
        $this->setConfig($di);
        // Registry
        $this->setRegistry($di);
        // Loader
        $this->setLoader($di);
        // Database
        $this->setDb($di);
        // URL
        $this->setUrl($di, true);
        // Cache
        $this->initCache($di);
        // CMS
        $this->setCmsConfig($di);
        // View
        $this->initView($di);
        // Application
        $this->setApplication($di);
        // Events Manager, Dispatcher
        $this->initEventManager($di);
        // Session
        $this->setSession($di);
        //Request
        $this->setRequest($di);
        //Acl
        $this->setAcl($di);
        //Services, Flash helper
        $this->setServices($di);
        // JS Assets
        $this->initAssetsManager($di);
        // Routing
        $this->setRouting($di);
        if(!$this->isAdminPanel($di)){
            // News site subdomain
            $this->setCountry($di);
        }
        // Database shard
        //$this->setDbCluster($di);
 
        // Main dispatching process
        $this->dispatch($di);
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setConfig($di)
    {
        require_once APPLICATION_PATH . '/modules/Cms/Config.php';
        $config = \Cms\Config::get();
        $di->set('config', $config);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setRegistry($di)
    {
        $registry = new \Phalcon\Registry();
        $di->set('registry', $registry);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setLoader($di)
    {
        $loader = new \Phalcon\Loader();
        $loader->registerNamespaces($di->get('config')->loader->namespaces->toArray());
        $loader->registerDirs([APPLICATION_PATH . "/plugins/"]);
        $loader->register();
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setCountry($di)
    {
      $url = $di->get('url');
        $country = new \News\Repository\Country($di);
    $host = $di->get('request')->getHttpHost();
    $url->setBaseUri("https://".$host."/");
        $di->set('country', $country);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setDb($di)
    {
        $config = $di->get('config');
        $db = new \Phalcon\Db\Adapter\Pdo\Mysql([
            "host" => $config->database->host,
            "username" => $config->database->username,
            "password" => $config->database->password,
            "dbname" => $config->database->dbname,
            "charset" => $config->database->charset,
        ]);
        $di->set('db', $db);
        return $di;
    }
 
    private function setDbCluster($di)
    {
        $country_code = $di->get('country')->getCountryCode();
        $country = \News\Model\Country::find("code = $country_code");
        $dbNodeConfig = $country->getDbConfig();
        p($dbNodeConfig);
        $dbPost = new \Phalcon\Db\Adapter\Pdo\Mysql($dbNodeConfig);
        $di->set('dbPost', $dbPost);
        return $di;
    }
 
    /**
     * @param $di
     * @param bool $cdn
     * @return mixed
     */
    private function setUrl($di, $cdn = false)
    {
        $config = $di->get('config');
        $url = new \Phalcon\Mvc\Url();
        $url->setBasePath($config->base_path);
        $url->setBaseUri("https://" . BASE_HOST . "/");
        // Статические ресурсы проходят через CDN, тоже в базу в настройки
        if ($cdn)
            $url->setStaticBaseUri('https://cdn.' . BASE_HOST . '/');
        $di->set('url', $url);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setCmsConfig($di)
    {
        $config = $di->get('config');
        $registry = $di->get('registry');
        $cmsModel = new \Cms\Model\Configuration();
        $registry->cms = $cmsModel->getConfig(); // Отправляем в Registry
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setApplication($di)
    {
        $config = $di->get('config');
        $application = new \Phalcon\Mvc\Application();
        $application->registerModules($config->modules->toArray());
        $di->set('application', $application);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setSession($di)
    {
        session_set_cookie_params(0, '/', '.' . BASE_HOST);
        $session = new \Phalcon\Session\Adapter\Files();
        $session->start();
        $di->set('session', $session);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setRequest($di)
    {
        $request = new \Phalcon\Http\Request();
        $di->set('request', $request);
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setAcl($di)
    {
        $acl = new \Application\Acl\DefaultAcl();
        $di->set('acl', $acl);
        return $di;
    }
 
    private function setServices($di)
    {
 
        //breadcrumbs
        $crumbs = new \Application\Breadcrumbs\Breadcrumbs();
        $di->set('crumbs', $crumbs);
 
        //file manager
        $fm = new \FileManager\FM();
        $di->set('fm', $fm);
 
        // Flash helper
        $flash = new \Phalcon\Flash\Session([
            'error' => 'alert alert-warning alert-dismissable',
            'success' => 'alert alert-success',
            'notice' => 'alert alert-info',
            'warning' => 'alert alert-warning',
        ]);
        $di->set('flash', $flash);
        $di->set('helper', new \Application\Mvc\Helper());
        return $di;
    }
 
    /**
     * @param $di
     * @return mixed
     */
    private function setRouting($di)
    {
        $config = $di->get('config');
        $application = $di->get('application');
 
        $core = new \Cms\Main($application->getModules());
        $di->set('core', $core);
 
        $this->initRouting($application, $di);
        $application->setDI($di);
        return $di;
    }
 
    /**
     * @param $application
     * @param $di
     */
    private function initRouting($application, $di)
    {
        $router = new \Application\Mvc\Router\DefaultRouter();
        $router->setDi($di);
        foreach ($application->getModules() as $module) {
            $routesClassName = str_replace('Module', 'Routes', $module['className']);
            if (class_exists($routesClassName)) {
                $routesClass = new $routesClassName();
                $router = $routesClass->init($router);
            }
            $initClassName = str_replace('Module', 'Init', $module['className']);
            if (class_exists($initClassName)) {
                $init = new $initClassName();
                if (method_exists($init, "setMenu")) {
                    $init->setMenu();
                }
            }
        }
        $di->set('router', $router);
    }
 
    /**
     * @param $di
     */
    private function initAssetsManager($di)
    {
        $config = $di->get('config');
 
        $assetsManager = new \Application\Assets\Manager();
        $js_collection = $assetsManager->collection('js')
            ->setLocal(true)
            ->addFilter(new \Phalcon\Assets\Filters\Jsmin())
            ->setTargetPath(ROOT . '/assets/js/main.js')
            ->setTargetUri('assets/js/main.js')
            ->join(true);
        /*if ($config->assets->js) {
            foreach ($config->assets->js as $js) {
                $js_collection->addJs(ROOT . '/' . $js);
            }
        }*/
 
 
        $di->set('assets', $assetsManager);
    }
 
    private function initEventManager($di)
    {
        $eventsManager = new \Phalcon\Events\Manager();
        $dispatcher = new \Phalcon\Mvc\Dispatcher();
 
        $eventsManager->attach("dispatch:beforeDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \ITD\Plugin\CheckPoint($di->get('request'));
            new \ITD\Plugin\Localization($dispatcher);
            new \ITD\Plugin\AdminLocalization($di->get('config'));
            new \ITD\Plugin\Acl($di->get('acl'), $dispatcher, $di->get('view'));
            new \ITD\Plugin\MobileDetect($di->get('session'), $di->get('view'), $di->get('request'));
            //отдельно переводы для стран
            if(!$this->isAdminPanel($di)) {
                new \Cms\Repository\Localization($di);
            }
        });
 
        $eventsManager->attach("dispatch:afterDispatchLoop", function ($event, $dispatcher) use ($di) {
            new \Seo\Plugin\SeoManager($dispatcher, $di->get('request'), $di->get('router'), $di->get('view'));
            new \ITD\Plugin\Title($di);
        });
 
        // Profiler
        $registry = $di->get('registry');
        if ($registry->cms['PROFILER']) {
            $profiler = new \Phalcon\Db\Profiler();
            $di->set('profiler', $profiler);
 
            $eventsManager->attach('db', function ($event, $db) use ($profiler) {
                if ($event->getType() == 'beforeQuery') {
                    $profiler->startProfile($db->getSQLStatement());
                }
                if ($event->getType() == 'afterQuery') {
                    $profiler->stopProfile();
                }
            });
        }
 
        $db = $di->get('db');
        $db->setEventsManager($eventsManager);
        $dispatcher->setEventsManager($eventsManager);
        $di->set('dispatcher', $dispatcher);
 
 
    }
 
    private function initView($di)
    {
        $config = $di->get('config');
        $registry = $di->get('registry');
        $url = $di->get('router')->getRewriteUri();
 
        $view = new \Phalcon\Mvc\View();
        define('TEMPLATE_ID', $registry->cms['TEMPLATE_ID']);
 
        define('MAIN_VIEW_PATH', '../../../views/templates/' . TEMPLATE_ID . '/views');
        define('MAIN_VIEW_PATH_ADMIN', '../../../views/admin/');
        $adminPanel = (strpos($url, '/admin') !== false) ? true : false;
        if ($adminPanel) {
            $view->setMainView(MAIN_VIEW_PATH_ADMIN . 'index');
            $view->setPartialsDir(MAIN_VIEW_PATH_ADMIN . 'partials/');
        } else {
            $view->setMainView(MAIN_VIEW_PATH . '/index');
            $view->setLayoutsDir(MAIN_VIEW_PATH . '/layouts/');
            $view->setLayout('index');
            $view->setPartialsDir(MAIN_VIEW_PATH . '/partials/');
        }
 
        // Volt
        $volt = new \Application\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(['compiledPath' => APPLICATION_PATH . '/cache/volt/']);
        $volt->initCompiler();
 
 
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);
        $viewEngines = [
            ".volt" => $volt,
            ".phtml" => $phtml,
            ".php" => $phtml,
        ];
 
        $view->registerEngines($viewEngines);
 
 
        $ajax = $di->get('request')->getQuery('_ajax');
        if ($ajax) {
            $view->setRenderLevel(\Phalcon\Mvc\View::LEVEL_LAYOUT);
        }
        $di->set('view', $view);
 
        return $view;
    }
 
    private function initCache($di)
    {
        $config = $di->get('config');
 
        $cacheFrontend = new \Phalcon\Cache\Frontend\Data([
            "lifetime" => 60,
            "prefix" => HOST_HASH,
        ]);
 
        $cache = null;
        switch ($config->cache) {
            case 'file':
                $cache = new \Phalcon\Cache\Backend\File($cacheFrontend, [
                    "cacheDir" => __DIR__ . "/cache/backend/",
                ]);
                break;
            case 'memcache':
                $cache = new \Phalcon\Cache\Backend\Memcache(
                    $cacheFrontend, [
                    "host" => $config->memcache->host,
                    "port" => $config->memcache->port,
                ]);
                break;
        }
        $di->set('cache', $cache, true);
        $di->set('modelsCache', $cache, true);
 
        \Application\Widget\Proxy::$cache = $cache; // Modules Widget System
 
        $modelsMetadata = new \Phalcon\Mvc\Model\Metadata\Memory();
        $di->set('modelsMetadata', $modelsMetadata);
    }
 
    private function dispatch($di)
    {
        $router = $di['router'];
        $router->handle();
        $view = $di['view'];
        $dispatcher = $di['dispatcher'];
        $response = $di['response'];
        $dispatcher->setModuleName($router->getModuleName());
        $dispatcher->setControllerName($router->getControllerName());
        $dispatcher->setActionName($router->getActionName());
        $dispatcher->setParams($router->getParams());
 
        $moduleName = \Application\Utils\ModuleName::camelize($router->getModuleName());
 
        $ModuleClassName = $moduleName . '\Module';
        if (class_exists($ModuleClassName)) {
            $module = new $ModuleClassName;
            $module->registerAutoloaders();
            $module->registerServices($di);
        }
 
        $view->start();
 
        $registry = $di['registry'];
        if ($registry->cms['DEBUG_MODE']) {
            $debug = new \Phalcon\Debug();
            $debug->listen();
            $dispatcher->dispatch();
        } else {
            try {
                $dispatcher->dispatch();
            } catch (\Phalcon\Exception $e) {
                // Errors catching
 
                $view->setViewsDir(__DIR__ . '/modules/Index/views/');
                $view->setPartialsDir('');
                $view->e = $e;
 
                if ($e instanceof \Phalcon\Mvc\Dispatcher\Exception) {
                    $response->setHeader(404, 'Not Found');
                    $view->partial('error/error404');
                } else {
                    $response->setHeader(503, 'Service Unavailable');
                    $view->partial('error/error503');
                }
                $response->sendHeaders();
                echo $response->getContent();
 
                return;
 
            }
        }
 
        $view->render(
            $dispatcher->getControllerName(),
            $dispatcher->getActionName(),
            $dispatcher->getParams()
        );
 
        $view->finish();
 
        $response = $di['response'];
 
        // AJAX
        $request = $di['request'];
        $_ajax = $request->getQuery('_ajax');
        if ($_ajax) {
            $contents = $view->getContent();
 
            $return = new \stdClass();
            $return->html = $contents;
            $return->title = $di->get('helper')->title()->get();
            $return->success = true;
 
            if ($view->bodyClass) {
                $return->bodyClass = $view->bodyClass;
            }
 
            $headers = $response->getHeaders()->toArray();
            if (isset($headers[404]) || isset($headers[503])) {
                $return->success = false;
            }
            $response->setContentType('application/json', 'UTF-8');
            $response->setContent(json_encode($return));
        } else {
            $response->setContent($view->getContent());
        }
 
        $response->sendHeaders();
 
        echo $response->getContent();
    }
 
 
    public function isAdminPanel($di)
    {
        $url = $di->get('router')->getRewriteUri();
        $adminPanel = (strpos($url, '/admin') !== false) ? true : false;
        return $adminPanel;
    }
 
}
#5ITD\Bootstrap->run()
/var/www/peopleread/data/www/peopleread.net/index.php (14)
<?php
chdir(dirname(__DIR__));
error_reporting(E_ERROR);
 
//base define var
define('ROOT', __DIR__);
define('HOST_HASH', substr(md5($_SERVER['HTTP_HOST']), 0, 12));
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
defined('BASE_HOST') || define('BASE_HOST', (getenv('BASE_HOST') ? getenv('BASE_HOST') : 'peopleread.net'));
define('APPLICATION_PATH', __DIR__ . '/app');
 
require_once APPLICATION_PATH . '/Bootstrap.php';
$bootstrap = new ITD\Bootstrap();
$bootstrap->run();
KeyValue
_url/post/1204875-spacex-launches-15th-mission-of-the-year-on-previously-flown-rocket-booster
KeyValue
USERpeopleread
HOME/var/www/peopleread/data
HTTP_CF_CONNECTING_IP54.221.136.62
HTTP_IF_MODIFIED_SINCEThu, 19 Oct 2017 19:48:54 GMT
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENTCCBot/2.0 (http://commoncrawl.org/faq/)
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_RAY3cc5fdcfddf62432-IAD
HTTP_X_FORWARDED_FOR54.221.136.62
HTTP_CF_IPCOUNTRYUS
HTTP_ACCEPT_ENCODINGgzip
HTTP_CONNECTIONKeep-Alive
HTTP_HOSTzw.peopleread.net
SCRIPT_FILENAME/var/www/peopleread/data/www/peopleread.net/index.php
REDIRECT_STATUS200
SERVER_NAMEpeopleread.net
SERVER_PORT443
SERVER_ADDR95.85.49.154
REMOTE_PORT17039
REMOTE_ADDR172.69.62.146
SERVER_SOFTWAREnginx/1.12.1
GATEWAY_INTERFACECGI/1.1
HTTPSon
REQUEST_SCHEMEhttps
SERVER_PROTOCOLHTTP/1.1
DOCUMENT_ROOT/var/www/peopleread/data/www/peopleread.net
DOCUMENT_URI/index.php
REQUEST_URI/post/1204875-spacex-launches-15th-mission-of-the-year-on-previously-flown-rocket-booster
SCRIPT_NAME/index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHODGET
QUERY_STRING_url=/post/1204875-spacex-launches-15th-mission-of-the-year-on-previously-flown-rocket-booster&
PHP_ADMIN_VALUEsendmail_path = /usr/sbin/sendmail -t -i -f [email protected]
FCGI_ROLERESPONDER
PHP_SELF/index.php
REQUEST_TIME_FLOAT1513137364.4964
REQUEST_TIME1513137364
#Path
0/var/www/peopleread/data/www/peopleread.net/index.php
1/var/www/peopleread/data/www/peopleread.net/app/Bootstrap.php
2/var/www/peopleread/data/www/peopleread.net/app/vendor/misc.php
3/var/www/peopleread/data/www/peopleread.net/app/modules/Cms/Config.php
4/var/www/peopleread/data/www/peopleread.net/app/config/development/application.php
5/var/www/peopleread/data/www/peopleread.net/app/config/global.php
6/var/www/peopleread/data/www/peopleread.net/app/config/modules.php
7/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Loader/Modules.php
8/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Widget/Proxy.php
9/var/www/peopleread/data/www/peopleread.net/app/modules/Cms/Model/Configuration.php
10/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Mvc/View/Engine/Volt.php
11/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Acl/DefaultAcl.php
12/var/www/peopleread/data/www/peopleread.net/app/modules/Admin/Model/GroupUser.php
13/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Breadcrumbs/Breadcrumbs.php
14/var/www/peopleread/data/www/peopleread.net/app/modules/FileManager/FM.php
15/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Mvc/Helper.php
16/var/www/peopleread/data/www/peopleread.net/app/modules/Menu/Helper/Menu.php
17/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Assets/Manager.php
18/var/www/peopleread/data/www/peopleread.net/app/modules/Cms/Main.php
19/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Mvc/Router/DefaultRouter.php
20/var/www/peopleread/data/www/peopleread.net/app/modules/Cms/Routes.php
21/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Mvc/Helper/CmsCache.php
22/var/www/peopleread/data/www/peopleread.net/app/modules/Cms/Init.php
23/var/www/peopleread/data/www/peopleread.net/app/modules/Admin/Routes.php
24/var/www/peopleread/data/www/peopleread.net/app/modules/Catalog/Routes.php
25/var/www/peopleread/data/www/peopleread.net/app/modules/Catalog/Init.php
26/var/www/peopleread/data/www/peopleread.net/app/modules/FileManager/Routes.php
27/var/www/peopleread/data/www/peopleread.net/app/modules/Files/Routes.php
28/var/www/peopleread/data/www/peopleread.net/app/modules/Index/Routes.php
29/var/www/peopleread/data/www/peopleread.net/app/modules/News/Routes.php
30/var/www/peopleread/data/www/peopleread.net/app/modules/News/Init.php
31/var/www/peopleread/data/www/peopleread.net/app/modules/Page/Routes.php
32/var/www/peopleread/data/www/peopleread.net/app/modules/Page/Init.php
33/var/www/peopleread/data/www/peopleread.net/app/modules/Publication/Routes.php
34/var/www/peopleread/data/www/peopleread.net/app/modules/Publication/Model/Type.php
35/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Mvc/Model/Model.php
36/var/www/peopleread/data/www/peopleread.net/app/modules/Seo/Routes.php
37/var/www/peopleread/data/www/peopleread.net/app/modules/Seo/Init.php
38/var/www/peopleread/data/www/peopleread.net/app/modules/Widget/Routes.php
39/var/www/peopleread/data/www/peopleread.net/app/modules/News/Repository/Country.php
40/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Mvc/Repository/Main.php
41/var/www/peopleread/data/www/peopleread.net/app/modules/News/Model/CountryTranslate.php
42/var/www/peopleread/data/www/peopleread.net/app/modules/News/Model/Country.php
43/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Utils/ModuleName.php
44/var/www/peopleread/data/www/peopleread.net/app/modules/News/Module.php
45/var/www/peopleread/data/www/peopleread.net/app/plugins/CheckPoint.php
46/var/www/peopleread/data/www/peopleread.net/app/plugins/Localization.php
47/var/www/peopleread/data/www/peopleread.net/app/modules/Cms/Model/Translate.php
48/var/www/peopleread/data/www/peopleread.net/app/plugins/AdminLocalization.php
49/var/www/peopleread/data/www/peopleread.net/app/translations/admin/ru.php
50/var/www/peopleread/data/www/peopleread.net/app/plugins/Acl.php
51/var/www/peopleread/data/www/peopleread.net/app/plugins/MobileDetect.php
52/var/www/peopleread/data/www/peopleread.net/app/vendor/Mobile_Detect.php
53/var/www/peopleread/data/www/peopleread.net/app/modules/Cms/Repository/Localization.php
54/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Localization/Database.php
55/var/www/peopleread/data/www/peopleread.net/app/modules/News/Controller/IndexController.php
56/var/www/peopleread/data/www/peopleread.net/app/modules/Application/Mvc/Controller.php
57/var/www/peopleread/data/www/peopleread.net/app/modules/News/Model/Post.php
Memory
Usage2097152