#!/usr/bin/env ruby ################################ # Author: Benjamin Kellermann # # License: CC-by-sa 3.0 # # see License # ################################ require "yaml" require "cgi" if __FILE__ == $0 $cgi = CGI.new TYPE = "text/html" #TYPE = "application/xhtml+xml" CHARSET = "utf-8" $htmlout = < HEAD load "charset.rb" if File.exists?("config.rb") load "config.rb" else puts "\nPlease configure me in the file config.rb" exit end require "poll" require "datepoll" require "timepoll" $htmlout += < dudle HEAD $htmlout += '' if File.exists?("atom.cgi") $htmlout += "

dudle

" if $cgi.include?("create_poll") SITE=$cgi["create_poll"].gsub(/^\//,"") unless File.exist?(SITE) Dir.mkdir(SITE) Dir.chdir(SITE) VCS.init File.symlink("../participate.rb","index.cgi") File.symlink("../atom_single.rb","atom.cgi") File.symlink("../config_poll.rb","config.cgi") File.symlink("../remove_poll.rb","remove.cgi") ["index.cgi","atom.cgi","config.cgi","remove.cgi"].each{|f| VCS.add(f) } ["data.yaml",".htaccess",".htdigest"].each{|f| File.open(f,"w").close VCS.add(f) } case $cgi["poll_type"] when "normal" Poll.new SITE when "time" TimePoll.new SITE end Dir.chdir("..") createnotice = < The poll was created successfully. The link to your new poll is:
#{SITEURL}#{SITE} SUCCESS else createnotice = "
Error: This poll already exists!
" end end $htmlout += <
Config #{UTFASCII}
CHARSET $htmlout += <Create New Poll
Type:
#{createnotice} CREATE $htmlout += NOTICE $htmlout += "" $htmlout += "" $cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout} end