<%@ page import="ebiz.ist.sqlutil.*"%> <%@ page import="ebiz.jsp.util.*"%> <%@ page import="ebiz.jsp.system.*"%> <%@ page import="ebiz.jsp.db.*"%> <%@ page import="java.util.*"%> <%@ page import="java.text.*"%> <%@ page import="java.sql.*"%> <%@ page import="java.awt.Color"%> <%@ page import="java.awt.Font"%> <%@ page import="java.awt.Graphics2D"%> <%@ page import="java.awt.geom.AffineTransform"%> <%@ page import="java.awt.image.BufferedImage"%> <%@ page import="java.io.IOException"%> <%@ page import="java.io.FileOutputStream"%> <%@ page import="javax.imageio.ImageIO"%> <% String value; Random mynum=new Random(System.currentTimeMillis()); String validate = "false"; String validatefield = "false"; String msg = ""; String strDate = ""; java.util.Date utilDate = new java.util.Date(); SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy"); String strTime = ""; String strVenue = ""; int intTel=0; int k = -1; //the selected row in crs_2 String strCourseID = request.getParameter("courseID"); String strCourseName = request.getParameter("txtCourseName"); String strName = request.getParameter("txtName"); String strEmail = request.getParameter("txtEmail"); String strEmail2 = request.getParameter("txtEmail2"); String strAcctNo = request.getParameter("txtAcctNo"); String strTel = request.getParameter("txtTel"); String strPartType = request.getParameter("txtPartType"); String strPlate = request.getParameter("txtPlate"); //Retain entered Participant's info if (strName == null) { strName=""; } if (strEmail == null) { strEmail=""; } if (strEmail2 == null) { strEmail2=""; } if (strAcctNo == null) { strAcctNo=""; } if (strTel == null) { strTel=""; } if (strPlate == null) { strPlate=""; } CustomResultSet crs = null; //using Connection Pool String propFile = "/ist/config_uobkhco/mysqlutil.properties"; JSPMysqlDatabaseAccess db = JSPMysqlDatabaseAccess._getInstance(propFile); SQLMysqlUtil sqlmysqlutil = null; try { //Get Connection fr pool sqlmysqlutil = db.pool.borrowConnection(); // Construct DB SQL scripts. String sqlc = "SELECT CourseID, Name, DATE_FORMAT(Date, '%e %b %Y') AS sDate, Venue, Time, PartType From Ind_Course WHERE Publish='Y' AND CourseID='"+strCourseID+"' and SeatsTaken < MaxSeats"; //testing sql //String sqlc = "SELECT CourseID, Name, DATE_FORMAT(Date, '%e %b %Y') AS sDate, Venue, Time, PartType From Course WHERE CourseID='"+strCourseID+"' and SeatsTaken < MaxSeats"; sqlmysqlutil.setSQL(sqlc); //out.println("After setSQL 2 "); crs = new CustomResultSet(sqlmysqlutil.executeQuery()); //out.println("After SQLQuery 2 "); sqlmysqlutil.reset(); if (crs.getRowCount()<=0) { %> <% } }//end-try catch (Exception ex) { System.err.println("ERROR in connection - " + ex.getMessage()); } finally { db.pool.returnConnection(sqlmysqlutil); } %> <%! // servlet methods private void ImageVerification (int height, int width, String outfile, String value) throws IOException { BufferedImage bimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Random rand=new Random(System.currentTimeMillis()); Graphics2D g = bimage.createGraphics(); FileOutputStream outf=new FileOutputStream(outfile); // create a random color Color color = new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255)); // the the background to the random color to fill the // background and make it darker g.setColor(color.darker()); g.fillRect(0, 0, width, height); // set the font g.setFont(new Font("arial",Font.BOLD,20)); // generate a random value //this.value = "1234"; // UUID.randomUUID().toString().replace("-","").substring(0,5); int w = (g.getFontMetrics()).stringWidth(value); int d = (g.getFontMetrics()).getDescent(); int a = (g.getFontMetrics()).getMaxAscent(); int x = 0, y =0; // randomly set the color and draw some straight lines through it for (int i = 0; i < height; i += 5) { g.setColor(new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255))); g.drawLine(x, y + i, width, y+i); } // reset x and y x=0; y=0; // randomly set the color of the lines and just draw think at an angle for (int i = 0; i < height; i += 5) { g.setColor(new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255))); g.drawLine(x, y + d - i, width + w, height + d - i); } // randomly set the color and make it really bright for more readability g.setColor(new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255)).brighter().brighter()); // we need to position the text in the center of the box x = width/2 - w/2; y = height/2 + a/2 - 2; // affine transform is used to rock the text a bit AffineTransform fontAT = new AffineTransform(); int xp = x-2; // walk through each character and rotate it randomly for (int c=0;c UOB Kay Hian
<% strPartType=((crs.getString(0,"PartType")==null)?"":crs.getString(0,"PartType")); %> <% strPartType=((crs.getString(0,"PartType")==null)?"":crs.getString(0,"PartType")); %> <% if (crs.getString(0,"PartType").equalsIgnoreCase("c")) { %> <% } else{ %> <% } %> <% int num, fnum; int ofnum=0; String display; if (request.getParameter("validno")!= null && request.getParameter("validno").trim().length()>0) { fnum=Integer.parseInt(request.getParameter("checkno")); num=Integer.parseInt(request.getParameter("validno")); ofnum=fnum; if (fnum==(num^3/12345+num*num/123+num*7/19)*11/17) { display="display:none"; %> <% } else { msg="Please enter the correct verification code"; display=""; num=mynum.nextInt(9999); if (num<1000) num+=1000; fnum=(num^3/12345+num*num/123+num*7/19)*11/17; ImageVerification(35,90,"/ist/web_public/http/workshop_in/ranimg/"+fnum+".png",""+num); //Thread.sleep(1000); } /*java.io.File myfile = new java.io.File("/ist/web_public/http/workshop/ranimg/"+ofnum+".png"); if (myfile.delete()) System.err.println("Deleted"); else System.err.println("Not deleted"); */ } else { msg="Please enter the correct verification code"; if ((request.getParameter("txtName") != null) && (request.getParameter("txtEmail") != null) && (request.getParameter("txtEmail2") != null)) display=""; else display="display:none"; num=mynum.nextInt(9999); if (num<1000) num+=1000; fnum=(num^3/12345+num*num/123+num*7/19)*11/17; ImageVerification(35,90,"/ist/web_public/http/workshop_in/ranimg/"+fnum+".png",""+num); //Thread.sleep(1000); /*if (request.getParameter("checkno")!= null && request.getParameter("checkno").trim().length()>0) { ofnum=Integer.parseInt(request.getParameter("checkno")); java.io.File myfile = new java.io.File("/ist/web_public/http/workshop/ranimg/"+ofnum+".png"); if (myfile.delete()) System.err.println("Deleted"); else System.err.println("Not deleted"); }*/ } %>
       
  Course Name:
  <% strCourseName=((crs.getString(0,"Name")==null)?"":crs.getString(0,"Name")); %> <%=strCourseName%>
  Date:
  <% strDate=((crs.getString(0,"sDate")==null)?"":crs.getString(0,"sDate")); %> <%=strDate%>
  Venue:
 

<% strVenue=((crs.getString(0,"Venue")==null)?"":crs.getString(0,"Venue")); %> <%=strVenue.replaceAll("\n","
")%>

  Time:   <% strCourseID=((crs.getString(0,"CourseID")==null)?"":crs.getString(0,"CourseID")); strTime=((crs.getString(0,"Time")==null)?"":crs.getString(0,"Time")); %> <%= strTime %>
  Name*:  
  Email Address*:
  Confirm Email Address*:
  Contact Number:  
  Account Number*:  
       
 
 
Click Submit
 
<%=msg%>
  *Mandatory