📄 lybbs_7.1to7.2.jsp
字号:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="net.lybbs.util.*"%>
<%@ page import="net.lycommon.util.*"%>
<%@ page import="net.lycommon.db.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<script>
var notErrorOccurs=true;
var finished=false;
</script>
<%
int step=ParameterUtils.getInt(request,"step");
int offset=ParameterUtils.getInt(request,"offset");
int limit=ParameterUtils.getInt(request,"limit");
System.out.println("step"+step+" currentoffset:"+offset+" limit:"+limit);
byte zeroTimes=ParameterUtils.getByte(request,"zeroTimes");
boolean notFirstTime=ParameterUtils.getBoolean(request,"notFirstTime");
int to=offset+limit;
out.println("<br>");
out.println("Next upgrade lybbs, if connection failed, please check test.jsp first:<br>");
DBConnect dbConnect=null;
PreparedStatement prestmt1=null;
PreparedStatement prestmt2=null;
PreparedStatement prestmt3=null;
PreparedStatement prestmt4=null;
ResultSet rs=null;
try {
dbConnect=DBConnectManager.getInstance().getDBConnect();
dbConnect.createConnection();
if(step==1) {
//清空待转换数据表的全部数据
Statement stmt=dbConnect.createStatement();
dbConnect.insert(stmt,"delete from lybbs_postlist");
dbConnect.insert(stmt,"delete from lybbs_posttopic");
dbConnect.insert(stmt,"delete from lybbs_postreply");
dbConnect.insert(stmt,"delete from lybbs_postvalidate");
dbConnect.insert(stmt,"delete from lybbs_postrecycle");
dbConnect.executeBatch(stmt,null);
out.println("<script>finished=true;</script>");
}
else if(step==2) {
//Statement stmt=dbConnect.createStatement();
//dbConnect.executeBatch(stmt,null);
out.println("<script>finished=true;</script>");
}
else if(step==3) {
//填充回复帖的title
int maxPostID=0;
prestmt4=dbConnect.createPreparedStatement("select max(id) from lybbs_posts where parentid=0");
rs=dbConnect.executeQuery(prestmt4);
if(rs.next()) {maxPostID=rs.getInt(1);}
rs.close();
int postID=0;
String title="";
prestmt1=dbConnect.createPreparedStatement("update lybbs_posts set title=? where parentid=?");
prestmt2=dbConnect.createPreparedStatement("select id,title from lybbs_posts where parentid=0 and id>"+offset+" and id<="+to);
rs=dbConnect.executeQuery(prestmt2);
while(rs.next()) {
postID=rs.getInt(1);
title="Re:"+rs.getString(2);
prestmt1.setString(1,title);
prestmt1.setInt(2,postID);
dbConnect.executeUpdate(prestmt1);
}
out.println("<br>postID:"+postID+" total:"+maxPostID);
if(postID==0){zeroTimes++;} else{zeroTimes=0;}
if(maxPostID<=postID){out.println("<script>finished=true;</script>");}
}
else if(step==4) {
//填充上传附件帖的title
int maxPostID=0;
prestmt4=dbConnect.createPreparedStatement("select max(postsid) from lybbs_uploadinfo");
rs=dbConnect.executeQuery(prestmt4);
if(rs.next()) {maxPostID=rs.getInt(1);}
rs.close();
int uploadInfoID=0;
int postID=0;
int forumID=0;
int topicID=0;
String title="";
prestmt1=dbConnect.createPreparedStatement("update lybbs_uploadinfo set forumid=?,parentid=?,title=? where id=?");
prestmt2=dbConnect.createPreparedStatement("select a.id,a.postsid,b.parentid,b.db,b.title from lybbs_uploadinfo a,lybbs_posts b where a.postsid=b.id and a.postsid>"+offset+" and a.postsid<="+to);
rs=dbConnect.executeQuery(prestmt2);
while(rs.next()) {
uploadInfoID=rs.getInt(1);
postID=rs.getInt(2);
topicID=rs.getInt(3);
forumID=rs.getInt(4);
title=rs.getString(5);
prestmt1.setInt(1,forumID);
prestmt1.setInt(2,topicID);
prestmt1.setString(3,title);
prestmt1.setInt(4,uploadInfoID);
dbConnect.executeUpdate(prestmt1);
}
out.println("<br>postID:"+postID+" total:"+maxPostID);
if(postID==0){zeroTimes++;} else{zeroTimes=0;}
if(maxPostID<=postID){out.println("<script>finished=true;</script>");}
}
else if(step==5) {
//转换论坛帖子
int maxPostID=0;
prestmt4=dbConnect.createPreparedStatement("select max(id) from lybbs_posts");
rs=dbConnect.executeQuery(prestmt4);
if(rs.next()) {maxPostID=rs.getInt(1);}
rs.close();
prestmt4.close();
int postID=0;
int topicID;
int forumID;
int userID;
String userName;
String title;
String content;
long postAt;
String postIp;
String titleIcon;
byte accessary;
byte accessaryImg;
String accessaryExt;
String accessaryPath;
int clickTimes;
int replyNum;
int voteNum;
byte lockTop;
int lockTopID;
byte lockReply;
byte lockVote;
byte vote;
byte voteCondition;
byte elite;
byte invisible=0;
byte showSign;
String color;
byte boldCode;
byte viewMode;
int viewNumber;
int lastEditAuthorID;
String lastEditAuthor;
int lastEditAt;
String lastEditIp;
int lastAuthorID;
String lastAuthor;
int lastPostAt;
String lastPostClue;
prestmt1=dbConnect.createPreparedStatement("insert into lybbs_postlist (id,forumid,authorid,author,title,postat,titleicon,accessaryimg,accessaryext,accessarypath,clicktimes,replynum,votenum,locktop,locktopid,lockreply,lockvote,vote,elite,invisible,color,boldcode,lastauthorid,lastauthor,lastpostat,lastpostclue) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
prestmt2=dbConnect.createPreparedStatement("insert into lybbs_posttopic (id,forumid,authorid,author,title,content,postat,postattime,postip,titleicon,accessary,clicktimes,replynum,votenum,locktop,locktopid,lockreply,lockvote,vote,votecondition,elite,invisible,showsign,color,boldcode,viewmode,viewnumber,lasteditauthorid,lasteditauthor,lasteditat,lasteditip) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
prestmt3=dbConnect.createPreparedStatement("insert into lybbs_postreply (id,forumid,topicid,authorid,author,title,content,postat,postattime,postip,titleicon,accessary,invisible,showsign,viewmode,viewnumber,lasteditauthorid,lasteditauthor,lasteditat,lasteditip) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
prestmt4=dbConnect.createPreparedStatement("select a.id,a.db,a.clicktimes,a.parentid,a.istop,a.topid,a.titlelock,a.titleimage,a.authorid,a.author,a.title,a.postat,a.ipfrom,a.accessary,a.accessaryname,a.vote,a.jinghua,a.showsignature,a.isrecommend,a.color,a.boldcode,a.viewmode,a.viewnumber,a.votecondition,a.replynum,a.votenum,a.lastauthorid,a.lastauthor,a.lastpostat,a.lastpostclue,b.content from lybbs_posts a,lybbs_postcontent b where a.id=b.postID and a.id>"+offset+" and a.id<="+to);
rs=dbConnect.executeQuery(prestmt4);
while(rs.next()) {
postID=rs.getInt(1);
forumID=rs.getInt(2);
clickTimes=rs.getInt(3);
topicID=rs.getInt(4);
lockTop=Byte.parseByte(rs.getString(5));
lockTopID=rs.getInt(6);
lockReply=Byte.parseByte(rs.getString(7));
titleIcon=rs.getString(8);
userID=rs.getInt(9);
userName=rs.getString(10);
title=rs.getString(11);
postAt=rs.getTimestamp(12).getTime();
postIp=rs.getString(13);
accessary=Byte.parseByte(rs.getString(14));
accessaryPath=rs.getString(15);
accessaryExt=org.apache.commons.io.FilenameUtils.getExtension(accessaryPath);
accessaryImg=ImgUtils.isImage(accessaryExt)?(byte)1:(byte)0;
vote=Byte.parseByte(rs.getString(16).length()==0?"0":rs.getString(16));
lockVote=vote!=(byte)0&&lockReply==(byte)1?(byte)1:(byte)0;
elite=Byte.parseByte(rs.getString(17));
showSign=rs.getByte(18);
elite=rs.getByte(19)==(byte)1?(byte)2:elite;
color=rs.getString(20);
boldCode=rs.getByte(21);
viewMode=rs.getByte(22);
viewNumber=rs.getInt(23);
voteCondition=rs.getByte(24);
replyNum=rs.getInt(25);
voteNum=rs.getInt(26);
lastAuthorID=rs.getInt(27);
lastAuthor=rs.getString(28);
lastPostAt=(int)(rs.getLong(29)/1000);
lastPostClue=rs.getString(30);
content=rs.getString(31);
if(topicID==0) {
prestmt1.setInt(1,postID);
prestmt1.setInt(2,forumID);
prestmt1.setInt(3,userID);
prestmt1.setString(4,userName);
prestmt1.setString(5,title);
prestmt1.setInt(6,DateUtils.getMillisToSeconds(postAt));
prestmt1.setString(7,titleIcon);
prestmt1.setByte(8,accessaryImg);
prestmt1.setString(9,accessaryExt);
prestmt1.setString(10,accessaryPath);
prestmt1.setInt(11,clickTimes);
prestmt1.setInt(12,replyNum);
prestmt1.setInt(13,voteNum);
prestmt1.setByte(14,lockTop);
prestmt1.setInt(15,lockTopID);
prestmt1.setByte(16,lockReply);
prestmt1.setByte(17,lockVote);
prestmt1.setByte(18,vote);
prestmt1.setByte(19,elite);
prestmt1.setByte(20,invisible);
prestmt1.setString(21,color);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -