/** * @brief ext中的CAS外部文件映射初始化接口 * * @return success-true failed-false * @retval boolean * @see php/phplib/ext/cas/中的phpCAS相关实现文件 * @note 将php/ext/cas目录下的文件进行路径映射,并读取ral/services/uuap.conf配置文件的信息 * @author chenyijie * @date 2012/09/28 22:25:52 **/ private static function getCasInit() { if (!self::$isInit) { //Bd_Autoloader::addClassMap(self::$casClassMap); self::$isInit = true; } // 加载配置 if (empty(self::$arrConf)) { self::$arrConf = Bd_Conf::getConf('ral/services/uuap/CamelConfig/ServiceConfig/Local/Service'); if (empty(self::$arrConf)) { Bd_Log::warning('Get configure from ral/services/uuap.conf failed'); self::$arrConf = null; return false; } //裁剪掉关于UIC服务的配置 foreach (self::$arrConf as $index) { if ($index['Name'] === 'uuapSSO') { self::$arrConf = $index; } } } if (self::$arrConf['ReverseProxy'] === 'On') { $str = $_SERVER['SERVER_NAME']; if (self::$arrConf['ProxyPort']) { $str .= ":" . self::$arrConf['ProxyPort']; } define("UUAP_SERVICE_URL", $str); } return true; }
/** * @brief 保存用户信息到passport * * @author cuichao02 * @date 2011/02/21 **/ public static function saveModDatat() { $arrSavePassport = Saf_SmartMain::getSavePassport(); if (is_array($arrSavePassport) && count($arrSavePassport) > 0) { $safConf = Bd_Conf::getAppConf('/saf'); if (empty($safConf)) { $safConf = Bd_Conf::getConf('/saf'); } $intPassportSaveLen = intval($safConf['passport_save_len']); if ($intPassportSaveLen == 0) { $intPassportSaveLen = 32; } Bd_Passport::initDataBuf($arrCachePass, $intPassportSaveLen); foreach ($arrSavePassport as $bit => $v) { Bd_Passport::modDataBufByBit($arrCachePass, intval($bit), intval($v)); } $arrOutput = Bd_Passport::modData($_COOKIE['BDUSS'], '', '', $arrCachePass['data'], $arrCachePass['mask']); if ($arrOutput['status'] != 0 || $arrOutput == false) { Saf_SmartMain::setSafLog("保存到passport服务器出错(" . var_export($arrOutput, true) . ")", 2); Saf_Base_Hook::warningAction('save_passport', 'system busy'); return false; } } return true; }
/** * @brief modify by luhaixia 获取全局定义了Hook和App域的Hook,如果都没有定义,则使用默认的Hook * * @return public function * @retval * @see * @note * @author luhaixia * @date 2012/03/28 13:44:21 **/ protected static function creatObjHook() { if (Saf_Base_Hook::$boolCreateHook) { //已经创建了Hook则直接返回 return true; } Saf_Base_Hook::$arrObjHook = array(); $strGlobalSafHook = Bd_Conf::getConf('/saf/hook_name'); if (!empty($strGlobalSafHook)) { if (class_exists($strGlobalSafHook)) { Saf_Base_Hook::$arrObjHook[] = new $strGlobalSafHook(); } else { Saf_SmartMain::setSafLog("创建的勾子类({$strGlobalSafHook})不存在", 2); } } $strAppSafHook = Bd_Conf::getAppConf('/saf/hook_name'); if (!empty($strAppSafHook)) { if (class_exists($strAppSafHook)) { Saf_Base_Hook::$arrObjHook[] = new $strAppSafHook(); } else { Saf_SmartMain::setSafLog("创建的勾子类({$strAppSafHook})不存在", 2); } } if (count(Saf_Base_Hook::$arrObjHook) == 0) { $strHookClassName = 'Saf_Base_Hook'; Saf_SmartMain::setSafLog("没有设置需要创建的勾子类,使用默认的({$strHookClassName})", 2); Saf_Base_Hook::$arrObjHook[] = new $strHookClassName(); } Saf_Base_Hook::$boolCreateHook = true; }
/** * 精确的UA词典,每一行的第一项是完整ua字符串的md5值 * @param string $ualist(文件名) * @return boolean */ private function loadExactly($ualist) { if (empty($ualist) || !file_exists($ualist)) { return false; } $arr = explode("\n", file_get_contents($ualist)); // ua词典的字段可配置,利于扩展 $arrFields = Bd_Conf::getConf('tpl_uaadaptation/UA_DICT_FIELDS'); if (empty($arrFields)) { // 默认字段 $arrFields = array('ua', 'os', 'os_version', 'vender', 'modal', 'browser', 'browser_version', 'resolution', 'measure'); } else { $arrFields = array_keys($arrFields); } foreach ($arr as $line) { if (trim($line) === '') { continue; } $arrItem = array(); $arrUA = @explode("\t", $line); if (!empty($arrUA)) { foreach ($arrUA as $k => $v) { $arrItem[$arrFields[$k]] = trim($v); } } $ua = array_shift($arrItem); self::$_exact_dict[$ua] = $arrItem; } return true; }
public static function init() { $session_conf = Bd_Conf::getAppConf('session'); $type = strtolower($session_conf['type']); $session_name = $session_conf['session_name']; $session_lifetime = $session_conf['lifetime']; $session_handler = null; if ($session_name) { session_name($session_name); } switch ($type) { case 'mysql': $db_conf_name = $session_conf['db_conf']; $db_conf = self::loadConfName($db_conf_name); //$db_proxy = Bd_Db_ConnMgr::getConn($db_conf,"session",false,true); //$db_proxy = new Navilib_DBFactory($db_conf); $db_conf = Bd_Conf::getConf('/db/' . $db_conf); //$session_handler = new Session_Mysql($db_proxy,$session_lifetime); $session_handler = new Session_Mysql($db_conf, $session_lifetime); break; default: // 默认存在本地文件 break; } if ($session_handler) { session_module_name('user'); //session_save_path('/tmp'); session_set_save_handler(array(&$session_handler, 'open'), array(&$session_handler, 'close'), array(&$session_handler, 'read'), array(&$session_handler, 'write'), array(&$session_handler, 'destroy'), array(&$session_handler, 'gc')); } }
/** * @brief CacheProxy初始化 根据配置文件进行适配 * * @param $objClass 使用CacheProxy的类 * @return $this->decorateClass * @retval object * @note * @author chenyijie * @date 2012/07/10 14:33:59 **/ public function __construct($objClass) { $this->objClass = $objClass; $strClassName = get_class($this->objClass); $cacheProxyClass = null; $layers = Bd_Conf::getConf('cacheproxy/layers'); if ($layers === false || $layers === null || !is_array($layers)) { //如果cacheproxy.conf中关于layers的配置项读取出错则不使用CacheProxy $this->decorateClass = $this->objClass; } else { //如果$strClassName中了layers中的一个$cacheProxyStr[index]正则式, //则将$cacheProxyClass设置为这个$cacheProxyStr[index]对应的$cacheProxyStr foreach ($layers as $cacheProxyStr => $index) { if (preg_match("/{$index}/", $strClassName)) { $cacheProxyClass = $cacheProxyStr; } } } if (!is_null($cacheProxyClass)) { $this->decorateClass = new $cacheProxyClass($this->objClass); } else { //如果$cacheProxyClass为空则说明没有中正则, //则$decorateClass为此类本身,不使用CacheProxy $this->decorateClass = $this->objClass; } }
/** * 网页编码与程序编码转化 * ie:页面提交编码(conf文件中定义,cgi传递,自动判断) de:程序需要的编码(conf文件中定义) * 编码标识以lib库中的编码转化转化函数一致(php手册中的iconv编码) * @param array &$value * @param cgi传过来的ie值 $strCgiIe * @return bool */ private static function __ieTode(&$value, $strCgiIe) { $safConf = Bd_Conf::getAppConf('/saf'); if (empty($safConf)) { $safConf = Bd_Conf::getConf('/saf'); } if ($strCgiIe == '') { $strCgiIe = $safConf['cgi_ie']; } $strConfOe = $safConf['cgi_oe']; if ($strCgiIe == '') { if (true === Bd_Charset::isUtf8(self::__arrToString($value))) { $strCgiIe = 'UTF-8'; } elseif (true === Bd_Charset::isGbk(self::__arrToString($value))) { $strCgiIe = 'GBK'; } } if ($strCgiIe == $strConfOe || $strConfOe == '' || $strCgiIe == '') { return true; } $ret = Bd_String::iconv_recursive($value, $strCgiIe, $strConfOe); if ($ret) { $value = $ret; } return true; }
protected function _extra_init(&$extra) { $this->_service = $this->_get_arch_service_name(); $conf = Bd_Conf::getConf('/ak/default/'); $default = $conf['default']; $force = $conf['force']; if (isset($force['pid'])) { $extra['pid'] = $force['pid']; } if (!isset($extra['pid'])) { if (isset($default['pid'])) { $extra['pid'] = $default['pid']; } else { $this->_add_error('pid not found in extra'); return false; } } if (isset($force['tk'][$extra['pid']])) { $extra['tk'] = $force['tk'][$extra['pid']]; } if (!isset($extra['tk']) && isset($default['tk'][$extra['pid']])) { $extra['tk'] = $default['tk'][$extra['pid']]; } return true; }
private function loadAppConf() { $confFile = "/" . parent::$app . "/" . parent::$app; parent::$arrAppConf = Bd_Conf::getConf($confFile); if (parent::$arrAppConf == false) { return false; } return true; }
/** * @brief 初始化passport config。判断运行时环境[ODP|PRO]; * 若运行在ODP 环境,使用Bd_Conf读取configure文件 * 若运行在其他环境,使用Bd_Passport_Inc类(Inc.php)作为配置文件 * @param null * @return null * @author fanmengzhe * @date 2011/11/10 12:02:48 * @note */ protected static function _initConf() { if (defined('IS_ODP') && true === IS_ODP) { self::$_conf = Bd_Conf::getConf('/passport/'); } else { self::$_conf = Bd_Passport_Inc::$conf; } self::$_isInit = true; }
public static function convertName($clusterName, $extra = array()) { if (empty(self::$_dbPreArr)) { $conf = Bd_Conf::getConf('/i18n/interface/db'); self::$_dbPreArr = $conf['pre']; } if (self::$_dbPreArr && in_array($clusterName, self::$_dbPreArr)) { $clusterName .= '_' . Bd_Global::getInstance(); } return $clusterName; }
/** * @brief 初始化通用流程,App域的配置覆盖全局配置,若用户为提供配置,则默认开启流程 * * @return private static function * @retval * @see * @note * @author luhaixia * @date 2012/03/28 14:16:42 **/ private static function initCommonAction() { $arrConf = Bd_Conf::getAppConf('saf/action'); if (empty($arrConf)) { $arrConf = Bd_Conf::getConf('saf/action'); } foreach (self::$arrCommonAction as $key => $value) { if (isset($arrConf[$key])) { self::$arrCommonAction[$key] = intval($arrConf[$key]) ? 1 : 0; } } }
function init($conf, $params) { //hook name if (isset($conf['hook_name'])) { if (!class_exists($conf['hook_name'])) { throw new Exception("class {$conf['hook_name']} not exists in /conf/layerproxy.conf, check to init conf before use layerproxy"); } $this->hooker = new $conf['hook_name'](); if (!$this->hooker instanceof Bd_Layerproxy_IHook) { throw new Exception("class {$conf['hook_name']} must extends from Bd_Layerproxy_IHook."); } } else { $this->hooker = null; } $class = $this->getMod(); $layers = $conf['layers']; if (empty($layers)) { throw new Exception("layers conf is empty in /conf/layerproxy.conf, check to init conf before use layerproxy"); } //add api call allow/deny controll $arrT = debug_backtrace(); $owner_info = $arrT[2]; $this->upperLayer = $owner_info['class']; if (is_null($this->upperLayer)) { throw new Exception("layerproxy must used in class {action | service_page | serivce_data | dao}"); } $this->lowerLayer = $class; foreach ($layers as $index => $layer) { if (preg_match("/{$layer}/", $owner_info['class'])) { //发起调用的class $this->upperLayerIndex = $index; if (!preg_match("/{$layers[$index + 1]}/", $class)) { //否则需要限制调用方类的开头合法性 //TODO 修改错误号 throw new Exception("invalid call from {$owner_info['class']} to {$class} as /{$layers[$index + 1]}/"); } } } if (class_exists($class)) { //don't autoload if ($this->hooker !== null) { $this->hooker->initHook($this->upperLayerIndex, $this->upperLayer, $this->lowerLayer); } $UseCache = Bd_Conf::getConf('layerproxy/UseCache'); if ($UseCache === 'true') { $this->srcCaller = new Saf_Cache_CacheProxy(new $class($params)); } else { $this->srcCaller = new $class($params); } } else { throw new Exception('Bd_Layerproxy_PHPProxy class ' . $class . ' not exists'); } }
/** * @brief 根据saf.conf配置文件初始化arrHook数组 * * @return true / false * @retval bool * @see adapterStart() * @author luhaixia * @date 2012/10/15 12:07:57 **/ private static function initHook() { $arrConf = Bd_Conf::getAppConf('saf/hook'); if (empty($arrConf)) { $arrConf = Bd_Conf::getConf('saf/hook'); } if (!is_array($arrConf)) { return false; } foreach ($arrConf as $key => $value) { if (isset($arrConf[$key]) && $value != '0') { $key = strtolower($key); self::$arrHook[$key] = $value; } } return true; }
public static function getInstance($param = null) { // 初始化Smarty自动加载 if (!self::$isInit) { Bd_Autoloader::addClassMap(self::$smartyClassMap); self::$isInit = true; } // 从配置中读取参数 if (!is_array($param)) { // 加载配置 if (empty(self::$arrConf)) { self::$arrConf = Bd_Conf::getConf('/smarty/'); if (empty(self::$arrConf)) { self::$arrConf = null; return null; } } // 取指定的配置组 if ($param != null) { $param = self::$arrConf[$param]; // 不存在则出错 if (!$param) { return null; } } else { $param = current(self::$arrConf); } } // new一个smarty $smarty = new Smarty(); // 根据参数初始化该smarty对象 $smarty->setTemplateDir(self::__absPath($param['template_dir'])); $smarty->setCompileDir(self::__absPath($param['compile_dir'])); $smarty->setCompileCheck($param['compile_check'] != '0'); $smarty->setConfigDir(self::__absPath($param['config_dir'])); if (!empty($param['config_load'])) { $smarty->configLoad($param['config_load']); } $smarty->addPluginsDir(self::__absPath($param['plugins_dir'])); $smarty->left_delimiter = $param['left_delimiter']; $smarty->right_delimiter = $param['right_delimiter']; if (isset($_COOKIE['FIS_DEBUG']) && $_COOKIE['FIS_DEBUG'] === 'YlwtSmt' && self::isInternalIp(Bd_Ip::getClientIp())) { return new Bd_TplFactory($smarty); } return $smarty; }
public function dispatchLoopStartup(Ap_Request_Abstract $request, Ap_Response_Abstract $response) { Saf_SmartMain::adapterStart(); $adaptInfo = Saf_SmartMain::getAdaptInfo(); if (!empty($adaptInfo['screenType'])) { $action = $request->getActionName(); $screenType = $adaptInfo['screenType']; $arrConf = Bd_Conf::getAppConf('saf/controller'); if (empty($arrConf)) { $arrConf = Bd_Conf::getConf('saf/controller'); } if (isset($arrConf[$screenType])) { $request->setControllerName($arrConf[$screenType]); $request->setActionName(strtolower($arrConf[$screenType]) . $action); } } }
public function get_ua_strategy() { $arrRes = array('type' => '', 'tpl' => '', 'name' => '', 'rollback_name' => ''); if (empty($this->_ua_string)) { return $arrRes; } // 全部UA适配策略配置 $adaptions = Bd_Conf::getConf('tpl_uaadaptation/TEMPLATE_UA_ADAPTATION'); if (empty($adaptions)) { return $arrRes; } $obj = UserAgent::getInstance(VUI_CONF_PATH . '/' . 'ualist_exact'); // 获取下全部的UA字段,包括厂商、机型、操作系统、系统版本号、浏览器、浏览器版本号等等 $arrFields = $obj->getFieldsFromUA($this->_ua_string); // 未查到相关字段,不做任何处理 if (empty($arrFields) || !is_array($arrFields)) { return $arrRes; } // 遍历适配规则,应用命中的策略 foreach ($adaptions as $perAdapt) { if (empty($perAdapt['rule']) || !is_array($perAdapt['rule'])) { continue; } $bHint = true; // rule中的字段均是UA所要强制匹配上的 foreach ($perAdapt['rule'] as $key => $pattern) { if (!preg_match('/' . $pattern . '/', $arrFields[$key])) { $bHint = false; } } if (!$bHint) { continue; } // 适配策略的应用目前包括模板类型(baidu/baiduhd)、模板名(page.2.0.tpl)、退化模板名(page.tpl) $arrRes['type'] = isset($perAdapt['strategy']['type']) ? trim($perAdapt['strategy']['type']) : ''; $arrRes['tpl'] = isset($perAdapt['strategy']['tpl']) ? trim($perAdapt['strategy']['tpl']) : ''; $arrRes['none_tpl'] = isset($perAdapt['strategy']['none_tpl']) ? trim($perAdapt['strategy']['none_tpl']) : ''; $arrRes['rollback_name'] = isset($perAdapt['strategy']['rollback_name']) ? trim($perAdapt['strategy']['rollback_name']) : ''; $arrRes['rollback_none_name'] = isset($perAdapt['strategy']['rollback_none_name']) ? trim($perAdapt['strategy']['rollback_none_name']) : ''; $arrRes['name'] = isset($perAdapt['strategy']['name']) ? trim($perAdapt['strategy']['name']) : ''; break; } return $arrRes; }
/** * @brief 此接口用于产生CacheCline实例并返回已有的CacheClient实例 * * @return success-CacheClient实例 failed-false * @retval object/boolean * @author chenyijie * @date 2012/07/09 13:36:23 **/ public static function getInstance() { if (!empty(self::$instance)) { return self::$instance; } $cacheClientClass = Bd_Conf::getConf('cacheproxy/which_cache_client'); if ($cacheClientClass === false) { Bd_Log::warning("The ClientClass which you set in the cache.conf file does not exist"); return false; } $cacheStr = 'Saf_Cache_Client_' . $cacheClientClass; if (!class_exists($cacheStr)) { Bd_Log::warning("The ClientClass which you set in the cache.conf file does not exist"); return false; } $cacheObj = new $cacheStr(); self::$instance = $cacheObj->create(); return self::$instance; }
protected static function getConf() { //从ral/services/uuap.conf中读取UUAP UIC的链接字符串与端口 if (empty(self::$arrConf)) { self::$arrConf = Bd_Conf::getConf('ral/services/uuap/CamelConfig/ServiceConfig/Local/Service'); if (self::$arrConf === false) { Bd_Log::warning('Get configure from ral/services/uuap.conf failed', self::GET_CONFIG_FAILED, null); self::$arrConf = null; self::$errCode = self::GET_CONFIG_FAILED; return false; } //裁剪掉关于SSO服务的配置 foreach (self::$arrConf as $index) { if ($index['Name'] === 'uuapUIC') { self::$arrConf = $index; } } self::$soapClientInitPreLink = 'http://' . self::$arrConf['Server'][0]['Hostname'] . ':' . self::$arrConf['DefaultPort'] . '/webservice/'; } return true; }
/** * * * @param mixed * @return */ private function __construct($clusterName) { try { $conf = \Bd_Conf::getConf("/db/cluster/{$clusterName}"); if (!$conf) { throw new Exception("Can not get [{$clusterName}] cluster conf."); } $this->debug = $this->getDebug($conf); $dbName = $this->getDbName($conf); $username = $this->getUsername($conf); $password = $this->getPassword($conf); $charset = $this->getCharset($conf); $hosts = $this->getHosts($conf); $microtime = microtime(true); while (true) { if (count($hosts) === 0) { throw new Exception("Can't connect any database host."); } try { $index = array_rand($hosts); $host = $hosts[$index]; $dsn = $this->getDsn($host, $dbName); $attributes = array(PDO::ATTR_TIMEOUT => 1); $pdo = new PDO($dsn, $username, $password, $attributes); break; } catch (\Exception $e) { unset($hosts[$index]); Logger::logException($e); } } $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if ($charset) { $pdo->exec('SET NAMES ' . $pdo->quote($charset)); } $this->pdo = $pdo; } catch (\Exception $e) { Logger::logException($e); throw new Exception("Can't connect to database server."); } }
public function queryFromUs($arrData) { $arrQueryInfo = $arrData['uiData']['queryInfo']; $arrSessionInfo = $arrData['uiData']['passport']; $arrControlInfo = $arrData['uiControl']; // 传递给us的数据结构 $objQuery = new QueryUSInfo(); $objQuery->time = time(); $objQuery->word = $arrQueryInfo['queryWord']; $objQuery->wordNoSyntax = $arrQueryInfo['wordNoSyntax']; $objQuery->otherResultQuery = $arrQueryInfo['otherResultQuery']; $objQuery->ip = $arrQueryInfo['ip']; if ($arrQueryInfo['interPage'] > 0) { $objQuery->isInterPage = 1; } else { $objQuery->isInterPage = 0; } if ($arrQueryInfo['bwsRetry'] > 0) { $objQuery->isBwsRetry = 1; } else { $objQuery->isBwsRetry = 0; } $objQuery->preference = $arrQueryInfo['preference']; $objQuery->passportUserName = $arrSessionInfo['passportUserName']; if (!empty($arrQueryInfo['JpAlaPre'])) { $objQuery->JpAlaPre = $arrQueryInfo['JpAlaPre']; } $objQuery->codeType = $arrQueryInfo['originCodeType'] & ~(DICT_SEARCH_BIT | MON_BIT | NEWS_SEARCH_BIT | BAIDU_REFER_BIT | TITLE_SEARCH_BIT | AUTHOR_SEARCH_BIT); if (($arrQueryInfo['isDebug'] && intval($arrData['uiData']['templateConfig']['debug'])) > 0) { $objQuery->isDebug = 1; } else { $objQuery->isDebug = 0; } $objQuery->strategyName = $arrQueryInfo['strategyName']; $objQuery->siteName = $arrQueryInfo['siteName']; $objQuery->lastModified = $arrQueryInfo['lastModified']; $strTemplateNameMod = null; if (!empty($arrControlInfo['templateName']) && $arrControlInfo['platform'] !== $GLOBALS['DEFAULT_PLATFORM']) { $strTemplateNameMod = 'baidu' . $arrQueryInfo['dspName']; } if (empty($strTemplateNameMod)) { $objQuery->templateName = $arrControlInfo['templateName']; } else { $objQuery->templateName = $strTemplateNameMod; } $objQuery->sid = $arrQueryInfo['samplingId']; $objQuery->cookie = $arrQueryInfo['baiduId']; $objQuery->needsp = $arrQueryInfo['needSp']; $objQuery->pageNo = $arrQueryInfo['pageNo']; $objQuery->queryId = $arrQueryInfo['queryIdInt']; $objQuery->beforeQueryId = $arrQueryInfo['beforeQueryId']; $objQuery->beforeUrl = $arrQueryInfo['beforeUrl']; $objQuery->accountName = $arrQueryInfo['accountName']; $objQuery->isContCluster = $arrQueryInfo['isContMirror']; $objQuery->isSiteCluster = $arrQueryInfo['isSiteCluster']; $intPageNum = 0; if ($arrQueryInfo['pageNo'] == 1 || $arrQueryInfo['pageNo'] == 2 && $arrQueryInfo['resNum'] == 10) { $intPageNum = $arrQueryInfo['pageNum']; } else { $intPageNum = $arrQueryInfo['pageNum'] - $arrQueryInfo['usm']; } if ($intPageNum < 0) { $intPageNum = 0; } if ($intPageNum >= MAX_OUTPUT_NUM) { $intPageNum = 750; } $objQuery->pageNum = $intPageNum; $objQuery->resNum = $arrQueryInfo['resNum']; $objQuery->resultLang = $arrQueryInfo['resultLang']; $objQuery->resultLocale = $arrQueryInfo['resultLocale']; $strUrlParam = self::filterParamFromUrl($arrQueryInfo['urlParam'], WENKU_WAP_PC_KEY); if (!empty($strUrlParam) && !empty($arrQueryInfo['wenkuUrlPara'])) { $strUrlParam .= '&' . $arrQueryInfo['wenkuUrlPara']; } $objQuery->urlParam = $strUrlParam; $objQuery->requestCode = $arrQueryInfo['requestCode']; $objQuery->usm = $arrQueryInfo['usm']; $objQuery->UrlParaPack = self::packUrlParam($strUrlParam, $arrQueryInfo['postData'], $strTemplateNameMod, $arrQueryInfo['cookieInfo']); if (PROTECTPP_SWITCH_OPEN == $arrQueryInfo['resLimitSwitch']) { $objQuery->enalbeModifyUsm = 1; } else { $objQuery->enalbeModifyUsm = 0; } $intCommand = 0; for ($intI = 0; $intI < DA_RES_COUNT; $intI++) { $intCommand |= $arrQueryInfo['daResource'][$intI]; } $objQuery->template_rsse_command = $intCommand; $objQuery->need_open_disphilight = $arrQueryInfo['need_open_disphilight']; $objQuery->need_RsSE_result = $arrQueryInfo['needRsSeResult']; $objQuery->need_ers_result = $arrQueryInfo['needERSResult']; $objQuery->need_asp_result = $arrQueryInfo['needASPResult']; $objQuery->need_as_result = $arrQueryInfo['need_as_result']; $objQuery->preQueryWord = $arrQueryInfo['preQueryWord']; $objQuery->querySource = $arrQueryInfo['querySource']; $objQuery->isInternalFlow = $arrQueryInfo['isInternalFlow']; $objQuery->srcId = $arrQueryInfo['srcId']; $objQuery->templateForRs = $arrQueryInfo['templateForRs']; $objQuery->beforeQueryId = $arrQueryInfo['beforeQueryId']; $objQuery->noscript = $arrQueryInfo['noscript']; $objQuery->cookieNoscript = $arrQueryInfo['cookieNoscript']; $objQuery->channel = $arrQueryInfo['channel']; $objQuery->rsPos = $arrQueryInfo['rsPos']; $objQuery->platformName = $arrControlInfo['platform']; $objQuery->is_bws_re = $arrQueryInfo['is_bws_re']; $objQuery->useragent_full = $arrQueryInfo['useragent_full']; $objQuery->confuse_Switch = $arrQueryInfo['confuse_Switch']; $objQuery->protectNum = $arrQueryInfo['protectNum']; $objQuery->ec_src = $arrQueryInfo['ec_src']; $objQuery->php_default_platform = $GLOBALS['DEFAULT_PLATFORM']; $objQuery->dspName = $arrQueryInfo['dspName']; $objQuery->ipv6Address = $arrQueryInfo['ipv6Address']; $objQuery->refer = $arrQueryInfo['refer']; $objQuery->needProtect = $arrQueryInfo['needProtect']; $objQuery->protectPPSwitch = $arrQueryInfo['protectPPSwitch']; $objQuery->nojc = $arrQueryInfo['nojc']; $objQuery->super_se_flag = $arrQueryInfo['superSeFlag']; $objQuery->isContainPunc = $arrQueryInfo['isContainPunc']; $objQuery->wordNoPunc = $arrQueryInfo['wordNoPunc']; $objQuery->clusterMod = $arrQueryInfo['clusterMod']; $objQuery->wordEnc = $arrQueryInfo['wordEnc']; $objQuery->extraStr = $arrQueryInfo['extraStr']; $objQuery->strategy_state = $arrQueryInfo['strategyState']; $objQuery->prompt_flag = $arrQueryInfo['promptUsOpen']; $objQuery->passport_user_id = $arrSessionInfo['passportUserId']; $objQuery->need_interleaving = $arrQueryInfo['need_interleaving']; $objQuery->comeFrom = $arrQueryInfo['comeFrom']; if (!empty($arrQueryInfo['country'])) { $objQuery->country_str = $arrQueryInfo['country']; } $objQuery->is_sample_template = isset($arrQueryInfo['is_sample_template']) ? intval($arrQueryInfo['is_sample_template']) : 0; $objQuery->superseSwitch = isset($arrQueryInfo['superseSwitch']) ? intval($arrQueryInfo['superseSwitch']) : 1; $objQuery->query_lang = $arrQueryInfo['query_lang']; $objQuery->displayLang = $arrControlInfo['language']; if (isset($arrQueryInfo['isParams'])) { if ($arrQueryInfo['isParams']['mod'] === IS_PRE_DICT_REQ) { if (!empty($arrQueryInfo['isParams']['hsug'])) { $objQuery->hsug = $arrQueryInfo['isParams']['hsug']; } if (!empty($arrQueryInfo['isParams']['sug'])) { $objQuery->sug = $arrQueryInfo['isParams']['sug']; } if (!empty($arrQueryInfo['isParams']['clist'])) { $objQuery->clist = $arrQueryInfo['isParams']['clist']; } } $objQuery->mod = $arrQueryInfo['isParams']['mod']; $objQuery->cqid = empty($arrQueryInfo['isParams']['cqid']) ? '0' : $arrQueryInfo['isParams']['cqid']; $objQuery->isid = empty($arrQueryInfo['isParams']['isid']) ? '0' : $arrQueryInfo['isParams']['isid']; $objQuery->chk = empty($arrQueryInfo['isParams']['chk']) ? '0' : $arrQueryInfo['isParams']['chk']; if (in_array($objQuery->mod, array(IS_PRE_REQ, IS_PRE_DICT_REQ)) && in_array($objQuery->word, array('baidu', '百度'))) { $objQuery->f4s = 1; } else { $objQuery->f4s = $arrQueryInfo['isParams']['f4s']; } $objQuery->isbd = $arrQueryInfo['isParams']['isbd']; $objQuery->csq = intval($arrQueryInfo['isParams']['csq']); $objQuery->pstg = intval($arrQueryInfo['isParams']['pstg']); $objQuery->isDebugSwitch = intval($arrQueryInfo['isDebugSwitch']); } // User Agent相关字段, by chenjinsheng@baidu.com, 2013-07-08 if (!empty($arrQueryInfo['userAgent'])) { list($resx, $resy) = @explode('x', $arrQueryInfo['userAgent']['resolution']); $arrUaInfo = array('ua_os' => $arrQueryInfo['userAgent']['os'], 'ua_browser' => $arrQueryInfo['userAgent']['browser'], 'ua_modal' => $arrQueryInfo['userAgent']['modal'], 'ua_measure' => $arrQueryInfo['userAgent']['measure'], 'ua_res_x' => $resx, 'ua_res_y' => $resy); $arrExpFields = Bd_Conf::getConf('tpl_uaadaptation/UA_DICT_EXPLICIT'); $arrExpFields = array_keys($arrExpFields); foreach ($arrExpFields as $filed) { unset($arrQueryInfo['userAgent'][$filed]); } if (!empty($arrQueryInfo['userAgent'])) { $objUaFields = Util::mcpack_normal($arrQueryInfo['userAgent']); $strUaFields = mc_pack_array2pack($objUaFields); $arrUaInfo['ua_ext'] = $strUaFields; } $objQuery->uaInfo = $arrUaInfo; } $arrQuery = $objQuery->toArray(); $arrQuery = Util::mcpack_normal($arrQuery); foreach ($arrQuery as $key => $value) { if (in_array($key, array('cookie', 'beforeUrl', 'UrlParaPack', 'JpAlaPre'))) { $arrQuery['(raw)' . $key] = $value; unset($arrQuery[$key]); } } if (!isset($_ENV['HHVM'])) { ral_set_logid(CLog::logId()); $ret = ral('us', 'us', $arrQuery, Volatile::rand()); if ($ret === false) { $intErrno = ral_get_errno(); CLog::fatal('Fail to connect us, errNo:' . $intErrno, $GLOBALS['logArr']); } } else { $ral = new RalClass(); $ral->ral_set_logid(CLog::logId()); $ret = $ral->ral('us', 'us', $arrQuery, Volatile::rand()); if ($ret === false) { $intErrno = $ral->ral_get_errno(); $strErrmsg = $ral->ral_get_error($intErrno); CLog::fatal('Fail to connect us, errNo:' . $intErrno . 'errMsg: ' . $strErrmsg, $GLOBALS['logArr']); } } return $ret; }
\t<tr><td></td><td style="color:#FFF; font-size:30px;font-weight:bold;height:60px;line-height:60px;"><a style="color:#FFF; text-decoration:underline;" href="http://hradmin.baidu.com/baidu/web/templet1000/index/corpwebPosition1000baidu!getOnePosition?postIdEnc=AA0DBB2F6C2B93D2F816AAD3D0DF3E42&brandCode=1&recruitType=8&lanType=1&operational=6637AA56FA08745E71A74EA6AC68D5FFF28F462DA4C19FB3FABC8882DE74DA1C0FDB6AEAC9F8C487108CCBE39D45983B54F375AA1CAE83E6A21F36A7DBB429FDA1AA45697C458F4EC32CB3FD0222CB1A8D5A4A8AD253895E287A02A1685A127DA463AE98C819D445E3B8090A3A0351A61C8FE41D11E20AFFA9511543837DA597ADA993F4A79495C6A5915B9555926B4121D98BCC2FE67575CAED499E9C86325CC3D44DA1C73F4DA945C7FA90CE9460F2" target="_blank">百度Hi 后台服务高级研发工程师 (Linux C++)</a></td><td></td></tr> \t<tr><td></td><td style="color:#FFF; font-size:30px;font-weight:bold;height:60px;line-height:60px;"><a style="color:#FFF; text-decoration:underline;" href="http://hradmin.baidu.com/baidu/web/templet1000/index/corpwebPosition1000baidu!getOnePosition?postIdEnc=CD35036EEC4D2763&brandCode=1&recruitType=8&lanType=1&operational=6637AA56FA08745E71A74EA6AC68D5FFF28F462DA4C19FB3FABC8882DE74DA1C0FDB6AEAC9F8C487108CCBE39D45983B54F375AA1CAE83E6A21F36A7DBB429FDA1AA45697C458F4E802BB8D48AF04E0CD8535E115E550FEA155631E9A968CA951C8FE41D11E20AFFA9511543837DA597ADA993F4A79495C6A5915B9555926B4121D98BCC2FE67575CAED499E9C86325CC3D44DA1C73F4DA945C7FA90CE9460F2" target="_blank">百度Hi Windows客户端高级研发工程师</a></td><td></td></tr> \t<tr><td></td><td style="color:#FFF; font-size:30px;font-weight:bold;height:60px;line-height:60px;"><a style="color:#FFF; text-decoration:underline;" href="http://hradmin.baidu.com/baidu/web/templet1000/index/corpwebPosition1000baidu!getOnePosition?postIdEnc=ADAD2347AF9E330C72EEA80B78D4F01A&brandCode=1&recruitType=8&lanType=1&operational=6637AA56FA08745E71A74EA6AC68D5FFF28F462DA4C19FB3FABC8882DE74DA1C0FDB6AEAC9F8C487108CCBE39D45983B54F375AA1CAE83E6A21F36A7DBB429FDA1AA45697C458F4EC32CB3FD0222CB1A671C9D35ED4250D3852A502C697378DA8352F916D187D27B5C43D775BC3D82151C8FE41D11E20AFFA9511543837DA597ADA993F4A79495C6A5915B9555926B4121D98BCC2FE67575CAED499E9C86325CC3D44DA1C73F4DA945C7FA90CE9460F2" target="_blank">百度Hi 高级运营产品经理</a></td><td></td></tr> \t<tr><td></td><td style="color:#FFF; font-size:30px;font-weight:bold;height:60px;line-height:60px;"><a style="color:#FFF; text-decoration:underline;" href="http://hradmin.baidu.com/baidu/web/templet1000/index/corpwebPosition1000baidu!getOnePosition?postIdEnc=C876F7057D7391800B861EE66D2667D5&brandCode=1&recruitType=8&lanType=1&operational=6637AA56FA08745E71A74EA6AC68D5FFF28F462DA4C19FB3FABC8882DE74DA1C0FDB6AEAC9F8C487108CCBE39D45983B54F375AA1CAE83E6A21F36A7DBB429FDA1AA45697C458F4E802BB8D48AF04E0CE9FC8B4936901B11FB0FDF6243CC13A49DA54BED694EB82016BAC2EF17C11A481C8FE41D11E20AFFA9511543837DA597ADA993F4A79495C6A5915B9555926B4121D98BCC2FE67575CAED499E9C86325CC3D44DA1C73F4DA945C7FA90CE9460F2" target="_blank">百度Hi UE交互设计师</a></td><td></td></tr> \t<tr><td></td><td style="color:#FFF; font-size:30px;font-weight:bold;height:60px;line-height:60px;"><a style="color:#FFF; text-decoration:underline;" href="http://hradmin.baidu.com/baidu/web/templet1000/index/corpwebPosition1000baidu!getOnePosition?postIdEnc=6F90DB0A77E1FF7FAC33796963D90F2D&brandCode=1&recruitType=8&lanType=1&operational=6637AA56FA08745E71A74EA6AC68D5FFF28F462DA4C19FB3FABC8882DE74DA1C0FDB6AEAC9F8C487108CCBE39D45983B54F375AA1CAE83E6A21F36A7DBB429FDA1AA45697C458F4E39A7ED57320CF149A48541C64FA002124C61C0C769F3973A0B2040C17DD208361823289D3FCEC87A1C8FE41D11E20AFFA9511543837DA597ADA993F4A79495C6A5915B9555926B4121D98BCC2FE67575CAED499E9C86325CC3D44DA1C73F4DA945C7FA90CE9460F2" target="_blank">质量部_IOS 高级测试开发工程师</a></td><td></td></tr> \t<tr><td></td><td></td><td></td></tr> \t<tr><td></td><td></td><td></td></tr> \t<tr><td></td><td></td><td></td></tr> \t<tr><td></td><td></td><td></td></tr> \t<tr><td></td><td></td><td></td></tr> </table> <!--[if gte mso 9]> </v:shape> <![endif]--> EOT; $conf_mail = Bd_Conf::getConf('/CmdHandler/mail'); $mail = new PHPMailer(); $mail->IsSMTP(); // 启用SMTP $mail->Host = $conf_mail['smtp_host']; //SMTP服务器 $mail->Port = $conf_mail['smtp_port']; //端口 //$mail->SMTPAuth = true; //开启SMTP认证 $mail->Username = false; // SMTP用户名 $mail->Password = false; // SMTP密码 $mail->IsHTML(true); // 是否HTML格式邮件 $mail->CharSet = "utf-8";
/** * @brief 统一调用接口 * * @param [in/out] $strService : string 即App,表示api调用的是哪个app的接口 * @param [in/out] $strMethod : string 即App的接口 * @param [in/out] $arrParams : 输入参数 * @param [in/out] $arrFilter : array 指定返回的keys,默认null为全部返回。 * @param [in/out] $extra : array 指定输入的参数的编码,输出编码将和输入编码一致 * @return 返回值: array() or false; //正确执行,则返回数据,格式同接口表述,若错误则返回false * @retval * @see * @note * @author wiki * @date 2011/09/06 16:24:49 **/ public static function call($strService, $strMethod, $arrParams, $arrFilter = null, $extra = null) { //判断strService是否存在 //servicename是驼峰形式 $apiLib = Bd_Conf::getConf("/saf"); $strPrefix = $apiLib['api_lib']; $strServiceClass = $strPrefix . "_Api_" . ucwords($strService) . "_Service"; if (!class_exists($strServiceClass)) { //是否是service调用 $strServiceClass = $strPrefix . "_Service_" . ucwords($strService); if (class_exists($strServiceClass)) { return self::callService($strServiceClass, $strMethod, $arrParams, $arrFilter, $extra); } else { self::$errMsg = "service or api {$strService} not exist"; self::$errNo = self::SERVICE_NOT_EXIST; return false; } } //判断strMethod是否存在 $objService = new $strServiceClass(); if (!method_exists($objService, $strMethod)) { self::$errNo = self::METHOD_NOT_EXIST; self::$errMsg = "class {$strServiceClass} method {$strMethod} not exist"; return false; } //输入参数编码格式转换成service内部的编码格式 if (is_array($extra) && isset($extra['ie']) && $objService->getServieEncode() != strtolower($extra['ie'])) { $arrParams = Bd_String::iconv_recursive($arrParams, strtolower($extra['ie']), $objService->getServieEncode()); } else { if ($extra !== null && (!is_array($extra) || !isset($extra['ie']))) { self::$errNo = self::EXTRA_INVALID; self::$errMsg = "{$strService}::{$strMethod} failed with invalid extra"; return false; } } //输入格式检查 $strMethodReqClass = $strPrefix . "_Api_" . ucwords($strService) . "_Entity_Req" . $strMethod; $strMethodResClass = $strPrefix . "_Api_" . ucwords($strService) . "_Entity_Res" . $strMethod; if (!class_exists($strMethodReqClass)) { self::$errNo = self::INPUT_INVALID; self::$errMsg = "class {$strMethodReqClass} not exist"; return false; } if (!class_exists($strMethodResClass)) { self::$errNo = self::OUTPUT_CHANGED; self::$errMsg = "class {$strMethodResClass} not exist"; return false; } $objMethodReq = new $strMethodReqClass(); $res = $objMethodReq->loadFromArray($arrParams); if (!$res) { self::$errNo = self::INPUT_INVALID; self::$errMsg = "{$strService}::{$strMethod} failed with invalid Input"; return false; } $objMethodRes = new $strMethodResClass(); $res = call_user_func_array(array($objService, $strMethod), array($objMethodReq, $objMethodRes, $arrFilter, $extra)); if ($res === false) { if ($objService->errno != null) { self::$serviceErr = $objService->errno; } else { self::$serviceErr = array(); } self::$errNo = self::METHOD_FAILED; self::$errMsg = "{$strService}::{$strMethod} failed in process"; return false; } if ($res == null) { self::$errNo = self::OUTPUT_CHANGED; self::$errMsg = "{$strService}::{$strMethod} failed with changed output"; return false; } $arrRes = $res->toArray(); //返回值过滤 if (is_array($arrFilter)) { foreach ($arrFilter as $key) { if (isset($arrRes[$key])) { unset($arrRes[$key]); } } } //Service返回值的编码格式和应用客户端编码格式不一致,则转换为api输入的编码格式 if (is_array($extra) && isset($extra['ie']) && $objService->getServieEncode() != strtolower($extra['ie'])) { $arrRes = Bd_String::iconv_recursive($arrRes, $objService->getServieEncode(), $extra['ie']); } //$arrRes = $objMethodRes->toArray(); //$objMethodRes->toArray(); //输出格式要求 return $arrRes; }
/** * @brief 获取db对象 * * @param $clusterName 集群名称 * @param $key 负载均衡key * @param $getNew 是否重新连接 * * @return */ public static function getConn($clusterName, $key = NULL, $getNew = false) { $hookBeforeInit = Bd_Conf::getConf('/db/hook_before_init'); if ($hookBeforeInit === false) { //cannot find hookBeforeInit in conf file self::$_error['errno'] = LOAD_CONF_ERROR; self::$_error['error'] = 'Can not read hookBeforeInit, please check db/global.conf'; Bd_Log::warning(self::$_error['error'], self::$_error['errno']); return false; } if ($hookBeforeInit != NULL) { //user sets hookBeforeInit if (is_callable($hookBeforeInit)) { $clusterName = call_user_func($hookBeforeInit, $clusterName); } else { //warnning self::$_error['errno'] = SET_HOOK_ERROR; self::$_error['error'] = 'Hook(beforinit):' . $before . 'is not callable'; Bd_Log::warning(self::$_error['error'], self::$_error['errno']); } } $conf =& self::$_conf; $hosts =& self::$_hosts; $dbData =& self::$_dbData; $lastDb =& self::$_lastDb; //(1) alreay save a connection (2)user do not need to recreate if (!empty($lastDb[$clusterName]) && !$getNew) { Bd_Log::trace('Return an existing connection', 0, array('db_cluster' => $clusterName)); return $lastDb[$clusterName]; } if (self::_init($clusterName) === false) { return false; } //create a new db object $db = new Bd_DB(Bd_Db_ConnMgr::$ENABLE_PROFILING); //add hook if ('' !== ($before = $conf['hook_before_query'])) { if (!$db->addHook(Bd_Db::HK_BEFORE_QUERY, $clusterName . '-before', $before)) { self::$_error['errno'] = SET_HOOK_ERROR; self::$_error['error'] = 'Hook(befor query):' . $before . ' is not callable'; Bd_Log::warning(self::$_error['error'], self::$_error['errno']); } } if ('' !== ($after = $conf['hook_after_query'])) { if (!$db->addHook(Bd_Db::HK_AFTER_QUERY, $clusterName . '-after', $after)) { self::$_error['errno'] = SET_HOOK_ERROR; self::$_error['error'] = 'Hook(after query):' . $after . ' is not callable'; Bd_Log::warning(self::$_error['error'], self::$_error['errno']); } } if ('' !== ($onFail = $conf['hook_on_fail'])) { if (!$db->onFail($onFail)) { self::$_error['errno'] = SET_HOOK_ERROR; self::$_error['error'] = 'Hook(on fail):' . $onFail . ' is not callable'; Bd_Log::warning(self::$_error['error'], self::$_error['errno']); } } //try to connect host until there is not host or connecting successfully while (true) { //balancer could not select a valid host to connect if (count($hosts['valid_hosts']) === 0 || ($index = $dbData['host_selector']->select($hosts, $key)) === false) { self::$_error['errno'] = ALL_CONNECT_ERROR; self::$_error['error'] = 'No host could be connected in the cluster'; Bd_Log::warning(self::$_error['error'], self::$_error['errno'], array('db_cluster' => $clusterName)); $hookOnConnFail = $conf['hook_on_connect_fail']; if ($hookOnConnFail != NULL) { if (is_callable($hookOnConnFail)) { call_user_func($hookOnConnFail); } else { //warnning self::$_error['errno'] = SET_HOOK_ERROR; self::$_error['error'] = 'Hook(on connect fail):' . $hookOnConnFail . 'is not callable'; Bd_Log::warning(self::$_error['error'], self::$_error['errno']); } } return false; } //log parameters $logPara = array('db_cluster' => $clusterName, 'db_host' => $hosts['valid_hosts'][$index]['ip'], 'db_port' => $hosts['valid_hosts'][$index]['port'], 'default_db' => $conf['default_db']); for ($i = 1; $i <= $conf['retry_times']; $i++) { $timeout = $conf['connect_timeout_s']; if ($timeout > 0) { $db->setConnectTimeOut($timeout); } $r_timeout = $conf['read_timeout_s']; if ($r_timeout > 0) { $db->setOption(MYSQL_OPT_READ_TIMEOUT, $r_timeout); } $w_timeout = $conf['write_timeout_s']; if ($w_timeout > 0) { $db->setOption(MYSQL_OPT_WRITE_TIMEOUT, $w_timeout); } Bd_Log::debug("retry times: {$i}"); $start = microtime(true) * 1000; //connect $ret = $db->connect($hosts['valid_hosts'][$index]['ip'], $conf['username'], $conf['password'], $conf['default_db'], $hosts['valid_hosts'][$index]['port'], $conf['connect_flag']); $end = microtime(true) * 1000; if ($ret) { if (empty($conf['charset']) || $db->charset($conf['charset'])) { $logPara['time_ms'] = $end - $start; Bd_Log::trace('Connect to Mysql successfully', 0, $logPara); $lastDb[$clusterName] = $db; return $lastDb[$clusterName]; } else { Bd_Log::debug('Set charset failed'); } } } //connect failed self::$_error['errno'] = CONNECT_ERROR; self::$_error['error'] = 'Connect to Mysql failed'; Bd_Log::warning(self::$_error['error'], self::$_error['errno'], $logPara); self::_recordFailedHost($index); } return false; }
public static function getSpeedConf($nettype, $browser, $sampling) { $result = array('keepalive' => array(), 'prefetch' => 0); $speed_conf = Bd_Conf::getAppConf('speed'); $prefetch_conf = Bd_Conf::getConf('prefetch'); //get keepalive conf if (!empty($speed_conf)) { if (!(empty($nettype) || empty($browser))) { if ($browser == 'ucweb applewebkit') { $browser = 'ucwebapplewebkit'; } if (isset($speed_conf['keepalive']['interval'][$nettype][$browser])) { $result['keepalive']['interval'] = $speed_conf['keepalive']['interval'][$nettype][$browser]; } if (isset($speed_conf['keepalive']['duration'][$nettype][$browser])) { $result['keepalive']['duration'] = $speed_conf['keepalive']['duration'][$nettype][$browser]; } } } //for keepalive sampling if ($sampling['match'] && is_array($sampling['vars']['interval']) && isset($sampling['vars']['interval'][0])) { $result['keepalive']['interval'] = $sampling['vars']['interval'][0]; } //get prefetch conf if (!empty($prefetch_conf)) { if (isset($prefetch_conf['prefetch']['enabled'])) { $result['prefetch'] = $prefetch_conf['prefetch']['enabled']; } } return $result; }
/** * @brief 检查userip是否在白名单内 * * @return private function * @retval * @see * @note * @author luhaixia * @date 2012/07/31 14:33:43 **/ private function userIpValid() { $userIp = Bd_Ip::getUserIp(); $validIpList = Bd_Conf::getConf('omp/iplist'); if (is_array($validIpList)) { foreach ($validIpList as $ip) { if ($userIp == $ip['IP']) { return true; } } } return false; }
private static function _enableProfiling() { if (!self::$bolInit) { $arrConf = Bd_Conf::getConf('profiler/log'); if (false !== $arrConf) { self::$enableProfiling = isset($arrConf['level']) ? (bool) $arrConf['level'] : true; self::$maxLogNum = isset($arrConf['maxlognum']) ? (int) $arrConf['maxlognum'] : 100; } self::$bolInit = true; } return self::$enableProfiling; }
/** * 模板回退,重新加载相应的模板配置 * @param unknown_type $data * @param unknown_type $strBakTemplateType 需要回退到的模板类型 默认baidu * @param unknown_type $strBakTemplateName 需要回退到的模板名字 默认baidu */ public static function templateBack(&$data, $strBakTemplateType = 'baidu', $strBakTemplateName = 'baidu') { $data['uiControl']['templateType'] = $strBakTemplateType; $data['uiControl']['templateName'] = $strBakTemplateName; $data['uiControl']['oriTplName'] = $strBakTemplateName; $GLOBALS['logArr']['templateType'] = $data['uiControl']['templateType']; $GLOBALS['logArr']['templateName'] = $data['uiControl']['templateName']; $objTemplateSelector = new TemplateSelector(); $bolRet = $objTemplateSelector->getUserInfo($data); if ($bolRet == false) { $status = $GLOBALS['STATUS_CODE']['TPL_SELECT_FAIL']; CLog::fatal($GLOBALS['STATUS_MSG'][$status], $status, $GLOBALS['logArr']); $result['status'] = $status; return false; } $arrTplConfig = $objTemplateSelector->getTplConfig($data['uiControl']['tplConfigPath']); if (!is_array($arrTplConfig) || empty($arrTplConfig) || count($arrTplConfig) <= 0) { $status = $GLOBALS['STATUS_CODE']['TPL_SELECT_FAIL']; CLog::fatal($GLOBALS['STATUS_MSG'][$status], $status, $GLOBALS['logArr']); return $status; } // 处理首页模板 if ($data['uiControl']['templateSwitch'] == 2) { $arrFrontPage = Bd_Conf::getConf('/baidu/'); if (!empty($arrFrontPage) && is_array($arrFrontPage)) { foreach ($arrFrontPage as $key => $value) { $arrTplConfig[$key] = $value; } } } // 解析模板配置项 $objTemplateSelector->parseTplConfig($data, $arrTplConfig); unset($arrData['uiControl']['tplConfigPath']); unset($arrData['uiControl']['tplConfigName']); unset($arrData['uiControl']['tplConfigType']); return true; }
public static function notice($str, $errno = 0, $arrArgs = null, $depth = 0) { if (self::isOMP() == 0 || self::isOMP() == 1) { $strFormat = self::DEFAULT_FORMAT_STD; if ((bool) Bd_Conf::getConf("/log/OMP/cookie")) { $strFormat = self::DEFAULT_FORMAT_STD_DETAIL; } $ret = self::getInstance()->writeLog(self::LOG_LEVEL_NOTICE, $str, $errno, $arrArgs, $depth + 1, '.new', $strFormat); } if (self::isOMP() == 0 || self::isOMP() == 2) { $ret = self::getInstance()->writeLog(self::LOG_LEVEL_NOTICE, $str, $errno, $arrArgs, $depth + 1); } }
/** * @brief 根据参数或instance获取该instance内部序号 * * @param $instance 指定的instance字符串,不传则为当前 * * @return */ public static function getInstanceIndex($instance = null) { if ($instance === null) { $instance = self::$_instance; } if (empty(self::$_instance_idx)) { self::$_instance_idx = Bd_Conf::getConf('/i18n/i18n/instances'); if (empty(self::$_instance_idx)) { Bd_Log::warning(" instances => index is empty! check /i18n/i18n.conf"); } } foreach (self::$_instance_idx as $_v) { if ($_v['instance'] === $instance) { return $_v['index']; } } return null; }