3 ;; this is a quick and dirty script for talking to your SQLite3 database
6 ;; sqlite3.cgi - version 1.0 - initial release
10 ;; (1) A 'libsqlite3.so' or 'sqlite3.dll' library for your server platform
11 ;; edit the file 'sqlite.lsp' for the correct location.
13 ;; (2) The files 'cgi.lsp' and 'sqlite3.lsp', edit the (load ...) statements
14 ;; below for the correct locations of these files.
18 (print "Content-type: text/html\n\n")
20 (load "cgi-bin/cgi.lsp")
21 (load "cgi-bin/sqlite3.lsp")
23 (set 'log-file "sqlite-log.txt")
25 ;; log access, log is only written, if log-file exists
27 (set 'fle (open log-file "u"))
30 (set 'ip-no (env "REMOTE_ADDR"))
31 (unless (starts-with ip-no "99")
33 (date (+ (apply date-value (now)) (* 7 60 60)))
34 " - " ip-no " - " (env "HTTP_USER_AGENT")) fle))
38 (if (empty? CGI:params)
40 (set 'mode (CGI:get "mode")))
42 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
44 (define (display-table data)
45 (println {<table border=1>})
49 (println {<td>} cell {</td>}))
55 ;; get input sql ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64 <form action="/sqlte.cgi" method="POST">
65 Enter Name of Database: <input type="text" name="database">
68 <textarea name="sql-str" rows=10 cols=80></textarea>
70 <input type="submit" value="Go">
71 <input type="hidden" name="mode" value="sql">
80 (set 'database (CGI:get "database"))
81 (set 'sql-str (CGI:get "sql-str"))
83 (set 'data (sql3:sql sql-str))
85 (println (sql3:error) {<br>})
90 (println {<br>Hit the [back] button on your browser to got back<br>})))