只拦截含有 Portal 的控制器方法
496587
@Override
    protected boolean isForAction(Method actionMethod, Class<?> controllerClazz) {
        for (Class<?> paramType : actionMethod.getParameterTypes()) {
            if (paramType == Portal.class) {
                return true;
            }
        }
        return false;
    }
43081
function tryFinishRequire() {
            if (typeof callback === 'function' && !isCallbackCalled) {
                var isAllCompleted = 1;
                each(ids, function (id) {
                    if (!BUILDIN_MODULE[id]) {
                        return (isAllCompleted = !!modIs(id, MODULE_DEFINED));
                    }
                });

                // 检测并调用callback
                if (isAllCompleted) {
                    isCallbackCalled = 1;

                    callback.apply(
                        global,
                        modGetModulesExports(ids, BUILDIN_MODULE)
                    );
                }
            }
        }
897726
private static void fillReqAndRes(ServletRequest req, ServletResponse res){
		//-- 填充请求和响应对象到ActionContext本地线程
		Request.init((HttpServletRequest)req);
		Response.init((HttpServletResponse)res);
	}
153782
async function handle(sofar) {
    //根据路由执行相关操作
    try{
        let rs = await sofar.facade.callFunc(sofar.msg.control, sofar.msg.func, sofar.socket.user, sofar.msg);
        sofar.fn(rs);
    }catch(e){
        sofar.fn({code: facade.const.ReturnCode.Error});

        console.error(e);
    }
}
1310203
@Override
    public boolean checkUserPermission(String pattern, RequestMethod method) {
        // 获取用户角色
        Visitor visitor = ThreadContext.getSessionVisitor();
        if (visitor == null) {
            return false;
        }

        String urlPattarn = pattern;
        if (!urlPattarn.endsWith(RoleResourceConstant.URL_SPLITOR)) {
            urlPattarn += RoleResourceConstant.URL_SPLITOR;
        }

        Integer roleId = visitor.getRoleId();

        Map<String, Map<RequestMethod, List<Integer>>> roleResMap = getAllAsMap();
        Map<RequestMethod, List<Integer>> methodMap = roleResMap.get(urlPattarn);
        if (methodMap == null) {
            return false;
        }

        List<Integer> roleIdList = methodMap.get(method);
        if (roleIdList == null) {
            return false;
        }

        if (!roleIdList.contains(roleId)) {
            return false;
        }
        return true;
    }
1190566
def user_portals_picker(self):
        
        # print("Getting Portals list. This could take a few seconds...")
        portals = self.get_portals_list()
        done = False
        while not done:
            opts = [ (i, p) for i, p in enumerate(portals) ]
            # print('')
            for opt, portal in opts:
                print("\t{0} - {1}".format(opt, portal[1]))
            # print('')
            valid_choices = [o[0] for o in opts]
            choice = _input("Enter choice ({0}): ".format(valid_choices) )
            if int(choice) in valid_choices:
                done = True

                # loop through all portals until we find an 'id':'rid' match
                self.set_portal_name( opts[int(choice)][1][1] )
                self.set_portal_id( opts[int(choice)][1][0] )
                # self.set_portal_rid( opts[int(choice)][1][2][1]['info']['key'] )
                # self.__portal_sn_rid_dict = opts[int(choice)][1][2][1]['info']['aliases']

            else:
                print("'{0}' is not a valid choice. Please choose from {1}".format(
                    choice, valid_choices))
55430
def queryAll(self, queryString):
    '''
    
    '''
    self._setHeaders('queryAll')
    return self._sforce.service.queryAll(queryString)
1318524
function _check(asyncClient, route) {
    return new Promise((resolve, reject) => {
        // 有问题时直接执行真实的fetch方法
        if (!asyncClient) {
            return reject(RESULT.NO_ASYNC_CLIENT);
        }

        // 如果远程服务未启动也需要放弃async
        if (!route) {
            return reject(RESULT.NO_ROUTE);
        }

        let i = 0;
        let checkT;

        function checkConnect() {
            if (asyncClient.isConnected()) {
                // 如果已经连接成功，则清除定时器，并返回
                if (checkT) {
                    clearTimeout(checkT);
                }

                resolve();
            } else if (i > 9) {
                // 如果重试次数大于了10次，也终止，清除定时器，并返回
                if (checkT) {
                    clearTimeout(checkT);
                }

                alert(`mockstar async 服务未启动！请检查 ${asyncClient.getURI()} 是否已启动`);
                reject(RESULT.NOT_CONNECTED);
            } else {
                i++;
                // 使之异步，避免 websocket 还未连接成功
                checkT = setTimeout(() => {
                    checkConnect();
                }, 10);
            }
        }

        checkConnect();
    });
}
1257023
async function handle(sofar) {
    let ret = { ret: 0 };
    try {
        if (!sofar.socket.user || sofar.msg.type == "login"/*如果是login则强制重新验证*/) {
            let signal = sofar.msg.oemInfo.auth.sign == facade.util.sign(sofar.msg.oemInfo.auth, sofar.facade.options.game_secret);
            let timer = Math.abs(sofar.msg.oemInfo.auth.t - facade.util.now()) <= 300;
            if (!signal || !timer) {
                console.log(signal, timer);
                sofar.fn({ code: ReturnCode.authThirdPartFailed });
                sofar.recy = false;
                return;
            }

            //此处要对domainId、openid重新赋值
            sofar.msg.oemInfo.openid = sofar.msg.oemInfo.auth.plat_user_id;
            sofar.msg.domainId = sofar.msg.oemInfo.domain + '.' + sofar.msg.oemInfo.openid;//用户唯一标识
            sofar.msg.oemInfo.token = facade.util.sign({ did: sofar.msg.domainId }, sofar.facade.options.game_secret); //为用户生成令牌

            let usr = {
                domain: sofar.msg.oemInfo.domain, 
                openid: sofar.msg.oemInfo.openid, 
                sign: sofar.msg.oemInfo.token,      //令牌
                time: facade.util.now(),             //记录标识令牌有效期的时间戳
                socket: sofar.socket,               //更新通讯句柄
            };
            sofar.socket.user = usr;
        }

        if (!sofar.socket.user) {//未通过身份校验
            sofar.fn({ code: ReturnCode.userIllegal });
            sofar.recy = false;
        }
    }
    catch (e) {
        console.error(e);
        sofar.fn({ code: ReturnCode.illegalData, data: ret });
        sofar.recy = false;
    }
}
1207123
function completePreDefine( currentId ) {
        var preDefines = wait4PreDefines.slice( 0 );

        wait4PreDefines.length = 0;
        wait4PreDefines = [];

        // 预定义模块：
        // 此时处理的模块都是匿名define的模块
        each(
            preDefines,
            function ( module ) {
                modPreDefine(
                    module.id || currentId,
                    module.deps,
                    module.factory
                );
            }
        );

        modAnalyse();
    }
585606
function (element, type, handler, context) {
            var own = this;
            //非Dom元素不处理
            if (!(1 == element.nodeType || element.nodeType == 9 || element === window)|| !vQ.isFunction(handler)) {
                return;
            }
            //获取传入参数
            var args = slice.call(arguments);

            //批量绑定事件处理
            if (vQ.isArray(type)) {
                return own._handleMultipleEvents.apply(own, [own.one].concat(args));
                //return own._handleMultipleEvents(own.one, element, type, handler);
            }

            var func = function () {
                own.unbind(element, type, func);
                handler.apply(context || element, arguments);
            };

            // copy the guid to the new function so it can removed using the original function's ID
            func.$$guid = handler.$$guid = handler.$$guid || own._guid++;
            own.bind(element, type, func);


            //var func = function(){
            //    own.unbind.apply(own,args);
            //    handler.apply(context || element, arguments);
            //};
            ////args = [type, func].concat(args.slice(2));//更换fun 这样支持不定个数的参数
            //
            //// copy the guid to the new function so it can removed using the original function's ID
            //func.$$guid = handler.$$guid = handler.$$guid || own._guid++;
            ////own.observe(element, type, func);
            //own.bind.apply(own,args);
        }
55844
static function CodingSwitch($app = "./",$charset='UTF-8',$mode = "FILES",$file_types = array(".html",".php")) {
		self::info("注意: 程序使用的文件编码检测算法可能对某些特殊字符不适用");
		$filearr = self::searchdir($app,$mode,$file_types);
		foreach($filearr as $file)
			self::DetectAndSwitch($file,$charset);
	}
753411
def portals(self):
        """"""
        url = "%s/portals" % self.root
        return _portals.Portals(url=url,
                                securityHandler=self._securityHandler,
                                proxy_url=self._proxy_url,
                                proxy_port=self._proxy_port)
42346
function (runtime, mod) {
            if (mod.status != LOADED) {
                return;
            }

            var fn = mod.fn;

            if (typeof fn === 'function') {
                // 需要解开 index，相对路径
                // 但是需要保留 alias，防止值不对应
                mod.value = fn.apply(mod, Utils.getModules(runtime, mod.getRequiresWithAlias()));
            } else {
                mod.value = fn;
            }

            mod.status = ATTACHED;
        }
416408
@Override
    public void perform() throws PortalException {
        Element plfNode = HandlerUtils.getPLFNode(ilfNode, person, false, false);

        if (plfNode == null) return;

        changeRestriction(Constants.ATT_MOVE_ALLOWED, plfNode, moveAllowed);
        changeRestriction(Constants.ATT_MOVE_ALLOWED, ilfNode, moveAllowed);
        changeRestriction(Constants.ATT_DELETE_ALLOWED, plfNode, deleteAllowed);
        changeRestriction(Constants.ATT_DELETE_ALLOWED, ilfNode, deleteAllowed);
        changeRestriction(Constants.ATT_EDIT_ALLOWED, plfNode, editAllowed);
        changeRestriction(Constants.ATT_EDIT_ALLOWED, ilfNode, editAllowed);

        if (plfNode.getAttribute(Constants.ATT_CHANNEL_ID).equals("")) {
            // if channel id is empty then this is not a channel.
            // childAllowed is always true for channel ad-hoc parameters.
            changeRestriction(Constants.ATT_ADD_CHILD_ALLOWED, plfNode, addChildAllowed);
            changeRestriction(Constants.ATT_ADD_CHILD_ALLOWED, ilfNode, addChildAllowed);
        }
    }
543154
private function routeApi()
    {
        // get protocol class
        if ($this->apiProtocolClass != "framework\\protocol\\Api") {
            try {
                $api_protocol_class = sprintf("main\\%s\\protocol\\%s", $this->currentApp, $this->apiProtocolClass);
                if (!class_exists($api_protocol_class)) {
                    throw new HornetCoreException($api_protocol_class . ' no found', 500);
                }
            } catch (HornetCoreException $exception) {
                $apiProtocol = new Api($this->enableTrace);
                $this->handleApiException($apiProtocol, $exception);
                return;
            }
            $apiProtocol = new $api_protocol_class($this->enableTrace);
        } else {
            $apiProtocol = new Api($this->enableTrace);
        }

        // url route to controller
        try {
            // sql注入检查
            if ($this->enableFilterSqlInject) {
                $filterSqlInject = new FilterSqlInject($this->storagePath . '/log/sql_inject/');
                $filterSqlInject->filterInput();
            }
            if (!strpos($this->cmd, '.')) {
                throw new \Exception('Api invoker error: cmd param error!', 500);
            }
            list ($service, $method) = explode('.', $this->cmd);
            $service = ucfirst($service);
            $service = $this->underlineToUppercase($service);
            $serviceClass = sprintf("main\\%s\\api\\%s", $this->currentApp, $service);
            if (!empty($this->mod) && $this->mod != 'api') {
                $serviceClass = sprintf("main\\%s\\api\\%s\\%s", $this->currentApp, $this->mod, $service);
            }

            $service_obj = new $serviceClass();

            if (!method_exists($service_obj, $method)) {
                $method = $this->underlineToUppercase($method);
                if (!method_exists($service_obj, $method)) {
                    throw new \Exception($this->ctrl . '->' . $method . ' no found;', 404);
                }
            }

            // 安全映射机制
            $this->securityMapCheck($this->modApiName, $service, $method);

            if (($this->appStatus == 'development' || $this->appStatus == 'test') && $this->enableWriteReqLog) {
                $reqLogPath = $this->storagePath . 'tmp/' . date('Y-m-d') . '_request.log';
                $dateTime = date('H:i:s');
                $getStr = var_export($_GET, true);
                $postStr = var_export($_POST, true);
                $cookieStr = var_export($_COOKIE, true);
                $logContent = $dateTime . ': ' . $getStr . $postStr . $cookieStr . "\n\n";
                f($reqLogPath, $logContent, FILE_APPEND);
                unset($dateTime, $getStr, $postStr, $cookieStr, $logContent);
            }
            $reflectMethod = null;
            // 通过反射获取调用方法的参数列表
            if ($this->enableReflectMethod) {
                $reflectMethod = new \ReflectionMethod($service_obj, $method);
                $args = [];
                $defaults = [];
                foreach ($reflectMethod->getParameters() as $param) {
                    $args[] = $param->getName();
                    $defaults[] = $param->isDefaultValueAvailable() ? $param->getDefaultValue() : null;
                }
                if (empty($args)) {
                    // 开始执行业务逻辑流程
                    $result = call_user_func_array([$service_obj, $method], []);
                } else {
                    $params = array();
                    foreach ($args as $ak => $arg) {
                        $params[$ak] = isset($_REQUEST[$arg]) ? $_REQUEST[$arg] : $defaults[$ak];
                    }
                    // 开始执行业务逻辑流程
                    $result = call_user_func_array([$service_obj, $method], $params);
                }
            } else {
                $result = call_user_func_array([$service_obj, $method], []);
            }

            // 执行结束检验结果类型
            $apiProtocol->builder('200', $result, '', $this->format);
            $jsonStr = $apiProtocol->getResponse();
            if ($this->format == 'json' && $this->enableReflectMethod) {
                $return_obj = json_decode(json_encode($result));
                $this->validReturnJson($reflectMethod, $apiProtocol, $return_obj, $jsonStr);
            }
            echo $jsonStr;
            if (($this->appStatus == 'development' || $this->appStatus == 'test') && $this->enableWriteReqLog) {
                $reqLogPath = $this->storagePath . 'tmp/' . date('Y-m-d') . '_request.log';
                $datetime = date('H:i:s');
                $getStr = var_export($_GET, true);
                $postStr = var_export($_POST, true);
                $cookieStr = var_export($_COOKIE, true);
                $logContent = $datetime . ': ' . $getStr . $postStr . $cookieStr . "\n\n";
                unset($datetime, $getStr, $postStr, $cookieStr);
                f($reqLogPath, $logContent, FILE_APPEND);
            }
            closeResources();
        } catch (HornetCoreException  $e) {
            $this->handleApiException($apiProtocol, $e);
        } catch (HornetLogicException  $e) {
            $this->handleApiException($apiProtocol, $e);
        } catch (\PDOException $e) {
            $this->handleApiException($apiProtocol, $e);
        } catch (\Exception $e) {
            $this->handleApiException($apiProtocol, $e);
        }
    }
448089
function(newQueryCriteria, requireCenterAndRadius) {
  if (typeof newQueryCriteria !== "object") {
    throw new Error("query criteria must be an object");
  }
  else if (typeof newQueryCriteria.center === "undefined" && typeof newQueryCriteria.radius === "undefined") {
    throw new Error("radius and/or center must be specified");
  }
  else if (requireCenterAndRadius && (typeof newQueryCriteria.center === "undefined" || typeof newQueryCriteria.radius === "undefined")) {
    throw new Error("query criteria for a new query must contain both a center and a radius");
  }

  //如果有任何附加属性抛出错误
  var keys = Object.keys(newQueryCriteria);
  var numKeys = keys.length;
  for (var i = 0; i < numKeys; ++i) {
    var key = keys[i];
    if (key !== "center" && key !== "radius") {
      throw new Error("Unexpected attribute '" + key + "'' found in query criteria");
    }
  }

  // 校验圆心属性
  if (typeof newQueryCriteria.center !== "undefined") {
    validateLocation(newQueryCriteria.center);
  }

  // 验半径属性
  if (typeof newQueryCriteria.radius !== "undefined") {
    if (typeof newQueryCriteria.radius !== "number" || isNaN(newQueryCriteria.radius)) {
      throw new Error("radius must be a number");
    }
    else if (newQueryCriteria.radius < 0) {
      throw new Error("radius must be greater than or equal to 0");
    }
  }
}