From 969bd165eece6e0ed8de7b2ba64138b5ae33550b Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Apr 2012 16:18:04 +0200 Subject: [PATCH] creation of bit.ly urls --- htdocs/application/config/stikked.php | 18 ++++++++++++++---- htdocs/application/libraries/process.php | 3 +-- htdocs/application/models/pastes.php | 10 ++++++++-- .../application/views/defaults/paste_form.php | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/htdocs/application/config/stikked.php b/htdocs/application/config/stikked.php index 3ac092e..89abd29 100755 --- a/htdocs/application/config/stikked.php +++ b/htdocs/application/config/stikked.php @@ -6,7 +6,7 @@ * The name of your site * */ -$config['site_name'] = "Stikked"; +$config['site_name'] = 'Stikked'; /** * Combine JS & CSS files @@ -16,13 +16,23 @@ $config['site_name'] = "Stikked"; */ $config['combine_assets'] = false; +/** + * Bit.ly config + * + * The username & API-Key for bit.ly + * (go to: http://bitly.com/a/your_api_key) + * +**/ +$config['bitly_username'] = ''; +$config['bitly_apikey'] = ''; + /** * Key for Cron * * The password required to run the cron job * **/ -$config['cron_key'] = ""; +$config['cron_key'] = ''; /** * Pastes Per Page @@ -41,7 +51,7 @@ $config['per_page'] = 10; * NOTE: if changed only pastes from then on will be updated. * **/ -$config['unknown_poster'] = "random"; +$config['unknown_poster'] = 'random'; /** * Name for untitled pastes @@ -50,7 +60,7 @@ $config['unknown_poster'] = "random"; * DO NOT SET BLANK * NOTE: if changed only pastes from then on will be updated. **/ -$config['unknown_title'] = "Untitled"; +$config['unknown_title'] = 'Untitled'; /** * diff --git a/htdocs/application/libraries/process.php b/htdocs/application/libraries/process.php index 510aa8d..5a627ee 100755 --- a/htdocs/application/libraries/process.php +++ b/htdocs/application/libraries/process.php @@ -9,7 +9,6 @@ * */ -#TODO include_once('geshi/geshi.php'); /** @@ -39,7 +38,7 @@ Class Process { $source = $source; $language = $lang; - $geshi =& new Geshi($source, $lang); + $geshi = new Geshi($source, $lang); $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS); $geshi->set_header_type(GESHI_HEADER_DIV); diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index a196eb3..a03e003 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -130,12 +130,18 @@ class Pastes extends CI_Model } else { - $target = 'http://snipr.com/site/snip?r=simple&link=' . site_url('view/' . $data['pid']); + $url = site_url('view/' . $data['pid']); + $url = urlencode($url); + $bitly_username = $this->config->item('bitly_username'); + $bitly_apikey = $this->config->item('bitly_apikey'); + $target = 'http://api.bitly.com/v3/shorten?login=' . $bitly_username . '&apiKey=' . $bitly_apikey . '&longUrl=' . $url; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $target); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - $data['snipurl'] = curl_exec($ch); + $resp = curl_exec($ch); curl_close($ch); + $resp = json_decode($resp); + $data['snipurl'] = $resp->data->url; if (empty($data['snipurl'])) { diff --git a/htdocs/application/views/defaults/paste_form.php b/htdocs/application/views/defaults/paste_form.php index 0e0d1ee..ee452d8 100644 --- a/htdocs/application/views/defaults/paste_form.php +++ b/htdocs/application/views/defaults/paste_form.php @@ -52,14 +52,14 @@
-