Exemplo n.º 1
0
function shareFileByUid($fsid, $uid)
{
    $fsid = intval($fsid);
    if ($fsid <= 0) {
        return false;
    }
    //构建请求header信息
    $header = array('pathinfo' => '/internal/share/set');
    //构建请求体
    $req = array();
    $req['fid_list'] = json_encode(array($fsid));
    $req['uid'] = intval($uid);
    $req['schannel'] = 0;
    //分享途径,0复制链接,1weibo,2邮件,3短信
    $req['channel_list'] = json_encode(array());
    //发起请求,ral需要配置为form形式
    $panRes = ral('PanShare', 'post', $req, rand(), $header);
    if ($panRes === false) {
        echo "share file failed when talk to pan in ral. fsid[{$fsid}] errno[" . ral_get_errno() . "]";
        return false;
    }
    //解析返回结果
    $panDecode = json_decode($panRes, true);
    if ($panDecode === false) {
        echo "decode share file result failed. fsid[{$fsid}] res[{$panRes}]";
        return false;
    }
    //操作失败
    if ($panDecode['errno'] != 0) {
        echo "share file failed when talk to pan. fsid[{$fsid}] errno[{$panDecode['errno']}]";
        return false;
    }
    return $panRes;
}
Exemplo n.º 2
0
 private static function pid2UrlRal($reqArr)
 {
     ral_set_logid(time() + mt_rand());
     $array = array("cmd_no" => 1012, "reqs" => $reqArr);
     $ret = ral('urlCrypt', 'nothing', $array, rand());
     if ($ret === false) {
         Bd_Pic_Log::warning(ral_get_error(), ral_get_errno());
         return false;
     }
     return $ret;
 }
Exemplo n.º 3
0
 public function __call($_method, $_param)
 {
     $this->_err_msg = '';
     if ($_method[0] === '_') {
         //functions start with '_' are reserved
         $this->_add_error("functions start with '_' are reserved for internal use only");
         return null;
     }
     //get extra
     if (isset($_param[1])) {
         $extra = $_param[1] + $this->_extra;
     } else {
         $extra = $this->_extra;
     }
     //get param
     $param = @$_param[0];
     //input convert
     $input = $this->_input_convert($_method, $param, $extra);
     if ($input === null) {
         $this->_add_error("error in _input_convert");
         return null;
     }
     //other flags
     $service = $this->_get_service($_method, $param, $extra);
     $method = $this->_get_method($_method, $param, $extra);
     $flag = $this->_get_flag($_method, $param, $extra);
     //real call
     $output = ral($service, $method, $input, $flag);
     //parse output
     if ($output === false) {
         //ral error
         $errno = ral_get_errno();
         if ($errno == 0) {
             //connect error
             $this->_add_error("ral connect error");
         } else {
             $this->_add_error("ral errno {$errno}, raw data {$output}");
         }
         return null;
     }
     //output convert
     $retval = $this->_output_convert($output, $extra);
     if ($retval === null) {
         $this->_add_error("error in output_convert");
         return null;
     }
     return $retval;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 /**
  * @brief 通过wise适配服务获取接入设备信息
  *
  * @return  success-array failed-false
  * @retval  array/boolean 
  * @author niuyunkun
  * @date 2012/07/10 21:38:54
  **/
 public function getScreenTypeFromWise()
 {
     //talk with wise server
     $data = ral('wise', 'getscreentype', $_SERVER, rand());
     if ($data === false) {
         Bd_Log::warning("getScreenTypeFromWise failed! ral error no:" . ral_get_errno() . " error_msg:" . ral_get_error() . " protocol_status:" . ral_get_protocol_code());
         return false;
     } else {
         return $data;
     }
 }
Exemplo n.º 6
0
 public function getBDUSSBySSIDWithRAL($ssid)
 {
     ral_set_logid(LOG_ID);
     ral_set_pathinfo('passport/get_sid');
     ral_set_querystring("ssid={$ssid}&plain=&version=2");
     $res = ral('wappass', 'get', array(), 1);
     if ($res != null) {
         $res = json_decode($res, true);
         self::$_errno = !$res ? -1 : 0;
         self::$_errmsg = !$res ? "[Wappass][get_sid]Result json_decode failed." : "";
         if (!$res) {
             Bd_Passport_Log::warning(self::$_errmsg, -1);
         }
         return is_array($res) ? $res : false;
     } else {
         self::$_errno = ral_get_errno();
         self::$_errmsg = "[Wappass][get_sid]Talk with server failed. errmsg:" . ral_get_error();
         Bd_Passport_Log::warning(self::$_errmsg, -1);
         return false;
     }
 }