From d172b56e183ab13b83604ce60f5c13694d2221aa Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Wed, 25 Nov 2009 10:08:22 +0100 Subject: use pwgen to generate address if not given --- index.cgi | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'index.cgi') diff --git a/index.cgi b/index.cgi index 79d9e6b..4af4546 100755 --- a/index.cgi +++ b/index.cgi @@ -45,11 +45,17 @@ $htlm.add_atom("atom.cgi") if File.exists?("atom.cgi") if $cgi.include?("create_poll") && $cgi.include?("poll_url") POLLNAME=$cgi["create_poll"] - POLLURL=$cgi["poll_url"] + if $cgi["poll_url"] == "" + POLLURL = `pwgen -1`.chomp + else + POLLURL=$cgi["poll_url"] + end + + if !(POLLURL =~ /^[\w\-_]*$/) - createnotice = "Custom alias may only contain letters, numbers, and dashes." + createnotice = "Custom address may only contain letters, numbers, and dashes." elsif File.exist?(POLLURL) - createnotice = "A Poll with this alias already exists." + createnotice = "A Poll with this address already exists." else Dir.mkdir(POLLURL) Dir.chdir(POLLURL) VCS.init @@ -99,7 +105,7 @@ unless $html.header["status"] == "REDIRECT" - Custom alias (optional): + Custom address (optional): May contain letters, numbers, and dashes. -- cgit v1.2.3