コード例 #1
0
 public function handleInitEnvironment($event)
 {
     Ibos::app()->performance->startClock();
     Ibos::app()->performance->startMemoryUsageMarker();
     define("STATICURL", Ibos::app()->assetManager->getBaseUrl());
     define("IN_MOBILE", EnvUtil::checkInMobile());
     define("IN_DASHBOARD", EnvUtil::checkInDashboard());
     define("TIMESTAMP", time());
     define("IN_APP", EnvUtil::checkInApp());
     $this->setTimezone();
     if (function_exists("ini_get")) {
         $memorylimit = @ini_get("memory_limit");
         if ($memorylimit && ConvertUtil::ConvertBytes($memorylimit) < 33554432 && function_exists("ini_set")) {
             ini_set("memory_limit", "128m");
         }
     }
     $global = array("timestamp" => TIMESTAMP, "version" => VERSION, "clientip" => EnvUtil::getClientIp(), "referer" => "", "charset" => CHARSET, "authkey" => "", "newversion" => 0, "config" => array(), "setting" => array(), "user" => array(), "cookie" => array(), "session" => array(), "lunar" => DateTimeUtil::getlunarCalendar(), "title" => MainUtil::getIncentiveWord(), "staticurl" => STATICURL);
     $global["phpself"] = $this->getScriptUrl();
     $sitePath = substr($global["phpself"], 0, strrpos($global["phpself"], "/"));
     $global["isHTTPS"] = isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"]) != "off" ? true : false;
     $global["siteurl"] = StringUtil::ihtmlSpecialChars("http" . ($global["isHTTPS"] ? "s" : "") . "://" . $_SERVER["HTTP_HOST"] . $sitePath . "/");
     $url = parse_url($global["siteurl"]);
     $global["siteroot"] = isset($url["path"]) ? $url["path"] : "";
     $global["siteport"] = empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == "80" || $_SERVER["SERVER_PORT"] == "443" ? "" : ":" . $_SERVER["SERVER_PORT"];
     $config = @(include PATH_ROOT . "/system/config/config.php");
     if (empty($config)) {
         throw new NotFoundException(Ibos::Lang("Config not found", "error"));
     } else {
         $global["config"] = $config;
     }
     Ibos::app()->setting->copyFrom($global);
 }
コード例 #2
0
ファイル: sso.php プロジェクト: AxelPanda/ibos
$returnurl = filter_input(INPUT_GET, "returnurl", FILTER_SANITIZE_STRING);
if (empty($openId) || empty($hashskey) || empty($cid)) {
    exit("参数错误");
}
$uid = UserBinding::model()->fetchUidByValue(StringUtil::filterCleanHtml($openId), "bqq");
if ($uid) {
    $checkCId = strcmp($imCfg["id"], $cid) == 0;
    $properties = array("company_id" => $cid, "company_token" => $imCfg["token"], "app_id" => $imCfg["appid"], "client_ip" => EnvUtil::getClientIp());
    $api = new BQQApi($properties);
    $status = $api->getVerifyStatus(array("open_id" => $openId, "hashskey" => $hashskey));
    if ($status["ret"] == 0) {
        $config = @(include PATH_ROOT . "/system/config/config.php");
        if (empty($config)) {
            throw new Exception(Ibos::Lang("Config not found", "error"));
        } else {
            define("IN_MOBILE", EnvUtil::checkInMobile());
            $global = array("clientip" => EnvUtil::getClientIp(), "config" => $config, "timestamp" => time());
            Ibos::app()->setting->copyFrom($global);
            handleloadsyscache();
            $saltkey = MainUtil::getCookie("saltkey");
            if (empty($saltkey)) {
                $saltkey = StringUtil::random(8);
                MainUtil::setCookie("saltkey", $saltkey, 86400 * 30, 1, 1);
            }
            $curUser = User::model()->fetchByUid($uid);
            $identity = new ICUserIdentity($curUser["username"], $curUser["password"]);
            $identity->setId($uid);
            $identity->setPersistentStates($curUser);
            $ip = Ibos::app()->setting->get("clientip");
            foreach ($_COOKIE as $k => $v) {
                $cookiePath = $config["cookie"]["cookiepath"];