function __destruct() { //flush(); //个别web配置下会出错 if (!empty($_GET['inajax'])) return; if (empty($_GET['action']) || 'newthread' !== $_GET['action']) return; if ('yes' !== $_GET['topicsubmit']) return; if ($_POST['formhash'] != FORMHASH) return; global $tid; if (empty($tid)) return; if (defined("_bds_w9x_{$tid}")) return; define("_bds_w9x_{$tid}", true); if (!baidu_get_plugin_setting('openping')) return; if (baidu_senddata_error()) return; //发新帖 $thread = get_thread_by_tid($tid); if ($thread) { $url = baidu_gen_thread_url($tid, 1, 1, $thread['fid']); $schema = new BaiduThreadSchema(); $schema->setThreadUrl($url); baidu_send_data($schema, 1); } }
function baidu_schema_body_build($forum, $thread) { if (!in_array($forum['status'], array(1, 3))) { return false; } if ($forum['status'] == 1 && $forum['viewperm']) { $_p = explode("\t", $forum['viewperm']); //检查游客组 if (!in_array('7', $_p)) { return false; } } if ($forum['status'] == 3 && $forum['gviewperm'] == 0) { return false; } if ($thread['readperm'] > 1) { return false; } $schema = new BaiduThreadSchema(); $schema->setForumIcon($forum['icon']); $schema->setModerators($forum['moderators']); $schema->setAuthorIcon($thread['authorid']); $schema->setAuthor($thread['author']); $schema->setForumName($forum['name']); $schema->setSupportCount($thread['recommend_add']); $schema->setOpposeCount($thread['recommend_sub']); $schema->setStickyLevel($thread['displayorder']); $schema->setIsDigest($thread['digest']); $schema->setLastReplier($thread['lastposter']); $schema->setFavorCount($thread['favtimes']); $schema->setSharedCount($thread['sharetimes']); //是否启用伪静态 $schema->setThreadUrl(baidu_gen_thread_url($thread['tid'], 1, 1, $forum['fid'])); $schema->setThreadTitle($thread['subject']); $schema->setReplyCount($thread['replies']); $schema->setViewCount($thread['views']); $schema->setLastReplyTime($thread['lastpost']); $postlist = C::t('forum_post')->fetch_all_by_tid($thread['posttableid'], $thread['tid'], true, 'ASC', 0, $_G['ppp']); //如果没有内容 if (empty($postlist)) { return false; } $attachpids = array(); foreach ($postlist as $row) { $row['attachment'] > 0 && $attachpids[] = $row['pid']; } //附件 $attachlist = empty($attachpids) ? array() : baidu_get_attachment_by_pids($attachpids, $thread['tid']); $sequenceNumber = 1; foreach ($postlist as $pid => $eachpost) { $post = false; $images = array(); //附件 if (1 == $eachpost['first']) { //主题帖 $post = new BaiduPostSchema(); if ($thread['price'] > 0 || $eachpost['status'] % 2 == 1) { //主题价格 看相应主题帖需要花金币 $post->setViewAuthority(lang('plugin/baidusubmit', 'haveperm')); } else { if (false !== stripos($eachpost['message'], '[/hide]')) { $post->setViewAuthority(lang('plugin/baidusubmit', 'hidecontent')); } else { $post->setViewAuthority(lang('plugin/baidusubmit', 'noperm')); } } $post->setIsHost(1); $post->setPostSequenceNumber(1); } else { $post = new BaiduPostSchema(); if (false !== stripos($eachpost['message'], '[/hide]')) { $post->setViewAuthority(lang('plugin/baidusubmit', 'hidecontent')); } else { $post->setViewAuthority(lang('plugin/baidusubmit', 'noperm')); } $post->setIsHost(0); $post->setPostSequenceNumber($sequenceNumber); } $content = baidu_content_filter($eachpost, $forum, $images); $post->setPostContent($content); $post->setCreatedTime($eachpost['dateline']); $post->setAuthor($eachpost['author']); $post->setAuthorIcon($eachpost['authorid']); $schema->addPost($post); $sequenceNumber++; //如果有附件 if ($post && !empty($attachlist[$pid])) { foreach ($attachlist[$pid] as $a) { $_obj = new BaiduAttachmentSchema(); $_obj->setName($a['filename']); $_obj->setSize($a['filesize']); $_obj->setDownloadCount($a['downloads']); $ap = baidu_get_attachment_authority($a); if ($ap > 0) { $authority = $ap; } elseif (empty($forum['getattachperm']) || (($t = explode("\t", $forum['getattachperm'])) && in_array(7, $t))) { $authority = 0; } else { $authority = 4; } if ($ap == 0) { $attachurl = $_G['setting']['attachurl'] . '/forum/' . $a['attachment']; $attachurl = str_replace(array('/./', '//'), '/', $attachurl); } else { $attachurl = 'forum.php?mod=attachment&aid=' . aidencode($a['aid']); } $_obj->setDownloadAuthority($authority); $_obj->setUrl($_G['siteurl'] . $attachurl); $post->addAttachment($_obj); } } //图片 if ($post && !empty($images)) { foreach ($images as $x) { if (intval($x) > 0) continue; //不要附件 if (0 != strncasecmp($x, 'http://', 7)) continue; //非网络图片不要 $_obj = new BaiduAttachmentSchema(); $_obj->setUrl($x); $_obj->setDownloadAuthority(0); $post->addAttachment($_obj); } } } return $schema->toXml() . "\n"; }