aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--charset.rb10
-rwxr-xr-xconfig_poll.rb12
-rwxr-xr-xindex.cgi53
-rwxr-xr-xparticipate.rb12
-rwxr-xr-xremove_poll.rb12
5 files changed, 52 insertions, 47 deletions
diff --git a/charset.rb b/charset.rb
index 07aedaf..5535844 100644
--- a/charset.rb
+++ b/charset.rb
@@ -4,10 +4,10 @@
# see License #
################################
-$utfcookie = CGI::Cookie.new("utf", "true")
-$utfcookie.path = "/"
+utfcookie = CGI::Cookie.new("utf", "true")
+utfcookie.path = "/"
if ($cgi.include?("utf") || $cgi.cookies["utf"][0]) && !$cgi.include?("ascii")
- $utfcookie.expires = Time.now+1*60*60*24*365
+ utfcookie.expires = Time.now+1*60*60*24*365
UTFASCII = "<a href='?ascii' style='text-decoration:none'>Change Charset to plain ASCII</a>"
YES = CGI.escapeHTML('✔')
@@ -23,7 +23,7 @@ if ($cgi.include?("utf") || $cgi.cookies["utf"][0]) && !$cgi.include?("ascii")
EDIT = CGI.escapeHTML("✍")
DELETE = CGI.escapeHTML("⌧")
else
- $utfcookie.expires = Time.now-1*60*60*24*36
+ utfcookie.expires = Time.now-1*60*60*24*36
UTFASCII = "<a href='?utf' style='text-decoration:none'>If you see all these characters: #{CGI.escapeHTML('✔✘?–↞←→↠✍⌧')} you can safely change the charset to UTF-8</a>"
YES = CGI.escapeHTML('OK')
@@ -39,4 +39,4 @@ else
EDIT = CGI.escapeHTML("edit")
DELETE = CGI.escapeHTML("delete")
end
-
+$header["cookie"] = utfcookie
diff --git a/config_poll.rb b/config_poll.rb
index 566ca3a..563816b 100755
--- a/config_poll.rb
+++ b/config_poll.rb
@@ -13,10 +13,11 @@ require "cgi"
if __FILE__ == $0
$cgi = CGI.new
+$header = {}
-TYPE = "text/html"
-#TYPE = "application/xhtml+xml"
-CHARSET = "utf-8"
+$header["type"] = "text/html"
+#$header["type"] = "application/xhtml+xml"
+$header["charset"] = "utf-8"
$htmlout = <<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
@@ -118,7 +119,7 @@ end
$htmlout += <<HTMLHEAD
<head>
- <meta http-equiv="Content-Type" content="#{TYPE}; charset=#{CHARSET}" />
+ <meta http-equiv="Content-Type" content="#{$header["type"]}; charset=#{$header["charset"]}" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>dudle - config - #{table.name}</title>
<link rel="stylesheet" type="text/css" href="../dudle.css" title="default"/>
@@ -220,6 +221,7 @@ $htmlout += "</div></body>"
$htmlout += "</html>"
-$cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout}
+$header["Cache-Control"] => "no-cache"
+$cgi.out($header){$htmlout}
end
diff --git a/index.cgi b/index.cgi
index 5904478..1bb3c05 100755
--- a/index.cgi
+++ b/index.cgi
@@ -13,10 +13,10 @@ require "cgi"
if __FILE__ == $0
$cgi = CGI.new
-
-TYPE = "text/html"
-#TYPE = "application/xhtml+xml"
-CHARSET = "utf-8"
+$header = {}
+$header["type"] = "text/html"
+#$header["type"] = "application/xhtml+xml"
+$header["charset"] = "utf-8"
$htmlout = <<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
@@ -39,7 +39,7 @@ require "timepoll"
$htmlout += <<HEAD
<head>
<title>dudle</title>
- <meta http-equiv="Content-Type" content="#{TYPE}; charset=#{CHARSET}" />
+ <meta http-equiv="Content-Type" content="#{$header["type"]}; charset=#{$header["charset"]}" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="stylesheet" type="text/css" href="dudle.css" title="default"/>
HEAD
@@ -49,9 +49,12 @@ HEAD
$htmlout += "</head><body id='main'><h1>dudle</h1>"
if $cgi.include?("create_poll")
- SITE=$cgi["create_poll"].gsub(/^\//,"")
- unless File.exist?(SITE)
- Dir.mkdir(SITE)
+ SITE=$cgi["create_poll"]
+ if SITE.include?("/")
+ createnotice = "<div class='error'>Error: The character '/' is not allowed.</div>"
+ elsif File.exist?(SITE)
+ createnotice = "<div class='error'>Error: This poll already exists!</div>"
+ else Dir.mkdir(SITE)
Dir.chdir(SITE)
VCS.init
File.symlink("../participate.rb","index.cgi")
@@ -72,21 +75,16 @@ if $cgi.include?("create_poll")
TimePoll.new SITE
end
Dir.chdir("..")
- $cgi.out("status" => "REDIRECT",
- "Location" => "#{SITEURL}#{SITE}/",
- "type" => TYPE,
- "charset" => CHARSET,
- "cookie" => $utfcookie,
- "Cache-Control" => "no-cache"){
- "The poll was created successfully. The link to your new poll is:<br /><a href='#{SITEURL}#{SITE}'>#{SITEURL}#{SITE}</a>"
- }
- exit
- else
- createnotice = "<div class='error'>Error: This poll already exists!</div>"
+ escapedsite = SITEURL + CGI.escapeHTML(CGI.escape(SITE)) + "/"
+ escapedsite.gsub!("+"," ")
+ $header["status"] = "REDIRECT"
+ $header["Location"] = escapedsite
+ $htmlout = "The poll was created successfully. The link to your new poll is:<br /><a href=\"#{escapedsite}\">#{escapedsite}</a>"
end
end
-$htmlout += <<CHARSET
+unless $header["status"] == "REDIRECT"
+ $htmlout += <<CHARSET
<div id='config'>
<fieldset><legend>Config</legend>
#{UTFASCII}
@@ -94,13 +92,13 @@ $htmlout += <<CHARSET
</div>
CHARSET
-$htmlout += <<CREATE
+ $htmlout += <<CREATE
<fieldset><legend>Create New Poll</legend>
<form method='post' action='.'>
<table>
<tr>
<td class='create_poll'><label title="#{poll_name_tip = "the name equals the link under which you receive the poll"}" for="poll_name">Name:</label></td>
- <td class='create_poll'><input title="#{poll_name_tip}" id="poll_name" size='16' type='text' name='create_poll' /></td>
+ <td class='create_poll'><input title="#{poll_name_tip}" id="poll_name" size='16' type='text' name='create_poll' value="#{CGI.escapeHTML($cgi["create_poll"])}" /></td>
</tr>
<tr>
<td>Type:</td>
@@ -118,15 +116,16 @@ $htmlout += <<CREATE
</tr>
</table>
</form>
-#{createnotice}
</fieldset>
CREATE
-$htmlout += NOTICE
-$htmlout += "</body>"
+ $htmlout += NOTICE
+ $htmlout += "</body>"
-$htmlout += "</html>"
+ $htmlout += "</html>"
+end
-$cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout}
+$header["Cache-Control"] = "no-cache"
+$cgi.out($header){$htmlout}
end
diff --git a/participate.rb b/participate.rb
index 7937ffc..57ecedf 100755
--- a/participate.rb
+++ b/participate.rb
@@ -13,10 +13,11 @@ require "cgi"
if __FILE__ == $0
$cgi = CGI.new
+$header = {}
-TYPE = "text/html"
-#TYPE = "application/xhtml+xml"
-CHARSET = "utf-8"
+$header["type"] = "text/html"
+#$header["type"] = "application/xhtml+xml"
+$header["charset"] = "utf-8"
$htmlout = <<HEAD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
@@ -60,7 +61,7 @@ end
$htmlout += <<HEAD
<head>
- <meta http-equiv="Content-Type" content="#{TYPE}; charset=#{CHARSET}" />
+ <meta http-equiv="Content-Type" content="#{$header["type"]}; charset=#{$header["charset"]}" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>dudle - #{table.name}</title>
<link rel="stylesheet" type="text/css" href="../dudle.css" title="default"/>
@@ -122,5 +123,6 @@ $htmlout += "</div></body>"
$htmlout += "</html>"
-$cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout}
+$header["Cache-Control"] = "no-cache"
+$cgi.out($header){$htmlout}
end
diff --git a/remove_poll.rb b/remove_poll.rb
index 3a0ebb1..542303d 100755
--- a/remove_poll.rb
+++ b/remove_poll.rb
@@ -19,10 +19,11 @@ require "ftools"
if __FILE__ == $0
$cgi = CGI.new
+$header = {}
-TYPE = "text/html"
-#TYPE = "application/xhtml+xml"
-CHARSET = "utf-8"
+$header["type"] = "text/html"
+#$header["type"] = "application/xhtml+xml"
+$header["charset"] = "utf-8"
POLL = File.basename(File.expand_path("."))
@@ -31,7 +32,7 @@ $htmlout = <<HEAD
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
- <meta http-equiv="Content-Type" content="#{TYPE}; charset=#{CHARSET}" />
+ <meta http-equiv="Content-Type" content="#{$header["type"]}; charset=#{$header["charset"]}" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>dudle - delete - #{POLL}</title>
<link rel="stylesheet" type="text/css" href="../dudle.css" title="default"/>
@@ -86,6 +87,7 @@ $htmlout += "</body>"
$htmlout += "</html>"
-$cgi.out("type" => TYPE ,"charset" => CHARSET, "Cache-Control" => "no-cache"){$htmlout}
+$header["Cache-Control"] = "no-cache"
+$cgi.out($header){$htmlout}
end