Exemple #1
0
 /**
  * 输出静态文件
  * @param boolean $forceExit 输出静态页面后,是否强制退出PHP程序.默认为true
  * @return boolean 当不需要缓存或者缓存过期时返回false,读取缓存成功后返回true
  */
 public static function cacheResponse($forceExit = true)
 {
     if (!HTML_CACHE_ON) {
         return false;
     }
     if (!isset(self::$requestParams)) {
         self::$requestParams = RequestUtil::getParams();
     }
     //暂不缓存搜索页
     if (RequestUtil::parseSearchFields()) {
         return false;
     }
     //此module action组是否需要缓存
     if (self::needCache(self::$requestParams->module, self::$requestParams->action)) {
         $cachedFileName = self::generateFilePathName();
         if (self::isCacheFileExpired($cachedFileName)) {
             //缓存过期则返回,继续执行其他程序
             return false;
         } else {
             //执行其它额外启动过程
             \Lib\Bootstrap::run();
             //获取静态缓存
             require $cachedFileName;
             if ($forceExit) {
                 die;
             } else {
                 return true;
             }
         }
     } else {
         return false;
     }
 }
Exemple #2
0
 public static function myErrorHandler($errno, $errstr, $errfile, $errline)
 {
     if (!(error_reporting() & $errno)) {
         // This error code is not included in error_reporting
         return;
     }
     switch ($errno) {
         case E_USER_ERROR:
             //				echo "<b>My ERROR</b> [$errno] $errstr<br />\n";
             //				echo "  Fatal error on line $errline in file $errfile";
             //				echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
             //				echo "Aborting...<br />\n";
             error_log("Fatal error: {$errstr} on line {$errline} in file {$errfile}");
             if (DEBUG_BAR) {
                 Bootstrap::getInstance()->debugbar['messages']->error("Fatal error: {$errstr} on line {$errline} in file {$errfile}");
             }
             include '../views/header.php';
             include '../views/error.php';
             include '../views/footer.php';
             exit(1);
             break;
         case E_USER_WARNING:
             if (DEBUG_BAR) {
                 Bootstrap::getInstance()->debugbar['messages']->warning("Warning: {$errstr} on line {$errline} in file {$errfile}");
             }
             break;
         case E_USER_NOTICE:
             if (DEBUG_BAR) {
                 Bootstrap::getInstance()->debugbar['messages']->notice("Notice: {$errstr} on line {$errline} in file {$errfile}");
             }
             break;
         case E_USER_DEPRECATED:
             if (DEBUG_BAR) {
                 Bootstrap::getInstance()->debugbar['messages']->warning("Depricated: {$errstr} on line {$errline} in file {$errfile}");
             }
             break;
         default:
             if (DEBUG_BAR) {
                 Bootstrap::getInstance()->debugbar['messages']->addMessage("Unknown Error: {$errstr} on line {$errline} in file {$errfile}");
             }
             break;
     }
     //return false;
     /* Don't execute PHP internal error handler */
     return true;
 }
Exemple #3
0
 /**
  * 启动应用
  */
 public function run()
 {
     self::$requestParams = RequestUtil::getParams();
     $moduleAction = 'Module\\' . self::$requestParams->module . '\\' . ucfirst(self::$requestParams->action);
     if (!class_exists($moduleAction, true)) {
         $msg = 'Milanoo module/action not found !' . $moduleAction . "\n" . 'Parsed request parameters:' . "\n" . var_export(self::$requestParams, true);
         if (DEBUG_MODE) {
             \Lib\common\Debug::setInfo('MethodNotFound', $msg);
             return;
         }
         error_log($msg);
         header('HTTP/1.1 404 Not found');
         require ROOT_PATH . 'errors/404.php';
         die;
     }
     header('content-type:text/html;charset=utf-8');
     //启动各模块之前运行各额外方法
     \Lib\Bootstrap::run();
     //执行个相应模块
     $module = new $moduleAction();
 }
 public function selectRow($sql, $cacheTime = false)
 {
     if ($cacheTime > 0) {
         $key = 'SQL:' . md5($sql);
         $result = $this->cache->get($key);
         if ($this->cache->wasResultFound()) {
             if (DEBUG_BAR) {
                 Bootstrap::getInstance()->debugbar['messages']->addMessage("Cached SQL: " . $sql);
             }
             return $result;
         }
     }
     try {
         $rows = $this->pdo->query($sql)->fetch(PDO::FETCH_ASSOC);
     } catch (\PDOException $e) {
         trigger_error($e->getMessage(), E_USER_ERROR);
     }
     if ($cacheTime > 0) {
         $this->cache->set($key, $rows, $cacheTime);
     }
     return $rows;
 }
if (DEBUG_BAR) {
    $debugbarRenderer = \lib\Bootstrap::getInstance()->debugbar->getJavascriptRenderer();
}
if (isset($this)) {
    $cacheTime = $this->getData('cacheTime', 0);
    if ($cacheTime > 0) {
        $ts = gmdate("D, d M Y H:i:s", time() + $cacheTime) . " GMT";
        header("Expires: {$ts}");
        header("Pragma: cache");
        header("Cache-Control: max-age={$cacheTime}");
    }
    $pageTitle = $this->getData('pageTitle', 'Paycoin Ledger');
    $pageName = $this->getData('pageName', 'Home');
    $pageDescription = $this->getData('pageName', $pageDescription);
    if (DEBUG_BAR) {
        $debugbarRenderer = \lib\Bootstrap::getInstance()->debugbar->getJavascriptRenderer();
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" CONTENT="<?php 
echo htmlspecialchars($pageDescription);
?>
">

	<title><?php 
//	<div class="my-template">
//	<div class="row">
//	<div class="col-md-3"></div>
//	<div class="col-md-6">
//		<a href="/"><img class="logo" src="/img/blockchainlogo1.png" border=""></a>
//	</div>
//
//	</div>
//	<div class="col-md-3"></div>
//	<div class="col-md-6" style="vertical-align: middle;   margin-top: 28px;">
//			<h1>Upgrading</h1>
//		</div>
//<div style="min-height: 500px"></div>
//
//	</div>
//	';
//	include('../views/footer.php');
//	exit;
//}
use lib\Bootstrap;
try {
    $app = Bootstrap::getInstance();
    $app->setConfig($config);
    $uri = false;
    if (empty($_SERVER['REQUEST_URI'])) {
        $uri = $argv[1];
    }
    $app->run($uri);
} catch (Exception $e) {
    \controllers\Home::myErrorHandler(E_USER_ERROR, "Uncaught exception 'Exception' with message '{$e->getMessage()}'", $e->getFile(), $e->getLine());
}
 public function getConfig($config, $default = false)
 {
     return $this->bootstrap->getConfig($config, $default);
 }
 public function routeNotFound()
 {
     if (DEBUG_BAR) {
         Bootstrap::getInstance()->debugbar['messages']->error("404: Page not found");
     }
     header('HTTP/1.0 404 Not Found');
     $controller = new Home($this);
     $controller->pageNotFound();
 }
 /**
  * @access public
  * @return void
  */
 public function run()
 {
     $bootstrap = new Bootstrap();
     $bootstrap->setCurrentController(DEFAULT_CONTROLLER);
     $bootstrap->setCurrentAction(DEFAULT_ACTION);
     $bootstrap->parseUrl();
     $route = $bootstrap->getRoute();
     if (!empty($this->routes[$route]['isOauthRequired']) && !Security::isUserLoggedIn()) {
         Helper::redirectTo(WEB . DEFAULT_ROUTE);
     } else {
         if (!empty($this->routes[$route]['controller'])) {
             $controller = $this->routes[$route]['controller'];
             $bootstrap->setController($controller);
         }
         $bootstrap->loadControllerFile();
         $bootstrap->initControllerClass();
         $bootstrap->runControllerAction($bootstrap->getAction(), $bootstrap->getParams());
     }
 }