#!/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 TYPE = "text/html" #TYPE = "application/xhtml+xml" 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!
config delete 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 += "" $cgi.out("type" => TYPE ,"charset" => CHARSET, "Cache-Control" => "no-cache"){$htmlout} end