|
PVD is a simple applet that reads some info from the computer of the navigator visiting your site and sends the data to your email address (don't use it if you have hundreds of visits every day! Version 1.1 of PVD courtesy of George Ruban (gruban@oocities.com) Version 1.2 of PVD Added background color to the applet rectangle. |
You have to upload Post.class to your directory in GeoCities and add to the main page (or whatever page you want) the following HTML tags:
<APPLET CODE="Post.class" WIDTH=2 HEIGHT=2> <PARAM NAME="account" VALUE="your_account"> <PARAM NAME="color" VALUE="background_color"> </APPLET>
for example, if your name in GeoCities is bgates and the background of your page is yellow (see below for more details about colors), you must write
<APPLET CODE="Post.class" WIDTH=2 HEIGHT=2> <PARAM NAME="account" VALUE="bgates"> <PARAM NAME="color" VALUE="ffff00"> </APPLET>
Then every time someone accesses your main page, the applet sends the data of his/her computer in your mailbox. The applet has to show nothing on the screen so it's very small. WIDTH and HEIGHT aren't zero because Netscape Navigator 3.0 doesn't paint the frame with the background image if the size of the applet is less than 2x2.
REMEMBER The first letter of "Post.class" is uppercase, "your_account" is your name in GeoCities and it's the first thing you must change. Optionally you can add the color parameter using exadecimal notation: the first two letters regards red component, the next two green and the last two blue. In the example ffff00 means yellow because there is full (ff = 255) red, full green and no blue. Choose the color according to your background.
WARNING You can use this applet only for Statistical Purposes. Privacy is a right granted by law.
(Reloads) 0 (LocalHost) localhost/127.0.0.1 (Date) 4/9/97, 13:13:35, -119 (OpSys) Windows 95, 4.0, x86 (Browser) ActiveX Scripting Host, ?, ? (Java) 1.0.2 (Graphics) 1024x768, 96, DirectColorModel
This guy uses Microsoft Internet Explorer 3.0. I know this because localhost is localhost/127.0.0.1 and the browser is ActiveX Scripting Host. Only this browser returns so poor information. Last versions of Explorer (4.0) returns a 1.1 Java version. Date is in the format day/month/year. -119 is the time zone in minutes (-2 hours) i.e. Italy or similar. 96 is the resolution of the monitor (in dots per inches) and DirectColorModel means that the graphic card uses more than 256 colors.
(Reloads) 1 (LocalHost) ****.****.***.***/***.***.***.** (Date) 4/9/97, 8:50:43, 420 (OpSys) OSF1, V3.2, alpha (Browser) Netscape Navigator, 3.0, Netscape Communications Corporation (Java) 1.02 (Graphics) 1280x1024, 95, IndexColorModel
Nescape Navigator 3.0 is more expressive. The localhost is hidden in this document to protect the innocents . 420 is the time zone (maybe Los Angeles), while IndexColorModel means that the graphic card is using 256 colors. The OpSys is an exotic OSF1 V3.2 running on an Alpha CPU. The visitor reloaded your page one time and you get a message for every reload.
In the new version (1.1) there is also a Page field that is the page that hosts the applet. Thus you can use Post.class on more than one page.
The only class used is java.applet.Applet and the only method overloaded is init(). We can separate the code in two parts:
import java.applet.*; import java.awt.*; import java.io.*; import java.net.*; import java.util.*; public class Post extends Applet {reload variable is used to keep track of the visitor's reloads.
static int reload;This is the only overloaded method. It's called every time the page of the applet is reloaded. The method constructs a String called post containing all the data (reloads, local host, date, time, time zone, operative system, CPU, browser, java version, graphics). The format of the string is the usual one (identifier_1=value_1&identifier_2=value_2& etc) Chuncks Index
public void init() { super.init(); Date today = new Date(); Runtime runtime = Runtime.getRuntime(); String post = "Reloads=" + reload + "&LocalHost="; try { post += InetAddress.getLocalHost().toString(); } catch(Exception e) { post += "?"; } post += "&Date=" + today.getDate()+"/"+(today.getMonth()+1)+"/"+today.getYear()+",+"+ today.getHours()+":"+today.getMinutes()+":"+today.getSeconds()+",+"+ today.getTimezoneOffset()+ "&OpSys=" ; try { post += System.getProperty("os.name") + ",+" + System.getProperty("os.version") + ",+" + System.getProperty("os.arch") ; } catch(Exception e) { post += "?,+?,+?"; } post += "&Browser="; try { post += System.getProperty("browser"); } catch(Exception e) { post += "?"; } try { post += ",+" + System.getProperty("browser.version") + ",+" + System.getProperty("browser.vendor") ; } catch(Exception e) { post += ",+?,+?"; } post += "&Java="; try { post += System.getProperty("java.version"); } catch(Exception e) { post += "?"; } post += "&Graphics="; try { Toolkit kit = Toolkit.getDefaultToolkit(); String colorModel = kit.getColorModel().getClass().toString(); post += kit.getScreenSize().width + "x" + kit.getScreenSize().height + ",+" + kit.getScreenResolution() + ",+" + colorModel.substring(colorModel.lastIndexOf('.')+1) ; } catch(Exception e) { post += "?x?,+?,+?"; } reload++;Here the connection to the CGI is opened in output. The stream is printed and flushed. Then the results of the CGI are read (however they are not displayed and you can find them in the cache of the browser). Chuncks Index
try { URL url = new URL( "http://www.oocities.org/cgi-bin/homestead/mail.pl?"+ getParameter("account") ); URLConnection uc = url.openConnection(); uc.setDoOutput(true); PrintStream ps = new PrintStream(uc.getOutputStream()); ps.print(post); ps.flush(); ps.close(); DataInputStream dis = new DataInputStream(uc.getInputStream()); while(dis.readLine() != null); dis.close(); } catch(Exception e) { } } }
![]() |
In the next Issue Java Tutorials will be JDBC: Quering a Database with Inquirer Weekly Applets will be Led Display: A Scrolling Text Display while Java GeoUtilities will be ParseMail: An application for UNIX Systems that filters out mail generated by PVD | ![]() |
---|