diff --git a/css/zerobin.css b/css/zerobin.css index 37f3b5c..ce4d781 100644 --- a/css/zerobin.css +++ b/css/zerobin.css @@ -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; diff --git a/js/zerobin.js b/js/zerobin.js index 45c1d57..a55fd1e 100644 --- a/js/zerobin.js +++ b/js/zerobin.js @@ -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 { diff --git a/lib/zerobin.php b/lib/zerobin.php index 2d2923f..3c260cf 100644 --- a/lib/zerobin.php +++ b/lib/zerobin.php @@ -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(); diff --git a/tpl/page.html b/tpl/page.html index b8295d4..bfb5eb3 100644 --- a/tpl/page.html +++ b/tpl/page.html @@ -34,7 +34,7 @@