diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 845145a..2a3936f 100644 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -104,11 +104,20 @@ class Pastes extends CI_Model } } while ($n == 0); + $burn = false; - if ($this->input->post('expire') == 0) + if ($this->input->post('expire') == '0') { $data['expire'] = 0; } + else + if ($this->input->post('expire') == 'burn') + { + $burn = true; + $data['toexpire'] = 1; + $data['expire'] = 0; + $data['private'] = 1; + } else { $format = 'Y-m-d H:i:s'; @@ -128,7 +137,16 @@ class Pastes extends CI_Model } $data['ip_address'] = $this->input->ip_address(); $this->db->insert('pastes', $data); - return 'view/' . $data['pid']; + + if ($burn) + { + echo 'copy this URL, it will become invalid on visit: ' . site_url('view/' . $data['pid']); + exit; + } + else + { + return 'view/' . $data['pid']; + } } private function _get_url($pid) @@ -235,6 +253,8 @@ class Pastes extends CI_Model $data['lang'] = $this->languages->code_to_description($row['lang']); $data['paste'] = $this->process->syntax(htmlspecialchars_decode($row['raw']) , $row['lang']); $data['created'] = $row['created']; + $data['expire'] = $row['expire']; + $data['toexpire'] = $row['toexpire']; $data['url'] = $this->_get_url($row['pid']); $data['raw'] = $row['raw']; $data['hits'] = $row['hits']; @@ -358,6 +378,13 @@ class Pastes extends CI_Model { $this->calculate_hits($pid, $data['hits']); } + + //burn if necessary + + if ($data['expire'] == 0 and $data['toexpire'] == 1) + { + $this->delete_paste($data['pid']); + } return $data; } diff --git a/htdocs/themes/bootstrap/views/defaults/paste_form.php b/htdocs/themes/bootstrap/views/defaults/paste_form.php index 6b401c4..2a9f058 100644 --- a/htdocs/themes/bootstrap/views/defaults/paste_form.php +++ b/htdocs/themes/bootstrap/views/defaults/paste_form.php @@ -92,7 +92,9 @@ lang('burn_on_reading'), "5" => lang('exp_5min'), "60" => lang('exp_1h'), "1440" => lang('exp_1d'), @@ -102,8 +104,9 @@ ); if(! config_item('disable_keep_forever')) { $options['0'] = lang('exp_forever'); + $default_expiration = '0'; // forever } - echo form_dropdown('expire', $options, $expire_set, $expire_extra); ?> + echo form_dropdown('expire', $options, $default_expiration, $expire_extra); ?> diff --git a/htdocs/themes/default/views/defaults/paste_form.php b/htdocs/themes/default/views/defaults/paste_form.php index 27ad339..0c33b1a 100644 --- a/htdocs/themes/default/views/defaults/paste_form.php +++ b/htdocs/themes/default/views/defaults/paste_form.php @@ -90,7 +90,9 @@ lang('burn_on_reading'), "5" => lang('exp_5min'), "60" => lang('exp_1h'), "1440" => lang('exp_1d'), @@ -100,8 +102,9 @@ ); if(! config_item('disable_keep_forever')) { $options['0'] = lang('exp_forever'); + $default_expiration = '0'; // forever } - echo form_dropdown('expire', $options, $expire_set, $expire_extra); ?> + echo form_dropdown('expire', $options, $default_expiration, $expire_extra); ?>