// Decompiled by DJ v2.9.9.61 Copyright 2000 Atanas Neshkov Date: 31-01-2002 16:55:20
// Home Page :
http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: password.java
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.io.*;
import java.net.URL;
import java.util.Vector;
public class password extends Applet
implements Runnable
{
public void init()
{
if(startURL == null)
{
String s = getParameter("start_url");
startURL = s != null ? s : new String();
}
String s1 = getParameter("bgcolor");
int i;
try
{
i = s1 != null ? Integer.parseInt(s1, 16) : Color.white.getRGB();
}
catch(Exception _ex)
{
i = Color.white.getRGB();
}
setBackground(new Color(i));
s1 = getParameter("home_url");
if(s1 != null)
try
{
if(s1.indexOf(":") == -1)
homeURL = new URL(getDocumentBase(), s1);
else
homeURL = new URL(s1);
}
catch(Exception exception)
{
System.err.println(exception);
}
if(homeURL == null)
try
{
homeURL = new URL(getDocumentBase(), "./");
}
catch(Exception exception1)
{
System.err.println(exception1);
}
s1 = getParameter("error_url");
if(s1 != null)
try
{
if(s1.indexOf(":") == -1)
errorURL = new URL(getDocumentBase(), s1);
else
errorURL = new URL(s1);
}
catch(Exception exception2)
{
System.err.println(exception2);
}
if(errorURL == null)
try
{
errorURL = new URL(getDocumentBase(), "./error.htm");
}
catch(Exception exception3)
{
System.err.println(exception3);
}
if(pswURL == null)
{
s1 = getParameter("psw_url");
if(s1 != null)
try
{
if(s1.indexOf(":") == -1)
pswURL = new URL(getDocumentBase(), s1);
else
pswURL = new URL(s1);
}
catch(Exception exception4)
{
System.err.println(exception4);
}
}
if(pswURL == null)
try
{
pswURL = new URL(getDocumentBase(), "./users.txt");
}
catch(Exception exception5)
{
System.err.println(exception5);
}
s1 = getParameter("use_base");
if(s1 != null)
useBase = !s1.equalsIgnoreCase("false");
setFont(new Font("SansSerif", 0, 14));
navpan = new NavPanel(this);
navpan.setVisible(false);
add(navpan);
}
public void start()
{
if(pswMon == null)
{
pswWin = new PswFrame(this, pswURL);
pswMon = new Thread(this);
pswMon.start();
}
}
public void run()
{
for(int i = 0; pswWin.isShowing() && i < 120;)
try
{
Thread.sleep(500L);
i++;
}
catch(Exception exception)
{
System.out.println(exception);
}
if(pswWin.isValid())
{
pswWin.dispose();
navpan.setVisible(true);
goStart();
return;
} else
{
pswWin.dispose();
redirect(errorURL, "_top");
return;
}
}
public void stop()
{
pswMon = null;
}
public void setStartURL(String s)
{
if(s != "")
startURL = s;
}
public void setPswURL(String s)
{
if(s != "")
{
try
{
if(s.indexOf(":") == -1)
{
pswURL = new URL(getDocumentBase(), s);
return;
} else
{
pswURL = new URL(s);
return;
}
}
catch(Exception exception)
{
System.err.println(exception);
}
return;
} else
{
return;
}
}
public synchronized String getURL()
{
String s = new String();
if(load)
{
URL url = (URL)list.elementAt(curr);
s = getContent(url);
}
load = false;
return s;
}
public synchronized void setList(int i, URL url)
{
if(i == 2)
{
if(curr > 0)
{
curr--;
load = true;
}
} else
if(i == 1)
{
if(curr < list.size() - 1)
{
curr++;
load = true;
}
} else
if(i == 3)
load = true;
else
if(i == 4)
if(curr == list.size() - 1)
{
if(list.size() < 50)
{
list.addElement(url);
curr++;
} else
{
list.removeElementAt(0);
list.addElement(url);
}
} else
{
list.insertElementAt(url, curr + 1);
curr++;
for(int j = list.size() - 1; j > curr; j--)
list.removeElementAt(j);
}
if(curr > 0)
navpan.setEnabled("Back", true);
else
navpan.setEnabled("Back", false);
if(curr < list.size() - 1)
{
navpan.setEnabled("Next", true);
return;
} else
{
navpan.setEnabled("Next", false);
return;
}
}
private void goStart()
{
System.out.println("Loading start page...");
int i = startURL.charAt(0) - 100;
String s = startURL.substring(1, i + 1);
String s1 = startURL.substring(i + 1);
s1 = c3.decode(s1, s);
try
{
URL url;
if(s1.indexOf(":") == -1)
url = new URL(getDocumentBase(), s1);
else
url = new URL(s1);
setList(4, url);
setList(3, null);
return;
}
catch(Exception exception)
{
System.err.println(exception);
}
redirect(errorURL, "_top");
}
public String fetchURL(String s)
{
int i = Integer.valueOf(s.substring(0, 2)).intValue();
String s1 = (String)keys.elementAt(i);
String s2 = s.substring(2);
return loadPage(s2, s1);
}
private String loadPage(String s, String s1)
{
String s2 = new String();
s = c3.decode(s, s1);
try
{
URL url;
if(s.indexOf(":") == -1)
url = new URL(getDocumentBase(), s);
else
url = new URL(s);
setList(4, url);
s2 = getContent(url);
}
catch(Exception exception)
{
System.err.println(exception);
s2 = s2 + "<hr><h3>Invalid URL</h3>";
}
return s2;
}
private String getContent(URL url)
{
StringBuffer stringbuffer = new StringBuffer();
navpan.setEnabled("Reload", false);
try
{
DataInputStream datainputstream = new DataInputStream(url.openStream());
if(useBase)
{
int i = url.toString().lastIndexOf('/');
String s1 = url.toString().substring(0, i + 1);
stringbuffer.append("<BASE HREF=\"" + s1 + "\">\n");
}
keys = new Vector(10);
do
{
char c = (char)datainputstream.readByte();
if(c == '<')
{
String s = readTag(datainputstream);
s = checkTag(s);
stringbuffer.append(s);
} else
{
stringbuffer.append(c);
}
} while(true);
}
catch(EOFException _ex)
{
System.out.println("Done loading page " + curr + ": " + stringbuffer.length() + " bytes");
}
catch(Exception exception)
{
System.err.println(exception);
stringbuffer.append("<hr><h3>Error Opening Input Stream</h3>");
}
navpan.setEnabled("Reload", true);
return stringbuffer.toString();
}
private static String readTag(DataInputStream datainputstream)
{
StringBuffer stringbuffer = new StringBuffer("<");
char c = '<';
try
{
while(c != '>')
{
c = (char)datainputstream.readByte();
stringbuffer.append(c);
}
}
catch(EOFException _ex) { }
catch(Exception exception)
{
System.err.println(exception);
}
return stringbuffer.toString();
}
private String checkTag(String s)
{
StringBuffer stringbuffer = new StringBuffer(s);
for(int l = 0; l < stringbuffer.length(); l++)
if(stringbuffer.charAt(l) == '\r' || stringbuffer.charAt(l) == '\n')
stringbuffer.setCharAt(l, ' ');
String s1 = stringbuffer.toString();
try
{
String s2 = s1.toUpperCase();
int i;
if(s2.startsWith("<A HREF"))
i = s2.indexOf("PARENT.NAVPANE.FETCH(");
else
if(s2.startsWith("<TITLE>"))
{
s = "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n" + s1;
return s;
} else
{
return s;
}
if(i == -1)
return s;
int j;
for(j = i + 21; Character.isWhitespace(s2.charAt(j)); j++);
if(s2.charAt(j) == '\'')
j++;
int k;
for(k = j + 1; !Character.isWhitespace(s2.charAt(k)) && s2.charAt(k) != '\'' && s2.charAt(k) != ')'; k++);
String s3 = s.substring(j, k);
String s4 = c3.getKey(s3);
keys.addElement(s4);
s3 = c3.encode(s3, s4);
String s5 = Integer.toString(keys.size() - 1);
s3 = s5.length() >= 2 ? s5 + s3 : "0" + s5 + s3;
s = s1.substring(0, j) + s3 + s1.substring(k, s1.length());
}
catch(StringIndexOutOfBoundsException _ex) { }
catch(Exception exception)
{
System.err.println(exception);
}
return s;
}
public void home()
{
redirect(homeURL, "_top");
}
private void redirect(URL url, String s)
{
try
{
InputStream inputstream = url.openStream();
inputstream.read();
inputstream.close();
getAppletContext().showDocument(url, s);
return;
}
catch(Exception exception)
{
System.out.println(exception);
}
}
public password()
{
useBase = true;
c3 = new cipher3();
list = new Vector(10);
curr = -1;
load = false;
}
protected final int FWD = 1;
protected final int BWD = 2;
protected final int GET = 3;
protected final int ADD = 4;
protected final int MAX = 50;
private String startURL;
private String name;
private String password;
private boolean cancel;
private NavPanel navpan;
private URL homeURL;
private URL errorURL;
private URL pswURL;
private boolean useBase;
private Vector keys;
private cipher c3;
private PswFrame pswWin;
private Thread pswMon;
private Vector list;
private int curr;
private boolean load;
}