<%@ page import="java.io.File" %> <%@ page import="java.io.FileInputStream" %> <%@ page import="java.io.BufferedReader" %> <%@ page import="java.io.InputStreamReader" %> <%@ page import="java.util.Calendar" %> <% // Config variables. Extra-easy customization. // Consider entire source code customizable, just // these areas especially. // ================================================= // URL of this JSP page for purposes of refresh rate form. String URL = "http://ool-457b3126.dyn.optonline.net:8081/cam.jsp"; // Read title from disk or use static? // Default is load from disk. boolean diskTitle = true; String titleFileName = "/home/andrew/.camtitle"; String staticTitle = "Long Island, NY, Represent"; // Same as title setup except this is for the comment // underneath the date and cam image and we can // keep this one disabled completely boolean showComment = true; boolean diskComment = true; String commentFileName = "/home/andrew/.camcomment"; String staticComment = "The seclusion room"; // Should refresh rate be customizable? boolean customRefresh = true; int refreshRate = 5; // Show the date under the cam image? boolean showDate = true; // Log clients that connect to this site and // display list of current connections? boolean logHosts = true; // Where to store the logs! Make sure this exissts // and is a directory! String logDirectoryName = "/var/log/tomcat"; // Use xmms-infopipe plugin to show currently playing // music file? boolean showXMMS = true; // Customalizable link to user homepage. // First URL then link text. Leave null to omit. String homepageURL = "http://www.goodandpure.org"; String homepageText = "Andrew's Homepage"; %> <% String refreshString = request.getParameter("rate"); if (customRefresh && refreshString != null) { refreshRate = Integer.parseInt(refreshString); } %> goodandpure.org - webcam

<% File titleFile = new File(titleFileName); if (diskTitle && titleFile.exists()) { FileInputStream fis = new FileInputStream(titleFile); InputStreamReader isr = new InputStreamReader(fis); BufferedReader reader = new BufferedReader(isr); String title; if ((title = reader.readLine()) != null) { out.print(title); reader.close(); isr.close(); fis.close(); } else { out.print(staticTitle); } } else { out.print(staticTitle); } %>

<% if(showDate) { %>

<%= new java.util.Date() %>

<% } if (showComment) { %>

<% File commentFile = new File(commentFileName); if (diskComment && commentFile.exists()) { FileInputStream fis = new FileInputStream(commentFile); InputStreamReader isr = new InputStreamReader(fis); BufferedReader reader = new BufferedReader(isr); String comment; if ((comment = reader.readLine()) != null) { out.print(comment); reader.close(); isr.close(); fis.close(); } else { out.print(staticComment); } } else { out.print(staticComment); } %>

<% } %> <% if (logHosts) { %>
<%-- Beginning of list of IPs connected to this server Touch a directory for each IP and a file in the directory for each time there is a new minute of time and a new (to that limit) request . E.G. directory: jon-cab-USAnet.net subfiles:200605031142 200605031143 Subdirectories are checked if they have a file pertaining to the current time- if they do, they will be displayed, since, it was at this minute, they viewed the page --%> <% Calendar now = Calendar.getInstance(); File parentDir = new File(logDirectoryName); String hostname = request.getRemoteHost(); int year = now.get(Calendar.YEAR); int month = now.get(Calendar.MONTH) +1; int day = now.get(Calendar.DAY_OF_MONTH); int hour = now.get(Calendar.HOUR_OF_DAY); int minute = now.get(Calendar.MINUTE); String yearDone = ""+year+""; String monthDone = month <10? "0" +month: ""+month; String dayDone = day < 10? "0" +day: ""+day; String hourDone = hour <10? "0"+hour:""+hour; String minuteDone = minute<10? "0" + minute:"" + minute; String time = yearDone + monthDone + dayDone + hourDone + minuteDone; File minuteDir = new File(parentDir, time); minuteDir.mkdir(); File hostFile = new File(minuteDir, hostname); hostFile.createNewFile(); String[] hosts = minuteDir.list(); for(int i = 0; i < hosts.length;i++) { %> <% } if(customRefresh) { %> <% } } %> <% if(showXMMS) { File infoFile = new File("/tmp/xmms-info"); String music = ""; boolean found = false; if (infoFile.exists()) { FileInputStream fis = new FileInputStream(infoFile); InputStreamReader isr = new InputStreamReader(fis); BufferedReader reader = new BufferedReader(isr); String current; while(((current = reader.readLine()) != null) && !found) { if (found = (current.indexOf("Title") != -1)) { music = current.substring(7, current.length()); } } fis.close(); isr.close(); reader.close(); } if (found) { %> <% } } %>
Cam Connections (this minute)
<%=hosts[i]%>
 
Refresh rate: s

<%=music%> is playing in xmms.

<%=homepageText%>