<@code> #!/usr/local/bin/ruby DB = "DBI:SQLite:data/data.sqlite" DB = "DBI:SQLite:data/route.sqlite" ENABLE_FCGI = false MASTER = false MASTER_MODE = ["initialize"] require "cgi" require "erb" require "dbi" require "fcgi" require "digest/sha1" $db = DBI.connect(DB) $db['AutoCommit'] = true class MyCGI def initialize(cgi) @cgi = cgi @cmd = cgi.params['cmd'].first if(!@cmd) @cmd = "top" end if !MASTER @cmd = "top" if MASTER_MODE.include? @cmd end __send__("cmd_#{@cmd}") @cgi.out{ERB.new(DATA.read).result(binding)} end def cmd_top end def cmd_src DATA.rewind @cgi.out({"type"=>"text/plain"}){ DATA.read } @cgi.out({"type"=>"text/plain"}){ DATA.read.gsub(KEY,"HIMITSU!") } exit end def cmd_initialize $db.do <<-EOL EOL end end if ENABLE_FCGI FCGI.each_cgi do |cgi| MyCGI.new(cgi) end else MyCGI.new(CGI.new) end __END__ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml"> <title></title> <div class="footer"> <a href="?cmd=src"> Source code </a> </div> </html>