diff options
Diffstat (limited to 'index.cgi')
-rwxr-xr-x | index.cgi | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -27,29 +27,29 @@ require_relative "dudle" $d = Dudle.new if $cgi.include?("create_poll") && $cgi.include?("poll_url") - POLLTITLE=$cgi["create_poll"] - if POLLTITLE == "" + polltitle=$cgi["create_poll"] + if polltitle == "" createnotice = _("Please enter a descriptive title.") else if $cgi["poll_url"] == "" - guessurl = POLLTITLE.gsub(" ","_").gsub(/[\?\!\.]/,"") + guessurl = polltitle.gsub(" ","_").gsub(/[\?\!\.]/,"") if guessurl =~ /^[a-zA-Z0-9_-]+$/ && !File.exist?(guessurl) - POLLURL = guessurl + pollurl = guessurl else chars = ("a".."z").to_a + ("1".."9").to_a - POLLURL = Array.new(8){chars[rand(chars.size)]}.join + pollurl = Array.new(8){chars[rand(chars.size)]}.join end else - POLLURL=$cgi["poll_url"] + pollurl=$cgi["poll_url"] end - if !(POLLURL =~ /\A[\w\-_]*\Z/) + if !(pollurl =~ /\A[\w\-_]*\Z/) createnotice = _("Custom address may only contain letters, numbers, and dashes.") - elsif File.exist?(POLLURL) + elsif File.exist?(pollurl) createnotice = _("A poll with this address already exists.") - else Dir.mkdir(POLLURL) - Dir.chdir(POLLURL) + else Dir.mkdir(pollurl) + Dir.chdir(pollurl) begin VCS.init File.symlink("../participate.rb","index.cgi") @@ -60,16 +60,16 @@ if $cgi.include?("create_poll") && $cgi.include?("poll_url") File.open(f,"w").close VCS.add(f) } - Poll.new(CGI.escapeHTML(POLLTITLE),$cgi["poll_type"]) + Poll.new(CGI.escapeHTML(polltitle),$cgi["poll_type"]) Dir.chdir("..") $d.html.header["status"] = "REDIRECT" $d.html.header["Cache-Control"] = "no-cache" - $d.html.header["Location"] = $conf.siteurl + POLLURL + "/edit_columns.cgi" - $d << _("The poll was created successfully. The link to your new poll is: %{link}") % {:link => "<br /><a href=\"#{POLLURL}\">#{POLLURL}</a>"} + $d.html.header["Location"] = $conf.siteurl + pollurl + "/edit_columns.cgi" + $d << _("The poll was created successfully. The link to your new poll is: %{link}") % {:link => "<br /><a href=\"#{pollurl}\">#{pollurl}</a>"} rescue WrongPollTypeError # should only happen in case of hacking Dir.chdir("..") require "fileutils" - FileUtils.rm_r(POLLURL) + FileUtils.rm_r(pollurl) $d.html.header["status"] = "REDIRECT" $d.html.header["Cache-Control"] = "no-cache" $d.html.header["Location"] = "http://localhost/" |