<?php
require dirname(__FILE__) . '/../jxcms/common.php';
$title = rawurlencode(strip_tags($_GET['title']));
$content = rawurlencode(strip_tags(preg_replace("/\[.+?\]/U", '', $_GET['content'])));
$data = @implode('', file("http://keyword.discuz.com/related_kw.html?title=$title&content=$content&ics=gbk&ocs=gbk"));

if ($data) {
	$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[] = Func :: shtmlspecialchars(trim($valuearray['value']));
		}
	}

	$tags = $kws ? implode(',', $kws) : '';
} else {
	$tags = '';
}
echo $tags;
?>