1,在dede根目錄下新建關鍵字列表txt---> key.txt,內容格式如下:
關鍵字1|鏈接網址1
關鍵字2|鏈接網址2
關鍵字3|鏈接網址3
關鍵字4|鏈接網址4
2,在dede根目錄下新建 update_keyword.php,內容如下:
<?php
require_once(dirname(__FILE__)."/include/common.inc.php");<p>
$sql = " truncate table `dede_keywords` "; //注意:此處刪除表,如果只是追加關鍵字,請注釋此處
if(!$dsql->ExecuteNoneQuery($sql)) echo "錯誤!<br />";
$convertedrows = 0;
$m_file = "key.txt";
//讀取key.txt
$fp = fopen($m_file,'r');
$allkey = fread($fp,filesize($m_file));
$allkeys = explode("\n", $allkey);
fclose($fp);
//print_r($allkeys);
foreach($allkeys as $keys)
{
$newkey = explode('|', $keys);
$keyword = trim($newkey['0']);
$rpurl = trim($newkey['1']);
$rank = trim($newkey['2']);
//echo $keyword."--".$rpurl."--".$rank;
//exit;
$query = "INSERT INTO `51_keywords`(keyword, rank, sta, rpurl) VALUES ('$keyword', '$rank', '1', '$rpurl')";
if(!$dsql->ExecuteNoneQuery($query)) echo "插入錯誤!<br />";
$convertedrows ++;
echo '插入第'.$convertedrows.'個關鍵字--->'.$keyword.'<br>';
}
echo '共插入'.$convertedrows.'個關鍵字';
exit();
?>
3,浏覽器直接訪問 update_keyword.php
*