mirror of
https://github.com/perlbot/perlbuut-pastebin
synced 2025-06-07 14:17:26 -04:00
Allow non-expiring pastes
This commit is contained in:
parent
29f5efaaa1
commit
af891b4b0c
2 changed files with 5 additions and 2 deletions
4
app.pl
4
app.pl
|
@ -43,6 +43,8 @@ $dbh->{sqlite_unicode} = 1;
|
|||
sub insert_pastebin {
|
||||
my ($paste, $who, $what, $where, $expire, $lang) = @_;
|
||||
|
||||
$expire = undef if !$expire; # make sure it's null if it's empty
|
||||
|
||||
$dbh->do("INSERT INTO posts (paste, who, 'where', what, 'when', 'expiration', 'language') VALUES (?, ?, ?, ?, ?, ?, ?)", {}, $paste, $who, $where, $what, time(), $expire, $lang);
|
||||
my $id = $dbh->last_insert_id('', '', 'posts', 'id');
|
||||
|
||||
|
@ -117,7 +119,7 @@ sub get_paste {
|
|||
if ($when) {
|
||||
my $whendt = DateTime->from_epoch(epoch => $when);
|
||||
|
||||
if ($whendt->clone()->add(hours => $row->{expiration}) >= DateTime->now()) {
|
||||
if (!$row->{expiration} || $whendt->clone()->add(hours => $row->{expiration}) >= DateTime->now()) {
|
||||
$row->{when} = $whendt->iso8601;
|
||||
return $row;
|
||||
} else {
|
||||
|
|
|
@ -117,6 +117,7 @@
|
|||
<option value="8">8 hours</option>
|
||||
<option value="1">1 hour</option>
|
||||
<option value="8760">1 year</option>
|
||||
<option value="">Never</option>
|
||||
</select>
|
||||
</div>
|
||||
<textarea name="paste" id="paste" cols="80" rows="25">[% pastedata | html %]</textarea>
|
||||
|
|
Loading…
Add table
Reference in a new issue