Phalcon Framework 3.4.2

RedisException: php_network_getaddresses: getaddrinfo failed: Name or service not known

/data/home/coam/WebEsp/Web/Applications/Common/di-services-base.php (278)
#0Redis->connect(redis.docker.donal.com, 6379, 0)
#1Phalcon\Cache\Backend\Redis->_connect()
#2Phalcon\Cache\Backend\Redis->get(c0f08cdf983f9fa648ace450b1, 60000)
#3Phalcon\Session\Adapter\Redis->read(c0f08cdf983f9fa648ace450b1)
#4session_start()
#5Phalcon\Session\Adapter->start()
/data/home/coam/WebEsp/Web/Applications/Common/di-services-base.php (278)
<?php
 
//$di = new \Phalcon\DI\FactoryDefault();
 
// * Register the global configuration as config
$di->set('config', $config);
 
$di->set('filter', function () {
    $filter = new \Phalcon\Filter();
 
    //用户名过滤
    /*$filter->add('uname',new UnameFilter());
 
    //密码过滤
    $filter->add('pwd',new PwdFilter());
 
    //MD5过滤
    $filter->add('md5',new md5Filter());*/
 
    // 使用匿名函数
//    $filter->add(
//        "md5",
//        function ($value) {
//            return preg_replace("/[^0-9a-f]/", "", $value);
//        }
//    );
 
    return $filter;
});
 
// * Loading routes from the routes.php file
$di->setShared('loader', function () use ($config, $loader) {
    //return require_once COMMON_WEB_APP_DIR . '/common/loader.php';
 
    return $loader;
});
 
//视图控制
//$di->set('view', function () use ($config, $di) {
//    $view = new \Phalcon\Mvc\View();
//    $view->setViewsDir($config->application->viewsDir);
//    $view->registerEngines(array(
//        ".volt" => 'volt'
//    ));
//
//    lg_debug("Start IN View..d..................................................");
//
//    //重新定义 Volt 全局引用变量
//    $view->setVar("AccessHostServer", AccessHostServer);
//    $view->setVar("HostServer", HostServer);
//    $view->setVar("MainServer", MainServer);
//    $view->setVar("MirrorSpace", MirrorSpace);
//    $view->setVar("WebCloudSpace", WebCloudSpace);
//
//    //Create an events manager
//    //$eventsManager = new \Phalcon\Events\Manager();
//
//    //Attach a listener for type "view"
////    $eventsManager->attach("view", function($event, $view) {
////        $LogViewInfo =  $event->getType() . ' ---- ' . $view->getActiveRenderPath() . PHP_EOL;
////        lg_debug($LogViewInfo);
////    });
//    //lg_debug($di->get("request")->isAjax());
//
//    $eventsManager = $di->getShared("eventsManager");
//
//    //监听视图渲染事件,其它事件{beforeRenderView}一次请求可能会触发多次
//    $eventsManager->attach('view:beforeRender', function ($event, $view) use ($di) {
//        lg_debug("Process view:beforeRender.....................................................");
//
//        //设定搜索引擎不抓取指定域名的内容,防止分散权重
//        $metaRobots = "all";
//        //设定 meta 让搜索引擎不怕取测试页面
//        if (in_array(HostServer, ['lonal.com', 'coopens.com', 'nocs.cn'])) {
//            $metaRobots = "noindex,nofollow";
//        }
//        $view->setVar("MetaRobots", $metaRobots);
//        ////////////////////////////////////////////////////////////////////////////////////////////
//
//        //lg_debug("TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT: beforeRender");
//        //lg_debug($view->getParamsToView()); // 'test_value' here OK
//        //$ViewRenderLevel = $view->getRenderLevel();
//
//        #1# LEVEL_MAIN_LAYOUT
//        #2# LEVEL_AFTER_TEMPLATE
//        #3# LEVEL_LAYOUT
//        #4# LEVEL_BEFORE_TEMPLATE
//        #5# LEVEL_ACTION_VIEW
//        #6# LEVEL_NO_RENDER
//        #7# CACHE_MODE_NONE
//        #8# CACHE_MODE_INVERSE
//
////        lg_debug("getRenderLevel:");
////        lg_debug($ViewRenderLevel);
////        lg_debug("EEEE");
//        //获取加载文件配置 -- 按需加载 {在配置文件里}
//        //if($ViewRenderLevel == 5){
////            $ProjectMinifyConfig = BASE_DIR . '/public/MinifyGroupsConfig.php';
////            if (file_exists($ProjectMinifyConfig)){
////                $LoadInfo = (require_once $ProjectMinifyConfig);
////                $view->setVar("LoadInfo", $LoadInfo);
////            }
//        //}
//
//        //判断是否已开启SESSION -- 这里实测已开启SessionInfo
//        //从缓存获取浏览器信息 -- 由于每次请求,获取的浏览器信息都是一样的,然而获取浏览器接口特别耗用CPU性能,所以这里特别开启浏览器检测缓存
//        // getShared 和 get 都返回当前已被实例化的 setShared ("session",function(){}) 实例,避免重复初始化 造成 {ini_set(): A session is active} 错误
//        $browserRenderInfo = $di->getShared("session")->get('browserRenderInfo');
//        if (!$browserRenderInfo) {
//            //$BrowserInfo = @get_browser(null, true);
//            //使用 https://github.com/browscap/browscap-php 代替 php.ini 提升速度
//            $BrowserInfo = $di->get("browsCap")->getBrowser();
//
//            //输出数组变量到视图
//            $browserRenderInfo = \ManagerTools::browserRenderInfo($BrowserInfo);
//
//            //lg_debug('IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII..');
//            //lg_debug($browserRenderInfo);
//            $di->getShared("session")->set('browserRenderInfo', $browserRenderInfo);
//        }
//
//        //向Browns Version 传值
//        //if ($di->get("request")->isAjax() !== true) {
//        $view->setVar("browserRenderInfo", $browserRenderInfo);
//        //}
//    });
//
//    //Bind the eventsManager to the view component
//    $view->setEventsManager($eventsManager);
//
//    return $view;
//});
 
////设定邮件显示View
//$di->set('mailView', function () use ($config) {
//    $view = new \Phalcon\Mvc\View();
//    $view->setViewsDir(WEB_APP_DIR . "/Multiple/mail/views");
//    $view->registerEngines(array(
//        ".volt" => 'volt'
//    ));
//
//    return $view;
//});
//
///* 使用一个独立的view来为CLI生成网页--不能直接使用上面的view */
//$di->set('sMailView', function () use ($config) {
//    $view = new \Phalcon\Mvc\View\Simple();
//    $view->setViewsDir(WEB_APP_DIR . '/Multiple/mail/views/');
//    /* 这个步骤非常重要,否则在一个di中将无法正常的生成多个网页模板 */
//    $view->registerEngines(array(
//        '.volt' => function ($view, $di) use ($config) {
//            $volt = new  \Phalcon\Mvc\View\Engine\Volt($view, $di);
//            return $volt;
//        }
//    ));
//
//    return $view;
//});
 
// * View cache
$di->set('viewCache', function () {
 
    //Cache data for one day by default
    $frontCache = new \Phalcon\Cache\Frontend\Output(array(
        "lifetime" => 2592000
    ));
 
    return new \Phalcon\Cache\Backend\Apc($frontCache, array(
        "prefix" => "cache-"
    ));
 
    //memcacheDBd connection settings
//    return new \Phalcon\Cache\Backend\File($frontCache, array(
//        "cacheDir" => BASE_DIR . "/cache/views/",
//        "prefix" => "cache-"
//    ));
});
 
// * Setting up volt
$di->set('volt', function ($view, $di) {
    //require_once APP_DIR.'/ComClass/LiveVolt.php';
    //$volt = (new LiveVolt())->getCompiler();
    $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
 
    $volt->setOptions(array(
        "compiledPath" => COMMON_WEB_BASE_DIR . "/cache/volt/",
        "compileAlways" => true
    ));
    return $volt;
}, true);
 
 
// * 事务数据回滚
//事务需要共享才能在多个脚本模块里维持一致性,这里可以设置为 setShare,然后在其它地方使用get获取到的TM都是表示一个对象;这里也可以使用set,像本例,如果需要保持一致性,在其他需要使用的地方使用getShare方法获取即可
//参考 https://docs.phalconphp.com/zh/latest/reference/di.html#shared-services
$di->set('transactionManager', function () use ($di) {
 
    // [What connection would Model::find() use in a transaction?](https://forum.phalconphp.com/discussion/10077/what-connection-would-modelfind-use-in-a-transaction)
    $txm = new \Phalcon\Mvc\Model\Transaction\Manager();
 
//    $txm->setDbService($this->db->getWriteConnectionService());
//    $txm->setDbService($di->getShared('dbWrite'));
 
    return $txm;
});
 
// collectionManager
$di->set('collectionManager', function () {
    return new \Phalcon\Mvc\Collection\Manager();
}, true);
 
 
// * 日志
$di->set('logger', function () {
    return new \Phalcon\Logger\Adapter\File(COMMON_WEB_BASE_DIR . "/logs/logger.log");
});
 
$di->set('modelsManager', function () use ($di) {
    $modelsManager = new \Phalcon\Mvc\Model\Manager();
    return $modelsManager;
});
 
// * If the configuration specify the use of metadata adapter use it or use memory otherwise
$di->set('modelsMetadata', function () use ($config) {
    if (isset($config->models->metadata)) {
        $metaDataConfig = $config->models->metadata;
        $metadataAdapter = '\Phalcon\Mvc\Model\Metadata\\' . $metaDataConfig->adapter;
        return new $metadataAdapter();
    }
    return new \Phalcon\Mvc\Model\Metadata\Memory();
});
 
$di->setShared('session', function () use ($config) {
//    ini_set('session.cookie_domain', '.' . HostServer);
    //ini_set('session.cookie_domain', '.coam.co');
    // 跨子域 Session
    // [Session service to be valid accross all subdomains](https://forum.phalconphp.com/discussion/64/session-service-to-be-valid-accross-all-subdomains)
    session_set_cookie_params(0, '/', '.' . HostServer);
 
    //设置浏览器Cookie存储安全
//        ini_set( "session.use_trans_sid", 0 );//禁用浏览器url设定phpsessionid
//        ini_set( "session.use_only_cookies", 1 );
//        ini_set( "session.use_cookies", 1 );
 
    $session = new \Phalcon\Session\Adapter\Redis(array(
        //'uniqueId' => 'my-private-app',
//        'host' => $config->server->host,
        'host' => $config->redis_session->host,
        'port' => $config->redis_session->port,
        'index' => $config->redis_session->db_index,//选择的数据库 从 0 ~ 15 ,默认为 0
        'auth' => $config->redis_session->password,//验证相关
        'persistent' => false,//是否持久连接,默认false
        'lifetime' => $config->redis_session->lifetime,
        //'statsKey' => 'SSS',//默认前缀
        'prefix' => $config->redis_session->prefix //加区分层结构
        //'prefix' => 'my_'
    ));
 
    //lg_debug('Set Session.................................');
 
    //判断是否是七牛的回调
    $UserAgent = null;
    if (isset($_SERVER["HTTP_USER_AGENT"])) $UserAgent = $_SERVER["HTTP_USER_AGENT"];
    //允许Get请求,不允许Post请求 isset($_POST['demo']) &&
    if (strpos($UserAgent, "qiniu-callback") !== false || true) {
 
        if (isset($_POST["sessionId"])) {
            $sessionId = $_POST["sessionId"];
            $session->setId($sessionId);
        }
//        $session->start();
 
//        lg_debug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU-QQQ...".$sessionId);
//        exit;
    }
 
    if (!$session->isStarted()) {
        $session->start();
        //lg_debug('Set Start Session...');
    }
 
//    $session->set('var', 'some-value');
//    echo $session->get('var');
 
    return $session;
});
 
 
// Isolating the session data
//$di->setShared(
//    "session",
//    function () {
//        // All variables created will prefixed with "my-app-1"
//        $session = new \Phalcon\Session\Adapter\Files(
//            [
//                "uniqueId" => "my-app-1",
//            ]
//        );
//
//        $session->start();
//
//        return $session;
//    }
//);
 
//使用setShared共享服务,避免在脚本其它地方重复初始化 --> 在 $di->set('view', function(){}) 会有问题
//参考 https://docs.phalconphp.com/zh/latest/reference/di.html#shared-services
//$di->set("session", function() use ($config){
//        ini_set('session.cookie_domain', '.'.HostServer);
//        //设置浏览器Cookie存储安全
////        ini_set( "session.use_trans_sid", 0 );//禁用浏览器url设定phpsessionid
////        ini_set( "session.use_only_cookies", 1 );
////        ini_set( "session.use_cookies", 1 );
//        $session = new \Phalcon\Session\Adapter\Redis(array(
//            //'path' => "tcp://127.0.0.1:6379?weight=1",
//            'host' => "43.241.222.110",//应该设置host,否则跨服务器会提示连接 127.0.0.1 失败
//            //'path' => "tcp://43.241.222.110:6379?weight=1",
//            //'cookie_domain' => '.'.HostServer  //'your.cookie.domain',
//        ));
//
//    //lg_debug('Set Session.................................');
//
//        if (!$session->isStarted()) {
//            $session->start();
//            //lg_debug('Set Start Session...');
//        }
//        return $session;
//    }
//);
 
 
//$di->set('cookies', function () {
//    //session_set_cookie_params(1800 , '/', '.lonal.com');
//    //ini_set('session.cookie_domain', '.lonal.com');
//    $cookies = new \Phalcon\Http\Response\Cookies();
//    $cookies->useEncryption(false);
//    return $cookies;
//});
 
 
$di->set("crypt", function () {
    $crypt = new \Phalcon\Crypt();
    $crypt->setKey('#1dj8$=dp?.ak//j1V$'); // 使用你自己的key!
 
    return $crypt;
});
 
$di->set("cookies", function () {
 
    session_set_cookie_params(1800, '/', '.' . HostServer);
//        ini_set('session.cookie_domain', '.dytlh.com');
 
    $cookies = new \Phalcon\Http\Response\Cookies();
    $cookies->useEncryption(true);
 
    return $cookies;
});
 
// * Register the flash service with custom CSS classes
$di->set('flash', function () {
    return new \Phalcon\Flash\Direct(array(
        'error' => 'alert alert-danger',
        'success' => 'alert alert-success',
        'notice' => 'alert alert-info',
        'warning' => 'alert alert-warning',
    ));
});
 
// Assign our new tag a definition so we can call it
$di->set('myTags', function () {
    return new \Phalcon\Tag();
});
 
// * Register a user component
$di->set('elements', function () {
    return new Elements();
});
 
 
 
 
 
 
 
 
#6Closure->{closure}()
#7Phalcon\Di\Service->resolve(null, Object(Phalcon\Di\FactoryDefault))
#8Phalcon\Di->get(session, null)
#9Phalcon\Di->getShared(session)
#10Phalcon\Di\Injectable->__get(session)
/data/home/coam/WebEsp/Web/Applications/Library/DiSecurityBase.php (698)
<?php
 
namespace Esp\App\Library;
 
use Esp\App\Collections;
use Esp\App\Library;
use Esp\App\Models;
use Esp\App\Library\Zz_Api;
use \Phalcon\Events\Event,
    \Phalcon\Mvc\User\Plugin,
    \Phalcon\Mvc\Dispatcher,
    \Phalcon\Acl;
 
/**
 * Security
 * This is the security plugin which controls that users only have access to the modules they're assigned to
 */
class DiSecurityBase extends Plugin
{
    // 请求的接口
    public $requestPathInterface;
    public $module;
    public $controller;
    public $action;
 
    // 角色列表 - 当前登录用户账户角色
    public $role_tag_list;
    public $roles;
    public $role;
 
    // 账户等级列表 - 当前登录用户账户等级
    public $level_tag_list;
    public $levels;
    public $level;
 
    // 通用资源权限配置 ...
    protected $cMcaRoleResources;
    protected $cMcaLevelResources;
    protected $aclAllowed;
    protected $roleAcl;
    protected $roleAclAllowed;
    protected $levelAcl;
    protected $levelAclAllowed;
 
    // token 验证相关...
    public $requestMethod = null;
    public $requestToken = null;
 
    // 其它配置变量
    protected $cross_dos = []; // 配置访问可跨的根域 ...
 
    public function __construct($dependencyInjector)
    {
        $this->_dependencyInjector = $dependencyInjector;
 
        // 设定角色列表 ["*" =>AEFMHOTICG]
        //$this->role_tag_list = ["Administrator" => "A", "Executive" => "E", "Financial" => "F", "Market" => "M", "HumanResource" => "H", "Operation" => "O", "Technical" => "T", "Information" => "I", "Supplier" => "S", "Manager" => "M", "Customer" => "C", "Guests" => "G"];
        $this->role_tag_list = ["Administrator" => "A", "Customer" => "C", "Driver" => "D", "Logistics" => "L", "Park" => "P", "Enterprise" => "E", "Supplier" => "S", "Guests" => "G"];
        $this->roles = array(
            // 超级管理员-[A] (Administrator)
            'administrator' => new \Phalcon\Acl\Role('Administrator'),
            // 其它一般权限-[C]
            'customer' => new \Phalcon\Acl\Role('Customer'),
            // 供应商权限-[L]
            'driver' => new \Phalcon\Acl\Role('Driver'),
            // 供应商权限-[L]
            'logistics' => new \Phalcon\Acl\Role('Logistics'),
            // 供应商权限-[L]
            'park' => new \Phalcon\Acl\Role('Park'),
            // 企业权限-[E]
            'enterprise' => new \Phalcon\Acl\Role('Enterprise'),
            // 供应商权限-[S]
            'supplier' => new \Phalcon\Acl\Role('Supplier'),
            // 访客-[G]
            'guests' => new \Phalcon\Acl\Role('Guests')
        );
 
        // 设定角色列表 ["*" =>AEFMHOTIX]
        $this->level_tag_list = ["Administrator" => "A", "Executive" => "E", "Financial" => "F", "Market" => "M", "Hon" => "H", "Operation" => "O", "Technical" => "T", "Information" => "I", "Supplier" => "S", "Xal" => "X"];
        $this->levels = array(
            // 超级管理员-[A] (Administrator)
            'administrator' => new \Phalcon\Acl\Role('Administrator'),
            // 总经办-[E] CEO(Chief Executive Officer)
            #'executive' => new \Phalcon\Acl\Role('Executive'),
            // 财务部-[F] CFO(Chief Financial Officer)
            'financial' => new \Phalcon\Acl\Role('Financial'),
            // 市场部-[M] CMO (Chief Marketing Officer)
            'market' => new \Phalcon\Acl\Role('Market'),
            // 首席人事官-[H] (Chief Hong Officer)
            'hon' => new \Phalcon\Acl\Role('Hon'),
            // 首席人事官-[H] (Chief HumanResource Officer)
            #'humanResource' => new \Phalcon\Acl\Role('HumanResource'),
            // 运营部-[O] COO(Chief Operation Officer)
            #'operation' => new \Phalcon\Acl\Role('Operation'),
            // 技术部-[T] CTO(Chief Technology Officer)
            #'technical' => new \Phalcon\Acl\Role('Technical'),
            // 首席信息官-[I] CIO(Chief Information Officer)
            #'information' => new \Phalcon\Acl\Role('Information'),
            // 客户微店账户-[S]
            'supplier' => new \Phalcon\Acl\Role('Supplier'),
            // 空账户-[X]
            'xal' => new \Phalcon\Acl\Role('Xal')
        );
    }
 
    public function loadRoleAcl()
    {
        //if (!isset($this->persistent->roleAcl)) {
        $roleAcl = new \Phalcon\Acl\Adapter\Memory();
        $roleAcl->setDefaultAction(\Phalcon\Acl::DENY);
 
        //Register roles
        foreach ($this->roles as $role) {
            $roleAcl->addRole($role);
        }
 
        // Grant acess to private area to role Users
        foreach ($this->cMcaRoleResources as $controller => $actions) {
 
            // 批量加入 actions,包括 action 通配符 *
            $roleAcl->addResource(new \Phalcon\Acl\Resource($controller), array_keys($actions));
 
            foreach ($actions as $action => $actionALC) {
 
                //Grant access to public areas to both users and guests
                foreach ($this->roles as $role) {
 
                    $role_name = $role->getName();
                    # $role_tag = substr( $role_name, 0, 1 ); // 获取 角色 首字符 tag
                    $role_tag = $this->role_tag_list[$role_name]; // 获取 角色 首字符 tag
                    if ($actionALC === "*" || strpos($actionALC, $role_tag) !== false) {
                        // action 包括通配符 *
                        $roleAcl->allow($role_name, $controller, $action);
 
                        #lg_debug("|DiSecurityBase|getRoleAcl|#[$ role: $role_name][$ controller: $controller][$ action: $action]");
                    }
                }
 
            }
        }
 
        //The acl is stored in session, APC would be useful here too
        $this->persistent->roleAcl = $roleAcl;
        //}
 
        //return $this->persistent->roleAcl;
    }
 
    public function loadLevelAcl()
    {
        //if (!isset($this->persistent->levelAcl)) {
        $levelAcl = new \Phalcon\Acl\Adapter\Memory();
        $levelAcl->setDefaultAction(\Phalcon\Acl::DENY);
 
        //Register roles
        foreach ($this->levels as $level) {
            $levelAcl->addRole($level);
        }
 
        // Grant acess to private area to role Users
        foreach ($this->cMcaLevelResources as $controller => $actions) {
 
            // 批量加入 actions,包括 action 通配符 *
            $levelAcl->addResource(new \Phalcon\Acl\Resource($controller), array_keys($actions));
 
            foreach ($actions as $action => $actionALC) {
 
                //Grant access to public areas to both users and guests
                foreach ($this->levels as $level) {
 
                    $level_name = $level->getName();
                    # $level_tag = substr( $level_name, 0, 1 ); // 获取 等级 首字符 tag
                    $level_tag = $this->level_tag_list[$level_name]; // 获取 等级 首字符 tag
                    if ($actionALC === "*" || strpos($actionALC, $level_tag) !== false) {
                        // action 包括通配符 *
                        $levelAcl->allow($level_name, $controller, $action);
 
                        #lg_debug("|DiSecurityBase|getLevelAcl|#[$ level: $level_name][$ controller: $controller][$ action: $action]");
                    }
                }
 
            }
        }
 
        //The acl is stored in session, APC would be useful here too
        $this->persistent->levelAcl = $levelAcl;
        //}
 
        //return $this->persistent->levelAcl;
    }
 
    // 在[跨域/不跨域]请求时,Nginx不自动返回非 200 错误跨域响应头,在此手动返回跨域响应头...
    public function responseStatusCorsHeader($status_code, $status_tag, $status_steps = "_")
    {
        if (!in_array($status_code, [401, 423, 429, 444])) Zz_Api::io(40005, "Sorry, unsupported response cors error [$ status_tag: $status_tag]....");
        if (!in_array($status_tag, ["Unauthorized", "Locked", "TooManyRequests", "UnverifiedError"])) Zz_Api::io(40005, "Sorry, unsupported response cors error [$ status_tag: $status_tag]...");
 
        // 跨域需要手动发送 跨域请求头,否则会清除 Nginx 设定的 跨域请求头导致 ajax 获取不到
        if (isset($_SERVER['HTTP_ORIGIN']) && in_array(RootServer, $this->cross_dos)) {
            $http_origin = $_SERVER['HTTP_ORIGIN'];
            header("Access-Control-Allow-Origin: $http_origin");
            header('Access-Control-Allow-Credentials:true');
            header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
            header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept');
        }
 
        $this->response->setStatusCode($status_code, $status_tag);
        $this->response->send();
 
        // 记录授权错误日志 ...
        #lg_debug("|#|responseStatusCorsHeader()|[$ status_code: $status_code][$ status_tag: $status_tag][$ status_steps: $status_steps]");
 
        return true;
    }
 
    // 接口访问频率限制...
    public function accessRequestInterface()
    {
        //第一层,访问IP次数限制
        $diSecurityControl = new DiSecurityControl();
        $mca = $this->requestPathInterface;
        $sc_code = $diSecurityControl->iMcaSecurityControl($mca);
        // 关闭 429 验证错误...
        //if ($sc_code != 200) return Zz_Api::fo((40000 + $sc_code), "-", ["sc" => $sc_code, "st" => "Locked", "ss" => "_"]);
 
        return Zz_Api::fo(20000, "");
    }
 
    public function authRequestInterface()
    {
        // load and start session
        $this->_dependencyInjector->get("session");
 
        // Post接口[Token]授权验证 ...
        if ($this->request->isPost()) {
 
            //对所有 Post 开启校验模式
            if (in_array($this->module, $this->atModuleList) && !in_array($this->requestPathInterface, $this->unTokenRequestPathList)) {
                lg_debug("Token SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSStarter...");
//                Zz_Api::io(44333, "|#@ acInfo:[acChannel: {$this->acChannel}][acType: {$this->acType}][acWay: {$this->acWay}][acAs: {$this->acAs}][acAsId: {$this->acAsId}][acAsLevel: {$this->acAsLevel}]", $this->disAccountInfo);
 
//                lg_debug("|atModuleList:");
//                lg_debug($this->atModuleList);
//
//                lg_debug("|requestPathInterface:");
//                lg_debug($this->requestPathInterface);
//
//                lg_debug("|unTokenRequestPathList:");
//                lg_debug($this->unTokenRequestPathList);
 
                // 依次取 Token [Header->Post->Get] 并检查 token 是否有效
                //$requestTokenHeader = $this->request->getHeader("HTTP_REQUEST_ACCESS_TOKEN");
                $this->requestMethod = "None";// 初始化
                if (!empty($_GET["token"])) $this->requestToken = $_GET["token"];
                if (!empty($_POST["token"])) $this->requestToken = $_POST["token"];
                $requestHeaderToken = $this->request->getHeader("HTTP_AUTHORIZATION");
                if (!empty($requestHeaderToken)) {
                    $requestTokenInfo = explode(" ", $requestHeaderToken);
                    $this->requestMethod = $requestTokenInfo[0];
                    if (!empty($requestTokenInfo[1])) $this->requestToken = $requestTokenInfo[1];
 
                    lg_debug("Header Token Info:...");
                    lg_debug($requestHeaderToken);
                }
 
                // 必要条件[requestToken]
                if (empty($this->requestToken)) return Zz_Api::fo(40401, "-", ["sc" => 401, "st" => "Unauthorized", "ss" => "_"]);
 
                lg_debug("Request Method Token Info:...");
                lg_debug($this->requestMethod);
                lg_debug($this->requestToken);
 
                // TOKEN Redis Cache...
                $ari_data = null;
                $c_token_rl_tag = "TOKEN:{$this->requestMethod}:{$this->requestToken}";
                //$this->redisDB->delete($c_token_rl_tag);
                if (!$this->redisDB->exists($c_token_rl_tag)) {
 
                    // 如果没有缓存配置,则创建判断权限,检索缓存...
                    $ariInfo = $this->authRequestInterfaceToken();
 
//                    // 强制返回 401 测试...
//                    $this->response->setStatusCode(401, "UnAuthorization");
//                    //Send response to the client
//                    $this->response->send();
//                    return Zz_Api::fo(40401, "-", ["sc" => 401, "st" => "Unauthorized", "ss" => "_"]);
 
                    //lg_debug("ariInfo:");
                    //lg_debug($ariInfo);
 
                    $fo_info = $ariInfo->fo_info;
                    $ari_data = $ariInfo->fo_data;
                    if (!$fo_info->result) return Zz_Api::fo(40401, "-", ["sc" => $ari_data->sc, "st" => $ari_data->st, "ss" => $ari_data->ss]);
 
                    // 设定缓存失效时间...
                    $exp = $ari_data->exp;
                    $_exp = $exp - time();
                    if ($_exp > 10) { // 仅缓存大于 10s 的有效token,排除掉 tmp token
                        $this->redisDB->set($c_token_rl_tag, json_encode($ari_data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
                        $this->redisDB->setTimeout($c_token_rl_tag, $_exp);
                    }
                } else {
                    // token 缓存未失效...
                    $ari_data = $this->redisDB->get($c_token_rl_tag);
                    $ari_data = json_decode($ari_data);
                }
 
                // 获取并设置[Token]认证结果
                $this->actType = $ari_data->actType;
                $this->actWay = $ari_data->actWay;
                // 返回 token 验证的 asId asLevel 账户信息...
                $this->actAs = $ari_data->actAs;
                $this->actAsTag = $ari_data->actAsTag;
                $this->actAsId = $ari_data->actAsId;
                $this->actAsLevel = $ari_data->actAsLevel;
 
                lg_debug("Token EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEnder...");
            }
        }
 
        // [Get+Post]接口[Session]授权验证 ...
        //if ($this->request->isPost()) $this->acType = "post";
        //if ($this->request->isGet()) $this->acType = "get";
 
        return Zz_Api::fo(20000, "-");
    }
 
    // 设置并加载访问账户角色等级...
    public function loadAclRls()
    {
        // 设置默认接口认证信息 ...
        $this->acChannel = "none";
        $this->acWay = "none";
        $this->acType = "none";
        $this->acAs = "G";
        $this->acAsTag = "GX";
        $this->acAsId = "G-0";
        $this->acAsLevel = "X";
        if ($this->actType) {
            // 优先使用 Token 认证信息
            $this->acChannel = "token";
            $this->acWay = $this->actWay;
            $this->acType = $this->actType;
            $this->acAs = $this->actAs;
            $this->acAsTag = $this->actAsTag;
            $this->acAsId = $this->actAsId;
            $this->acAsLevel = $this->actAsLevel;
        } else if ($this->disAccountInfo) {
            // 在 get 请求或没有 token 认证的 [unTokenRequestPathList]post 请求尝试使用 session 认证...
            $this->acChannel = "session";
            $this->acWay = $this->acsWay;
            $this->acType = $this->acsType;
            $this->acAs = $this->acsAs;
            $this->acAsTag = $this->acsAsTag;
            $this->acAsId = $this->acsAsId;
            $this->acAsLevel = $this->acsAsLevel;
        }
        //\Zz_Api::io(44333, "|#@ acInfo:[acChannel: {$this->acChannel}][acType: {$this->acType}][acWay: {$this->acWay}][acAs: {$this->acAs}][acAsId: {$this->acAsId}][acAsLevel: {$this->acAsLevel}]", $this->disAccountInfo);
 
        // 如果是 token 验证的单点登录,则尝试重建 sAccountInfo 会话信息...
        if ($this->actType == "verify" && (!isset($this->disAccountInfo["asId"]) || ($this->disAccountInfo["asId"] !== $this->acAsId))) {
            lg_info("[888][$ acAsId: {$this->acAsId}]");
            $this->session->set("sAccountInfo", ["asId" => $this->acAsId, "aInfoLevel" => $this->acAsLevel]);
            (new CommonAccountInfo())->refreshCommonAccountLoginSession($this->acAsId);
        }
 
        // 默认未登陆用户类型 Guests
        $acAs = $this->acAs;
        $acAsId = $this->acAsId;
        $acAsLevel = $this->acAsLevel;
 
        // 用户账户等级
        //$this->role = 'Guests';
        //$this->level = 'X';
 
        lg_info("[acAs: $acAs][$ acAsId: $acAsId][$ actType: {$this->actType}][$ acType: {$this->acType}][$ acChannel: {$this->acChannel}]");
        lg_info("$ sAccountInfo:");
        $sAccountInfo = $this->session->get('sAccountInfo');
        lg_info($sAccountInfo);
 
        // 如果有账号归属关系 - 包括 Guests 账号类型
        if (!in_array($acAs, $this->role_tag_list)) Zz_Api::io(44044, "unknown role [$ acAs: $acAs]...");
        $role_tag_flip_list = array_flip($this->role_tag_list); // 取数组反转结果
        $this->role = $role_tag_flip_list[$acAs];
 
        // 如果有等级归属关系 - 包括 Xal 账号等级
        if (!in_array($acAsLevel, $this->level_tag_list)) Zz_Api::io(44044, "unknown level [$ acAsLevel: {$acAsLevel}]...");
        $level_tag_flip_list = array_flip($this->level_tag_list); // 取数组反转结果
        $this->level = $level_tag_flip_list[$acAsLevel];
    }
 
    // 判断是否有接口权限...
    public function mcaAclAllowed($module, $controller, $action)
    {
        // 必须先知道当前用户角色等级...
        if (!isset($this->role) || !isset($this->level)) Zz_Api::io(44044, "|mcaAclAllowed(role,level)...");
 
        $aclAllowed = null;
        // ACL Redis Cache...
        $c_acl_rl_tag = "ACL:{$this->acAs}:{$this->acAsLevel}:{$module}:{$controller}:{$action}";
        //$this->redisDB->delete($c_acl_rl_tag);
        //Zz_Api::io(44332, "=", ["aclAllowed" => $this->redisDB->get($c_acl_rl_tag), "role" => $this->role, "level" => $this->level, "c_acl_rl_tag" => $c_acl_rl_tag]);
        //lg_debug($c_acl_rl_tag);
        if (!$this->redisDB->exists($c_acl_rl_tag)) {
            // 如果没有缓存配置,则创建判断权限,检索缓存...
 
            // role
            if (!isset($this->persistent->roleAcl)) $this->loadRoleAcl();
            $roleAclAllowed = $this->persistent->roleAcl->isAllowed($this->role, $controller, $action);
 
            // level
            if (!isset($this->persistent->levelAcl)) $this->loadLevelAcl();
            $levelAclAllowed = $this->persistent->levelAcl->isAllowed($this->level, $controller, $action);
 
            $aclAllowed = ($roleAclAllowed && $levelAclAllowed);
 
            //lg_debug("@[Role: {$this->role}][Level: {$this->level}][module: {$this->module}][controller: {$controller}][action: {$action}][aclAllowed: {$aclAllowed}][roleAclAllowed: {$roleAclAllowed}][levelAclAllowed: {$levelAclAllowed}]");
//            Zz_Api::io(40008, "[acl]", [
//                "c_acl_rl_tag" => $c_acl_rl_tag,
//                "role" => $this->role,
//                "level" => $this->level,
//                "controller" => $controller,
//                "action" => $action,
//                "aclAllowed" => $aclAllowed,
//                "roleAclAllowed" => $roleAclAllowed,
//                "levelAclAllowed" => $levelAclAllowed
//            ]);
 
            // 缓存一天
            $this->redisDB->set($c_acl_rl_tag, $aclAllowed);
            $this->redisDB->setTimeout($c_acl_rl_tag, 86400);
        } else {
            $aclAllowed = $this->redisDB->get($c_acl_rl_tag);
            //lg_debug("@[Role: {$this->role}][Level: {$this->level}][module: {$this->module}][controller: {$controller}][action: {$action}][aclAllowed: {$aclAllowed}]");
        }
 
        return $aclAllowed;
    }
 
    // 通用接口授权访问校验方法 ...
    public function authRequestInterfaceToken()
    {
//        $eaToken = $this->openSsl->createTokenInfo("tmp");
//        $this->response->setHeader("Authorization", "Bearer $eaToken");
//        $this->session->set("token", $eaToken);
 
        // 判断认证方式
        switch ($this->requestMethod) {
            case "Basic":
                $requestInfo = base64_decode($this->requestToken);
                lg_debug("requestInfo:");
                lg_debug($requestInfo);
                $requestInfo = explode(":", $requestInfo);
                lg_debug($requestInfo);
                $auth_name = $requestInfo[0];
                $auth_pass = $requestInfo[1];
 
                // 逐次检查登陆...
                $commonAccountInfo = (new Library\CommonAccountInfo())->inspectAccountInfoSerial(array("accountName" => $auth_name, "password" => md5($auth_pass)), "AND");
                if (!$commonAccountInfo) $commonAccountInfo = (new Library\CommonAccountInfo())->inspectAccountInfoSerial(array("aInfoPhone" => $auth_name, "password" => md5($auth_pass)), "AND");
                if (!$commonAccountInfo) $commonAccountInfo = (new Library\CommonAccountInfo())->inspectAccountInfoSerial(array("aInfoEmail" => $auth_name, "password" => md5($auth_pass)), "AND");
 
                // 如果检索登录失败则返回 401
                if (!$commonAccountInfo) return Zz_Api::fo(40401, "-", ["sc" => 401, "st" => "Unauthorized", "ss" => "Basic"]);
 
                // 强制刷新登录验证带用户信息的长效 [verify:token] ...
                $asId = $commonAccountInfo->asId;
                $asLevel = $commonAccountInfo->aInfoLevel;
                $eaToken = (new OpenSsl(null))->createTokenInfo("verify", $asId, $asLevel);
                // 存储 token 认证信息...
                $this->session->set("at_type", "verify");
                $this->session->set("at_way", "Bearer");
                $this->session->set("access_token", $eaToken->fo_data->token);
                // 向客户端返回最新的 [verify:token] ...
                $this->response->setHeader("Authorization", "Bearer {$eaToken->fo_data->token}");
                $this->response->sendHeaders();
 
                // 设置 token 校验类型...
                $exp = time() + 60 * 10;// 设置 Basic Token 有效期为 10 min 内...
                $as = explode("-", $asId)[0];
                $asTag = $as . $asLevel;
                return Zz_Api::fo(20000, "-", ["actType" => "verify", "actWay" => "Basic", "actAs" => $as, "actAsTag" => $asTag, "actAsId" => $asId, "actAsLevel" => $asLevel, "exp" => $exp]);
                break;
            case "Bearer":
                $deTokenInfo = $this->openSsl->deTokenInfo($this->requestToken);
                lg_debug("deTokenInfo:");
                lg_debug($deTokenInfo);
                $deToken = null;
                if ($deTokenInfo->fo_info->result) $deToken = $deTokenInfo->fo_data->deToken;
                lg_debug("deToken:");
                lg_debug($deToken);
 
                lg_debug("#Token Checker:...");
                if (!($deToken instanceof \stdClass)) lg_debug("|#|[$ deToken: $deToken]...");
                if (!$deToken || in_array($deToken, ["token-blacklisted", "token-expired", "token-exception"]))
                    return Zz_Api::fo(40401, "-", ["sc" => 401, "st" => "Unauthorized", "ss" => "Bearer|A"]);
 
                // 获取 Token 基本验证信息
                $iss = $deToken->iss;
                $asId = $sub = $deToken->sub;
                $aud = $deToken->aud;
                $iat = $deToken->iat;
                $exp = $deToken->exp;
                $jti = $deToken->jti;
                $info = $deToken->info;
                $token_type = $info->atType;
                $sid = $info->sId;
                $as = $info->as;
                $aiId = $info->aiId;
                $asLevel = $info->asLevel;
                $scope = $info->scope;
 
                // 匹配客户端 ...
                if ($sid != session_id()) return Zz_Api::fo(40401, "-", ["sc" => 401, "st" => "Unauthorized", "ss" => "Bearer|S|[$ sid: $sid|$ session_id:" . session_id() . "]"]);
 
                switch ($token_type) {
                    # 测试验证 token
                    case "test":
                        // TODO...
                        break;
                    # 一次性 token
                    case "tmp":
                        // TODO...
                        break;
                    # 30天/一次性有效 token
                    case "ovt":
                        // 加入过期黑名单...
                        $df_exp = $exp - time();
                        (new OpenSsl(null))->destroyTokenInfo($jti, $this->requestToken, $df_exp);
                        break;
                    # 已登录验证长效 token
                    case "verify":
                        // 强制续签接近过期的 Token
                        $diff_exp = $exp - time();
                        $lrt_dn = OpenSsl::$token_type_dnst[$token_type]["lrt_dn"];
                        if ($diff_exp < $lrt_dn) {
                            // 强制刷新登录验证带用户信息的长效 [verify:token] ...
                            $eaToken = (new OpenSsl(null))->refreshTokenInfo($this->requestToken);
                            // 如果续签了有效的 token ,则通过 header 发送到客户端...
                            if ($eaToken->fo_info->result) {
                                // 存储 token 认证信息...
                                $this->session->set("at_type", "verify");
                                $this->session->set("at_way", "Bearer");
                                $this->session->set("access_token", $eaToken->fo_data->token);
                                // 向客户端返回最新的 [verify:token] ...
                                $this->response->setHeader("Authorization", "Bearer {$eaToken->fo_data->token}");
                                $this->response->sendHeaders();
 
                                lg_debug("|#|authRequestInterfaceToken()|Bearer|AutoRenew|...");
                                // 过期时间续签到2小时后...
                                //$exp = time() + 60 * 60 * 2;
                            }
                        }
                        break;
                    default:
                        // TODO...
                        Zz_Api::io(40044, "Bearer Token: [$ token_type: $token_type] Error...");
                        break;
                }
 
                // 设置 token 校验类型...
                $as = explode("-", $asId)[0];
                $asTag = $as . $asLevel;
                return Zz_Api::fo(20000, "-", ["actType" => $token_type, "actWay" => "Bearer", "actAs" => $as, "actAsTag" => $asTag, "actAsId" => $asId, "actAsLevel" => $asLevel, "exp" => $exp]);
                break;
            case "QBox":
                // [鉴权类](https://developer.qiniu.com/kodo/sdk/php)
                //获取回调的body信息
                $callbackBody = file_get_contents('php://input');
                //回调的contentType
                $contentType = 'application/x-www-form-urlencoded';
                //回调的签名信息,可以验证该回调是否来自七牛
                $authorization = $_SERVER['HTTP_AUTHORIZATION'];
                //七牛回调的url,具体可以参考
                $callback_url = 'https://ap.coam.co/cloud/uploadAInfoPicture';
                $callbackUrl = $this->config->cs->callback_url . $this->action;
                // 可能有 Token 验证成功后-上传接口授权失败重定向后验证返回(401)的问题[需要开放重定向后的错误接口Token验证(Eg:/admin/common/error)]...
                $isQiniuCallback = $this->cloudStorage->cloudAuth->verifyCallback($contentType, $authorization, $callbackUrl, $callbackBody);
                // 如果七牛七牛鉴权失败则返回 401
                if (!$isQiniuCallback) return Zz_Api::fo(40401, "-", ["sc" => 401, "st" => "Unauthorized", "ss" => "QBox|_|"]);
 
                // 刷新最新用户登录信息
                $asId = null;
                $asLevel = null;
                //$sAccountInfo = $this->session->get("sAccountInfo");
                if (isset($this->disAccountInfo["asId"])) $asId = $this->disAccountInfo["asId"];
                if (isset($this->disAccountInfo["aInfoLevel"])) $asLevel = $this->disAccountInfo["aInfoLevel"];
 
                // 默认用户等级...
                $asId = "G-0";
                $asLevel = "X";
 
                // 加载 session 用户登录信息...
                $slsAi = $_POST["sessionId"];
                $slsAiTag = '_PHCR:' . $slsAi;
                lg_info("[$ _slsAiTag: $slsAiTag]");
                $upAccountSessions = $this->redisDB->get($slsAiTag);
 
                //如果存在需要更新的会话信息
                if ($upAccountSessions) {
                    //临时解压到当前用户的全局变量 $_SESSION 中
                    $_SESSION = [];//清除当前用户的 $_SESSION 防止污染转换信息
                    session_decode($upAccountSessions);
 
                    //lg_info("[$ _SESSION: ]");
                    //lg_info($_SESSION);
 
                    //$sAccountInfo = $this->session->get("sAccountInfo");
                    $sAccountInfo = $_SESSION["sAccountInfo"];
                    lg_info("[$ _sAccountInfo: ....]");
                    lg_info($sAccountInfo);
                    // 如果存在本地登录信息...
                    if ($sAccountInfo) {
                        if (isset($sAccountInfo["asId"])) $asId = $sAccountInfo["asId"];
                        if (isset($sAccountInfo["aInfoLevel"])) $asLevel = $sAccountInfo["aInfoLevel"];
                    }
 
                    //$this->redisDB->set($slsAiTag, session_encode());
                    $_SESSION = [];//清空 $_SESSION 保存的信息
                }
 
 
                // 设置 token 校验类型...
                $as = explode("-", $asId)[0];
                $asTag = $as . $asLevel;
                return Zz_Api::fo(20000, "-", ["actType" => "verify", "actWay" => "QBox", "actAs" => $as, "actAsTag" => $asTag, "actAsId" => $asId, "actAsLevel" => $asLevel, "exp" => 0]);
                break;
            default:
                return Zz_Api::fo(40444, "[$ requestMethod: {$this->requestMethod}]", ["sc" => 444, "st" => "UnverifiedError", "ss" => "_"]);
                break;
        }
 
        //return Zz_Api::fo(40444, "-", ["sc" => 444, "st" => "UnverifiedError", "ss" => "_"]);
    }
 
    // 通用接口授权访问校验方法 ...
    public function authRequestInterfaceSession()
    {
        // $this->disAccountInfo 可内部重写重定向,防止覆盖...
        if ($this->disAccountInfo) {
            // 获取并设置[Session]认证结果
            $this->acsWay = "login";
            $this->acsType = "verify";
            $asId = $this->disAccountInfo["asId"];
            $aInfoLevel = $this->disAccountInfo["aInfoLevel"];
            $as = explode("-", $asId)[0];
            $this->acsAs = $as;
            $this->acsAsTag = $as . $aInfoLevel;
            $this->acsAsId = $asId;
            $this->acsAsLevel = $aInfoLevel;
        }
    }
 
    // 设定全局登录账户认证会话信息...
    public $disAccountInfo = null;
 
    // 配置授权接口(获取token信息,可依据token认证信息完成acl接口权限认证) ...
    public $atModuleList = [];
    public $unTokenRequestPathList = [];
    public $onTokenRequestPathList = [];
    # 接口访问权限授权认证方式 ...
    public $acChannel = null; // [none|token|session]
    public $acWay = null; // [none|login|Basic|Bearer|QBox]
    public $acType = null; // [none|login|test|tmp|verify|ovt]
    public $acAs = null; // [C]
    public $acAsTag = null; // [as+level][CM]
    public $acAsId = null; // [C-*]
    public $acAsLevel = null; // [A]
    # token 认证信息 - [Post]
    public $actWay = null; // [Basic|Bearer|QBox]
    public $actType = null; // [Basic:(verify) || Bearer:(test|tmp|verify|ovt) || QBox:(verify)]
    public $actAs = null; // [C]
    public $actAsTag = null; // [CM]
    public $actAsId = null; // [C-*]
    public $actAsLevel = null; // [A]
    # session 认证信息 - [Get|Post]
    public $acsWay = null; // [none|login]
    public $acsType = null; // [none|verify]
    public $acsAs = null; // [C]
    public $acsAsTag = null; // [CM]
    public $acsAsId = null; // [C-*]
    public $acsAsLevel = null; // [A]
 
    // [Phalcon Framework的Mvc结构及启动流程(部分源码分析)- MVC事件](http://avnpc.com/pages/phalcon-mvc-process)
    //[I] dispatch:beforeDispatchLoop 分发循环开始前
    //[II] dispatch:beforeDispatch 单次分发开始前
    //[III] dispatch:beforeExecuteRoute Action执行前
    //[IV] dispatch:afterExecuteRoute Action执行后
    //[V] dispatch:beforeNotFoundAction 找不到Action
    //[VI] dispatch:beforeException 抛出异常前
    //[VII] dispatch:afterDispatch 单次分发结束
    //[VIII] dispatch:afterDispatchLoop 分发循环结束
 
    //[I] dispatch:beforeDispatchLoop 分发循环开始前
    public function beforeDispatchLoop(Event $event, Dispatcher $dispatcher)
    {
        lg_info("D[dispatch]:beforeDispatchLoop...");
        $sAccountInfo = $this->session->get('sAccountInfo');
        if ($sAccountInfo) $this->disAccountInfo = $sAccountInfo;
    }
 
    //[II] dispatch:beforeDispatch 单次分发开始前
    public function beforeDispatch(Event $event, Dispatcher $dispatcher)
    {
        lg_info("D[dispatch]:beforeDispatch...");
 
//        Zz_Api::io(42222, "-{$this->module}-{$this->controller}-{$this->action}-{$this->requestPathInterface}-");
 
        return true;
    }
 
    //[III] dispatch:beforeExecuteRoute Action执行前
    public function beforeExecuteRoute(Event $event, Dispatcher $dispatcher)
    {
        lg_info("D[dispatch]:beforeExecuteRoute...");
    }
 
    //[IV] dispatch:afterExecuteRoute Action执行后
    public function afterExecuteRoute(Event $event, Dispatcher $dispatcher)
    {
        lg_info("D[dispatch]:afterExecuteRoute...");
 
        //输出 Json 格式数据,防止 Content-Type:text/html; charset=UTF-8 后 Chrome 难调试
        // https://forum.phalconphp.com/discussion/2038/get-rendered-view-contents-and-transform-it-into-a-json-object-o
        if ($this->request->isPost()) {
//            header('Content-Type: application/json');
            //$this->response->setHeader('Content-type', 'application/json');
            $this->response->setContentType('application/json', 'UTF-8');
            //$this->response->setContentType('Content-type', 'application/json');
        }
 
        // [afterExecuteRoute does not get called in Micro app](https://forum.phalconphp.com/discussion/1429/afterexecuteroute-does-not-get-called-in-micro-app)
//        $this->response->setContentType('application/json', 'UTF-8');
//
//        $data = $dispatcher->getReturnedValue();
//
//        if (is_array($data))
//        {
//            $this->response->setJsonContent($data);
//        } else {
//            $this->response->setStateCode(500, "Internal Server Error~~~~~~~~~~ zhangyafei ~~~");
//            $this->response->setJsonContent(array("status" => "ERROR"));
//        }
//
//        $this->response->send();
    }
 
//    //[V] dispatch:beforeNotFoundAction 找不到 Action
//    public function beforeNotFoundAction(Event $event, Dispatcher $dispatcher)
//    {
//        lg_info("D[dispatch]:beforeNotFoundAction...");
//    }
//
//    //[VI] dispatch:beforeException 抛出异常前
//    public function beforeException(Event $event, Dispatcher $dispatcher, $exception)
//    {
//        lg_info("D[dispatch]:beforeException...");
////        //处理404异常
////        if ($exception instanceof DispatchException) {
////            $dispatcher->forward(array(
////                'controller' => 'index',
////                'action' => 'errorPage'
////            ));
////            return false;
////        }
////
////        //代替控制器或者动作不存在时的路径
////        if ($event->getType() == 'beforeException') {
////            switch ($exception->getCode()) {
////                case \Phalcon\Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
////                case \Phalcon\Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
////                    $dispatcher->forward(array(
////                        'controller' => 'index',
////                        'action' => 'Error404'
////                    ));
////                    return false;
////            }
////        }
////
////        //处理其他异常
////        $dispatcher->forward(array(
////            'controller' => 'index',
////            'action' => 'Error503'
////        ));
////
////        return false;
//    }
//
//    //[VII] dispatch:afterDispatch 单次分发结束
//    public function afterDispatch(Event $event, Dispatcher $dispatcher)
//    {
//        lg_info("D[dispatch]:afterDispatch...");
//    }
//
//    //[VIII] dispatch:afterDispatchLoop 分发循环结束
//    public function afterDispatchLoop(Event $event, Dispatcher $dispatcher)
//    {
//        lg_info("D[dispatch]:afterDispatchLoop...");
//    }
}
#11Esp\App\Library\DiSecurityBase->beforeDispatchLoop(Object(Phalcon\Events\Event), Object(Phalcon\Mvc\Dispatcher), null)
#12Phalcon\Events\Manager->fireQueue(Array([0] => Object(DiSecurity)), Object(Phalcon\Events\Event))
#13Phalcon\Events\Manager->fire(dispatch:beforeDispatchLoop, Object(Phalcon\Mvc\Dispatcher))
#14Phalcon\Dispatcher->dispatch()
#15Phalcon\Mvc\Application->handle()
/data/home/coam/WebEsp/Web/public/index.php (172)
<?php
 
# 获取定义用户 web 根目录 [/data/home/coam]
//define('HOME_DIR', dirname(__DIR__) . "/../../../..");
define('HOME_DIR', "/data/home/coam");
 
// 切换开发测试环境
define('ENV', 'dev');
 
// 开启 xhprof 性能分析...
define('DEBUG_ENV', false);
 
if (!defined('ENV')) {
    error_log('Error: The application ENV constant is not set.');
    exit(1);
}
 
// 开发测试环境配置
define('DEV_ENV', 'dev');
define('TEST_ENV', 'test');
define('UPGRADE_ENV', 'upgrade');
define('DIST_ENV', 'dist');
define('DEV_ING', ENV === DEV_ENV);
define('TEST_ING', ENV === TEST_ENV);
define('UPGRADE_ING', ENV === UPGRADE_ENV);
define('DIST_ING', ENV === DIST_ENV);
 
/*
 * Environment setup
 * Different environments will require different levels of error reporting.
*/
switch (ENV) {
    case DEV_ENV:
        // 关闭支付测试环境...
        // define('DEV_PAY_ENV', false);
        if (isset($_POST["sign"]))
            define('DEV_PAY_ENV', false);
        else
            // 是否开启开发支付测试环境
            define('DEV_PAY_ENV', false);
 
        error_reporting(E_ALL);
        ini_set("display_errors", 1);
        (new \Phalcon\Debug)->listen();
        break;
    case TEST_ENV:
        // 关闭支付测试环境...
        // define('DEV_PAY_ENV', false);
        if (isset($_POST["sign"]))
            define('DEV_PAY_ENV', false);
        else
            // 是否开启开发支付测试环境
            define('DEV_PAY_ENV', false);
 
        //ini_set("display_errors", 0);
        //ini_set("log_errors", 1);
        //error_reporting(E_ALL);
        break;
    case UPGRADE_ENV:
        // 开启支付测试环境...
        define('DEV_PAY_ENV', false);
 
        //ini_set("display_errors", 0);
        //ini_set("log_errors", 1);
        //error_reporting(E_ALL);
        break;
    case DIST_ENV:
        // 开启支付测试环境...
        define('DEV_PAY_ENV', false);
 
        //ini_set("display_errors", 0);
        //ini_set("log_errors", 1);
        //error_reporting(E_ALL);
        break;
    default:
        error_log('Error: The application ENV constant is not set correctly.');
        exit(1);
}
 
// 开启 xhprof 性能分析...
if (DEBUG_ENV) xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
 
try {
 
    # 获取当前网站的根目录
    if (!defined('WEB_BASE_DIR')) define('WEB_BASE_DIR', dirname(__DIR__));
    if (!defined('WEB_APP_DIR')) define('WEB_APP_DIR', dirname(__DIR__) . '/Applications');
 
    // 加载主配置文件...
    include_once WEB_APP_DIR . '/Common/Config/config_common.php';
 
 
    // pay.coam.co
    //aliPay
    //require_once(APP_DIR."/plugins/Pay/ali/ali.config.php");
    //$aliPayConfig = include APP_DIR."/plugins/Pay/ali/ali.config.php";
    require_once(WEB_APP_DIR . "/Plugins/Pay/aliPay/lib/alipay_submit.class.php");
    require_once(WEB_APP_DIR . "/Plugins/Pay/aliPay/lib/alipay_notify.class.php");
 
//    //tenPay
//    require_once(WEB_APP_DIR . "/plugins/Pay/tenPay/InstantAccount/classes/RequestHandler.class.php");
//    //---------------------------------------------------------
//    //财付通即时到帐支付后台回调示例,商户按照此文档进行开发即可
//    //---------------------------------------------------------
//    require(WEB_APP_DIR . "/plugins/Pay/tenPay/InstantAccount/classes/ResponseHandler.class.php");
//    //require (COMMON_APP_DIR."/plugins/Pay/tenPay/InstantAccount/classes/RequestHandler.class.php");
//    require(WEB_APP_DIR . "/plugins/Pay/tenPay/InstantAccount/classes/client/ClientResponseHandler.class.php");
//    require(WEB_APP_DIR . "/plugins/Pay/tenPay/InstantAccount/classes/client/TenpayHttpClient.class.php");
 
 
    // *** Read auto-loader˜
    include_once WEB_APP_DIR . '/Common/loader.php';
 
    // *** Read auto-logger
    include_once WEB_APP_DIR . '/Common/logger.php';
 
    // 设置默认控制器工厂函数
    $di = new \Phalcon\DI\FactoryDefault();
 
    // *** setting di services
    include_once WEB_APP_DIR . '/Common/di-services-base.php';
    include_once WEB_APP_DIR . '/Common/di-services-common.php';
    include_once WEB_APP_DIR . '/Common/di-services-db.php';
    include_once WEB_APP_DIR . '/Common/di-services-web.php';
 
    //$application = new \Phalcon\Mvc\Application();
    //$application->setDI($di);
 
    $application = new \Phalcon\Mvc\Application($di);
    //Phalcon--debugbar第三方调试-打开500错误
 
//    $di['app'] = $application; //  Important
////    $di->set('app', $application);
//    (new Snowair\Debugbar\ServiceProvider())->start();
 
    // after start the debugbar, you can do noting but handle your app right now.
 
    // 注册模块
    $application->registerModules(
        [
            "web" => [
                "className" => "Esp\\App\\Multiple\\Web\\Module",
                "path" => WEB_APP_DIR . "/Multiple/Web/Module.php",
            ],
            "wpi" => [
                "className" => "Esp\\App\\Multiple\\Wpi\\Module",
                "path" => WEB_APP_DIR . "/Multiple/Wpi/Module.php",
            ],
            "api" => [
                "className" => "Esp\\App\\Multiple\\Api\\Module",
                "path" => WEB_APP_DIR . "/Multiple/Api/Module.php",
            ],
            "cli" => [
                "className" => "Esp\\App\\Multiple\\Cli\\Module",
                "path" => WEB_APP_DIR . "/Multiple/Cli/Module.php",
            ],
            "open" => [
                "className" => "Esp\\App\\Multiple\\Open\\Module",
                "path" => WEB_APP_DIR . "/Multiple/Open/Module.php",
            ],
            "pay" => [
                "className" => "Esp\\App\\Multiple\\Pay\\Module",
                "path" => WEB_APP_DIR . "/Multiple/Pay/Module.php",
            ],
            "mail" => [
                "className" => "Esp\\App\\Multiple\\Mail\\Module",
                "path" => WEB_APP_DIR . "/Multiple/Mail/Module.php",
            ],
        ]
    );
 
    echo $application->handle()->getContent();
 
} catch (\Phalcon\Exception $e) {
    echo $e->getMessage();
} catch (PDOException $e) {
    echo $e->getMessage();
}
 
# 是否开启 XhProf 调试日志 ...
if (DEBUG_ENV) Coam\App\Library\Zz_Api::endXhProfDebug();
KeyValue
_url/web/
KeyValue
USERwww-data
HOME/home/www-data
HTTP_CONTENT_LENGTH0
HTTP_X_B3_SAMPLED0
HTTP_X_B3_SPANID5fc700a2305c9011
HTTP_X_B3_TRACEID6e3b238f249abebe5fc700a2305c9011
HTTP_X_REQUEST_IDffce81c3-1ef9-4266-8bdb-5caed1daa652
HTTP_X_REAL_IP34.204.179.0
HTTP_X_FORWARDED_SERVERa.us.1
HTTP_X_FORWARDED_PROTOhttp
HTTP_X_FORWARDED_PORT80
HTTP_X_FORWARDED_HOSTossse.com
HTTP_X_FORWARDED_FOR34.204.179.0
HTTP_IF_MODIFIED_SINCETue, 16 Jul 2019 20:50:05 UTC
HTTP_ACCEPT_LANGUAGEen-US,en;q=0.5
HTTP_ACCEPT_ENCODINGgzip
HTTP_ACCEPTtext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
HTTP_USER_AGENTCCBot/2.0 (https://commoncrawl.org/faq/)
HTTP_HOSTossse.com
REDIRECT_STATUS200
SERVER_NAMEossse.com
SERVER_PORT8080
SERVER_ADDR127.0.0.1
REMOTE_PORT48458
REMOTE_ADDR127.0.0.1
SERVER_SOFTWAREnginx/1.16.0
GATEWAY_INTERFACECGI/1.1
REQUEST_SCHEMEhttp
SERVER_PROTOCOLHTTP/1.1
DOCUMENT_ROOT/data/home/coam/WebEsp/Web/public/
DOCUMENT_URI/index.php
REQUEST_URI/
SCRIPT_NAME/index.php
CONTENT_LENGTH0
CONTENT_TYPE
REQUEST_METHODGET
QUERY_STRING_url=/web/
SCRIPT_FILENAME/data/home/coam/WebEsp/Web/public//index.php
FCGI_ROLERESPONDER
PHP_SELF/index.php
REQUEST_TIME_FLOAT1566575994.5247
REQUEST_TIME1566575994
#Path
0/data/home/coam/WebEsp/Web/public/index.php
1/data/home/coam/WebEsp/Web/Applications/Common/Config/config_common.php
2/data/home/coam/WebEsp/Web/Applications/Plugins/Pay/aliPay/lib/alipay_submit.class.php
3/data/home/coam/WebEsp/Web/Applications/Plugins/Pay/aliPay/lib/alipay_core.function.php
4/data/home/coam/WebEsp/Web/Applications/Plugins/Pay/aliPay/lib/alipay_md5.function.php
5/data/home/coam/WebEsp/Web/Applications/Plugins/Pay/aliPay/lib/alipay_notify.class.php
6/data/home/coam/WebEsp/Web/Applications/Common/loader.php
7/data/home/coam/WebEsp/Web/vendor/autoload.php
8/data/home/coam/WebEsp/Web/vendor/composer/autoload_real.php
9/data/home/coam/WebEsp/Web/vendor/composer/ClassLoader.php
10/data/home/coam/WebEsp/Web/vendor/composer/autoload_static.php
11/data/home/coam/WebEsp/Web/vendor/ralouphie/getallheaders/src/getallheaders.php
12/data/home/coam/WebEsp/Web/vendor/guzzlehttp/psr7/src/functions_include.php
13/data/home/coam/WebEsp/Web/vendor/guzzlehttp/psr7/src/functions.php
14/data/home/coam/WebEsp/Web/vendor/clue/stream-filter/src/functions.php
15/data/home/coam/WebEsp/Web/vendor/php-http/message/src/filters.php
16/data/home/coam/WebEsp/Web/vendor/symfony/polyfill-ctype/bootstrap.php
17/data/home/coam/WebEsp/Web/vendor/symfony/polyfill-mbstring/bootstrap.php
18/data/home/coam/WebEsp/Web/vendor/symfony/polyfill-php70/bootstrap.php
19/data/home/coam/WebEsp/Web/vendor/guzzlehttp/promises/src/functions_include.php
20/data/home/coam/WebEsp/Web/vendor/guzzlehttp/promises/src/functions.php
21/data/home/coam/WebEsp/Web/vendor/guzzlehttp/guzzle/src/functions_include.php
22/data/home/coam/WebEsp/Web/vendor/guzzlehttp/guzzle/src/functions.php
23/data/home/coam/WebEsp/Web/vendor/khanamiryan/qrcode-detector-decoder/lib/Common/customFunctions.php
24/data/home/coam/WebEsp/Web/vendor/myclabs/deep-copy/src/DeepCopy/deep_copy.php
25/data/home/coam/WebEsp/Web/vendor/overtrue/wechat/src/Payment/helpers.php
26/data/home/coam/WebEsp/Web/vendor/qiniu/php-sdk/src/Qiniu/functions.php
27/data/home/coam/WebEsp/Web/vendor/qiniu/php-sdk/src/Qiniu/Config.php
28/data/home/coam/WebEsp/Web/vendor/tinify/tinify/lib/Tinify.php
29/data/home/coam/WebEsp/Web/vendor/tinify/tinify/lib/Tinify/Exception.php
30/data/home/coam/WebEsp/Web/vendor/xxtea/xxtea/xxtea.php
31/data/home/coam/WebEsp/Web/Applications/Plugins/CurlFuture/curl_future.php
32/data/home/coam/WebEsp/Web/Applications/Plugins/CurlFuture/inc/future.php
33/data/home/coam/WebEsp/Web/Applications/Plugins/CurlFuture/inc/http_future.php
34/data/home/coam/WebEsp/Web/Applications/Plugins/CurlFuture/inc/task.php
35/data/home/coam/WebEsp/Web/Applications/Plugins/CurlFuture/inc/task_manager.php
36/data/home/coam/WebEsp/Web/Applications/Common/logger.php
37/data/home/coam/WebEsp/Web/Applications/Common/di-services-base.php
38/data/home/coam/WebEsp/Web/Applications/Common/di-services-common.php
39/data/home/coam/WebEsp/Web/Applications/Common/di-services-db.php
40/data/home/coam/WebEsp/Web/Applications/Common/di-services-web.php
41/data/home/coam/WebEsp/Web/Applications/Common/routes.php
42/data/home/coam/WebEsp/Web/Applications/Multiple/Web/Module.php
43/data/home/coam/WebEsp/Web/Applications/Utils/ModuleBase.php
44/data/home/coam/WebEsp/Web/Applications/Utils/DiSecurity.php
45/data/home/coam/WebEsp/Web/Applications/Library/DiSecurityBase.php
46/data/home/coam/WebEsp/Web/vendor/mobiledetect/mobiledetectlib/Mobile_Detect.php
Memory
Usage2097152