summaryrefslogtreecommitdiff
path: root/lib/cgi-lib.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cgi-lib.rb')
-rw-r--r--lib/cgi-lib.rb56
1 files changed, 0 insertions, 56 deletions
diff --git a/lib/cgi-lib.rb b/lib/cgi-lib.rb
deleted file mode 100644
index afadbff3b6..0000000000
--- a/lib/cgi-lib.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/local/bin/ruby
-#
-# Get CGI String
-#
-# EXAMPLE:
-# require "cgi-lib.rb"
-# foo = CGI.new
-# foo['field'] <== value of 'field'
-# foo.keys <== array of fields
-# foo.inputs <== hash of { <field> => <value> }
-
-class CGI
- attr("inputs")
-
- def initialize
- str = if ENV['REQUEST_METHOD'] == "GET"
- ENV['QUERY_STRING']
- elsif ENV['REQUEST_METHOD'] == "POST"
- $stdin.read ENV['CONTENT_LENGTH'].to_i
- else
- ""
- end
- arr = str.split(/&/)
- @inputs = {}
- arr.each do |x|
- x.gsub!(/\+/, ' ')
- key, val = x.split(/=/, 2)
- val = "" unless val
-
- key.gsub!(/%(..)/) { [$1.hex].pack("c") }
- val.gsub!(/%(..)/) { [$1.hex].pack("c") }
-
- @inputs[key] += "\0" if @inputs[key]
- @inputs[key] += val
- end
- end
-
- def keys
- @inputs.keys
- end
-
- def [](key)
- @inputs[key]
- end
-
- def CGI.message(msg, title = "")
- print "Content-type: text/html\n\n"
- print "<html><head><title>"
- print title
- print "</title></head><body>\n"
- print msg
- print "</body></html>\n"
- TRUE
- end
-
-end