summaryrefslogtreecommitdiff
path: root/index.cgi
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-10-07 19:28:58 +0200
committerYorhel <git@yorhel.nl>2010-10-07 19:28:58 +0200
commit9b1a86d82292141b7fdb5cf22313af4ce837416a (patch)
treeb5ff244895b29a9d46d82a6ce21d960798cb26e7 /index.cgi
parent8f33fd3de4d505696e308987ec64d2415b14604c (diff)
Added passcode input field and database column.
To be used later for deletion and listing.
Diffstat (limited to 'index.cgi')
-rwxr-xr-xindex.cgi16
1 files changed, 13 insertions, 3 deletions
diff --git a/index.cgi b/index.cgi
index 884d56c..d5af2fc 100755
--- a/index.cgi
+++ b/index.cgi
@@ -12,9 +12,12 @@
# date timestamp with time zone NOT NULL DEFAULT now(),
# lastvisit timestamp with time zone NOT NULL DEFAULT now(),
# ip inet,
-# parse_urls boolean NOT NULL DEFAULT false
+# parse_urls boolean NOT NULL DEFAULT false,
+# passcode varchar
# );
+# ALTER TABLE pastes ADD COLUMN passcode varchar;
+
use strict;
use warnings;
@@ -89,7 +92,9 @@ sub upload {
my $s = $cgi->param('s') || 'nosyntax';
my $w = $cgi->param('w') ? 1 : 0;
my $c = $cgi->param('c') ? 1 : 0;
+ my $p = $cgi->param('p') || undef;
msg('Unknown syntax code.', 'backform') if !grep $s eq $_, @syntax;
+ msg('Passcode too long!', 'backform') if length($p) > 64;
my $dat = $cgi->param('u') || $cgi->param('f') || '';
$dat =~ s/\x0D\x0A?/\n/g;
msg("Only UTF-8 encoded data is allowed!\nMake sure you're not uploading a binary file.", 'backform')
@@ -100,8 +105,8 @@ sub upload {
my $html = $s eq 'nosyntax' ? undef
: decode_utf8(Text::VimColor->new(string => encode_utf8($dat), filetype => $s)->html());
- $db->do('INSERT INTO pastes (code, syntax, wrap, raw, html, ip, parse_urls) VALUES(?,?,?,?,?,?,?)',
- undef, $code, $s, $w, $dat, $html, $ENV{REMOTE_ADDR}, $c);
+ $db->do('INSERT INTO pastes (code, syntax, wrap, raw, html, ip, parse_urls, passcode) VALUES(?,?,?,?,?,?,?,?)',
+ undef, $code, $s, $w, $dat, $html, $ENV{REMOTE_ADDR}, $c, $p);
print "Status: 303\nLocation: http://$ENV{HTTP_HOST}/$code\nContent-type: text/plain\n\nRedirecting...\n";
exit;
@@ -186,6 +191,11 @@ sub form {
<i>Syntax highlighting:</i> <input type="text" name="s" id="s" size="10" value="nosyntax" /> <i>Popular: <b class="syntax">%s</b> | <a href="#" onclick="return showall()">Show all &raquo;</a></i>
<div id="syntax" style="display: none">%s</div>
</fieldset>
+ <fieldset>
+ <legend>▾ Passcode</legend>
+ <label for="p">Passcode:</label> <input type="password" name="p" id="p" size="10" /><br />
+ <i>(Optional, necessary for listing and/or removing your pastes, which is not implemented yet...)</i>
+ </fieldset>
</form>
<fieldset>
<legend>▾</legend>