diff --git a/README.md b/README.md index 6f81449..c1a328b 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ Changelog * Blocked words; maintain a comma separated list in your config, e.g. '.es.tl, mycraft.com, yourbadword' - pastes with this words will never get pasted * TODO: Spam trap for bots (thanks to the\_compiler, http://www.the-compiler.org/) * Bugfix: Remove\_invisible\_characters removing legitimate paste content (https://github.com/claudehohl/Stikked/issues/28) +* Possibility to manually set the paste's displayed URL (used with mod\_rewrite configurations) * TODO: Print layout for pastes * TODO: Updated to CodeIgniter version 2.1.3 diff --git a/htdocs/application/config/stikked.php b/htdocs/application/config/stikked.php index 8738161..676f0f9 100755 --- a/htdocs/application/config/stikked.php +++ b/htdocs/application/config/stikked.php @@ -68,12 +68,11 @@ $config['per_page'] = 10; * * private_only: No recent pastes will be displayed. * enable_captcha: Users must enter a captcha to post. + * blocked_words: Comma separated list, e.g. '.es.tl, mycraft.com, yourbadword' * **/ $config['private_only'] = false; $config['enable_captcha'] = false; - -//blocked words; comma separated list, e.g. '.es.tl, mycraft.com, yourbadword' $config['blocked_words'] = ''; //spamadmin: accessible via /spamadmin (only active when user + pass is set) @@ -117,6 +116,16 @@ $config['unknown_title'] = 'Untitled'; **/ $config['require_auth'] = false; +/** + * Override the displayed URL + * + * Display this URL in a paste's detail view instead of the main URL - e.g. if you use mod_rewrite + * Variable $id: the paste_id + * Example: 'http://example.com/$id' + * +**/ +$config['displayurl_override'] = ''; + /** * * @@ -124,7 +133,6 @@ $config['require_auth'] = false; * * **/ - $config['nouns'] = array('Hornbill', 'Elephant', 'Bison', 'Lion', 'Camel', 'Sheep', 'Monkey', 'Prairie Dog', 'Plover', 'Tapir', 'Capybara', 'Cheetah', 'Flamingo', 'Peccary', 'Eider', 'Porcupine', 'Pelican', 'Dove', 'Crane', 'Tortoise', 'Agouti', 'Tamarin', 'Pheasant', 'Owl', 'Gibbon', 'Goose', 'Baboon', 'Hamerkop', 'Zebra', diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 146ccda..a2dc39d 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -6,6 +6,7 @@ * - countPastes() * - countReplies() * - createPaste() + * - _get_url() * - checkPaste() * - getPaste() * - calculate_hits() @@ -116,7 +117,7 @@ class Pastes extends CI_Model } else { - $url = site_url('view/' . $data['pid']); + $url = $this->_get_url($data['pid']); $url = urlencode($url); $config_gwgd_url = $this->config->item('gwgd_url'); $gwgd_url = ($config_gwgd_url ? $config_gwgd_url : 'http://gw.gd/'); @@ -137,6 +138,12 @@ class Pastes extends CI_Model $this->db->insert('pastes', $data); return 'view/' . $data['pid']; } + private + function _get_url($pid) + { + $override_url = $this->config->item('displayurl_override'); + return ($override_url ? str_replace('$id', $pid, $override_url) : site_url('view/' . $pid)); + } function checkPaste($seg = 2) { @@ -185,7 +192,7 @@ 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['url'] = site_url('view/' . $row['pid']); + $data['url'] = $this->_get_url($row['pid']); $data['raw'] = $row['raw']; $data['hits'] = $row['hits']; $data['hits_updated'] = $row['hits_updated'];