<%@ page import="java.util.Properties" %> <%@ page import="java.util.UUID" %> <%@ page import="java.io.File" %> <%@ page import="java.io.FileOutputStream" %> <%@ page import="org.crosswire.utils.SMTPMail" %> <%@ page import="org.crosswire.utils.Utils" %> <% String login = request.getParameter("reg_user"); String email = request.getParameter("email"); // check if we have all required data filled in if ((login == null) || (email == null) || (login.length() < 2) || (email.length() < 2)) { %> Please enter your requested user ID and email <% return; } // check if username is ok for (int i = 0; i < login.length(); i++) { char c = login.charAt(i); if (((c < 'a') || (c > 'z')) && ((c < 'A') || (c > 'Z')) && ((c < '0') || (c > '9')) && (c != '_') && (c != '.') ) { %> Valid user IDs consist of [A-Z][a-z][0-9][._] <% return; } } // check if user exists File user = new File(pageContext.getServletContext().getRealPath("/users/"+login)); if (user.exists()) { %> User exists. Try another user id. <% return; } // created uuid token on server and // send confirmation email String fromEmail = Utils.getSysConfig(session).getProperty("SendMailFrom"); String siteName = Utils.getSysConfig(session).getProperty("SiteName"); String siteRoot = Utils.getSysConfig(session).getProperty("SiteRoot"); Properties u = new Properties(); u.setProperty("login", login); u.setProperty("email", email); String uuid = UUID.randomUUID().toString(); File uuidFileName = new File(pageContext.getServletContext().getRealPath("/WEB-INF/regs/"+uuid+".properties")); FileOutputStream uuidFile = new FileOutputStream(uuidFileName); u.store(uuidFile, null); uuidFile.close(); SMTPMail.sendEmail(session, fromEmail, email, siteName+" Registration", "Someone-- hopefully you-- is attemping to create an account:\n" +login+" at "+siteName+" site using your email address.\n" +"To activate this account click the link below:\n\n" +siteRoot+"/modules/login/activate.jsp?uuid="+uuid+"\n\n" +"If you did not request this, do nothing and this account will not be created."); %> Verification sent. Please check your email.