【即将关站通知●已关闭注册功能】,倒计时剩余:计算中...

[Discuz资源] TAG标签自动获取SEOV4.9核心代码分享

[复制链接]
魔趣吧站长魔趣吧官方成员 实名认证 发表于 2020-4-26 16:35:16 | 显示全部楼层 |阅读模式
   资源介绍:
【测试说明】用户分享的插件,缺少配置文件,懒得修复,直接分享核心代码给大家学习研究吧!
% @$ w8 J3 |$ N
  1. <?php
  2. if(!defined('IN_DISCUZ')) {
  3.   exit('Access Denied');
  4. }
  5. class plugin_exx_tagseo_forum{
  6.         function viewthread_posttop_output() {
  7.                 global $_G,$postlist;
  8.                 $exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];       
  9.                 $section = empty($exx_tagseo['bk']) ? array() : unserialize($exx_tagseo['bk']);
  10.                 if(!is_array($section)) $section = array();
  11.                 if(!(empty($section[0]) || in_array($_G['fid'],$section))){
  12.                         return array();
  13.                 }
  14.                 $firspid=$_G['forum_firstpid'];
  15.                 if(empty($postlist[$firspid]['tags'])){
  16.                         $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>";
  17.                         return array($ajax);
  18.                 }
  19.                 return array();
  20.         }
  21.        
  22.        
  23.         function post_message($param) {
  24.                 global $_G;
  25.                 $exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];       
  26.                 $section = empty($exx_tagseo['bk']) ? array() : unserialize($exx_tagseo['bk']);
  27.                 if(!is_array($section)) $section = array();
  28.                 if(!(empty($section[0]) || in_array($_G['fid'],$section))){
  29.                         return;
  30.                 }
  31.                 $param = $param['param'];
  32.                 if(($param[0]=="post_newthread_succeed" || $param[0]=="post_newthread_mod_succeed") && $exx_tagseo['qz'] && $_GET['subject']){
  33.                         $pid = intval($param[2]['pid']);
  34.                         DB::query("update ".DB::table('forum_post')." set tags='' where pid=".$pid);
  35.                 }
  36.                 return ;
  37.         }
  38.        
  39.        
  40. }
  41. class plugin_exx_tagseo_group extends plugin_exx_tagseo_forum{
  42.        
  43. }
复制代码
  1. <?php
  2.         if(!defined('IN_DISCUZ')) {
  3.                 exit('Access Denied');
  4.         }
  5.         function getmode($tid,$pid,$title,$msg){
  6.                 global $_G;
  7.                 $exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];       
  8.                 if($exx_tagseo['hq']==2){
  9.                         return baiduKeyword($tid,$pid,$title,$msg);
  10.                 }else{
  11.                         return pullwordKeyword($tid,$pid,$title,$msg);
  12.                 }
  13.         }
  14.        
  15.        
  16.         function baiduKeyword($tid,$pid,$title,$msg){
  17.                 global $_G;
  18.                 $exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];       
  19.                 if($exx_tagseo['jr']){
  20.                         $w=file_get_contents("http://www.baidu.com/s?wd=".urlencode($title));
  21.                 }else{
  22.                         $w=dfsockopen("http://www.baidu.com/s?wd=".urlencode($title));
  23.                 }
  24.                 $w=str_replace(array("/r","/n","/t","/s"), '', $w);      
  25.                 preg_match('/<div id="rs">(.*?)<\/div>/iU',$w,$con);
  26.                 $list=$con[0];
  27.                 preg_match_all('/<a(.*?)>(.*?)<\/a>/i',$list,$content);
  28.                 if($exx_tagseo['sl']){$content[2]=array_slice($content[2], 0, $exx_tagseo['sl']);}
  29.                 $result=implode(",",$content[2]);
  30.                 if(!(CHARSET=='UTF-8')){$result=diconv($result,'UTF-8' ,CHARSET);}
  31.                 $return=settag($tid,$pid,$result);
  32.                 if($_GET['debug'])print_r($return);
  33.                 return $return;
  34.         }
  35.        
  36.         function pullwordKeyword($tid,$pid,$title,$msg){
  37.                 global $_G;
  38.                 $exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];
  39.                 $xs=$exx_tagseo['xs']?$exx_tagseo['xs']:0.9;
  40.                 $tagarr=array();
  41.                 if(!(CHARSET=='UTF-8')){
  42.                         $title=diconv($title,CHARSET,'UTF-8');
  43.                 }
  44.                 $title=dhtmlspecialchars($title);
  45.                 $url ='http://api.pullword.com/get.php?source='.urlencode($title).'¶m1=0¶m2=1&json=1';
  46.                 if($exx_tagseo['jr']){
  47.                         $w=file_get_contents($url);
  48.                 }else{
  49.                         $w=dfsockopen($url);
  50.                 }
  51.                 $arr = json_decode($w,true);
  52.                 foreach($arr as $val){
  53.                         if($val['p']>$xs){
  54.                                 $tagarr[]=$val['t'];
  55.                         }
  56.                 }
  57.                 $result=implode(",",$tagarr);
  58.                 $result=diconv($result,'UTF-8' ,CHARSET);
  59.                 $return=settag($tid,$pid,$result);
  60.                 return $return;
  61.        
  62.         }
  63.         function settag($tid,$pid,$result){
  64.                 $newtagclass = new tag();
  65.                 $tags = $newtagclass->add_tag($result, $tid, 'tid');
  66.                 if($result) {
  67.                         loadcache('censor');
  68.                         C::t('forum_post')->update('tid:'.$tid, $pid, array(
  69.                         'tags' => $tags,
  70.                         ));
  71.                 }
  72.                 if($tags){
  73.                         $tagarray = explode("\t", $tags);
  74.                         if($tagarray) {
  75.                                 foreach($tagarray as $v) {
  76.                                         if($v) {
  77.                                                 $tag = explode(',', $v);
  78.                                                 $ptag_array[] = $tag;
  79.                                         }
  80.                                 }
  81.                         }
  82.                 }
  83.                 return $ptag_array;
  84.         }
复制代码
  1. <?php
  2. if (! defined ('IN_DISCUZ')) {
  3.         exit ('Access Denied');
  4. }
  5. global $_G;
  6. $exx_tagseo = $_G['cache']['plugin']['exx_tagseo'];       
  7. $tid=intval($_GET['tid']);
  8. if($_GET['formhash']!=FORMHASH)return;
  9. include_once DISCUZ_ROOT.'./source/plugin/exx_tagseo/fun.inc.php';
  10. $group = empty($exx_tagseo['yhz']) ? array() : unserialize($exx_tagseo['yhz']);
  11. if(!(empty($group[0]) || in_array($_G['groupid'],$group))){
  12.         return;
  13. }
  14. $postdata=DB::fetch_first("select pid,subject from ".DB::table('forum_post')." where tid=".$tid." AND first=1 limit 1");
  15. $postdata['subject']=str_replace(array('[',']','.','-',lang('plugin/exx_tagseo', 'f01'),lang('plugin/exx_tagseo', 'f02'),'&','*','(',')','#','@','~','
  16. ,'%','+','=','^','_'),'',$postdata['subject']);//20180509
  17. if($postdata && empty($postdata['tags'])){
  18.         require_once libfile('function/post');
  19.         $message=strip_tags($thread['message']);
  20.         $msg=messagecutstr($message, 500);
  21.         getmode($tid,$postdata['pid'],$postdata['subject'],$msg);
  22. }
复制代码

' c) \, N( s( a9 T( k  g( p5 |6 `" q: @4 G, Q+ t' q

魔趣吧版权声明1,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2,本文内容仅代表作者本人观点,不代表本网站立场,作者文责自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3,本文内容,包括但不限于源码、文字、图片等,仅供参考使用,本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容
4,如您认为本文内容侵犯了您的权益,请与我们联系!我们将在5个工作日内做出处理!本站保留全部修改、解释、更新本声明的权利魔趣吧

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

在线支持
关闭
欢迎来到魔趣吧
如果你有建站技术问题、仿站需求、模板插件修改需求,请联系我们的技术支持!高效率,低价格的帮你搞定!
请认准魔趣吧唯一官网:www.moqu8.com,谨防假冒网站!

一般问题请到【求助区】发帖咨询(免费)!

邮箱咨询:
winkill2012@qq.com

邮箱咨询需注明:资源地址+本站用户名+具体问题,三者缺一不做处理。非本站资源不处理!
在线支持
快速回复 返回列表

关于魔趣吧|魔趣建站

魔趣吧,志在打造全国最大的建站资源共享平台。 本站提供海量免费的建站资源,包括WordPress模板、Discuz精仿模板、PHPWind模板、phpcms模板、Discuz精仿插件、帝国cms模板、织梦模板等上万精品模板!同时,提供各种建站素材、JS特效、整站程序源码!
服务中文站长,传播分享精神!建站,就来魔趣吧!!
2015-2024 魔趣吧 ( 豫ICP备2021024354号 )   豫公网安备41030402000182号 百度统计
HTTPS安全认证
|网站地图 | 已运行:天 
温馨提示:本站所有资源、教程、源码,不得用于非法站点及用途,否则,本站将终止提供任何服务! Powered by Discuz! Licensed