From 771e5cbfe743a81c00a4cbf89cd869e3b6a28bb2 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Mon, 7 Jan 2019 21:06:47 +0100 Subject: change constants to variables --- index.cgi | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'index.cgi') diff --git a/index.cgi b/index.cgi index 6e26ebb..b96a358 100755 --- a/index.cgi +++ b/index.cgi @@ -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 => "
#{POLLURL}"} + $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 => "
#{pollurl}"} 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/" -- cgit v1.2.3