_author = baidu_strip_invalid_xml(baidu_diconv(trim($author), CHARSET, 'utf-8')); } public function setAuthorIcon($uid, $size = "small") { $authorIconUrl = baidu_get_avatar($uid, $size); $this->_authorIcon = $authorIconUrl; } public function setPostContent($content) { $this->_postContent = baidu_strip_invalid_xml(baidu_diconv(trim($content), CHARSET, 'utf-8')); } public function setCreatedTime($time) { $time = trim($time); $this->_createdTime = preg_match('#^\d+$#', $time) ? baidu_date_format($time) : $time; } public function setViewAuthority($string) { $this->_viewAuthority = baidu_diconv(trim($string), CHARSET, 'utf-8'); } public function setIsHost($ishost) { $this->_isHost = intval($ishost); } public function setPostSequenceNumber($number) { $this->_postSequenceNumber = intval($number); } public function addAttachment(BaiduAttachmentSchema $attach) { $this->_attachment[] = $attach; } public function toXml() { $attach_xml = ''; foreach ($this->_attachment as $x) { $attach_xml .= $x->toXml(); } return "" . "_postContent}]]>" . "{$this->_createdTime}" . "_viewAuthority}]]>" . "_author}]]>" . "_authorIcon}]]>" . //"{$this->_isHost}" . "{$this->_postSequenceNumber}" . $attach_xml . ""; } } class BaiduAttachmentSchema { protected $_attachmentName; // protected $_attachmentUrl; // protected $_attachmentSize; // protected $_attachmentDownloadAuthority; // protected $_attachmentDownloadCount; // protected $_attachmentType; public function setName($name) { $this->_attachmentName = baidu_strip_invalid_xml(baidu_diconv(trim($name), CHARSET, 'utf-8')); $this->_setType(strtolower(fileext($this->_attachmentName))); } public function setUrl($url) { $this->_attachmentUrl = baidu_encode_url(trim($url)); } public function setSize($size) { if (preg_match('#^\d+$#', $size)) { if ($size > 1024 * 1024) { $size = round($size / 1024 / 1024, 1) . 'M'; } elseif ($size > 1024) { $size = round($size / 1024, 1) . 'K'; } else { $size .= 'B'; } } $this->_attachmentSize = $size; } public function setDownloadAuthority($authority) { $this->_attachmentDownloadAuthority = intval($authority); } public function setDownloadCount($count) { $this->_attachmentDownloadCount = intval($count); } protected function _setType($extname) { /** * 0=普通 * 1=图片 * 2=音频 * 3=视频 * 4=下载 */ if (preg_match("/bittorrent|^torrent/", $extname)) { $typeid = 4; } elseif (preg_match("/pdf|^pdf/", $extname)) { $typeid = 4; } elseif (preg_match("/image|^(jpg|gif|png|bmp)/", $extname)) { $typeid = 1; } elseif (preg_match("/flash|^(swf|fla|flv|swi)/", $extname)) { $typeid = 3; } elseif (preg_match("/audio|video|^(wav|mid|mp3|m3u|wma|asf|asx|vqf|mpg|mpeg|avi|wmv)/", $extname)) { $typeid = 2; } elseif (preg_match("/real|^(ra|rm|rv)/", $extname)) { $typeid = 3; } elseif (preg_match("/htm|^(php|js|pl|cgi|asp)/", $extname)) { $typeid = 0; } elseif (preg_match("/text|^(txt|rtf|wri|chm)/", $extname)) { $typeid = 0; } elseif (preg_match("/word|powerpoint|^(doc|ppt)/", $extname)) { $typeid = 0; } elseif (preg_match("/^rar/", $extname)) { $typeid = 4; } elseif (preg_match("/compressed|^(zip|arj|arc|cab|lzh|lha|tar|gz)/", $extname)) { $typeid = 4; } elseif (preg_match("/octet-stream|^(exe|com|bat|dll)/", $extname)) { $typeid = 4; } else { $typeid = 0; } $this->_attachmentType = $typeid; } public function toXml() { return "" . "_attachmentName}]]>" . "_attachmentUrl}]]>" . "_attachmentSize}]]>" . "{$this->_attachmentDownloadAuthority}" . "{$this->_attachmentDownloadCount}" . "_attachmentType}]]>" . ""; } } class BaiduThreadSchema { protected $_forumName; //版块名称 protected $_threadUrl; //链接地址 protected $_threadTitle; //主题title protected $_post = array(); //帖子 protected $_replyCount; //回复数 protected $_viewCount; //浏览数 protected $_lastReplyTime; //最后回复时间 protected $_forumIcon; //版块图片 protected $_moderators; //版主 protected $_authorIcon; //用户头像 protected $_author; //作者 protected $_supportCount = null; //主题 支持数 protected $_opposeCount = null; //主题 反对数 protected $_isDigest; //是否精华 protected $_stickyLevel; //置顶,0为不置顶,1为版面,2为分区,3为全局 protected $_lastReplier; //最后回复人 protected $_favorCount; //收藏数 protected $_sharedCount; //分享数 public function setFavorCount($favtimes) { $this->_favorCount = $favtimes; } public function setSharedCount($sharetimes) { $this->_sharedCount = $sharetimes; } public function setLastReplier($name) { $this->_lastReplier = baidu_strip_invalid_xml(baidu_diconv(trim($name), CHARSET, 'utf-8')); } public function setStickyLevel($level) { $this->_stickyLevel = $level; } public function setIsDigest($digest) { $this->_isDigest = $digest; } public function setSupportCount($count) { global $_G; $recommendthread = $_G['setting']['recommendthread']; if (isset($recommendthread['status'])) { $this->_supportCount = $count; } } public function setOpposeCount($count) { global $_G; $recommendthread = $_G['setting']['recommendthread']; if (isset($recommendthread['status'])) { $this->_opposeCount = $count; } } public function setAuthor($author) { $this->_author = baidu_strip_invalid_xml(baidu_diconv(trim($author), CHARSET, 'utf-8')); } public function setForumIcon($forumIcon) { global $_G; if ($forumIcon) { $url = $_G['siteurl'] . $_G['setting']['attachurl'] . "common/" . $forumIcon; } else { $url = $_G['siteurl'] . $_G['style']['imgdir'] . "/forum.gif"; } $this->_forumIcon = $url; } public function setModerators($moderators) { $this->_moderators = baidu_strip_invalid_xml(baidu_diconv(trim($moderators), CHARSET, 'utf-8')); } public function setAuthorIcon($uid, $size = "small") { $authorIconUrl = baidu_get_avatar($uid, $size); $this->_authorIcon = $authorIconUrl; } public function setForumName($name) { $this->_forumName = baidu_strip_invalid_xml(baidu_diconv(trim($name), CHARSET, 'utf-8')); } public function setThreadUrl($url) { $this->_threadUrl = trim($url); } public function setThreadTitle($title) { $this->_threadTitle = baidu_strip_invalid_xml(baidu_diconv(trim($title), CHARSET, 'utf-8')); } public function setReplyCount($count) { $this->_replyCount = intval($count); } public function setViewCount($count) { $this->_viewCount = intval($count); } public function setLastReplyTime($time) { $time = trim($time); $this->_lastReplyTime = preg_match('#^\d+$#', $time) ? baidu_date_format($time) : $time; } public function addPost(BaiduPostSchema $post) { $this->_post[] = $post; } public function toXml() { $xml = "" . "_threadUrl}]]>" . "_lastReplyTime}]]>" . "" . "" . "_threadUrl}]]>" . "_author}]]>" . "_authorIcon}]]>" . "_threadTitle}]]>" . "_stickyLevel}]]>" . "_isDigest}]]>"; foreach ($this->_post as $post) { $xml .= $post->toXml(); } $xml .= "{$this->_replyCount}" . "{$this->_viewCount}" . "" . "_lastReplier}]]>" . "" . "{$this->_lastReplyTime}" . "{$this->_favorCount}" . "{$this->_sharedCount}"; if ($this->_supportCount != null && $this->_opposeCount != null) { $xml .= "{$this->_supportCount}" . "{$this->_opposeCount}"; } $xml .= "" . "_forumName}]]>" . "_forumIcon}]]>" . "_moderators}]]>" . "" . "" . "" . ""; return $xml; } public function toDeleteXml() { $xml = "_threadUrl}]]>"; return $xml; } public function toSitemapXml() { $date = date('Y-m-d'); return "_threadUrl}]]>{$date}"; } } class BaiduForumSchema { protected $_boardName; protected $_boardUrl; protected $_logo; protected $_boardMaster = array(); protected $_description; protected $_postCount; protected $_memberCount; protected $_activeMemberCount; protected $_hotPost = array(); public function setBoardName($name) { $this->_boardName = baidu_strip_invalid_xml(baidu_diconv(trim($name), CHARSET, 'utf-8')); } public function setBoardUrl($url) { $this->_boardUrl = $url; } public function setLogo($url) { $this->_logo = $url; } public function setBoardMaster(BaiduBoardMasterSchema $boardMaster) { $this->_boardMaster[] = $boardMaster; } public function setDescripttion($description) { $this->_description = baidu_strip_invalid_xml(baidu_diconv(trim($description), CHARSET, 'utf-8')); } public function setPostCount($count) { $this->_postCount = $count; } public function setMemberCount($count) { $this->_memberCount = $count; } public function setActiveMemberCount($count) { $this->_activeMemberCount = $count; } public function setHotPost(BaiduHotPostSchema $hotPost) { $this->_hotPost[] = $hotPost; } public function toXml() { $xml = "" . '_boardUrl . ']]>' . '' . '' . '_boardName . ']]>' . '_boardUrl . ']]>' . '_logo . ']]>'; if ($this->_boardMaster) { foreach ($this->_boardMaster as $boardMaster) { $xml .= $boardMaster->toXml(); } } $xml .= '_description . ']]>' . '' . $this->_postCount . '' . '' . $this->_memberCount . '' . '' . $this->_activeMemberCount . ''; if ($this->_hotPost) { foreach ($this->_hotPost as $hotPost) { $xml .= $hotPost->toXml(); } } $xml .= ''; return $xml; } } class BaiduBoardMasterSchema { protected $_name; protected $_url; public function setName($name) { $this->_name = baidu_strip_invalid_xml(baidu_diconv(trim($name), CHARSET, 'utf-8')); } public function setUrl($url) { $this->_url = $url; } public function toXml() { return '' . '_name . ']]>' . '_url . ']]>' . ''; } } class BaiduHotPostSchema { protected $_threadUrl; protected $_postTitle; protected $_createTime; protected $_viewCount; protected $_replyCount; public function setThreadUrl($url) { $this->_threadUrl = $url; } public function setPostTitle($title) { $this->_postTitle = baidu_strip_invalid_xml(baidu_diconv(trim($title), CHARSET, 'utf-8')); } public function setCreateTime($time) { $this->_createTime = preg_match('#^\d+$#', $time) ? baidu_date_format($time) : $time; } public function setViewCount($count) { $this->_viewCount = $count; } public function setReplayCount($count) { $this->_replyCount = $count; } public function toXml() { return '' . '_threadUrl . ']]>' . '_postTitle . ']]>' . '' . $this->_createTime . '' . '' . $this->_viewCount . '' . '' . $this->_replyCount . '' . ''; } } class BaiduForumUserSchema { protected $_nickName; protected $_spaceUrl; protected $_photoUrl; protected $_profile; protected $_level; protected $_postCount; protected $_fanCount; protected $_friendCount; protected $_gender; protected $_location; protected $_constellation; protected $_birthday; protected $_registerTime; protected $_netAge; protected $_lastLoginTime; protected $_signatureText; protected $_signaturePhoto; public function getNickName() { return $this->_nickName; } public function setNickName($name) { $this->_nickName = baidu_strip_invalid_xml(baidu_diconv(trim($name), CHARSET, 'utf-8')); } public function setSpaceUrl($url) { $this->_spaceUrl = $url; } public function setPhotoUrl($url) { $this->_photoUrl = $url; } public function setProfile($profile) { $this->_profile = baidu_strip_invalid_xml(baidu_diconv(trim($profile), CHARSET, 'utf-8')); } public function setLevel($level) { $this->_level = baidu_diconv(trim($level), CHARSET, 'utf-8'); } public function setPostCount($count) { $this->_postCount = $count; } public function setFanCount($count) { $this->_fanCount = $count; } public function setFriendCount($count) { $this->_friendCount = $count; } public function setGender($gender) { $zh_gender = array(0 => "保密", 1 => "男", 2 => "女"); $this->_gender = $zh_gender[$gender]; } public function setLocation($location) { $this->_location = baidu_diconv(trim($location), CHARSET, 'utf-8'); } public function setConstellation($constellation) { $this->_constellation = baidu_diconv(trim($constellation), CHARSET, 'utf-8'); ; } public function setBirthday($birthday) { $this->_birthday = $birthday; } public function setRegisterTime($time) { $this->_registerTime = date("Y-m-d", $time); ; } public function setNetAge($age) { $this->_netAge = $age; } public function setLastLoginTime($time) { $this->_lastLoginTime = preg_match('#^\d+$#', $time) ? baidu_date_format($time) : $time; } public function setSignatureText($text) { $this->_signatureText = baidu_strip_invalid_xml(baidu_diconv(trim($text), CHARSET, 'utf-8')); ; } public function setSignaturePhoto($photo) { $this->_signaturePhoto = $photo; } public function toXml() { return '' . '_spaceUrl . ']]>' . '' . '' . '_nickName . ']]>' . '_spaceUrl . ']]>' . '_photoUrl . ']]>' . '_profile . ']]>' . '_level . ']]>' . '' . $this->_postCount . '' . '' . $this->_fanCount . '' . '' . $this->_friendCount . '' . '' . $this->_gender . '' . '' . $this->_location . '' . '' . $this->_constellation . '' . '' . $this->_birthday . '' . '' . $this->_registerTime . '' . '' . $this->_netAge . '' . ($this->_lastLoginTime ? '' . $this->_lastLoginTime . '' : "") . '_signatureText . ']]>' . '_signaturePhoto . ']]>' . '' . '' . ''; } }