\r\n";
flush();
$ws = $wserr = $wsnew = "";
$dsql->SetQuery("SELECT * FROM `#@__keywords`");
$dsql->Execute();
while($row = $dsql->GetObject())
{
if($row->sta==1) $ws[$row->keyword] = 1;
else $wserr[$row->keyword] = 1;
}
echo "完成关键字数据库的载入!
\r\n";
flush();
echo "读取档案数据库,并对禁用的关键字和生字进行处理...
\r\n";
flush();
$dsql->SetQuery("SELECT id,keywords FROM `#@__archives`");
$dsql->Execute();
while($row = $dsql->GetObject())
{
$keywords = explode(',',trim($row->keywords));
$nerr = false;
$mykey = '';
if(is_array($keywords))
{
foreach($keywords as $v)
{
$v = trim($v);
if($v=='')
{
continue;
}
if(isset($ws[$v]))
{
$mykey .= $v." ";
}
else if(isset($wsnew[$v]))
{
$mykey .= $v.' ';
$wsnew[$v]++;
}
else if(isset($wserr[$v]))
{
$nerr = true;
}
else
{
$mykey .= $v." ";
$wsnew[$v] = 1;
}
}
}
}
echo "完成档案数据库的处理!
\r\n";
flush();
if(is_array($wsnew))
{
echo "对关键字进行排序...
\r\n";
flush();
arsort($wsnew);
echo "把关键字保存到数据库...
\r\n";
flush();
foreach($wsnew as $k=>$v)
{
if(strlen($k)>20)
{
continue;
}
$dsql->SetQuery("INSERT INTO `#@__keywords`(keyword,rank,sta,rpurl) VALUES('".addslashes($k)."','$v','1','')");
$dsql->Execute();
}
echo "完成关键字的导入!
\r\n";
flush();
sleep(1);
}
else
{
echo "没发现任何新的关键字!
\r\n";
flush();
sleep(1);
}
ShowMsg('完成所有操作,现在转到关键字列表页!','article_keywords_main.php');
exit();
}
//自动获取关键字(适用于默认的文章模型)
else if($dopost=='fetch')
{
require_once(DEDEINC."/splitword.class.php");
if(empty($startdd))
{
$startdd = 0;
}
if(empty($pagesize))
{
$pagesize = 20;
}
if(empty($totalnum))
{
$totalnum = 0;
}
//统计记录总数
if($totalnum==0)
{
$row = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__archives` WHERE channel='1' ");
$totalnum = $row['dd'];
}
//获取记录,并分析关键字
if($totalnum > $startdd+$pagesize)
{
$limitSql = " LIMIT $startdd,$pagesize";
}
else if(($totalnum-$startdd)>0)
{
$limitSql = " LIMIT $startdd,".($totalnum - $startdd);
}
else
{
$limitSql = '';
}
$tjnum = $startdd;
if($limitSql!='')
{
$fquery = "SELECT arc.id,arc.title,arc.keywords,addon.body FROM `#@__archives` arc
LEFT JOIN `#@__addonarticle` addon ON addon.aid=arc.id WHERE arc.channel='1' $limitSql ";
$dsql->SetQuery($fquery);
$dsql->Execute();
$sp = new SplitWord($cfg_soft_lang , $cfg_soft_lang );
while($row=$dsql->GetObject())
{
if($row->keywords!='')
{
continue;
}
$tjnum++;
$id = $row->id;
$keywords = "";
$sp->SetSource($row->title, $cfg_soft_lang , $cfg_soft_lang );
$sp->SetResultType(2);
$sp->StartAnalysis(TRUE);
$titleindexs = $sp->GetFinallyIndex();
$sp->SetSource(Html2Text($row->body), $cfg_soft_lang , $cfg_soft_lang );
$sp->SetResultType(2);
$sp->StartAnalysis(TRUE);
$allindexs = $sp->GetFinallyIndex();
if(is_array($allindexs) && is_array($titleindexs))
{
foreach($titleindexs as $k => $v)
{
if(strlen($keywords)>=30)
{
break;
}
else
{
if(strlen($k) <= 2) continue;
$keywords .= $k.",";
}
}
foreach($allindexs as $k => $v)
{
if(strlen($keywords)>=30)
{
break;
}
else if(!in_array($k,$titleindexs))
{
if(strlen($k) <= 2) continue;
$keywords .= $k.",";
}
}
}
$keywords = addslashes($keywords);
if($keywords=='')
{
$keywords = ',';
}
$dsql->ExecuteNoneQuery("UPDATE `#@__archives` SET keywords='$keywords' WHERE id='$id'");
}
unset($sp);
}//end if limit
//返回提示信息
if($totalnum>0) $tjlen = ceil( ($tjnum/$totalnum) * 100 );
else $tjlen=100;
$dvlen = $tjlen * 2;
$tjsta = "