mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-26 04:51:08 -05:00
Merge pull request #420 from ColdSphinX/master
add support for polr url shortener
This commit is contained in:
commit
bdba48ca13
@ -101,6 +101,7 @@ $config['cron_key'] = '';
|
||||
* @string gwgd
|
||||
* @string googl
|
||||
* @string bitly
|
||||
* @string polr
|
||||
* @string random - Randomly chose any of upper API-s !WARNING! May be slow! For maximum performanse, it's recommended to either set all API keys or use random_url_engines to list working engines.
|
||||
* @string none - same as off
|
||||
*
|
||||
@ -132,6 +133,9 @@ $config['cron_key'] = '';
|
||||
* bitly_url_api: Famous URL shortening service (API: http://dev.bitly.com/get_started.html)
|
||||
* Usage: Your API key
|
||||
*
|
||||
* polr_url: Your own instance of polr URL-shortener (Download: https://github.com/cydrobolt/polr)
|
||||
* polr_api: Your polr api key
|
||||
*
|
||||
**/
|
||||
$config['url_shortening_use'] = 'off';
|
||||
$config['random_url_engines'] = 'googl,bitly'; // Used only in random mode, read comment above for more info
|
||||
@ -150,6 +154,9 @@ $config['googl_url_api'] = '';
|
||||
// Bit.ly API key
|
||||
$config['bitly_url_api'] = '';
|
||||
|
||||
// polr
|
||||
$config['polr_url'] = '';
|
||||
$config['polr_api'] = '';
|
||||
|
||||
|
||||
/**
|
||||
|
@ -186,6 +186,7 @@ class Pastes extends CI_Model
|
||||
"bit.ly",
|
||||
"yourls",
|
||||
"gwgd",
|
||||
"polr",
|
||||
"random"
|
||||
);
|
||||
|
||||
@ -283,6 +284,14 @@ class Pastes extends CI_Model
|
||||
$url_shortening_api = "bitly";
|
||||
}
|
||||
break;
|
||||
case "polr":
|
||||
$var_polr_url = $this->config->item('polr_url');
|
||||
$var_polr_api = $this->config->item('polr_api');
|
||||
if ((!empty($var_polr_url)) && (!empty($var_polr_api)))
|
||||
{
|
||||
$url_shortening_api = "polr";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$url_shortening_api = false;
|
||||
break;
|
||||
@ -376,6 +385,20 @@ class Pastes extends CI_Model
|
||||
$fetchResp = $this->curl_connect($prep_data);
|
||||
$shorturl = ((strlen($fetchResp) > 4) ? $fetchResp : false);
|
||||
break;
|
||||
case "polr":
|
||||
$config_polr_url = $this->config->item('polr_url');
|
||||
$config_polr_api = $this->config->item('polr_api');
|
||||
$url = urlencode($url);
|
||||
|
||||
// Prepare CURL options array
|
||||
$prep_data = array(
|
||||
CURLOPT_URL => "{$config_polr_url}/api/v2/action/shorten?key={$config_polr_api}&url={$url}&is_secret=false",
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false
|
||||
);
|
||||
$fetchResp = $this->curl_connect($prep_data);
|
||||
$shorturl = ((strlen($fetchResp) > 4) ? $fetchResp : false);
|
||||
break;
|
||||
default:
|
||||
$shorturl = false;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user