123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- /**
- * Class DefaultController
- * @author Blackbinbin
- */
- class DefaultController extends BaseController {
- public function __construct() {
- parent::__construct(true);
- }
- /**
- * 判断ip,输出首页
- */
- public function actionIndex() {
- // if (ENV != ENV_DEV) {
- // header('Location: https://dice.eosget.io/#/box');
- // Response::exitMsg('');
- // } else {
- // // 清除无效的cookie
- // Account::checkToken();
- //
- // if (ENV != ENV_DEV) {
- // $GLOBALS['eosProtocol'] = "https";
- // $GLOBALS['eosHost'] = "api.eosbeijing.one";
- // $GLOBALS['eosPort'] = 443;
- // }
- $this->tpl->display('index');
- // }
- }
- /**
- * 判断ip,输出首页
- */
- public function actionMini() {
- $this->tpl->display('mini');
- }
- /**
- * 判断ip,输出首页
- */
- public function actionSw() {
- // 不需要默认头部信息
- $GLOBALS['FORBID_ORIGIN'] = true;
- $path = BASE_DIR . 'dist/sw.js';
- // 增加浏览器缓存
- $filemd5 = md5_file($path);
- $this->_addEtag($filemd5);
- $content = file_get_contents($path);
- header("Content-Type: application/javascript; charset=utf-8");
- Response::exitMsg($content, CODE_SUCCESS, null, true);
- }
- private function _addEtag($etag) {
- // always send headers
- header("Etag: $etag");
- // exit if not modified
- if (@trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
- header("HTTP/1.1 304 Not Modified");
- Response::exitMsg('', CODE_SUCCESS, '304 Not Modified');
- }
- }
- }
|