#!/usr/bin/env ruby ############################################################################ # Copyright 2009 Benjamin Kellermann # # # # This file is part of dudle. # # # # Dudle is free software: you can redistribute it and/or modify it under # # the terms of the GNU Affero General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # Dudle is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or # # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public # # License for more details. # # # # You should have received a copy of the GNU Affero General Public License # # along with dudle. If not, see . # ############################################################################ if __FILE__ == $0 load "../dudle.rb" $d = Dudle.new("Delete Poll") require "ftools" QUESTIONS = ["Yes, I know what I am doing!", "I hate these stupid entry fields.", "I am aware of the consequences.", "Please delete this poll."] if $cgi.include?("confirmnumber") CONFIRM = $cgi["confirmnumber"].to_i if $cgi["confirm"] == QUESTIONS[CONFIRM] Dir.chdir("..") File.move($d.urlsuffix, "/tmp/#{$d.urlsuffix}.#{rand(9999999)}") $d.html << < 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.

SUCCESS $d.out($cgi) exit else hint = < To delete the poll, you have to type: #{QUESTIONS[CONFIRM]} but you typed: #{$cgi["confirm"]} HINT end else CONFIRM = rand(QUESTIONS.size) end $d.html << <Delete this Poll You want to delete the poll named #{$d.table.name}.
This is an irreversible action!
If you are sure in what you are doing, please type into the form “#{QUESTIONS[CONFIRM]}” #{hint}
TABLE $d.out($cgi) end