/** * $guidtype 在构造时使用一次 * a 180组服务器,30几年后溢出,(每个请求需要一个进程处理至少1个毫秒,) * b 18组服务器, 300年后溢出, (每个请求需要一个进程处理至少1个毫秒,) * c 18组服务器, 30年后溢出, (每个请求需要一个进程处理至少0.1个毫秒,) * @param string $guidtype * @return \Sooh\Base\Log\Data */ public static function getInstance($guidtype = 'c') { if (self::$_instance == null) { self::$_instance = new Data(); $dt = \Sooh\Base\Time::getInstance(); self::$_instance->ymd = $dt->YmdFull; self::$_instance->hhiiss = $dt->his; self::$_instance->ip = \Sooh\Base\Tools::remoteIP(); self::$_instance->logGuid = self::$_instance->newLogId($guidtype); \Sooh\Base\Ini::registerShutdown(get_called_class() . '::onShutdown', 'logOnShutdown'); } return self::$_instance; }
/** * start session if session not init */ protected function start() { if ($this->sessionArr === null) { $this->timestamp = \Sooh\Base\Time::getInstance()->timestamp(); $tmp = $this->storage->load($this->sessionId); if (empty($tmp) || empty($tmp['trans'])) { $this->record = array('sessionId' => $this->sessionId); $this->sessionArr = array(); //error_log("[TRACE-session ".$_COOKIE['SoohSessId']." data] skip init"); } else { $this->record = $tmp['trans']; $this->sessionArr = $tmp['data']; if ($this->get('accountId')) { $secLast = $this->sessionArr['__dTaCcOuNt__'] - 0; $secPast = $this->timestamp - $secLast; if ($secPast > 300) { $this->sessionArr['__eXpIrE__']['accountId'] += min([$secPast, 900]); $this->sessionArr['__dTaCcOuNt__'] = $this->timestamp; $this->changed = true; //error_log("[TRACE-session ".$_COOKIE['SoohSessId']." data] update expire as secPast=$secPast"); } else { //error_log("[TRACE-session ".$_COOKIE['SoohSessId']." data] skip secPast=$secPast"); } } else { //error_log("[TRACE-session ".$_COOKIE['SoohSessId']." data] skip not login"); } } \Sooh\Base\Ini::registerShutdown(array($this, 'shutdown'), 'sessionOnShutdown'); } }
define("APP_PATH", dirname(__DIR__)); /* 指向public的上一级 */ if (!defined('SOOH_INDEX_FILE')) { define('SOOH_INDEX_FILE', 'index.php'); } define('SOOH_ROUTE_VAR', '__'); error_log("-------------------------------------------------------tart:route=" . $_GET['__'] . " cmd=" . $_GET['cmd'] . " pid=" . getmypid()); include dirname(__DIR__) . '/conf/globals.php'; $ini = \Sooh\Base\Ini::getInstance(); $app = new Yaf_Application(APP_PATH . "/conf/application.ini"); $dispatcher = $app->getDispatcher(); if (!empty($reqeustReal)) { $dispatcher->setRequest($reqeustReal); } $view = \SoohYaf\SoohPlugin::initYafBySooh($dispatcher); $dispatcher->returnResponse(TRUE); try { $response = $app->run(); } catch (\ErrorException $e) { $view->assign('code', $e->getCode()); $view->assign('msg', $e->getMessage()); error_log("Error Caught at index.php:" . $e->getMessage() . "\n" . \Sooh\DB\Broker::lastCmd() . "\n" . $e->getTraceAsString() . "\n"); $response = new Yaf_Response_Http(); $response->setBody($view->render('ctrl/action.phtml')); } if ($ini->viewRenderType() === 'json') { header('Content-type: application/json'); } $response->response(); \Sooh\Base\Ini::registerShutdown(null, null); error_log("====================================================================end:route=" . $_GET['__'] . " cmd=" . $_GET['cmd'] . " pid=" . getmypid());