TAG标签自动获取SEOV4.9核心代码分享 [复制链接]

moqu8 2020-4-26

2086 0


资源介绍:
【测试说明】用户分享的插件,缺少配置文件,懒得修复,直接分享核心代码给大家学习研究吧!

<?php

if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}

class plugin_exx_tagseo_forum{
function viewthread_posttop_output() {
global $_G,$postlist;
$exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];
$section = empty($exx_tagseo['bk']) ? array() : unserialize($exx_tagseo['bk']);
if(!is_array($section)) $section = array();
if(!(empty($section[0]) || in_array($_G['fid'],$section))){
return array();
}
$firspid=$_G['forum_firstpid'];
if(empty($postlist[$firspid]['tags'])){
$ajax="<script>settag();function settag() {var x = new Ajax();x.get('plugin.php?id=exx_tagseo:settag&tid=".$_G['tid']."&formhash=".FORMHASH."' , function(s){});}</script>";
return array($ajax);
}
return array();
}


function post_message($param) {
global $_G;
$exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];
$section = empty($exx_tagseo['bk']) ? array() : unserialize($exx_tagseo['bk']);
if(!is_array($section)) $section = array();
if(!(empty($section[0]) || in_array($_G['fid'],$section))){
return;
}
$param = $param['param'];
if(($param[0]=="post_newthread_succeed" || $param[0]=="post_newthread_mod_succeed") && $exx_tagseo['qz'] && $_GET['subject']){
$pid = intval($param[2]['pid']);
DB::query("update ".DB::table('forum_post')." set tags='' where pid=".$pid);
}
return ;
}


}

class plugin_exx_tagseo_group extends plugin_exx_tagseo_forum{

}
<?php
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}

function getmode($tid,$pid,$title,$msg){
global $_G;
$exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];
if($exx_tagseo['hq']==2){
return baiduKeyword($tid,$pid,$title,$msg);
}else{
return pullwordKeyword($tid,$pid,$title,$msg);
}
}


function baiduKeyword($tid,$pid,$title,$msg){
global $_G;
$exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];
if($exx_tagseo['jr']){
$w=file_get_contents("http://www.baidu.com/s?wd=".urlencode($title));
}else{
$w=dfsockopen("http://www.baidu.com/s?wd=".urlencode($title));
}
$w=str_replace(array("/r","/n","/t","/s"), '', $w);
preg_match('/<div id="rs">(.*?)<\/div>/iU',$w,$con);
$list=$con[0];
preg_match_all('/<a(.*?)>(.*?)<\/a>/i',$list,$content);
if($exx_tagseo['sl']){$content[2]=array_slice($content[2], 0, $exx_tagseo['sl']);}
$result=implode(",",$content[2]);
if(!(CHARSET=='UTF-8')){$result=diconv($result,'UTF-8' ,CHARSET);}
$return=settag($tid,$pid,$result);
if($_GET['debug'])print_r($return);
return $return;
}

function pullwordKeyword($tid,$pid,$title,$msg){
global $_G;
$exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];
$xs=$exx_tagseo['xs']?$exx_tagseo['xs']:0.9;
$tagarr=array();
if(!(CHARSET=='UTF-8')){
$title=diconv($title,CHARSET,'UTF-8');
}
$title=dhtmlspecialchars($title);
$url ='http://api.pullword.com/get.php?source='.urlencode($title).'¶m1=0¶m2=1&json=1';
if($exx_tagseo['jr']){
$w=file_get_contents($url);
}else{
$w=dfsockopen($url);
}
$arr = json_decode($w,true);
foreach($arr as $val){
if($val['p']>$xs){
$tagarr[]=$val['t'];
}
}
$result=implode(",",$tagarr);
$result=diconv($result,'UTF-8' ,CHARSET);
$return=settag($tid,$pid,$result);
return $return;

}


function settag($tid,$pid,$result){
$newtagclass = new tag();
$tags = $newtagclass->add_tag($result, $tid, 'tid');
if($result) {
loadcache('censor');
C::t('forum_post')->update('tid:'.$tid, $pid, array(
'tags' => $tags,
));
}
if($tags){
$tagarray = explode("\t", $tags);
if($tagarray) {
foreach($tagarray as $v) {
if($v) {
$tag = explode(',', $v);
$ptag_array[] = $tag;
}
}
}
}
return $ptag_array;
}
<?php
if (! defined ('IN_DISCUZ')) {
exit ('Access Denied');
}

global $_G;
$exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];
$tid=intval($_GET['tid']);

if($_GET['formhash']!=FORMHASH)return;
include_once DISCUZ_ROOT.'./source/plugin/exx_tagseo/fun.inc.php';

$group = empty($exx_tagseo['yhz']) ? array() : unserialize($exx_tagseo['yhz']);
if(!(empty($group[0]) || in_array($_G['groupid'],$group))){
return;
}
$postdata=DB::fetch_first("select pid,subject from ".DB::table('forum_post')." where tid=".$tid." AND first=1 limit 1");
$postdata['subject']=str_replace(array('[',']','.','-',lang('plugin/exx_tagseo', 'f01'),lang('plugin/exx_tagseo', 'f02'),'&','*','(',')','#','@','~','


,'%','+','=','^','_'),'',$postdata['subject']);//20180509
if($postdata && empty($postdata['tags'])){
require_once libfile('function/post');
$message=strip_tags($thread['message']);
$msg=messagecutstr($message, 500);
getmode($tid,$postdata['pid'],$postdata['subject'],$msg);
}




最新回复 (0)
返回
支持中心
邮箱:winkill2012@qqcom
新站优化中!部分功能尚未完善,敬请谅解!
支持中心