"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;
}
#expiration, #language, #opendisc {
#expiration, #language, #burnafterreadingoption, #opendisc {
background-color: #414d5a;
padding: 6px 8px;
margin: 0 5px 0 0;

View File

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

View File

@ -191,15 +191,24 @@ class zerobin
// Read expiration date
if (!empty($_POST['expire']))
{
if ($_POST['expire'] == 'burn') {
$meta['burnafterreading'] = true;
} elseif (array_key_exists($_POST['expire'], $this->_conf['expire_options'])) {
$expire = $this->_conf['expire_options'][$_POST['expire']];
if (array_key_exists($_POST['expire'], $this->_conf['expire_options'])) {
$expire = $this->_conf['expire_options'][$_POST['expire']];
} else {
$expire = $this->_conf['expire_options'][$this->_conf['expire']['default']];
}
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.
if ($this->_conf['main']['opendiscussion'] && !empty($_POST['opendiscussion']))
@ -320,16 +329,16 @@ class zerobin
$this->_return_message(1, 'Server error.');
}
/**
* Delete an existing paste
*
* @access private
/**
* Delete an existing paste
*
* @access private
* @param string $dataid
* @param string $deletetoken
* @return void
*/
private function _delete($dataid, $deletetoken)
{
* @return void
*/
private function _delete($dataid, $deletetoken)
{
// Is this a valid paste identifier?
if (preg_match('\A[a-f\d]{16}\z', $dataid))
{
@ -428,12 +437,12 @@ class zerobin
private function _view()
{
// set headers to disable caching
$time = gmdate('D, d M Y H:i:s \G\M\T');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');
header('Expires: ' . $time);
header('Last-Modified: ' . $time);
header('Vary: Accept');
$time = gmdate('D, d M Y H:i:s \G\M\T');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Pragma: no-cache');
header('Expires: ' . $time);
header('Last-Modified: ' . $time);
header('Vary: Accept');
// label all the expiration options
$expire = array();

View File

@ -34,7 +34,7 @@
<h3>{$VERSION}</h3>
<div id="noscript" class="nonworking">Javascript is required for ZeroBin to work.<br />Sorry for the inconvenience.</div>
<div id="oldienotice" class="nonworking">ZeroBin requires a modern browser to work.</div>
<div id="ienotice">Still using Internet Explorer ? Do yourself a favor, switch to a modern browser:
<div id="ienotice">Still using Internet Explorer ? Do yourself a favor, switch to a modern browser:
<a href="http://www.mozilla.org/firefox/">Firefox</a>,
<a href="http://www.opera.com/">Opera</a>,
<a href="http://www.google.com/chrome">Chrome</a>,
@ -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="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>
<div id="expiration" class="hidden">Expire:
<div id="expiration" class="hidden">Expires:
<select id="pasteExpiration" name="pasteExpiration">
<option value="burn"{if="$BURNAFTERREADINGSELECTED"} selected="selected"{/if}>Burn after reading</option>{loop="EXPIRE"}
<option value="{$key}"{if="!$BURNAFTERREADINGSELECTED && $key == $EXPIREDEFAULT"} selected="selected"{/if}>{$value}</option>{/loop}
{loop="EXPIRE"}
<option value="{$key}"{if="$key == $EXPIREDEFAULT"} selected="selected"{/if}>{$value}</option>{/loop}
</select>
</div>
<div id="remainingtime" class="hidden"></div>
@ -64,6 +64,10 @@
<option value="python">Python</option>
</select>
</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" />
<div id="opendisc" class="button hidden">
<input type="checkbox" id="opendiscussion" name="opendiscussion" {if="!$OPENDISCUSSION"} disabled="disabled"{/if} />