setup5.jsp
资源名称:NetOffice.rar [点击查看]
上传用户:guhaomin
上传日期:2007-06-10
资源大小:23203k
文件大小:6k
源码类别:
电子政务应用
开发平台:
Java
- <%
- /**
- * Jive Setup Tool
- * November 28, 2000
- */
- %>
- <%@ page import="java.io.*,
- java.util.*,
- java.sql.*,
- java.security.*,
- com.coolservlets.forum.*,
- com.coolservlets.forum.util.*,
- com.coolservlets.forum.database.*,
- com.coolservlets.util.*"
- %>
- <%!
- private String[] getPropertyNames( DbConnectionProvider conProvider ) {
- Enumeration enum = conProvider.propertyNames();
- Vector v = new Vector();
- while( enum.hasMoreElements() ) {
- v.addElement( enum.nextElement() );
- }
- String[] propNames = new String[ v.size() ];
- v.copyInto(propNames);
- return propNames;
- }
- %>
- <%
- //DbConnectionProvider conProvider = DbConnectionManager.getDbConnectionProvider();
- %>
- <%
- boolean error = false;
- String errorMessage = null;
- //Make sure the install has not already been completed.
- String setup = PropertyManager.getProperty("setup");
- if( setup != null && setup.equals("true") ) {
- error = true;
- errorMessage = "BBS设置已经完成,如果您想重新设置,请删除jive.properties配置文件中'setup=true'字段,然后再试。";
- }
- %>
- <% // get parameters
- boolean createAdmin = ParamUtils.getBooleanParameter(request,"createAdmin");
- String username = ParamUtils.getParameter(request,"username");
- String password = ParamUtils.getParameter(request,"password");
- if (password == null) {
- password = "";
- }
- String confirmPassword = ParamUtils.getParameter(request,"confirmPassword");
- if (confirmPassword == null) {
- confirmPassword = "";
- }
- String name = ParamUtils.getParameter(request,"name");
- String email = ParamUtils.getParameter(request,"email");
- if( name == null ) { name = ""; }
- if( createAdmin ) {
- if (! password.equals(confirmPassword)) {
- error = true;
- errorMessage = "您输入的密码不匹配,请返回重新输入!";
- }
- else {
- Connection con = null;
- Statement stmt = null;
- PreparedStatement pstmt = null;
- try {
- String sql = "insert into jiveUser(userID,username,passwordHash,name,email,emailVisible,nameVisible) "
- + " values(?,?,?,?,?,?,?)";
- password = StringUtils.hash(password);
- con = DbConnectionManager.getConnection();
- if( con == null ) {
- error = true;
- errorMessage = "无法建立数据库连接,请确认您数据库设置正确!";
- }
- else {
- pstmt = con.prepareStatement(sql);
- pstmt.setInt(1,1);
- pstmt.setString(2,username);
- pstmt.setString(3,password);
- pstmt.setString(4,name);
- pstmt.setString(5,email);
- pstmt.setInt(6,1);
- pstmt.setInt(7,1);
- pstmt.executeUpdate();
- pstmt.close();
- stmt = con.createStatement();
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,0)");
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,1)");
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,2)");
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,3)");
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,4)");
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,5)");
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,6)");
- stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,1,7)");
- //stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,-1,0)");
- //stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,-1,6)");
- //stmt.executeUpdate("insert into jiveUserPerm(forumID,userID,permission) values(-1,-1,7)");
- stmt.close();
- }
- if( !error ) {
- out.println( "ok");
- response.sendRedirect("setup6.jsp");
- return;
- }
- }
- catch( SQLException sqle ) {
- System.err.println( sqle );
- sqle.printStackTrace();
- error = true;
- errorMessage = "在创建超级管理员是发生错误。可能有如下原因: <ul> <li>无法建立数据库连接。 <li> 没有建立数据库表 <li> 数据库中已经存在超级管理员帐号 </ul> <p> 您可以在log文件中检查更多的原因,如果可能,返回重新建立超级管理员帐号。";
- }
- finally {
- try {
- con.close();
- } catch (Exception e) { }
- }
- }
- }
- %>
- <html>
- <head>
- <title>BBS设置-第五步</title>
- <link rel="stylesheet" href="style/global.css">
- </head>
- <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
- <img src="images/setup.gif" width="210" height="38" alt="BBS设置" border="0">
- <hr size="0"><p>
- <%
- if (!error) {
- %>
- <b>创建管理员帐号</b>
- <ul>
- <font size="-1">
- 管理员拥有最高的权限,可以管理BBS论坛,请一定记住您管理员的密码,如果您忘了,您只能手工修改数据库。
- <form action="setup5.jsp" mode="post">
- <input type="hidden" name="createAdmin" value="true">
- <table cellpadding="3" cellspacing="0" border="0">
- <tr>
- <td><font size="-1">姓名</font></td>
- <td><input type="text" size="30" name="name" value=""></td>
- </tr>
- <tr>
- <td><font size="-1">用户名</font></td>
- <td><input type="text" size="30" name="username" value=""></td>
- </tr>
- <tr>
- <td><font size="-1">email地址</font></td>
- <td><input type="text" size="30" name="email" value=""></td>
- </tr>
- <tr>
- <td><font size="-1">口令</font></td>
- <td><input type="password" size="30" name="password" value=""></td>
- </tr>
- <tr>
- <td><font size="-1">口令</font><br><font size="-1"><i>(确认)</i></font></td>
- <td><input type="password" size="30" name="confirmPassword" value=""></td>
- </tr>
- </table>
- </ul>
- <center>
- <input type="submit" value="创建管理员帐号">
- </center>
- <%
- } //end no error
- else {
- %>
- <font color="Red">错误:</font>
- <p><font size=2>
- <%= errorMessage %>
- </font>
- <%
- } //end error
- %>
- <p>
- 如果您已经创建了管理员帐号,您可以<a href="setup6.jsp">跳过此步</a>。
- <p><hr size="0">
- <center><font size="-1"><i>www.visionnex.com</i></font></center>
- </font>
- </body>
- </html>