"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.

(cherry picked from commit 190b278402c086ebc4d1a78aae27d1e2666e3e7a)

Conflicts:
	css/zerobin.css
	index.php
	js/zerobin.js
	tpl/page.html
This commit is contained in:
Sebastien SAUVAGE 2013-02-24 14:33:51 +01:00 committed by El RIDO
parent 1b95d6fff7
commit cff4d99f05
4 changed files with 43 additions and 25 deletions

View File

@ -178,7 +178,7 @@ button img {
top: 2px; top: 2px;
} }
#expiration, #language, #opendisc { #expiration, #language, #burnafterreadingoption, #opendisc {
background-color: #414d5a; background-color: #414d5a;
padding: 6px 8px; padding: 6px 8px;
margin: 0 5px 0 0; margin: 0 5px 0 0;

View File

@ -319,6 +319,7 @@ function send_data() {
var cipherdata = zeroCipher(randomkey, $('textarea#message').val()); var cipherdata = zeroCipher(randomkey, $('textarea#message').val());
var data_to_send = { data: cipherdata, var data_to_send = { data: cipherdata,
expire: $('select#pasteExpiration').val(), expire: $('select#pasteExpiration').val(),
burnafterreading: $('input#burnafterreading').is(':checked') ? 1 : 0,
opendiscussion: $('input#opendiscussion').is(':checked') ? 1 : 0 opendiscussion: $('input#opendiscussion').is(':checked') ? 1 : 0
}; };
$.post(scriptLocation(), data_to_send, 'json') $.post(scriptLocation(), data_to_send, 'json')
@ -384,6 +385,7 @@ function stateNewPaste() {
$('div#remainingtime').addClass('hidden'); $('div#remainingtime').addClass('hidden');
$('div#language').addClass('hidden'); // $('#language').removeClass('hidden'); $('div#language').addClass('hidden'); // $('#language').removeClass('hidden');
$('input#password').addClass('hidden'); //$('#password').removeClass('hidden'); $('input#password').addClass('hidden'); //$('#password').removeClass('hidden');
$('div#burnafterreadingoption').removeClass('hidden');
$('div#opendisc').removeClass('hidden'); $('div#opendisc').removeClass('hidden');
$('button#newbutton').removeClass('hidden'); $('button#newbutton').removeClass('hidden');
$('div#pasteresult').addClass('hidden'); $('div#pasteresult').addClass('hidden');
@ -412,6 +414,7 @@ function stateExistingPaste() {
$('div#expiration').addClass('hidden'); $('div#expiration').addClass('hidden');
$('div#language').addClass('hidden'); $('div#language').addClass('hidden');
$('input#password').addClass('hidden'); $('input#password').addClass('hidden');
$('div#burnafterreadingoption').addClass('hidden');
$('div#opendisc').addClass('hidden'); $('div#opendisc').addClass('hidden');
$('button#newbutton').removeClass('hidden'); $('button#newbutton').removeClass('hidden');
$('div#pasteresult').addClass('hidden'); $('div#pasteresult').addClass('hidden');
@ -523,9 +526,11 @@ $(function() {
// hide "no javascript" message // hide "no javascript" message
$('#noscript').hide(); $('#noscript').hide();
$('select#pasteExpiration').change(function() { // If "burn after reading" is checked, disable discussion.
if ($(this).val() == 'burn') { $('input#burnafterreading').change(function() {
if ($(this).is(':checked') ) {
$('div#opendisc').addClass('buttondisabled'); $('div#opendisc').addClass('buttondisabled');
$('input#opendiscussion').attr({checked: false});
$('input#opendiscussion').attr('disabled',true); $('input#opendiscussion').attr('disabled',true);
} }
else { else {

View File

@ -191,9 +191,7 @@ class zerobin
// Read expiration date // Read expiration date
if (!empty($_POST['expire'])) if (!empty($_POST['expire']))
{ {
if ($_POST['expire'] == 'burn') { if (array_key_exists($_POST['expire'], $this->_conf['expire_options'])) {
$meta['burnafterreading'] = true;
} elseif (array_key_exists($_POST['expire'], $this->_conf['expire_options'])) {
$expire = $this->_conf['expire_options'][$_POST['expire']]; $expire = $this->_conf['expire_options'][$_POST['expire']];
} else { } else {
$expire = $this->_conf['expire_options'][$this->_conf['expire']['default']]; $expire = $this->_conf['expire_options'][$this->_conf['expire']['default']];
@ -201,6 +199,17 @@ class zerobin
if ($expire > 0) $meta['expire_date'] = time() + $expire; if ($expire > 0) $meta['expire_date'] = time() + $expire;
} }
// Destroy the paste when it is read.
if (!empty($_POST['burnafterreading']))
{
$burnafterreading = $_POST['burnafterreading'];
if ($burnafterreading != '0')
{
if ($burnafterreading != '1') $error = true;
$meta['burnafterreading'] = true;
}
}
// Read open discussion flag. // Read open discussion flag.
if ($this->_conf['main']['opendiscussion'] && !empty($_POST['opendiscussion'])) if ($this->_conf['main']['opendiscussion'] && !empty($_POST['opendiscussion']))
{ {

View File

@ -49,10 +49,10 @@
<button id="newbutton" onclick="window.location.href=scriptLocation();return false;" class="hidden"><img src="img/icon_new.png#" width="11" height="15" alt="" />New</button> <button id="newbutton" onclick="window.location.href=scriptLocation();return false;" class="hidden"><img src="img/icon_new.png#" width="11" height="15" alt="" />New</button>
<button id="sendbutton" onclick="send_data();return false;" class="hidden"><img src="img/icon_send.png#" width="18" height="15" alt="" />Send</button> <button id="sendbutton" onclick="send_data();return false;" class="hidden"><img src="img/icon_send.png#" width="18" height="15" alt="" />Send</button>
<button id="clonebutton" onclick="clonePaste();return false;" class="hidden"><img src="img/icon_clone.png#" width="15" height="17" alt="" />Clone</button> <button id="clonebutton" onclick="clonePaste();return false;" class="hidden"><img src="img/icon_clone.png#" width="15" height="17" alt="" />Clone</button>
<div id="expiration" class="hidden">Expire: <div id="expiration" class="hidden">Expires:
<select id="pasteExpiration" name="pasteExpiration"> <select id="pasteExpiration" name="pasteExpiration">
<option value="burn"{if="$BURNAFTERREADINGSELECTED"} selected="selected"{/if}>Burn after reading</option>{loop="EXPIRE"} {loop="EXPIRE"}
<option value="{$key}"{if="!$BURNAFTERREADINGSELECTED && $key == $EXPIREDEFAULT"} selected="selected"{/if}>{$value}</option>{/loop} <option value="{$key}"{if="$key == $EXPIREDEFAULT"} selected="selected"{/if}>{$value}</option>{/loop}
</select> </select>
</div> </div>
<div id="remainingtime" class="hidden"></div> <div id="remainingtime" class="hidden"></div>
@ -64,6 +64,10 @@
<option value="python">Python</option> <option value="python">Python</option>
</select> </select>
</div> </div>
<div id="burnafterreadingoption" class="button" style="display:none;">
<input type="checkbox" id="burnafterreading" name="burnafterreading" {if="$BURNAFTERREADINGSELECTED"} checked="checked"{/if} />
<label for="burnafterreading">Burn after reading</label>
</div>
<input id="password" value="Optional password..." class="hidden" /> <input id="password" value="Optional password..." class="hidden" />
<div id="opendisc" class="button hidden"> <div id="opendisc" class="button hidden">
<input type="checkbox" id="opendiscussion" name="opendiscussion" {if="!$OPENDISCUSSION"} disabled="disabled"{/if} /> <input type="checkbox" id="opendiscussion" name="opendiscussion" {if="!$OPENDISCUSSION"} disabled="disabled"{/if} />