mirror of
https://github.com/fooflington/wordsearch.git
synced 2025-07-09 17:39:06 +00:00
Compare commits
2 Commits
save-grids
...
master
Author | SHA1 | Date | |
---|---|---|---|
fddec0d82c | |||
e7e69263c7 |
11
README.md
11
README.md
@ -12,15 +12,4 @@ A simple ```Makefile``` is provided:
|
||||
$ make
|
||||
```
|
||||
|
||||
Once built, you need to make a "war" file to deploy to your J2EE container (tested on Tomcat)
|
||||
|
||||
```
|
||||
$ cd war && jar cfv ../wordsearch.war .
|
||||
```
|
||||
Then deploy your war file :-)
|
||||
|
||||
Alternatively you can test-run the engine...
|
||||
```
|
||||
$ make run <wordlist.txt
|
||||
```
|
||||
|
||||
|
53
war/db.jsp
Normal file
53
war/db.jsp
Normal file
@ -0,0 +1,53 @@
|
||||
<%@ page contentType="text/html" %>
|
||||
<%@ page import="java.sql.*" %>
|
||||
<%@ page import="org.sqlite.*" %>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Database dump</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Database stats</h1>
|
||||
<%
|
||||
Connection conn =
|
||||
DriverManager.getConnection("jdbc:sqlite:" + getServletContext().getRealPath("/WEB-INF/files/database.sqlite"));
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("select * from sqlite_master where type='table' and name='grids';");
|
||||
if(rs.next()) {
|
||||
// we have a row and are probably ok
|
||||
} else {
|
||||
// Initialise the schema
|
||||
PreparedStatement pstmt = conn.prepareStatement("CREATE TABLE grids (id integer primary key, ts timestamp default current_timestamp, remotehost varchar, input, size_x int, size_y int, simple tinyint, result varchar);");
|
||||
pstmt.execute();
|
||||
}
|
||||
|
||||
rs.close();
|
||||
|
||||
PreparedStatement ps_count = conn.prepareStatement("SELECT COUNT(*) FROM grids");
|
||||
PreparedStatement ps_last = conn.prepareStatement("SELECT max(ts) FROM grids;");
|
||||
|
||||
ResultSet rs_count = ps_count.executeQuery();
|
||||
ResultSet rs_last = ps_last.executeQuery();
|
||||
int count = -1;
|
||||
String last = "unknown";
|
||||
if(rs_count.next()) {
|
||||
count = rs_count.getInt(1);
|
||||
}
|
||||
if(rs_last.next()) {
|
||||
last = rs_last.getString(1);
|
||||
}
|
||||
rs_count.close();
|
||||
rs_last.close();
|
||||
%>
|
||||
|
||||
<ul>
|
||||
<li>Number of grids generated: <%= count %></li>
|
||||
<li>Last grid generated at: <%= last %></li>
|
||||
<li>Path to db: <pre><%= getServletContext().getRealPath("/WEB-INF/files/database.sqlite") %></pre></li>
|
||||
</ul>
|
||||
</body>
|
||||
<%
|
||||
conn.close();
|
||||
%>
|
||||
</html>
|
@ -5,7 +5,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>SQLite Demo</title>
|
||||
<title>Database dump</title>
|
||||
</head>
|
||||
<body>
|
||||
<table border="1">
|
||||
|
22
war/env.jsp
Normal file
22
war/env.jsp
Normal file
@ -0,0 +1,22 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h1>Environment</h1>
|
||||
<ul>
|
||||
<li>You are connecting from: <%= request.getRemoteHost() %> (<%= request.getRemoteAddr() %>)</li>
|
||||
<li>If present your X-Forwarded-For header is: <%= request.getHeader("X-Forwarded-For") %></li>
|
||||
</ul>
|
||||
|
||||
<h2>Header dump</h2>
|
||||
<pre>
|
||||
<%
|
||||
for (java.util.Enumeration<String> headers = request.getHeaderNames(); headers.hasMoreElements(); ) {
|
||||
String h = headers.nextElement();
|
||||
%>
|
||||
<%= h %>=<%= request.getHeader(h) %>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</pre>
|
||||
</body>
|
Reference in New Issue
Block a user