예제 #1
0
파일: Hook.php 프로젝트: drehere/shenmegui
 /**
  * @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;
 }
예제 #2
0
파일: Sample.php 프로젝트: WayWingsDev/mis
 public function execute($arrInput)
 {
     Bd_Log::debug('sample page service called');
     $arrResult = array();
     $arrResult['errno'] = 0;
     try {
         $intId = intval($arrInput['id']);
         if ($intId <= 0) {
             //参数错误的时候,从配置文件取消息
             $strData = Bd_Conf::getAppConf('sample/msg');
             $arrResult['data'] = $strData;
         } else {
             if ($this->objServiceDataSample->isExist($intId)) {
                 //以下获取数据的方式提供3种示例,3选1
                 //1. 调用本地DS
                 $strData = $this->objServiceDataSample->getSample($intId);
                 //2. 子系统交互, 注意:请确保conf/saf.conf中的api_lib配置成Navi, 否则会出错
                 //$strData = $this->objServiceDataSample->callOtherApp($intId);
                 //3. 调用本地库
                 //$objUtil = new App2_Util();
                 //$strData = $objUtil->getUtilMsg();
                 $arrResult['data'] = $strData;
             } else {
                 $arrResult['errno'] = 222;
                 //示例错误码
             }
         }
     } catch (Exception $e) {
         Bd_Log::warning($e->getMessage(), $e->getCode());
         $arrResult['errno'] = $e->getCode();
     }
     return $arrResult;
 }
예제 #3
0
 /**
  * 精确的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;
 }
예제 #4
0
 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;
 }
예제 #5
0
 /**
  * @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;
     }
 }
예제 #6
0
 public function invoke($arrInput)
 {
     try {
         $strAppName = $arrInput["appName"];
         $strActionName = $arrInput["actionName"];
         //获取所有模块的名称
         $strCurPath = dirname(__FILE__);
         $strParamConfName = "param_" . strtolower(str_replace("/", "_", $strActionName));
         $strParamConfPath = $strCurPath . "/../../../../../../conf/app/{$strAppName}/{$strParamConfName}.conf";
         $arrRet["errno"] = Navilib_CommonError::SUCCESS;
         $arrRet["data"]["actionParamPath"] = $strParamConfPath;
         //解析参数
         $arrConf = Bd_Conf::getAppConf($strParamConfName, $strAppName);
         foreach ($arrConf as $strParamName => &$arrItem) {
             $arrItem['type'] = self::_getParamType(intval($arrItem['type']));
         }
         $arrRet["data"]["actionParamList"] = $arrConf;
         //解析注释
         if ($mixFileHandle = fopen($strParamConfPath, 'r+')) {
             while (!feof($mixFileHandle)) {
                 $strLine = trim(fgets($mixFileHandle));
                 if (preg_match(self::$regDescription, $strLine, $arrContent)) {
                     $arrRet["data"]['description'] = $arrContent[1];
                 }
                 if (preg_match(self::$regAuthor, $strLine, $arrContent)) {
                     $arrRet["data"]['author'] = $arrContent[1];
                 }
             }
         }
         return Navilib_Utils::result($arrRet["errno"], $arrRet["data"]);
     } catch (Exception $e) {
         Bd_Log::warning($e->getMessage(), $e->getCode());
         return Navilib_Utils::result($e->getCode(), array());
     }
 }
예제 #7
0
 /**
  * @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;
 }
예제 #8
0
파일: Cgi.php 프로젝트: drehere/shenmegui
 /**
  * 网页编码与程序编码转化
  * 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;
 }
예제 #9
0
파일: PhpCas.php 프로젝트: WayWingsDev/mis
 /**
  * @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;
 }
예제 #10
0
파일: Factory.php 프로젝트: WayWingsDev/mis
 public static function loadConfName($confName)
 {
     $debug_open = (int) Bd_Conf::getAppConf('debug/open');
     if ($debug_open === 1) {
         $confName .= "_debug";
     }
     return $confName;
 }
예제 #11
0
 public function __construct($conf)
 {
     parent::__construct($conf);
     $this->_conf = Bd_Conf::getAppConf("FeedbackAdmin");
     //        $this->objServiceDataTrack = new Service_Data_Track_V1_Track();
     $this->ignoreLogin = true;
     $this->ignoreSign = true;
 }
예제 #12
0
 public function __construct()
 {
     $message_conf = "message/Message";
     if (Bd_Conf::getAppConf('debug/open')) {
         $message_conf = "message_debug/Message";
     }
     $this->_proxy = new Navilib_DBFactory($message_conf);
 }
예제 #13
0
파일: Conf.php 프로젝트: drehere/shenmegui
 /**
  * @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;
 }
예제 #14
0
 public function invoke($arrInput)
 {
     try {
         $strUrlHost = $arrInput["urlHost"];
         $strAppName = $arrInput["appName"];
         self::$_strPath = $arrInput["urlPath"];
         $strActionName = $arrInput["actionName"];
         $strUrl = $strUrlHost . "/" . $strAppName . "/" . self::$_strPath;
         //获取所有模块的名称
         $strCurPath = dirname(__FILE__);
         $strParamConfName = "param_" . strtolower(str_replace("/", "_", $strActionName));
         $strTestConfName = "test_" . strtolower(str_replace("/", "_", $strActionName));
         $strParamConfPath = "conf/app/{$strAppName}/{$strParamConfName}.conf";
         $strTestConfPath = "conf/app/{$strAppName}/{$strTestConfName}.conf";
         $arrRet["errno"] = Navilib_CommonError::SUCCESS;
         //解析参数配置
         $arrParamConf = Bd_Conf::getAppConf($strParamConfName, $strAppName);
         if (false === ($arrUrlParam = self::_getUrlParam($arrParamConf, $strParamConfPath, $strAppName))) {
             $arrRet['data']['testResult'] = self::$_strResult;
             return Navilib_Utils::result($arrRet["errno"], $arrRet["data"]);
         }
         //var_dump($arrParamConf);
         //解析test配置
         $arrTestConf = Bd_Conf::getAppConf($strTestConfName, $strAppName);
         if (false === $arrTestConf) {
             self::_appendResult("测试配置文件" . $strTestConfPath . "不存在,将使用默认策略来进行测试", self::CONTENT_WARNING);
             //默认的配置是:call_type为post,errno为0
             $arrTestConf = array('call_type' => 'post', 'result' => array('errno' => 0));
         }
         if (isset($arrTestConf["call_type"])) {
             self::$_strCallType = strtolower($arrTestConf["call_type"]);
         }
         self::_appendResult("使用" . self::$_strCallType . "方式请求" . $strUrl . "?" . http_build_query($arrUrlParam));
         $strType = self::$_strCallType;
         if ("post" === self::$_strCallType) {
             $strType = true;
         } elseif ("get" === self::$_strCallType) {
             $strType = false;
         }
         //通过fetchurl访问url
         $str = Navilib_NetUtil::getUrlContent($strUrl, $arrUrlParam, $strType);
         $mixData = json_decode($str, true);
         //检查结果
         self::_checkTest($mixData, $arrTestConf["result"]);
         if (true === self::$_bolTestRet) {
             self::_appendResult("测试通过");
         } else {
             self::_appendResult("测试未通过", self::CONTENT_FATAL);
         }
         $arrRet['data']['testResult'] = self::$_strResult;
         return Navilib_Utils::result($arrRet["errno"], $arrRet["data"]);
     } catch (Exception $e) {
         Bd_Log::warning($e->getMessage(), $e->getCode());
         return Navilib_Utils::result($e->getCode(), array());
     }
 }
예제 #15
0
 /**
  * @brief 构造函数,读取service的配置
  *
  * @return   
  * @retval   
  * @see 
  * @note 
  * @author wiki
  * @date 2011/09/06 16:12:35
  **/
 public function __construct($service = MAIN_APP)
 {
     $this->service = $service;
     //读service的配置文件
     $arrConf = Bd_Conf::getMyConf("service/app_" . strtolower($this->service));
     $this->bolLocal = $arrConf['proxy'] === 'php' ? true : false;
     $this->defaultUrl = "/api/" . $this->service . "/data?fromapi=1";
     $this->oe = null;
     //命名方式同saf
 }
예제 #16
0
 public function __construct()
 {
     $this->_conf = Bd_Conf::getAppConf("FeedbackAdmin");
     //$this->_proxy = new Navilib_DBFactory('messageOperation/Message');
     $messageConf = 'message/Message';
     if (Bd_Conf::getAppConf('debug/open')) {
         $messageConf = "message_debug/Message";
     }
     $this->_proxy = new Navilib_DBFactory($messageConf);
 }
예제 #17
0
 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;
 }
예제 #18
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');
     }
 }
예제 #19
0
 /**
  * @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;
         }
     }
 }
예제 #20
0
파일: Message.php 프로젝트: WayWingsDev/mis
 public function __construct()
 {
     $this->objOperation = new Dao_Message_V2_Operation();
     //$this->_bcs = new Bcs_Util();
     /*
     $bcsConf['host'] = 'bcs.duapp.com';
     $bcsConf['bucket'] = 'operation-storage';
     $bcsConf['ak'] = 'fVAhPlTUjPnhCBp00XAgTDBE';
     $bcsConf['sk'] = 'QpNac1pFdTsGMGM6X6aBpbNo1TMIFp4c';
     */
     $bcsConf = Bd_Conf::getAppConf('operationMessage/bcsConf');
     $this->_bcs = Navilib_Bcs_Helper::getInstance($bcsConf);
 }
예제 #21
0
파일: Mis.php 프로젝트: WayWingsDev/mis
 public function __construct()
 {
     $debug = intval(Bd_Conf::getAppConf("debug/open"));
     if (0 === $debug) {
         $this->proxy = new Navilib_DBFactory("mis/Mis", 1);
     } else {
         $this->proxy = new Navilib_DBFactory("mis_debug/Mis");
     }
     if (!$this->proxy) {
         Bd_Log::fatal("Mysql connect failed");
         throw new Exception(Navilib_CommonError::$ERRMSG[Navilib_CommonError::MYSQL_CONNECT_FAILED], Navilib_CommonError::MYSQL_CONNECT_FAILED);
     }
 }
예제 #22
0
 public function invoke($arrInput)
 {
     //用于登录
     $params = $arrInput['data'];
     $params = json_decode(base64_decode($params), true);
     $url = Bd_Conf::getAppConf('intelligence/url');
     $ret = Navilib_NetUtil::getUrlContent($url, $params);
     $ret = $ret ? json_decode($ret, true) : false;
     $return = array('errno' => 0, 'errmsg' => 'success');
     if ($ret['errno'] !== 0) {
         $return['errno'] = 1;
         $return['errmsg'] = '通知情报系统失败';
     }
     return $return;
 }
예제 #23
0
 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);
         }
     }
 }
예제 #24
0
 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;
 }
예제 #25
0
 /**
  * @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;
 }
예제 #26
0
 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;
 }
예제 #27
0
 /**
  * @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;
 }
예제 #28
0
파일: Base.php 프로젝트: drehere/shenmegui
 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;
 }
예제 #29
0
파일: Action.php 프로젝트: WayWingsDev/mis
 public function execute()
 {
     // 验证控制器反问权限
     $this->controller = $this->getRequest()->getControllerName();
     $this->action = $this->getRequest()->getActionName();
     $valid_users = Bd_Conf::getAppConf('operation/user');
     // 临时方案,继承该类的action需要验证用户
     $valid_access = false;
     foreach ($valid_users as $k => $v) {
         if ($v['name'] == CURRENT_USER) {
             $valid_access = true;
             break;
         }
     }
     if ($valid_access) {
         $this->invoke();
     } else {
         Net_Util::showAndReturn("没有权限\\n有需要可以找zhangyuliang01", '/naviServerAdmin/index');
         exit;
     }
 }
예제 #30
0
 /**
  * 
  *
  * @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.");
     }
 }