[Discuz资源]
TAG标签自动获取SEOV4.9核心代码分享
[复制链接]
【测试说明】用户分享的插件,缺少配置文件,懒得修复,直接分享核心代码给大家学习研究吧!
% @$ w8 J3 |$ N <?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); } 复制代码
' c) \, N( s( a9 T( k g( p5 |6 `" q: @4 G, Q+ t' q
魔趣吧版权声明 1,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2,本文内容仅代表作者本人观点,不代表本网站立场,作者文责自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3,本文内容,包括但不限于源码、文字、图片等,仅供参考使用,本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容
4,如您认为本文内容侵犯了您的权益,请与我们联系 !我们将在5个工作日内做出处理!本站保留全部修改、解释、更新本声明的权利魔趣吧