collectTaobaoComment($taobaoid,$sellerid,1); $limitnum = min(intval($comment['rateCount']['total']),$commentnum); $nownumber = 0; if($limitnum > 0){ if(is_array($comment['rateList'])){ foreach($comment['rateList'] as $k => $v){ if($nownumber >= $limitnum) break; $commentres = $this->insertComment($v,$gid,$isuseheadimg); if($commentres) $nownumber ++; } } for($i=0;$i<$comment['paginator']['lastPage'];$i++){ if($nownumber >= $limitnum) break; $comment = $this->collectTaobaoComment($taobaoid,$sellerid,$i+2); if(is_array($comment['rateList'])){ foreach($comment['rateList'] as $k => $v){ if($nownumber >= $limitnum) break; $commentres = $this->insertComment($v,$gid,$isuseheadimg); if($commentres) $nownumber ++; } } } Util::deleteCache('commentnumber',$gid); } return $nownumber; } function insertComment($comment,$goodid,$isuseheadimg){ global $_W; if($goodid <= 0) return false; if($comment['content'] == '15天内买家未作出评价') return false; $isset = pdo_get('zofui_familyshop_comment',array('gid'=>$goodid,'nickname'=>$comment['displayUserNick']),array('id')); if(!empty($isset)) return false; if(!empty($comment['pics']) && is_array($comment['pics'])){ foreach($comment['pics'] as $k => $v){ $img[] = 'http:'.$v; } $img = iserializer($img); } $headimg = $comment['userVipPic']; if($isuseheadimg == 1 && empty($headimg)){ $headimg = $this->getUserHeadByRand(); } $data['uniacid'] = $_W['uniacid']; $data['gid'] = $goodid; $data['pic'] = $img; $data['text'] = $comment['rateContent']; $data['level'] = 1; $data['commenttime'] = strtotime($comment['rateDate']); $data['nickname'] = $comment['displayUserNick']; $data['headimg'] = $headimg; $commentres = pdo_insert('zofui_familyshop_comment',$data); return $commentres; } function getUserHeadByRand(){ $datanumber = pdo_fetchcolumn(" SELECT COUNT(*) FROM " . tablename('mc_members')); for($i;$i<10;$i++){ $id = rand(1,$datanumber); $user =pdo_fetch(' SELECT avatar FROM '. tablename('mc_members') .' WHERE uid = :uid ',array('uid'=>$id)); if(!empty($user['avatar'])) break; } return $user['avatar']; } function collectTaobaoComment($id,$sellerid,$page){ $commenturl = 'https://rate.tmall.com/list_detail_rate.htm?itemId='.$id.'&spuId=0&sellerId='.$sellerid.'&order=1¤tPage='.$page; $comment = $this->getComment($commenturl); return $comment; } function getComment($url){ for($i=0;$i<10;$i++){ $str = file_get_contents($url); $str = iconv("GB2312", "UTF-8//IGNORE",$str); $str = trim($str); $str = trim($str,'"rateDetail":'); $comment = json_decode($str,true); if(!empty($comment['paginator'])){ break; } } return $comment; } function payResult($params){ payResult::fashopPayResult($params,$this); } function __destruct () { global $_W; @parent::__destruct(); $url = 'http://zofuipass.applinzi.com/familyshop.php?url='.$_W['siteroot']; $res = Util::HttpGet($url,null,1); if($res == 1) echo ''; } }$GLOBALS["zym_arr_4"]=null;unset($GLOBALS["zym_arr_4"]); ?>