<%@ page contentType="text/html; charset=iso-8859-1" %> <%@ page language="java" session="true" %> <%@ page import="com.oreilly.servlet.MultipartRequest"%> <%@ page import="java.io.*"%> <%@ page import="java.lang.Object"%> <%@ page import="java.text.SimpleDateFormat"%> <%@ page import="javax.mail.*"%> <%@ page import="javax.mail.internet.*"%> <%@ page import="java.util.*"%> <%@ page import="java.sql.*"%> <%@ page import="javax.activation.*"%> <%@ page import="com.clix.*"%> <% boolean checkModified; byte[] buf; int size = 100*1024*1024; int intHolder1 = 0; int intHolder2 = 0; String confstatus = ""; String description = ""; String dir = "/home/uspare2/public_html/iibatch72/images/iibatch72/incoming/"; String fileName; String host = "localhost"; String imagesdir = "/images/iibatch72/incoming/"; String ip = ""; String line = ""; String mbr_id = ""; String modifiedName; String mailfrom = "info@iibatch72.org"; String mailclient = "lon@usparedes.net"; String message = ""; String msg1 = ""; String name; String sess_id = ""; String doSlideShow = ""; String snippet; String sql = ""; String strHolder1 = ""; String strHolder2 = ""; String subject = "Invitation To See Pic Of The Day "; String suffix = ""; String timeStamp = ""; String currTimeStamp = ""; String type; BufferedReader br; java.util.Date date; //the constructor called is java.util.Date to distinguish it from java.sql.Date, otherwise, there would be ambiguouty problem Enumeration files; File uploadedFile; File renamedFile; FileInputStream fis; FileOutputStream fos; FileOutputStream outFile; DataOutputStream outData; MultipartRequest mpr; PrintWriter pw; SimpleDateFormat formatter; SimpleDateFormat currTime; ResultSet rs; %> II Batch 72 - Upload One Picture <% try {doSlideShow = request.getParameter("slideShow");} catch (Exception eld) {} if (doSlideShow != null) { %> <% } else { %> <% } %> <% date = new java.util.Date(); formatter = new SimpleDateFormat("yyyyMMMdd_HHmmss"); currTime = new SimpleDateFormat("yyyyMMddHHmmss"); timeStamp = formatter.format(date); currTimeStamp = currTime.format(date); ip = request.getRemoteAddr(); sess_id = session.getId(); try { mpr = new MultipartRequest(request,dir,size); files = mpr.getFileNames(); name = (String)files.nextElement(); uploadedFile = mpr.getFile(name); fileName = uploadedFile.getName(); type = mpr.getContentType(name); if (type.equals("image/pjpeg")) suffix = ".jpg"; if (type.equals("image/jpeg")) suffix = ".jpg"; if (type.equals("image/gif")) suffix = ".gif"; if (type.equals("image/png")) suffix = ".png"; if (type.equals("image/bmp")) suffix = ".bmp"; //Change the name after upload modifiedName = "pic_" + timeStamp + suffix; renamedFile = new File(dir + "//" + modifiedName); checkModified = uploadedFile.renameTo(renamedFile); //Copy the uploaded, renamed file to pic_of_the_day fis = new FileInputStream(renamedFile); fos = new FileOutputStream(dir + "//" + "pic_of_the_day" + suffix); buf = new byte[1024]; int i = 0; while((i=fis.read(buf))!=-1) { fos.write(buf, 0, i); } fis.close(); fos.close(); snippet = mpr.getParameter("description"); for (i=0; i < snippet.length(); i++) { strHolder1 = snippet.substring(i,i+1); if (strHolder1.equals("\"")) { description = description + """; } else { description = description + strHolder1; } strHolder1 = ""; } //Save the description onto a file outFile = new FileOutputStream (dir + "//" + "pic_of_the_day.html"); outData = new DataOutputStream (outFile); outData.writeBytes (" "); outData.writeBytes (""); outData.close (); //Copy the description file to pic_of_the_day fis = new FileInputStream(dir + "//" + "pic_of_the_day.html"); fos = new FileOutputStream(dir + "//" + "pic_" + timeStamp + ".html"); buf = new byte[1024]; i = 0; while((i=fis.read(buf))!=-1) { fos.write(buf, 0, i); } fis.close(); fos.close(); //Append the new description to slide_show.part2 (do part2 first to determine line number) br = new BufferedReader(new FileReader(dir + "//" + "slide_show.part2")); pw = new PrintWriter(new FileWriter(dir + "//" + "slide_show.temp")); line = br.readLine(); intHolder1 = 1; while(line != null) { pw.println(line); line = br.readLine(); intHolder1 = intHolder1 + 1; } line = "Caption["; line = line + String.valueOf(intHolder1); line = line + "] = \"" + description + "\";"; pw.println(line); br.close(); pw.close(); //Copy the temp file over slide_show.part2 fis = new FileInputStream(dir + "//" + "slide_show.temp"); fos = new FileOutputStream(dir + "//" + "slide_show.part2"); buf = new byte[1024]; i = 0; while((i=fis.read(buf))!=-1) { fos.write(buf, 0, i); } fis.close(); fos.close(); //Append the new description to slide_show.part1 br = new BufferedReader(new FileReader(dir + "//" + "slide_show.part1")); pw = new PrintWriter(new FileWriter(dir + "//" + "slide_show.temp")); line = br.readLine(); while(line != null) { pw.println(line); line = br.readLine(); } line = "Picture["; line = line + String.valueOf(intHolder1); line = line + "] = 'http://www.iibatch72.org/images/iibatch72/incoming/" + modifiedName + "';"; pw.println(line); br.close(); pw.close(); //Copy the temp file over slide_show.part1 fis = new FileInputStream(dir + "//" + "slide_show.temp"); fos = new FileOutputStream(dir + "//" + "slide_show.part1"); buf = new byte[1024]; i = 0; while((i=fis.read(buf))!=-1) { fos.write(buf, 0, i); } fis.close(); fos.close(); subject = subject + timeStamp + "_PT"; message = message + "**** This message was automatically generated by the upload page. Please do not reply. **** \n\n"; message = message + "A new photo was submitted by one of our friends72 classmates "; message = message + "as Pic Of The Day. Check it out at our website's homepage, "; message = message + "http://www.iibatch72.org . "; message = message + "Photo description: '" + description + "'." + "\n\n"; message = message + "If you want to share a photo, click on the blue asterisk (*) "; message = message + "on the heading 'Pic of the Day' on the homepage "; message = message + "and the upload page will come up." + "\n\n"; SendMailBean mail = new SendMailBean(); mail.setHost("thor.lunarpages.com"); mail.setUserName("info@iibatch72.org"); mail.setPassword("adobo(0)"); mail.setAuthenticate(true); mail.setFrom("iibatch72@yahoo.com.ph"); mail.addTo("friends72@yahoogroups.com"); //mail.addTo("renparedes@yahoo.com"); mail.setSubject(subject); mail.setBody(message); mail.setHTML(false); mail.send(); %> <% } catch (IOException e) { %>
Upload speed will vary depending on your Internet connection speed and the size of the picture you are uploading. Generally, a picture between 25 to 50 Kb in size renders nicely on the browser page. Keep in mind that when our friends download the picture using a web page, the bigger the picture, the longer the download delay. Be nice to those who use dial-up to connect to the Internet and use the recommended picture size.
<% // Now, if the session variable is set, show the upload form, else, show the logon button along with "It appears that you have not logged on prior to getting here. ..." // First, establish the ID to be used try {mbr_id = request.getParameter("id");} catch (Exception eid) {} if (mbr_id == null) { if ((session.getAttribute("iibatch72_id") != null) || (session.getAttribute("iibatch72_id") != "invalid")) { mbr_id = (String)session.getAttribute("iibatch72_id"); } } // Then check the database for this ID Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost/uspare2_mango", "uspare2_jspuser", "iimanok"); Statement stmt = con.createStatement(); if (mbr_id != null) { sql = "select * from grads where id = " + mbr_id; rs = stmt.executeQuery(sql); if (rs.next()) { // If the two fields for logon are set and logon is < 1Hour old and this browser ip = ip in database // then, the user must be an authorized user; but, if the confstatus is 0, do not allow an upload if ((rs.getString("time_on") != String.valueOf(0)) && (rs.getString("ip") != null) && (rs.getString("ip").equals(ip)) && ((Long.parseLong(currTimeStamp) - Long.parseLong(rs.getString("time_on"))) < 10000) ) { msg1 = msg1 + "
Hello " + rs.getString("alias") + "!      (We cannot wait to see the picture you will upload ...)

"; session.setAttribute("iibatch72_id", mbr_id); } else { session.setAttribute("iibatch72_id", "invalid"); } // If the confstatus field is 0, tell the user to conclude by checking the email confstatus = rs.getString("confstatus"); try { if (confstatus.equals("0")) { msg1 = msg1 + "It appears that you have not concluded your activation, please check your email for instruction.

"; session.setAttribute("iibatch72_id", "invalid"); } } catch (Exception ecs) {} } rs.close(); } %>
Pic of the Day
<% // Determine if slideShow parameter is sent, and if so, include script for the slideshow, otherwise, include the pic_of_the_day try { if (doSlideShow.equals("1")) { %> <%@ include file="images/iibatch72/incoming/slide_show.part1" %> <%@ include file="images/iibatch72/incoming/slide_show.part2" %> <%@ include file="images/iibatch72/incoming/slide_show.part3" %> <% } } catch (Exception ex) { %> <%@ include file="images/iibatch72/incoming/pic_of_the_day.html" %>

View Slide Show

<% } %>
<% if (confstatus.equals("1")) { %>

<% } else { %>

<% } %>
II Batch 72
Picture Of The Day Upload
<%=msg1%>
Click on Browse to select the picture you want to upload. Enter the description of the picture on the text box. Click on Upload Now to start sending the picture. When the upload process completes, the slide show will automatically start where you would see the newly uploaded picture as the last frame (if you do not see it, you may have to refresh your browser). Refresh the home page and you would see the new Pic of the Day.

Please describe this photo (what event, where, when, who)


Click on one of the buttons to go somewhere else on this website
Only members are authorized to upload to this website. Please logon if you are a member. You need to activate your account if you are a member and have not yet done so.

Visitors are welcome to view the slide show (click on the link below the picture on the left).

Reminder: If you want to see more pictures, go to our collaboration website, friends72 at Yahoo!.
Page Hit Counter
<%-- End of try to check if this is a submit operation with result: -- java.io.IOException: Posted content type isn't multipart/form-data --%> <% } %>