Beispiel #1
0
 /**
  * 静态方法, 单例统一访问入口
  * @return object  返回对象的唯一实例
  */
 public static function getInstance()
 {
     if (is_null(self::$_instance) || !isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #2
0
 public function MiniWeixin()
 {
     //如果系统尚未初始化,则直接跳转到安装页面
     $configPath = dirname(__FILE__) . '/protected/config/miniyun-config.php';
     if (!file_exists($configPath)) {
         echo "迷你云尚未安装";
         exit;
     }
     //加载系统信息
     $config = dirname(__FILE__) . '/protected/config/main.php';
     $yii = dirname(__FILE__) . '/yii/framework/yii.php';
     require_once $yii;
     $this->webApp = Yii::createWebApplication($config);
     MiniAppParam::getInstance()->load();
     MiniPlugin::getInstance()->load();
     $port = $_SERVER["SERVER_PORT"];
     if ($port == "443") {
         $this->staticServerHost = "https://" . STATIC_SERVER_HOST . "/";
     } else {
         $this->staticServerHost = "http://" . STATIC_SERVER_HOST . "/";
     }
 }
Beispiel #3
0
date_default_timezone_set("PRC");
defined('YII_DEBUG') or define('YII_DEBUG', false);
@ini_set('display_errors', '1');
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
// change the following paths if necessary
$config = dirname(__FILE__) . '/protected/config/main.php';
$yii = dirname(__FILE__) . '/yii/framework/yii.php';
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 8);
// 客户端请求
defined('CLIENT_REQUEST_API') or define('CLIENT_REQUEST_API', TRUE);
require_once $yii;
Yii::createWebApplication($config);
header('Access-Control-Allow-Origin: http://static.miniyun.cn');
header('Access-Control-Allow-Methods: POST');
header('Access-Control-Allow-Methods: GET');
MiniAppParam::getInstance()->load();
//初始化APP静态数据
MiniPlugin::getInstance()->load();
//加载插件
$routePath = MiniHttp::getParam("route", "");
if (empty($routePath)) {
    //老接口
    $meta = new MAPIController();
    //通过meta的控制器进行跳转处理逻辑
    $meta->invoke();
} else {
    //新接口
    $api = new APIController();
    $api->invoke();
}
Beispiel #4
0
 public function MiniBox()
 {
     $requestUri = Util::getRequestUri();
     $this->isMixCloudVersion = Util::isMixCloudVersion();
     //如果系统尚未初始化,则直接跳转到安装页面
     $configPath = dirname(__FILE__) . '/protected/config/miniyun-config.php';
     if (!file_exists($configPath) && !strpos($requestUri, "install")) {
         header('Location: ' . Util::getMiniHost() . "index.php/install/index");
         exit;
     }
     //加载系统信息
     $config = dirname(__FILE__) . '/protected/config/main.php';
     $yii = dirname(__FILE__) . '/yii/framework/yii.php';
     require_once $yii;
     $this->webApp = Yii::createWebApplication($config);
     MiniAppParam::getInstance()->load();
     MiniPlugin::getInstance()->load();
     //根据外部的参数判断是什么客户端
     $this->isWeb = !Util::isPCClient();
     //初始化cookie等信息
     $accessToken = Util::getParam("accessToken");
     if (!empty($accessToken)) {
         Yii::app()->session["accessToken"] = $accessToken;
         setcookie("accessToken", $accessToken, time() + 10 * 24 * 3600, "/");
     }
     $version = Util::getParam("cloudVersion");
     if (!empty($version)) {
         setcookie("cloudVersion", $version, time() + 10 * 24 * 3600, "/");
     }
     $appKey = Util::getParam("appKey");
     if (!empty($appKey)) {
         setcookie("appKey", $appKey, time() + 10 * 24 * 3600, "/");
     }
     $appSecret = Util::getParam("appSecret");
     if (!empty($appSecret)) {
         setcookie("appSecret", $appSecret, time() + 10 * 24 * 3600, "/");
     }
     //根据物理路径判断网页客户端本地是否存在
     $this->offline = $this->isOffline();
     if ($this->isMixCloudVersion) {
         $port = $_SERVER["SERVER_PORT"];
         if ($port == "443") {
             $this->staticServerHost = "https://" . STATIC_SERVER_HOST . "/";
         } else {
             $this->staticServerHost = "http://" . STATIC_SERVER_HOST . "/";
         }
     } else {
         //私有云模式下
         $this->staticServerHost = "http://" . $_SERVER["HTTP_HOST"] . "/statics/";
     }
     //解析形如/index.php/site/login?backUrl=/index.php/box/index这样的字符串
     //提取出controller与action
     $uriInfo = explode("/", $requestUri);
     if (count($uriInfo) === 1) {
         //用户输入的是根路径
         $url = Util::getMiniHost() . "index.php/box/index";
         $this->redirectUrl($url);
     }
     //兼容/index.php/box,自动到/index.php/box/index下
     $this->controller = $uriInfo[1];
     if ($this->controller === "k") {
         //外链短地址
         $key = $uriInfo[2];
         $url = Util::getMiniHost() . "index.php/link/access/key/" . $key;
         $this->redirectUrl($url);
     }
     if (count($uriInfo) === 2 || empty($uriInfo[2])) {
         if (empty($this->controller)) {
             $this->controller = "box";
         }
         $url = Util::getMiniHost() . "index.php/" . $this->controller . "/index";
         $this->redirectUrl($url);
     } else {
         $actionInfo = explode("?", $uriInfo[2]);
         $this->action = $actionInfo[0];
     }
     if ($this->isWeb) {
         if (empty($this->controller)) {
             $accessToken = $this->getCookie("accessToken");
             if (!empty($accessToken)) {
                 //根目录访问
                 if ($this->offline) {
                     $url = Util::getMiniHost() . "index.php/netdisk/index";
                 } else {
                     $url = Util::getMiniHost() . "index.php/box/index";
                 }
             } else {
                 $url = Util::getMiniHost() . "index.php/site/login";
             }
             $this->redirectUrl($url);
         }
     }
 }