|
|
@ -24,6 +24,8 @@ import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import readers.Reader; |
|
|
|
|
|
|
|
|
|
|
|
public class sigServer { |
|
|
|
public class sigServer { |
|
|
|
ServerSocket socket; |
|
|
|
ServerSocket socket; |
|
|
|
|
|
|
|
|
|
|
@ -89,6 +91,16 @@ public class sigServer { |
|
|
|
if (line.contains("filename=")) { |
|
|
|
if (line.contains("filename=")) { |
|
|
|
filename=line.substring(line.indexOf("filename=")+"filename=".length()+1); |
|
|
|
filename=line.substring(line.indexOf("filename=")+"filename=".length()+1); |
|
|
|
filename = filename.substring(0,filename.length()-1); |
|
|
|
filename = filename.substring(0,filename.length()-1); |
|
|
|
|
|
|
|
int dotPosition=0; |
|
|
|
|
|
|
|
if (filename.contains(".")) { |
|
|
|
|
|
|
|
for (int i=filename.length()-1;i>=0;i--) { |
|
|
|
|
|
|
|
if (filename.charAt(i)=='.') { |
|
|
|
|
|
|
|
dotPosition=i; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
filename="upload"+System.nanoTime()+filename.substring(dotPosition); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
System.out.println(line); |
|
|
|
System.out.println(line); |
|
|
|
} |
|
|
|
} |
|
|
@ -123,14 +135,19 @@ public class sigServer { |
|
|
|
} |
|
|
|
} |
|
|
|
stream.close(); |
|
|
|
stream.close(); |
|
|
|
|
|
|
|
|
|
|
|
filename=null; |
|
|
|
|
|
|
|
if (!wroteData) { |
|
|
|
if (!wroteData) { |
|
|
|
System.out.println("Upload failed!"); |
|
|
|
System.out.println("Upload failed!"); |
|
|
|
in.close(); |
|
|
|
in.close(); |
|
|
|
CreateRequest(client,"400","Bad Request",Paths.get(sigPlace.OUTDIR,"testfile.html")); |
|
|
|
CreateRequest(client,"400","Bad Request",Paths.get(sigPlace.OUTDIR,"testfile.html")); |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
System.out.println("Saving upload to "+sigPlace.UPLOADSDIR+" directory."); |
|
|
|
|
|
|
|
if (filename.contains(".png")) { |
|
|
|
|
|
|
|
ArcadeReader.submitToDatabase(Paths.get(sigPlace.OUTDIR,sigPlace.UPLOADSDIR,filename)); |
|
|
|
|
|
|
|
System.out.println("Submitted to the database!"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
System.out.println("Saving upload to "+sigPlace.UPLOADSDIR+" directory."); |
|
|
|
filename=null; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (line.contains("Content-Length: ")) { |
|
|
|
if (line.contains("Content-Length: ")) { |
|
|
|