#!/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" 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| user,realm = l.scan(/^(.*):(.*):.*$/).flatten acusers[user] = realm } 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["columnid"],$cgi["new_columnname"],$cgi) if $cgi.include?("new_columnname") table.delete_column($cgi["deletecolumn"]) if $cgi.include?("deletecolumn") def writehtaccess(acusers) File.open(".htaccess","w"){|htaccess| if acusers.values.include?("config") htaccess << < AuthType digest AuthName "config" AuthUserFile "#{File.expand_path(".").gsub('"','\\\\"')}/.htdigest" Require valid-user HTACCESS end if acusers.values.include?("vote") htaccess << < dudle - Administration - #{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 # ACCESS CONTROL $accesslevels = { "vote" => "Vote Interface", "config" => "Config Interface" } $htmlout +=<
Change Access Control Settings
ACL acusers.each{|user,action| $htmlout += < USER } $htmlout += < ACL $htmlout += < #{usercreatenotice} 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
Access toUsernamePasswordPassword (repeat)
#{$accesslevels[action]} #{user} ***************** *****************