3 ;; this is a quick and dirty script for talking to your SQLite database
6 ;; sqlite.cgi - version 1.0 - initial release
7 ;; sqlite.cgi - version 1.1 - replaced deprecated 'getenv' with 'env'
11 ;; (1) A 'sqlite.so' or 'sqlite.dll' library for your server platform
12 ;; edit the file 'sqlite.lsp' for the correct location.
14 ;; (2) The files 'cgi.lsp' and 'sqlite.lsp', edit the (load ...) statements
15 ;; below for the correct locations of these files.
19 (print "Content-type: text/html\n\n")
21 (load "cgi-bin/cgi.lsp")
22 (load "cgi-bin/sqlite.lsp")
24 (set 'log-file "sqlite-log.txt")
26 ;; log access, log is only written, if log-file exists
28 (set 'fle (open log-file "u"))
31 (set 'ip-no (env "REMOTE_ADDR"))
32 (unless (starts-with ip-no "99")
34 (date (+ (apply date-value (now)) (* 7 60 60)))
35 " - " ip-no " - " (env "HTTP_USER_AGENT")) fle))
39 (if (empty? CGI:params)
41 (set 'mode (CGI:get "mode")))
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45 (define (display-table data)
46 (println {<table border=1>})
50 (println {<td>} cell {</td>}))
56 ;; get input sql ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
65 <form action="/sqlite.cgi" method="POST">
66 Enter Name of Database: <input type="text" name="database">
69 <textarea name="sql-str" rows=10 cols=80></textarea>
71 <input type="submit" value="Go">
72 <input type="hidden" name="mode" value="sql">
81 (set 'database (CGI:get "database"))
82 (set 'sql-str (CGI:get "sql-str"))
83 (SQLite:open database)
84 (set 'data (SQLite:sql sql-str))
86 (println (SQLite:error) {<br>})
91 (println {<br>Hit the [back] button on your browser to got back<br>})))