<?
PHP @H_
301_3@/* @H_
301_3@supesite7.0导入
PHPcms 2008 sp3 导入脚本 @H_
301_3@warran@qq.com @H_
301_3@http://www.veryhuo.com@H_
301_3@*/ @H_
301_3@header("Content-Type: text/html;charset=utf-8"); @H_
301_3@set_time_limit(0); @H_
301_3@define('IN_ADMIN',TRUE); @H_
301_3@define('IN_
PHPCMS',TRUE); @H_
301_3@require_once '../include/common.inc.
PHP'; @H_
301_3@require_once '../include/admin/process.class.
PHP'; @H_
301_3@require '../include/priv_role.class.
PHP'; @H_
301_3@require_once '../include/attachment.class.
PHP'; @H_
301_3@require_once '../include/admin/content.class.
PHP'; @H_
301_3@//
数据库连接 @H_
301_3@//conn1为supesite
数据库 @H_
301_3@//conn2为
PHPcms
数据库 @H_
301_3@$conn1=
MysqL_connect("localhost","root",""); @H_
301_3@
MysqL_select_db("site",$conn1); @H_
301_3@$conn2=
MysqL_connect("localhost",""); @H_
301_3@
MysqL_select_db("
PHPcms",$conn2); @H_
301_3@//清空
PHPcms
文章和
评论数据 @H_
301_3@if($_GET["action"]=='clean'){ @H_
301_3@
MysqL_query("delete from
PHPcms_content where 1=1",$conn2); @H_
301_3@
MysqL_query("delete from
PHPcms_content_count where 1=1",$conn2); @H_
301_3@
MysqL_query("delete from
PHPcms_c_news where 1=1",$conn2); @H_
301_3@
MysqL_query("delete from
PHPcms_content_tag where 1=1",$conn2); @H_
301_3@
MysqL_query("delete from
PHPcms_keyword where 1=1",$conn2); @H_
301_3@
MysqL_query("delete from
PHPcms_member_group_priv where 1=1",$conn2); @H_
301_3@
MysqL_query("delete from
PHPcms_comment where 1=1",$conn2); @H_
301_3@exit("清空完成"); @H_
301_3@} @H_
301_3@if($_GET["action"]=='test'){ @H_
301_3@echo hasuser("warran"); @H_
301_3@exit(); @H_
301_3@} @H_
301_3@//读取
分类表 @H_
301_3@$result=
MysqL_query("select catid,catname from
PHPcms_category",$conn2); @H_
301_3@while($row=
MysqL_fetch_array($result)){ @H_
301_3@$cat["$row[catname]"]=$row[catid]; @H_
301_3@} @H_
301_3@$_roleid = cache_read('admin_role_'.$_userid.'.
PHP'); @H_
301_3@$priv_role = new priv_role(); @H_
301_3@$c = new content(); @H_
301_3@$tmp=0; @H_
301_3@//
添加文章 @H_
301_3@$result=
MysqL_query("select supe_spaceitems.*,supe_categories.name as catname from supe_spaceitems,supe_categories where supe_spaceitems.catid=supe_categories.catid and supe_spaceitems.folder=1",$conn1); @H_
301_3@while($row=
MysqL_fetch_array($result)){ @H_
301_3@//使用
PHPcms
自带的类,
添加内容 @H_
301_3@$data["catid"]=$cat[$row["catname"]]; @H_
301_3@$attachment = new attachment("
PHPcms",$data["catid"]); @H_
301_3@$data["title"]=addslashes($row["subject"]); @H_
301_3@$data["style"]=""; @H_
301_3@$data["thumb"]=""; @H_
301_3@$res=
MysqL_query("select * from supe_spacenews where itemid=$row[itemid]",$conn1); @H_
301_3@$includetags=""; @H_
301_3@$message=""; @H_
301_3@while($rs=
MysqL_fetch_array($res)){ @H_
301_3@$message.=$rs["message"]; @H_
301_3@if($rs["includetags"]!=''){ @H_
301_3@$includetags.=" ".$rs["includetags"]; @H_
301_3@} @H_
301_3@} @H_
301_3@$data["keywords"]=addslashes($includetags); @H_
301_3@$data["author"]=addslashes($row["username"]); @H_
301_3@$data["copyfrom"]=addslashes($row["newsauthor"]); @H_
301_3@$data["description"]=""; @H_
301_3@$data["content"]=addslashes($message); @H_
301_3@$data["paginationtype"]="0"; @H_
301_3@$data["maxcharperpage"]="10000"; @H_
301_3@$data["titleintact"]=addslashes($row["short_subject"]); @H_
301_3@$data["islink"]="99"; @H_
301_3@$time_tmp=date("Y-m-d h:i:s"); @H_
301_3@$data["inputtime"]=$time_tmp; @H_
301_3@$data["posids"]="-99"; @H_
301_3@$data["groupids_view"]=array("-99"); @H_
301_3@$data["readpoint"]=""; @H_
301_3@$data["prefix"]=""; @H_
301_3@$data["template"]="show"; @H_
301_3@$data["status"]=99; @H_
301_3@$data["updatetime"]=$time_tmp; @H_
301_3@$contentid=$c->add($data,"",1); @H_
301_3@@H_
301_3@//
添加评论 @H_
301_3@$res=
MysqL_query("select * from supe_spacecomments where itemid=$row[itemid] and rates=0",$conn1); @H_
301_3@$comment_num=0; @H_
301_3@while($rs=
MysqL_fetch_array($res)){ @H_
301_3@$comment["keyid"]="
PHPcms-content-title-".$contentid; @H_
301_3@if($rs["authorid"]==0){ @H_
301_3@$comment["username"]="游客"; @H_
301_3@$comment["userid"]=0; @H_
301_3@}else{ @H_
301_3@$comment["username"]=addslashes($rs["author"]); @H_
301_3@$hasuser=hasuser($rs["author"]); @H_
301_3@if($hasuser==0){ @H_
301_3@$userinfo["username"]=addslashes($rs["author"]); @H_
301_3@$userinfo["password"]="82790085228cf8a1e3bac41f45271e5f"; @H_
301_3@$userinfo["touserid"]=$rs["authorid"]; @H_
301_3@$userinfo["email"]=""; @H_
301_3@$comment["userid"]=adduser($userinfo); @H_
301_3@}else{ @H_
301_3@$comment["userid"]=$hasuser; @H_
301_3@} @H_
301_3@@H_
301_3@} @H_
301_3@$comment["content"]=$rs["message"]; @H_
301_3@$comment["ip"]=$rs["ip"]; @H_
301_3@$comment["addtime"]=$rs["dateline"]; @H_
301_3@if(
MysqL_query("insert into
PHPcms_comment(keyid,userid,username,content,ip,addtime,status) values('$comment[keyid]',$comment[userid],'$comment[username]','$comment[content]','$comment[ip]',$comment[addtime],1)",$conn2)){ @H_
301_3@$comment_num+=1; @H_
301_3@} @H_
301_3@} @H_
301_3@
MysqL_query("update
PHPcms_content_count set comments=$comment_num,comments_checked=$comment_num where contentid=$contentid"); @H_
301_3@} @H_
301_3@function dump($vars,$label = '',$return = false) @H_
301_3@{ @H_
301_3@if (ini_get('html_errors')) { @H_
301_3@$content = "<pre>"; @H_
301_3@if ($label != '') { @H_
301_3@$content .= "<b>{$label} :</b>"; @H_
301_3@} @H_
301_3@$content .= htmlspecialchars(print_r($vars,true)); @H_
301_3@$content .= "</pre>"; @H_
301_3@} else { @H_
301_3@$content = $label . " :" . print_r($vars,true); @H_
301_3@} @H_
301_3@if ($return) { return $content; } @H_
301_3@echo $content; @H_
301_3@return null; @H_
301_3@} @H_
301_3@/* @H_
301_3@向
PHPcms中
添加用户 @H_
301_3@*/ @H_
301_3@function adduser($userinfo){ @H_
301_3@global $conn2; @H_
301_3@
MysqL_query("insert into
PHPcms_member(username,password,groupid,touserid,email) values('$userinfo[username]','$userinfo[password]',6,$userinfo[touserid],'$userinfo[email]')",$conn2); @H_
301_3@$userid=
MysqL_insert_id(); @H_
301_3@
MysqL_query("insert into
PHPcms_member_cache(username,$conn2); @H_
301_3@return $userid; @H_
301_3@} @H_
301_3@/* @H_
301_3@判断
PHPcms中是否有此
用户 @H_
301_3@*/ @H_
301_3@function hasuser($username) @H_
301_3@{ @H_
301_3@global $conn2; @H_
301_3@$res=
MysqL_query("select userid from
PHPcms_member where username='".$username."'",$conn2); @H_
301_3@$row=
MysqL_fetch_array($res); @H_
301_3@if($row[0]){ @H_
301_3@//有
用户 @H_
301_3@return $row[0]; @H_
301_3@}else{ @H_
301_3@//没
用户 @H_
301_3@return 0; @H_
301_3@} @H_
301_3@} @H_
301_3@?>