Skip to content

Commit 190b278

Browse files
committed
"Burn after reading" as a checkbox
"Burn after reading" option has been moved out of Expiration combo to a separate checkbox. Reason is: You can prevent a read-once paste to be available ad vitam eternam on the net.
1 parent 75a27b6 commit 190b278

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

css/zerobin.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ position:relative;
164164
top:2px;
165165
}
166166

167-
div#expiration, div#language, div#opendisc, div#syntaxcoloringoption {
167+
div#expiration, div#language, div#burnafterreadingoption, div#opendisc, div#syntaxcoloringoption {
168168
background-color:#414D5A;
169169
padding:6px 8px;
170170
margin:0px 5px 0px 0px;;

index.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,14 @@ function deletePaste($pasteid)
170170
elseif ($expire=='1week') $meta['expire_date']=time()+7*24*60*60;
171171
elseif ($expire=='1month') $meta['expire_date']=time()+30*24*60*60; // Well this is not *exactly* one month, it's 30 days.
172172
elseif ($expire=='1year') $meta['expire_date']=time()+365*24*60*60;
173-
elseif ($expire=='burn') $meta['burnafterreading']=true;
173+
}
174+
175+
// Destroy the paste when it is read.
176+
if (!empty($_POST['burnafterreading']))
177+
{
178+
$burnafterreading = $_POST['burnafterreading'];
179+
if ($burnafterreading!='0' && $burnafterreading!='1') { $error=true; }
180+
if ($burnafterreading!='0') { $meta['burnafterreading']=true; }
174181
}
175182

176183
// Read open discussion flag

js/zerobin.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ function send_data() {
330330
var cipherdata = zeroCipher(randomkey, $('textarea#message').val());
331331
var data_to_send = { data: cipherdata,
332332
expire: $('select#pasteExpiration').val(),
333+
burnafterreading: $('input#burnafterreading').is(':checked') ? 1 : 0,
333334
opendiscussion: $('input#opendiscussion').is(':checked') ? 1 : 0,
334335
syntaxcoloring: $('input#syntaxcoloring').is(':checked') ? 1 : 0
335336
};
@@ -398,6 +399,7 @@ function stateNewPaste() {
398399
$('div#remainingtime').hide();
399400
$('div#language').hide(); // $('#language').show();
400401
$('input#password').hide(); //$('#password').show();
402+
$('div#burnafterreadingoption').show();
401403
$('div#opendisc').show();
402404
$('div#syntaxcoloringoption').show();
403405
$('button#newbutton').show();
@@ -426,6 +428,7 @@ function stateExistingPaste() {
426428
$('div#expiration').hide();
427429
$('div#language').hide();
428430
$('input#password').hide();
431+
$('div#burnafterreadingoption').hide();
429432
$('div#opendisc').hide();
430433
$('div#syntaxcoloringoption').hide();
431434
$('button#newbutton').show();
@@ -534,9 +537,12 @@ function pageKey() {
534537
}
535538

536539
$(function() {
537-
$('select#pasteExpiration').change(function() {
538-
if ($(this).val() == 'burn') {
540+
541+
// If "burn after reading" is checked, disable discussion.
542+
$('input#burnafterreading').change(function() {
543+
if ($(this).is(':checked') ) {
539544
$('div#opendisc').addClass('buttondisabled');
545+
$('input#opendiscussion').attr({checked: false});
540546
$('input#opendiscussion').attr('disabled',true);
541547
}
542548
else {

tpl/page.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ <h3>{$VERSION}</h3>
4646
<button id="newbutton" onclick="window.location.href=scriptLocation();return false;" style="display:none;"><img src="img/icon_new.png#" width="11" height="15" />New</button>
4747
<button id="sendbutton" onclick="send_data();return false;" style="display:none;"><img src="img/icon_send.png#" width="18" height="15" />Send</button>
4848
<button id="clonebutton" onclick="clonePaste();return false;" style="display:none;"><img src="img/icon_clone.png#" width="15" height="17" />Clone</button>
49-
<div id="expiration" style="display:none;">Expire:
49+
<div id="expiration" style="display:none;">Expires:
5050
<select id="pasteExpiration" name="pasteExpiration">
51-
<option value="burn">Burn after reading</option>
5251
<option value="5min">5 minutes</option>
5352
<option value="10min">10 minutes</option>
5453
<option value="1hour">1 hour</option>
@@ -68,6 +67,10 @@ <h3>{$VERSION}</h3>
6867
<option value="python">Python</option>
6968
</select>
7069
</div>
70+
<div id="burnafterreadingoption" class="button" style="display:none;">
71+
<input type="checkbox" id="burnafterreading" name="burnafterreading" />
72+
<label for="burnafterreading">Burn after reading</label>
73+
</div>
7174
<input id="password" value="Optional password..." style="display:none;" />
7275
<div id="opendisc" class="button" style="display:none;">
7376
<input type="checkbox" id="opendiscussion" name="opendiscussion" />

0 commit comments

Comments
 (0)