#!/usr/bin/env ruby
################################
# Author: Benjamin Kellermann #
# License: CC-by-sa 3.0 #
# see License #
################################
QUESTIONS = ["Yes, I know what I am doing!",
"I hate these stupid entry fields.",
"I am aware of the consequences.",
"Please delete this poll."]
CONFIRM = rand(QUESTIONS.size)
require "cgi"
require "ftools"
if __FILE__ == $0
$cgi = CGI.new
$header = {}
$header["type"] = "text/html"
#$header["type"] = "application/xhtml+xml"
$header["charset"] = "utf-8"
POLL = File.basename(File.expand_path("."))
$htmlout = <
dudle - delete - #{POLL}
HEAD
if $cgi.include?("confirmnumber")
if $cgi["confirm"] == QUESTIONS[$cgi["confirmnumber"].to_i]
Dir.chdir("..")
File.move(POLL, "/tmp/#{POLL}.#{rand(9999999)}")
$htmlout += <
The poll was deleted successfully!
If this was done by accident, please contact the administrator of the system.
The poll can be recovered for an indeterministic amount of time, maybe it is already to late. home
SUCCESS
else
$htmlout += <
You canceld the deletion!
configdelete
CANCEL
end
else
$htmlout += <
Delete a Poll
You want to delete the poll named #{POLL}.
This is an irreversible action!
If you are sure in what you are doing, please type into the form “#{QUESTIONS[CONFIRM]}”
TABLE
end
$htmlout += ""
$htmlout += ""
$header["Cache-Control"] = "no-cache"
$cgi.out($header){$htmlout}
end