Esempio n. 1
0
 /**
  * @param $config Core_Lib_Config
  * @return $this
  */
 public static function createApp($config)
 {
     if (self::$instance === null) {
         self::$instance = new self($config);
     }
     return self::$instance;
 }
Esempio n. 2
0
 public function before(&$action)
 {
     if (!static::groupsCanGoPath(Core_Lib_App::app()->getRequest()->getPath())) {
         Core_Lib_App::app()->getController()->setOuterAction($action, static::getNoPermissionAction());
     }
     return true;
 }
Esempio n. 3
0
 public function testlogAction()
 {
     Core_Lib_App::app()->getLogger()->critical('critical message');
     Core_Lib_App::app()->getLogger()->alert('alert message');
     Core_Lib_App::app()->getLogger()->debug('debug message');
     Core_Lib_App::app()->getLogger()->emergency('emergency message');
     Core_Lib_App::app()->getLogger()->error('error message');
     Core_Lib_App::app()->getLogger()->info('info message');
     Core_Lib_App::app()->getLogger()->notice('notice message');
     Core_Lib_App::app()->getLogger()->warning('warning message');
 }
Esempio n. 4
0
 public function before(&$action)
 {
     $req = Core_Lib_App::app()->getRequest();
     $res = Core_Lib_App::app()->getResponse();
     $origin = $req->getOrigin();
     if ($origin) {
         $res->setHeader('Access-Control-Allow-Origin', $origin);
     }
     if ('OPTIONS' == $req->getMethod()) {
         $acrh = $req->getAccessControlRequestHeaders();
         $res->setHeader('Access-Control-Allow-Headers', $acrh);
         $res->setHeader('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
         $res->setHeader('Access-Control-Max-Age', 86400);
         $res->setStatus(204);
         return false;
     }
     return true;
 }
Esempio n. 5
0
 public function __construct()
 {
     $path = Core_Lib_App::app()->getRequest()->getPath();
     if (isset($path[1])) {
         $slice = array_filter(explode('/', trim($path, '/')));
         if (sizeof($slice) > 0) {
             $this->controllerName = basename(PROJECT_PATH) . '_Controller_' . ucfirst(array_shift($slice));
         }
         if (sizeof($slice) > 0) {
             $this->actionName = array_shift($slice);
         }
         if (sizeof($slice) > 0) {
             $this->args = $slice;
         }
     }
     if (!is_callable([$this->controllerName, $this->actionName . 'Action'])) {
         $this->actionName = 'index';
         $this->controllerName = Core_Lib_App::app()->getConfig()->get('404Controller');
     }
 }
Esempio n. 6
0
 /**
  * @deprecated 0.3.0
  * @return Core_Lib_Conn
  * @throws Exception
  */
 protected static function getConn()
 {
     static $conn;
     if (null === $conn) {
         $conf = Core_Lib_App::app()->getConfig()->get('modelServers.' . get_called_class());
         if ($conf['sid'] > 0) {
             $ipport = Core_Helper_L5::getInstance()->route($conf['sid']);
             if (!empty($ipport) && $ipport[1] != '0') {
                 $conf['host'] = $ipport[0];
                 $conf['port'] = $ipport[1];
             }
         }
         $conn = new Core_Lib_MysqliConn($conf['host'], $conf['user'], $conf['psw'], $conf['dbname'], $conf['port'], null, $conf['tbname']);
         if ($conn->connect_errno != 0) {
             throw new Exception('model server connect error: ' . $conn->connect_error);
         }
         if (isset($conf['charset'])) {
             $conn->set_charset($conf['charset']);
         }
     }
     return $conn;
 }
Esempio n. 7
0
 public function __construct()
 {
     $this->localhostName = Core_Lib_App::App()->getConfig()->get('appId');
     $this->fp = fopen(static::filePath(), 'a');
 }
Esempio n. 8
0
 public function __construct()
 {
     $this->localhostName = Core_Lib_App::App()->getConfig()->get('appId');
     $this->udpHandle = Core_Helper_Net_Udp::getInstance('localhost', 514, 2);
 }
Esempio n. 9
0
<?php

/**
 * Created by PhpStorm.
 * User: mofan
 * Date: 2016/5/18 0018
 * Time: 17:24
 */
ini_set('display_errors', 'On');
define('PROJECT_PATH', strtr(dirname(__DIR__), '\\', '/'));
$loader = (require __DIR__ . '/../../Core/autoload.php');
$loader->add('Test_', dirname(PROJECT_PATH));
//Core_Helper_ClassCache::run(
//    PROJECT_PATH.'/Cache/ClassesCached',
//    function(){
Core_Lib_App::createApp(new Test_Config_Dev())->run();
//    }
//);
Esempio n. 10
0
 private function __construct()
 {
     $l5conf = Core_Lib_App::app()->getConfig()->get('UUIDServer');
     $this->tcp = new Core_Helper_Net_Tcp();
     $this->serverDown = !$this->tcp->connect($l5conf['host'], $l5conf['port']);
 }
Esempio n. 11
0
 /**
  * @return Core_Lib_Request
  */
 public function getRequest()
 {
     return Core_Lib_App::app()->getRequest();
 }