From 91f39f17d91499fd653f497001b5c7a1b0b020f3 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Mon, 18 Jan 2010 12:06:00 +0100 Subject: pollname -> polltitle + check if empty --- index.cgi | 68 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'index.cgi') diff --git a/index.cgi b/index.cgi index 57f3728..deb76c7 100755 --- a/index.cgi +++ b/index.cgi @@ -32,41 +32,45 @@ end $d = Dudle.new("Home") if $cgi.include?("create_poll") && $cgi.include?("poll_url") - POLLNAME=$cgi["create_poll"] - if $cgi["poll_url"] == "" - if $cgi["create_poll"] =~ /^[\w\-_]*$/ - POLLURL = $cgi["create_poll"] + POLLTITLE=$cgi["create_poll"] + if POLLTITLE == "" + createnotice = "Please enter a descriptive title." + else + if $cgi["poll_url"] == "" + if POLLTITLE =~ /^[\w\-_]*$/ + POLLURL = POLLTITLE + else + POLLURL = `pwgen -1`.chomp + end else - POLLURL = `pwgen -1`.chomp + POLLURL=$cgi["poll_url"] end - else - POLLURL=$cgi["poll_url"] - end - if !(POLLURL =~ /^[\w\-_]*$/) - createnotice = "Custom address may only contain letters, numbers, and dashes." - elsif File.exist?(POLLURL) - createnotice = "A Poll with this address already exists." - else Dir.mkdir(POLLURL) - Dir.chdir(POLLURL) - VCS.init - File.symlink("../participate.rb","index.cgi") - VCS.add("index.cgi") - ["atom","customize", "history", "overview", "edit_columns","access_control", "delete_poll", "invite_participants"].each{|f| - File.symlink("../#{f}.rb","#{f}.cgi") - VCS.add("#{f}.cgi") - } - ["data.yaml",".htaccess",".htdigest"].each{|f| - File.open(f,"w").close - VCS.add(f) - } - Poll.new(POLLNAME,$cgi["poll_type"]) - Dir.chdir("..") - $d.html.header["status"] = "REDIRECT" - $d.html.header["Cache-Control"] = "no-cache" - $d.html.header["Location"] = SITEURL + POLLURL+ "/edit_columns.cgi" - $d << "The poll was created successfully. The link to your new poll is:
#{POLLURL}" + if !(POLLURL =~ /^[\w\-_]*$/) + createnotice = "Custom address may only contain letters, numbers, and dashes." + elsif File.exist?(POLLURL) + createnotice = "A Poll with this address already exists." + else Dir.mkdir(POLLURL) + Dir.chdir(POLLURL) + VCS.init + File.symlink("../participate.rb","index.cgi") + VCS.add("index.cgi") + ["atom","customize", "history", "overview", "edit_columns","access_control", "delete_poll", "invite_participants"].each{|f| + File.symlink("../#{f}.rb","#{f}.cgi") + VCS.add("#{f}.cgi") + } + ["data.yaml",".htaccess",".htdigest"].each{|f| + File.open(f,"w").close + VCS.add(f) + } + Poll.new(POLLTITLE,$cgi["poll_type"]) + Dir.chdir("..") + $d.html.header["status"] = "REDIRECT" + $d.html.header["Cache-Control"] = "no-cache" + $d.html.header["Location"] = SITEURL + POLLURL+ "/edit_columns.cgi" + $d << "The poll was created successfully. The link to your new poll is:
#{POLLURL}" + end end end @@ -77,7 +81,7 @@ unless $d.html.header["status"] == "REDIRECT"
- + -- cgit v1.2.3