#!/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 $header = {} $header["type"] = "text/html" #$header["type"] = "application/xhtml+xml" $header["charset"] = "utf-8" $htmlout = < HEAD olddir = File.expand_path(".") Dir.chdir("..") load "charset.rb" load "config.rb" require "poll" require "datepoll" require "timepoll" Dir.chdir(olddir) # BUGFIX for Time.parse, which handles the zone indeterministically class << Time alias_method :old_parse, :parse def Time.parse(date, now=self.now) Time.old_parse("2009-10-25 00:30") Time.old_parse(date) end end acusers = {} if $cgi.include?("revision") REVISION=$cgi["revision"].to_i table = YAML::load(VCS.cat(REVISION, "data.yaml")) VCS.cat(REVISION,".htdigest").each_line{|l| v,k = l.scan(/^(.*):(.*):.*$/).flatten acusers[k] = v } else table = YAML::load_file("data.yaml") File.open(".htdigest","r").each_line{|l| v,k = l.scan(/^(.*):(.*):.*$/).flatten acusers[k] = v } if $cgi.include?("add_participant") if $cgi.include?("delete_participant") table.delete($cgi["olduser"]) else table.add_participant($cgi["olduser"],$cgi["add_participant"],{}) end end table.edit_column($cgi["new_columnname"],$cgi["columndescription"],$cgi["old_columnname"]) if $cgi.include?("new_columnname") table.delete_column($cgi["delete_column"]) if $cgi.include?("delete_column") def writehtaccess(acusers) File.open(".htaccess","w"){|htaccess| if acusers["admin"] htaccess << < AuthType digest AuthName "admin" AuthUserFile "#{File.expand_path(".").gsub('"','\\\\"')}/.htdigest" Require valid-user HTACCESS end if acusers["participant"] htaccess << < dudle - config - #{table.name}
HTMLHEAD $htmlout += <

#{table.name}

#{table.to_html($cgi["edituser"],true,$cgi["editcolumn"])} TABLE # ADD/REMOVE COLUMN $htmlout +=< #{table.edit_column_htmlform($cgi["editcolumn"])} ADD_EDIT $htmlout +=<
Change Access Control settings If you want to restrict the access to the poll, add the user “participant”.
If you want to restrict the access to the configuration interface seperately, please add the user “admin”!
ACL acusers.each{|action,user| $htmlout += < USER } remainder = ["admin","participant"] - acusers.keys unless remainder.empty? $htmlout += < ACL end $htmlout += < ACL $htmlout +=<
Delete the Whole Poll
Warning: This is an irreversible action!
REMOVE $htmlout += "" $htmlout += "" $header["Cache-Control"] = "no-cache" $cgi.out($header){$htmlout} end
NamePassword
#{user} *****************