<?
$old_db="xplusnew";
$old_prefix="plus_";
$new_db="color";
$new_prefix="glad_";
include "config.inc.php";
$sql="select * from ".$old_db.".".$old_prefix."category ";
$rt=$PlusDB->query($sql);
while($row=$PlusDB->fetchArray($rt)){
	$sql="insert into ".$new_db.".".$new_prefix."category  ( `id` , `title` , `icon` , `english_name` , `pid` , `o_num` , `intro` , `ctime` , `mod` , `cate_template` , `list_template` , `detail_template` , `other_1` , `other_2` , `other_3` , `hits` , `page_title` , `page_keyword` , `page_discription` , `page_num` , `page_col` ) VALUES ('$row[cate_id]', '$row[cate_title]', '', '', '$row[cate_parent_id]', '0', '$row[cate_intro]', '".date("Y-m-d H:i:s",$row[ctime])."', '', 'index.php', 'default.tpl', 'index.tpl', '', '', '', '0', '', '', '', '20', '1');";
$PlusDB->queryF($sql);
}
$sql="select * from ".$old_db.".".$old_prefix."articles  where 1=1";
$rt=$PlusDB->query($sql);
while($row=$PlusDB->fetchArray($rt)){
	$sql="insert into ".$new_db.".".$new_prefix."articles ( `id` , `uid` , `cid` , `title` , `intro` , `content` , `author` , `source` , `img` , `thumb` , `first` , `isimg` , `ctime` , `etime` , `utime` , `voter` , `vote` , `hits` , `active` , `mark` ) values ('$row[article_id]', '$row[article_id]', '$row[editor]','$row[article_cate_id] ','$row[article_title]','$row[article_intro]','','$row[article_author]','$row[article_source]' ,'','','','','".date("Y-m-d H:i:s",$row[article_date])."','','','','$row[hits]','yes','')";
	$PlusDB->queryF($sql);
	$sql="select * from ".$old_db.".".$old_prefix."article_chapters where article_id=$row[article_id]";
	$rt2=$PlusDB->query($sql);
	while($row2=$PlusDB->fetchArray($rt2)){
		$sql="insert into ".$new_db.".".$new_prefix."contents (id,aid,cid,title,content,ctime) values ('$row2[chapter_id]','$row2[article_id]','$row[article_cate_id]','$row2[chapter_title]','$row2[chapter_content]','".date("Y-m-d H:i:s",$row2[chapter_date])."')";
		$PlusDB->queryF($sql);
	}
}
?>