#!/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" if __FILE__ == $0 $cgi = CGI.new TYPE = "text/html" #TYPE = "application/xhtml+xml" CHARSET = "utf-8" POLL = File.basename(File.expand_path(".")) $htmlout = < dudle - remove - #{POLL} HEAD if $cgi.include?("confirmnumber") if $cgi["confirm"] == QUESTIONS[$cgi["confirmnumber"].to_i] Dir.chdir("..") `mv #{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!
config remove CANCEL end else $htmlout += <

Remove a Poll

You want to remove 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 += "" $cgi.out("type" => TYPE ,"charset" => CHARSET, "Cache-Control" => "no-cache"){$htmlout} end