home *** CD-ROM | disk | FTP | other *** search
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.OutputStream;
- import java.io.PrintWriter;
- import java.net.URL;
- import netscape.net.URLInputStream;
-
- class BOHTTPDConnection implements Runnable {
- // $FF: renamed from: cl BOSocket
- public BOSocket field_0 = null;
- // $FF: renamed from: sv BOHTTPD
- public BOHTTPD field_1 = null;
-
- public void dump_to(String var1, OutputStream var2) throws IOException {
- PrintWriter var3 = new PrintWriter(var2, true);
-
- try {
- String var4;
- int var16;
- for(var4 = var1; (var16 = var4.indexOf("%20")) >= 0; var4 = var4.substring(0, var16) + " " + var4.substring(var16 + 3, var4.length())) {
- }
-
- while((var16 = var4.indexOf("%3a")) >= 0) {
- var4 = var4.substring(0, var16) + ":" + var4.substring(var16 + 3, var4.length());
- }
-
- while((var16 = var4.indexOf("%3A")) >= 0) {
- var4 = var4.substring(0, var16) + ":" + var4.substring(var16 + 3, var4.length());
- }
-
- while((var16 = var4.indexOf("%2F")) >= 0) {
- var4 = var4.substring(0, var16) + "/" + var4.substring(var16 + 3, var4.length());
- }
-
- while((var16 = var4.indexOf("%2f")) >= 0) {
- var4 = var4.substring(0, var16) + "/" + var4.substring(var16 + 3, var4.length());
- }
-
- while((var16 = var4.indexOf("%2E")) >= 0) {
- var4 = var4.substring(0, var16) + "." + var4.substring(var16 + 3, var4.length());
- }
-
- while((var16 = var4.indexOf("%2e")) >= 0) {
- var4 = var4.substring(0, var16) + "." + var4.substring(var16 + 3, var4.length());
- }
-
- while(var4.length() >= 1 && var4.startsWith("/")) {
- var4 = var4.substring(1, var4.length());
- }
-
- while(var4.length() >= 2 && var4.endsWith("//")) {
- var4 = var4.substring(0, var4.length() - 1);
- }
-
- if (!var4.startsWith("http:") && !var4.startsWith("https:") && !var4.startsWith("ftp:") && !var4.startsWith("file:")) {
- var4 = "file:/" + var4;
- }
-
- URL var6 = new URL(var4);
- if (var4.equals("file:/")) {
- String var25 = "Rerouted.\n";
- var3.println("HTTP/1.1 302 Found");
- var3.println("Location: http://" + this.field_1.host + ":" + this.field_1.port + "/" + this.field_1.path);
- var3.println("Content-type: text/plain");
- var3.println("Content-length: " + var25.length());
- var3.println("");
- var3.print(var25);
- var3.flush();
- return;
- }
-
- if (var4.startsWith("file:") && !var4.startsWith("file:/" + this.field_1.path) || var4.indexOf("..") >= 0) {
- String var24 = "Permission Denied.\n";
- var3.println("HTTP/1.1 403 Permission Denied");
- var3.println("Content-type: text/plain");
- var3.println("Content-length: " + var24.length());
- var3.println("");
- var3.print(var24);
- var3.flush();
- return;
- }
-
- BOURLConnection var7 = new BOURLConnection(var6);
- BOURLInputStream var8 = new BOURLInputStream(var7);
-
- int var10;
- for(var10 = 0; ((URLInputStream)var8).read() >= 0; ++var10) {
- }
-
- ((URLInputStream)var8).close();
- String var11 = BOMimeType.get(var4);
- String var12 = "";
- String var13 = "";
- if (var11 == "text/html") {
- String var14 = "http://" + this.field_1.remote_host + "/proj/dan/BOHTTPD-0.2";
- var12 = "<link rel=stylesheet href=\"" + var14 + "/BOHTTPD.css\">\n" + "<table bgcolor=white width=640>" + "<tr valign=top>" + "<td><img src=\"" + var14 + "/BOHTTPD_logo.gif\"></td>" + "<td width=100% align=left>" + "<h2>Brown Orifice<br><code>" + var4 + "</code></h2>" + "<ul>" + "<li><a href=\"" + var14 + "/BOHTTPD.cgi\">Brown Orifice HTTPD Homepage</a>" + "<li><a href=\"" + var14 + "/BOHTTPD_search.cgi\">BOHTTPD Search</a>" + "<li><a href=\"" + var14 + "/BOHTTPD_download.cgi\">Download BOHTTPD!</a>" + "</ul>" + "</td>" + "</tr>" + "</table><hr>";
- var13 = "<script>\nvar ss;\nvar ll = document.links.length;\nfor (var i = 0; i < ll; i++) {\n ss += 'q=' + escape(document.links[i]) + '&';\n}\nvar i = new Image;i.src='" + var14 + "/BOHTTPD_log.cgi?' + ss;" + "</script>";
- var10 += var12.length() + var13.length();
- }
-
- var3.println("HTTP/1.1 200 OK");
- var3.println("Content-type: " + var11);
- var3.println("Content-length: " + var10);
- var3.println("");
- var3.print(var12);
- var3.flush();
- var7 = new BOURLConnection(var6);
- var8 = new BOURLInputStream(var7);
-
- int var9;
- while((var9 = ((URLInputStream)var8).read()) >= 0) {
- var2.write(var9);
- }
-
- var3.print(var13);
- var3.flush();
- ((URLInputStream)var8).close();
- } catch (Exception var15) {
- String var5 = String.valueOf(String.valueOf(var15));
- var3.println("HTTP/1.1 500 Internal Server Error");
- var3.println("Content-type: text/plain");
- var3.println("Content-length: " + var5.length());
- var3.println("");
- var3.print(var5);
- var3.flush();
- }
-
- }
-
- public void run() {
- try {
- new PrintWriter(this.field_0.getOutputStream(), true);
- BufferedReader var2 = new BufferedReader(new InputStreamReader(this.field_0.getInputStream()));
- String var3 = var2.readLine();
-
- while(var2.readLine().length() > 0) {
- }
-
- int var4 = var3.indexOf(" ");
- if (var4 < 0) {
- throw new IOException();
- }
-
- int var5 = var3.indexOf(" HTTP");
- if (var5 < 0) {
- throw new IOException();
- }
-
- String var6 = var3.substring(var4 + 1, var5);
- this.dump_to(var6, this.field_0.getOutputStream());
- this.field_0.close_real();
- } catch (Exception var7) {
- System.out.println(var7);
- }
-
- }
-
- public void setServer(BOHTTPD var1) {
- this.field_1 = var1;
- }
-
- public void setSock(BOSocket var1) {
- this.field_0 = var1;
- }
- }
-