Exemplo 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());
     }
 }
Exemplo n.º 2
0
 public function invoke($arrInput)
 {
     try {
         //获取所有模块的名称
         $strCurPath = dirname(__FILE__);
         $strAppPath = $strCurPath . "/../../../../../";
         $arrRet["errno"] = Navilib_CommonError::SUCCESS;
         $arrRet["data"]["appPath"] = $strAppPath;
         if (is_dir($strAppPath)) {
             if ($objHandler = opendir($strAppPath)) {
                 while (($strFile = readdir($objHandler)) !== false) {
                     //只需要遍历出第一层目录
                     if (is_dir($strAppPath . "/" . $strFile) && $strFile != "." && $strFile != "..") {
                         $arrRet["data"]["appList"][] = $strFile;
                     }
                 }
                 closedir($objHandler);
             }
         }
         sort($arrRet["data"]["appList"]);
         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());
     }
 }
Exemplo n.º 3
0
 protected function invoke($arrInput)
 {
     $arrResult = array();
     $arrResult['errno'] = 0;
     try {
         $this->objServiceDataMessage = new Service_Data_Message_V1_Message();
         $data['operation_title'] = $arrInput['operation_title'];
         $data['operation_content'] = $arrInput['operation_content'];
         $data['operation_link'] = $arrInput['operation_link'];
         $data['select_city'] = intval($arrInput['select_city']);
         if (isset($_FILES["operation_pic_address_vertical"])) {
             $ret = $this->objServiceDataMessage->uploadPic($_FILES["operation_pic_address_vertical"]);
             if (false === $ret) {
                 return Navilib_Utils::result(Navilib_CommonError::FAIL);
             }
             $data['operation_pic_address_vertical'] = $ret;
         }
         if (isset($_FILES["operation_pic_address_across"])) {
             $ret = $this->objServiceDataMessage->uploadPic($_FILES["operation_pic_address_across"]);
             if (false === $ret) {
                 return Navilib_Utils::result(Navilib_CommonError::FAIL);
             }
             $data['operation_pic_address_across'] = $ret;
         }
         $data['start_time'] = strtotime($arrInput['start_time']);
         $data['end_time'] = strtotime($arrInput['end_time']);
         $ret = $this->objServiceDataMessage->insert_operation_in_db($data);
     } catch (Exception $e) {
         Bd_Log::warning($e->getMessage(), $e->getCode());
         $arrResult['errno'] = $e->getCode();
     }
     return $arrResult;
 }
Exemplo n.º 4
0
 public function getRecode($strUname, $strUrlKeyWord, $intOffset, $intLimit)
 {
     $field = array("uname", "url_host", "app_name", "action_info", "call_type", "param", "url", "op_time");
     $conds = array("uname = " => $strUname, "url like" => "%{$strUrlKeyWord}%");
     $appends = array("order by op_time desc limit {$intOffset}, {$intLimit}");
     $ret = $this->proxy->select(self::TABLE_TESTMAN_RECODE, $field, $conds, $option, $appends);
     if (false === $ret) {
         Bd_Log::fatal("Mysql query failed in " . __FUNCTION__);
         return Navilib_Utils::result(Navilib_CommonError::MYSQL_QUERY_FAILED);
     }
     return Navilib_Utils::result(Navilib_CommonError::SUCCESS, $ret);
 }
Exemplo n.º 5
0
 public function invoke($arrInput)
 {
     try {
         $objDataService = new Service_Data_Testman();
         $strUrlHost = trim($arrInput["urlHost"]);
         $strProxyHost = $objDataService->replaceOnlineHost($strUrlHost);
         $arrRet = array("errno" => Navilib_CommonError::SUCCESS, "data" => array("urlHost" => $strUrlHost, "appName" => trim($arrInput["appName"]), "proxyHost" => $strProxyHost));
         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());
     }
 }
Exemplo n.º 6
0
 public function invoke($arrInput)
 {
     try {
         $strSignCode = $arrInput["signCodeForCreateSign"];
         $objDataService = new Service_Data_Testman();
         $strSign = $objDataService->createSign($strSignCode, $_POST, $_FILES);
         //开始生成签名
         $arrRet = array("errno" => Navilib_CommonError::SUCCESS, "data" => $strSign);
         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());
     }
 }
Exemplo n.º 7
0
 public function invoke($arrInput)
 {
     try {
         $strUrlKeyWord = $arrInput["urlKeyWord"];
         $intOffset = intval($arrInput["offset"]);
         $intLimit = intval($arrInput["limit"]);
         $objDataService = new Service_Data_Testman();
         $arrRet = $objDataService->getRecode(CURRENT_USER, $strUrlKeyWord, $intOffset, $intLimit);
         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());
     }
 }
Exemplo n.º 8
0
 public function invoke($arrInput)
 {
     try {
         $strAppName = $arrInput["appName"];
         //获取所有模块的名称
         $strCurPath = dirname(__FILE__);
         $strDataPath = $strCurPath . "/../../../../../{$strAppName}/models/service/data";
         $arrRet["errno"] = Navilib_CommonError::SUCCESS;
         $arrRet["data"]["dataPath"] = $strDataPath;
         self::_iterDir($strDataPath, $arrRet);
         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());
     }
 }
Exemplo n.º 9
0
 public function invoke($arrInput)
 {
     try {
         $strUrlHost = $arrInput["urlHostForCurlProxy"];
         $strAppName = $arrInput["appNameForCurlProxy"];
         $strActionInfo = $arrInput["actionInfoForCurlProxy"];
         $strCallType = $arrInput["callTypeForCurlProxy"];
         $arrParamType = json_decode($arrInput["paramTypeForCurlProxy"]);
         $arrUrlParam = array();
         //解析出待发起请求的所有参数
         foreach ($arrParamType as $strParamName => $strType) {
             $arrUrlParam[$strParamName]["type"] = $strType;
             if ("file" !== $strType) {
                 $arrUrlParam[$strParamName]["value"] = $_POST[$strParamName];
             } else {
                 $arrUrlParam[$strParamName]["value"] = "";
             }
         }
         /*foreach ($_POST as $strKey => $strVal) {
         		if($strKey !== 'urlHostForCurlProxy' &&
         			$strKey !== 'appNameForCurlProxy' &&
         			$strKey !== 'actionInfoForCurlProxy' &&
         			$strKey !== 'callTypeForCurlProxy' &&
         			$strKey !== 'paramTypeForCurlProxy' &&
         			$strKey !== 'signCodeForCreateSign') {
             		$arrUrlParam[$strKey] = $strVal;
         		}
             }
             foreach ($_FILES as $strKey => $arrItem) {
             	$arrUrlParam[$strKey] = '@upload_file';
             }*/
         //没有对应的用户,直接退出
         if (strlen(CURRENT_USER) <= 0) {
             Bd_Log::warning("username is null");
             return Navilib_Utils::result(Navilib_CommonError::USER_NOT_LOGIN, array());
         }
         $objDataService = new Service_Data_Testman();
         $arrRet = $objDataService->addRecode(CURRENT_USER, $strUrlHost, $strAppName, $strActionInfo, $strCallType, $arrUrlParam);
         return Navilib_Utils::result($arrRet["errno"], array());
     } catch (Exception $e) {
         Bd_Log::warning($e->getMessage(), $e->getCode());
         return Navilib_Utils::result($e->getCode(), array());
     }
 }
Exemplo n.º 10
0
 public function invoke($arrInput)
 {
     try {
         $strUrl = $arrInput["url"];
         $strCallType = $arrInput["callType"];
         $strUrlParam = $arrInput["urlParam"];
         $arrUrlParam = json_decode($strUrlParam, true);
         $arrUrlParam["ignoreLogin"] = 1;
         $arrRet["errno"] = Navilib_CommonError::SUCCESS;
         $strType = "post" === $strCallType ? true : false;
         //通过fetchurl访问url
         $str = Navilib_NetUtil::getUrlContent($strUrl, $arrUrlParam, $strType);
         $mixData = json_decode($str, true);
         $arrRet["data"] = $mixData;
         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());
     }
 }
Exemplo n.º 11
0
 public function invoke($arrInput)
 {
     try {
         $arrRet["errno"] = Navilib_CommonError::SUCCESS;
         //获取历史记录
         $objDataService = new Service_Data_Testman();
         $arrRecode = $objDataService->getRecode(CURRENT_USER, "", 0, 50);
         $arrRet['data'] = $arrRecode['data'];
         //常用域名:0表示线下域名,1表示线上域名
         $arrRet["data"]["freqDomain"] = $objDataService->getFreqDomain();
         ksort($arrRet["data"]["freqDomain"]);
         //常用模块
         $arrRet["data"]["freqModule"] = array("ucenter");
         sort($arrRet["data"]["freqModule"]);
         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());
     }
 }
Exemplo n.º 12
0
 public function invoke($arrInput)
 {
     try {
         $strUrlHost = $arrInput["urlHostForCurlProxy"];
         $strAppName = $arrInput["appNameForCurlProxy"];
         $strActionInfo = $arrInput["actionInfoForCurlProxy"];
         $strCallType = $arrInput["callTypeForCurlProxy"];
         $strType = "post" === $strCallType ? true : false;
         $arrActionInfo = explode("##", $strActionInfo);
         $strPath = $arrActionInfo[0];
         $strUrl = $strUrlHost . "/" . $strAppName . "/" . $strPath;
         //解析出待发起请求的所有参数
         $arrUrlParam = array();
         //$arrUrlParam["ignoreLogin"] = 1;
         foreach ($_POST as $strKey => $strVal) {
             if ($strKey !== 'urlHostForCurlProxy' && $strKey !== 'appNameForCurlProxy' && $strKey !== 'actionInfoForCurlProxy' && $strKey !== 'callTypeForCurlProxy' && $strKey !== 'paramTypeForCurlProxy' && $strKey !== 'signCodeForCreateSign') {
                 $arrUrlParam[$strKey] = $strVal;
             }
         }
         foreach ($_FILES as $strKey => $arrItem) {
             $arrUrlParam[$strKey] = '@' . $arrItem['tmp_name'];
             $strType = 'upload';
         }
         $arrRet["errno"] = Navilib_CommonError::SUCCESS;
         //通过fetchurl访问url
         $str = Navilib_NetUtil::getUrlContent($strUrl, $arrUrlParam, $strType);
         $mixData = json_decode($str, true);
         if (!empty($mixData)) {
             $mixData = self::_buildHtmlOutput($mixData);
         } else {
             $mixData = $str;
         }
         $arrRet["data"] = $mixData;
         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());
     }
 }
Exemplo n.º 13
0
 public static function getYunInfo($apiMethod, $params, $method = "POST")
 {
     $conf = Navilib_Utils::loadConf('yuncfg');
     $method = strtoupper($method);
     $url = "http://{$conf['host']}/rest/2.0/channel/channel";
     $params['method'] = $apiMethod;
     $params['apikey'] = $conf['ak'];
     $params['timestamp'] = time();
     $params['sign'] = self::genYunSign($conf['sk'], $method, $url, $params);
     $http_type = $method == 'POST';
     $ret = Navilib_NetUtil::getUrlContent($url, $params, $http_type);
     if ($ret) {
         $ret = json_decode($ret, true);
     }
     return $ret;
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 15
0
 public function get_other_version()
 {
     $ret = Navilib_Utils::getUrlContent('http://cq01-rdqa-pool211.cq01.baidu.com:8434/ucenter/track/mis/getselect', array());
     return $ret;
 }