function _iconv($s, $t, $data) { if (function_exists('iconv')) { return iconv($s, $t, $data); } else { require_once 'chinese.class.php'; $chs = new Chinese($s, $t); return $chs->convert($data); } }
function insenz_convert($str, $type = 1) { global $charset, $discuz_chs, $insenz_chs; if ($charset != 'utf-8') { require_once DISCUZ_ROOT . './include/chinese.class.php'; if ($type) { if (!$insenz_chs) { $insenz_chs = new Chinese($charset, 'utf-8', TRUE); } $str = $insenz_chs->convert($str); } else { if (!$discuz_chs) { $discuz_chs = new Chinese('utf-8', $charset, TRUE); } $str = $discuz_chs->convert($str); } } return $type ? htmlspecialchars($str) : addslashes($str); }
require_once libfile('class/chinese'); $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); $xmldata = array('chanl', 'fid', 'title', 'tid', 'author', 'pdate', 'rdate', 'rnum', 'vnum', 'insite'); $relatedthreadlist = $keywords = array(); $nextuptime = 0; foreach ($index as $tag => $valuearray) { if (in_array($tag, $xmldata)) { foreach ($valuearray as $key => $value) { if ($values[$index['title'][$key]]['value']) { $relatedthreadlist[$key][$tag] = !empty($chs) ? $chs->convert(trim($values[$value]['value'])) : trim($values[$value]['value']); $relatedthreadlist[$key]['fid'] = !$values[$index['fid'][$key]]['value'] ? preg_replace("/(.+?)\\/forum\\-(\\d+)\\-(\\d+)\\.html/", "\\2", trim($values[$index['curl'][$key]]['value'])) : trim($values[$index['fid'][$key]]['value']); $relatedthreadlist[$key]['tid'] = !$values[$index['tid'][$key]]['value'] ? preg_replace("/(.+?)\\/thread\\-(\\d+)\\-(\\d+)-(\\d+)\\.html/", "\\2", trim($values[$index['surl'][$key]]['value'])) : trim($values[$index['tid'][$key]]['value']); } } } elseif (in_array($tag, array('kw', 'ekw'))) { $type = $tag == 'kw' ? 'general' : 'trade'; foreach ($valuearray as $value) { $keywords[$type][] = !empty($chs) ? $chs->convert(trim($values[$value]['value'])) : trim($values[$value]['value']); } } elseif ($tag == 'nextuptime') { $nextuptime = $values[$index['nextuptime'][0]]['value']; } elseif ($tag == 'keep' && intval($values[$index['keep'][0]]['value'])) { exit; } }
/** * GBK字符串转utf8为字符串 * @param string $str 要转换的字符串 * @return void */ function gbToUTF8($str) { static $chinese = NULL; if ($chinese === NULL) { require_once fimport('class/chinese'); $chinese = new Chinese('GBK', 'UTF-8'); } return $chinese->convert($str); }
$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 libfile('class/chinese'); $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 = dhtmlspecialchars($kw); $return .= $kw . ','; } $return = dhtmlspecialchars($return); } $return = substr($return, 0, strlen($return) - 1); if (!$tid) { $_G['inajax'] = 1; include template('forum/relatekw'); } elseif ($kws) {
function dz_get_tag($subject, $message, $return_array = 0) { if (VIP) { return FALSE; } if (empty($subject) && empty($message)) { return FALSE; } $subjectenc = rawurlencode(strip_tags($subject)); $message = strip_tags(preg_replace("/\\[.+?\\]/U", '', $message)); $message = cutstr($message, 960, ''); $messageenc = rawurlencode($message); $data = @implode('', file("http://keyword.discuz.com/related_kw.html?ics=" . CHARSET . "&ocs=" . CHARSET . "&title={$subjectenc}&content={$messageenc}")); if (!$data) { return FALSE; } if (PHP_VERSION > '5' && CHARSET != 'utf-8') { require_once libfile('class/chinese'); $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']); } } if ($return_array) { return $kws; } $return = ''; if ($kws) { foreach ($kws as $kw) { $kw = htmlspecialchars($kw); $return .= $kw . ' '; } $return = htmlspecialchars($return); } return $return; }