Esempio n. 1
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());
     }
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
 /**
  * 网页编码与程序编码转化
  * 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;
 }
Esempio n. 5
0
 /**
  * @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;
 }
Esempio n. 6
0
 public static function loadConfName($confName)
 {
     $debug_open = (int) Bd_Conf::getAppConf('debug/open');
     if ($debug_open === 1) {
         $confName .= "_debug";
     }
     return $confName;
 }
Esempio n. 7
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;
 }
Esempio n. 8
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);
 }
Esempio n. 9
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());
     }
 }
Esempio n. 10
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);
 }
Esempio n. 11
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;
         }
     }
 }
Esempio n. 12
0
 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);
     }
 }
Esempio n. 13
0
 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);
 }
Esempio n. 14
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;
 }
Esempio n. 15
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;
 }
Esempio n. 16
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);
         }
     }
 }
Esempio n. 17
0
 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;
     }
 }
Esempio n. 18
0
File: Log.php Progetto: fanscout/omz
 public static function getInstance($app = null, $logType = null)
 {
     if (empty($app)) {
         $app = self::getLogPrefix();
     }
     if (empty(self::$arrInstance[$app])) {
         $g_log_conf = Bd_Conf::getConf('/log/');
         $app_log_conf = Bd_Conf::getAppConf('log', $app);
         // app配置优先
         if (is_array($app_log_conf)) {
             $g_log_conf = array_merge($g_log_conf, $app_log_conf);
         }
         // 生成路径
         $logPath = self::getLogPath();
         if ($g_log_conf['use_sub_dir'] == "1") {
             if (!is_dir($logPath . "/{$app}")) {
                 @mkdir($logPath . "/{$app}");
             }
             $log_file = $logPath . "/{$app}/{$app}.log";
         } else {
             $log_file = $logPath . "/{$app}.log";
         }
         if ($logType == "stf") {
             $logDir = dirname($log_file) . "/" . $logType . "/";
             if (!file_exists($logDir)) {
                 @mkdir($logDir);
             }
             $log_file = $logDir . $app . "_" . $logType . ".log";
         }
         //get log format
         if (isset($g_log_conf['format'])) {
             $format = $g_log_conf['format'];
         } else {
             $format = self::DEFAULT_FORMAT;
         }
         if (isset($g_log_conf['format_wf'])) {
             $format_wf = $g_log_conf['format_wf'];
         } else {
             $format_wf = $format;
         }
         $log_conf = array('level' => intval($g_log_conf['level']), 'auto_rotate' => $g_log_conf['auto_rotate'] == '1', 'log_file' => $log_file, 'format' => $format, 'format_wf' => $format_wf);
         self::$arrInstance[$app] = new Bd_Log($log_conf);
     }
     return self::$arrInstance[$app];
 }
Esempio n. 19
0
 /**
  * @brief 取得app相关配置文档
  *
  * @param  $confItem 配置所在路径
  * @return success-array或者string failed-false
  * @retval array/boolean
  * @author chenyijie
  * @date 2012/09/27 17:20:22
  **/
 protected function _getConf($confRoute)
 {
     $conf = Bd_Conf::getAppConf($confRoute, Bd_AppEnv::getCurrApp());
     if ($conf === false) {
         $arrErr = array('caller' => 'CacheProxy', 'class' => get_class($this->objClass));
         Bd_Log::warning("Get config from config file: " . $confRoute . " failed.", self::GET_CONF_FAILED, $arrErr);
         self::$errCode = self::GET_CONF_FAILED;
     }
     return $conf;
 }
Esempio n. 20
0
 /**
  * 获取消息消息中心地址
  * @param $path string
  * @param $param array
  * @return string
  **/
 public static function getSiteUrl($path, $params = array())
 {
     $host = Bd_Conf::getAppConf('webconfig/domain');
     if (!$host) {
         $host = $_SERVER['HTTP_HOST'];
     }
     if (!$host) {
         return false;
     }
     $url = "http://{$host}{$path}?" . http_build_query($params);
     return $url;
 }
Esempio n. 21
0
 private static function initAp()
 {
     // 读取App的ap框架配置
     require_once LIB_PATH . '/bd/Conf.php';
     $ap_conf = Bd_Conf::getAppConf('ap');
     // 设置代码目录,其他使用默认或配置值
     $ap_conf['directory'] = Bd_AppEnv::getEnv('code');
     // 生成ap实例
     $app = new Ap_Application(array('ap' => $ap_conf));
     return true;
 }
Esempio n. 22
0
 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;
 }
Esempio n. 23
0
 public static function getOnlineInfo($srcid = '', &$data)
 {
     $data['isonline'] = false;
     if (empty($srcid)) {
         return;
     }
     $onlineConf = Bd_Conf::getAppConf('online');
     if (!empty($onlineConf) && !empty($onlineConf['srcid']) && !empty($onlineConf['appid'])) {
         $appid = $onlineConf['srcid'][$srcid];
         if (!empty($appid) && !empty($onlineConf['appid'][$appid])) {
             $appInfo = $onlineConf['appid'][$appid];
             $data['apikey'] = $appInfo['apikey'];
             $secretkey = $appInfo['secretkey'];
             $data['type'] = $appInfo['type'];
             $data['url'] = $appInfo['url'];
             $data['ajaxurl'] = $appInfo['ajaxurl'];
             $data['prixurl'] = $appInfo['prixurl'];
             if (preg_match('/^(\\w+\\:\\/\\/[^\\/ ]+)([^ ]*)/', trim($data['ajaxurl']), $matches)) {
                 $data['ajaxurl'] = Wise_Utils::getHttpsHost($matches[1]) . $matches[2];
             }
             if (!empty($data['apikey']) && !empty($secretkey)) {
                 $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
                 $password = '';
                 for ($i = 0; $i < 10; $i++) {
                     $password .= $chars[mt_rand(0, strlen($chars) - 1)];
                 }
                 $data['nonce'] = $password;
                 $data['csrftoken'] = md5($data['nonce'] . $secretkey);
                 $data['isonline'] = true;
             }
         }
     }
 }
Esempio n. 24
0
 public function __construct()
 {
     $this->_conf = Bd_Conf::getAppConf("FeedbackAdmin");
 }