function GetKeywords($keyword)
{
global $cfg_soft_lang;
$keyword = cn_substr($keyword, 50);
$row = $this->dsql->GetOne("SELECT spwords FROM `dede_search_keywords` WHERE keyword='".addslashes($keyword)."'; ");
if(!is_array($row))
{
if(strlen($keyword)>7)
{
$sp = new SplitWord($cfg_soft_lang, $cfg_soft_lang);
$sp->SetSource($keyword, $cfg_soft_lang, $cfg_soft_lang);
$sp->SetResultType(2);
$sp->StartAnalysis(TRUE);
$keywords = $sp->GetFinallyResult();
$idx_keywords = $sp->GetFinallyIndex();
ksort($idx_keywords);
$keywords = $keyword.' ';
foreach ($idx_keywords as $key => $value) {
if (strlen($key) <= 3) {
continue;
}
$keywords .= ' '.$key;
}
$keywords = preg_replace("/[ ]{1,}/", " ", $keywords);
//var_dump($idx_keywords);exit();
unset($sp);
}
else
{
$keywords = $keyword;
}
$inquery = "INSERT INTO `dede_search_keywords`(`keyword`,`spwords`,`count`,`result`,`lasttime`)
VALUES ('".addslashes($keyword)."', '".addslashes($keywords)."', '1', '0', '".time()."'); ";
$this->dsql->ExecuteNoneQuery($inquery);
}
else
{
$this->dsql->ExecuteNoneQuery("UPDATE `dede_search_keywords` SET count=count+1,lasttime='".time()."' WHERE keyword='".addslashes($keyword)."'; ");
$keywords = $row['spwords'];
}
return $keywords;
}
|