博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
relatekw.php,relatekw.php
阅读量:5106 次
发布时间:2019-06-13

本文共 3148 字,大约阅读时间需要 10 分钟。

/*

[Discuz!] (C)2001-2009 Comsenz Inc.

This is NOT a freeware, use is subject to license terms

$Id: relatekw.php 16688 2008-11-14 06:41:07Z cnteacher $

*/

error_reporting(0);

set_magic_quotes_runtime(0);

define('DISCUZ_ROOT', './');

define('IN_DISCUZ', TRUE);

define('NOROBOT', TRUE);

require_once './forumdata/cache/cache_settings.php';

if(!$_DCACHE['settings']['tagstatus']) {

exit;

}

require_once './config.inc.php';

require_once './include/global.func.php';

if($tid = @intval($_GET['tid'])) {

require_once './include/db_'.$database.'.class.php';

$db = new dbstuff;

$db->connect($dbhost, $dbuser, $dbpw, $dbname, $pconnect, true, $dbcharset);

$db->select_db($dbname);

unset($dbhost, $dbuser, $dbpw, $dbname, $pconnect);

if($db->result_first("SELECT count(*) FROM {$tablepre}threadtags WHERE tid='$tid'")) {

exit;

}

$query = $db->query("SELECT subject, message FROM {$tablepre}posts WHERE tid='$tid' AND first='1'");

$data = $db->fetch_array($query);

$subject = $data['subject'];

$message = cutstr($data['message'], 500, '');

} else {

$subject = $_GET['subjectenc'];

$message = $_GET['messageenc'];

}

$subjectenc = rawurlencode(strip_tags($subject));

$messageenc = rawurlencode(strip_tags(preg_replace("/\[.+?\]/U", '', $message)));

$data = @implode('', file("http://keyword.discuz.com/related_kw.html?ics=$charset&ocs=$charset&title=$subjectenc&content=$messageenc"));

if($data) {

if(PHP_VERSION > '5' && $charset != 'utf-8') {

require_once DISCUZ_ROOT.'./include/chinese.class.php';

$chs = new Chinese('utf-8', $charset);

}

$parser = xml_parser_create();

xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);

xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);

xml_parse_into_struct($parser, $data, $values, $index);

xml_parser_free($parser);

$kws = array();

foreach($values as $valuearray) {

if($valuearray['tag'] == 'kw' || $valuearray['tag'] == 'ekw') {

$kws[] = !empty($chs) ? $chs->convert(trim($valuearray['value'])) : trim($valuearray['value']);

}

}

$return = '';

if($kws) {

foreach($kws as $kw) {

$kw = htmlspecialchars($kw);

$return .= $kw.' ';

}

$return = htmlspecialchars($return);

}

if(!$tid) {

$inajax = 1;

include template('relatekw');

} else {

if($_DCACHE['settings']['tagstatus'] && $kws) {

require_once DISCUZ_ROOT.'/forumdata/cache/cache_censor.php';

$tagcount = 0;

foreach($kws as $tagname) {

$tagname = trim(empty($_DCACHE['censor']['filter']) ? $tagname : preg_replace($_DCACHE['censor']['filter']['find'], $_DCACHE['censor']['filter']['replace'], $tagname));

if(preg_match('/^([\x7f-\xff_-]|\w|\s){3,20}$/', $tagname)) {

$query = $db->query("SELECT closed FROM {$tablepre}tags WHERE tagname='$tagname'");

if($db->num_rows($query)) {

if(!$tagstatus = $db->result($query, 0)) {

$db->query("UPDATE {$tablepre}tags SET total=total+1 WHERE tagname='$tagname'", 'UNBUFFERED');

}

} else {

$db->query("INSERT INTO {$tablepre}tags (tagname, closed, total)

VALUES ('$tagname', 0, 1)", 'UNBUFFERED');

$tagstatus = 0;

}

if(!$tagstatus) {

$db->query("INSERT {$tablepre}threadtags (tagname, tid) VALUES ('$tagname', $tid)", 'UNBUFFERED');

}

$tagcount++;

if($tagcount > 4) {

break;

}

}

}

}

}

}

?>

一键复制

编辑

Web IDE

原始数据

按行查看

历史

转载地址:http://ohudv.baihongyu.com/

你可能感兴趣的文章
[BZOJ 3489] A simple rmq problem 【可持久化树套树】
查看>>
STM32单片机使用注意事项
查看>>
swing入门教程
查看>>
好莱坞十大导演排名及其代表作,你看过多少?
查看>>
Loj #139
查看>>
StringBuffer是字符串缓冲区
查看>>
hihocoder1187 Divisors
查看>>
java入门
查看>>
Spring 整合 Redis
查看>>
Azure 托管镜像和非托管镜像对比
查看>>
JSP:Cookie实现永久登录(书本案例)
查看>>
js window.open 参数设置
查看>>
032. asp.netWeb用户控件之一初识用户控件并为其自定义属性
查看>>
Ubuntu下安装MySQL及简单操作
查看>>
前端监控
查看>>
clipboard.js使用方法
查看>>
0906第一次作业
查看>>
移动开发平台-应用之星app制作教程
查看>>
leetcode 459. 重复的子字符串(Repeated Substring Pattern)
查看>>
伪类与超链接
查看>>