clean services files and remove un-ping-able ones
This commit is contained in:
parent
2acf82b4e0
commit
cba24bc78c
20
_prepend.php
20
_prepend.php
@ -45,26 +45,26 @@ $__autoload['kutrlLog'] = $d . 'lib.kutrl.log.php';
|
|||||||
# Services
|
# Services
|
||||||
$__autoload['bilbolinksKutrlService'] = $d . 'services/class.bilbolinks.service.php';
|
$__autoload['bilbolinksKutrlService'] = $d . 'services/class.bilbolinks.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["bilbolinks","bilbolinksKutrlService"]; } );
|
$core->addBehavior('kutrlService', function() { return ["bilbolinks","bilbolinksKutrlService"]; } );
|
||||||
$__autoload['bitlyKutrlService'] = $d . 'services/class.bitly.service.php';
|
//$__autoload['bitlyKutrlService'] = $d . 'services/class.bitly.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["bitly","bitlyKutrlService"]; } );
|
//$core->addBehavior('kutrlService', function() { return ["bitly","bitlyKutrlService"]; } );
|
||||||
$__autoload['customKutrlService'] = $d . 'services/class.custom.service.php';
|
$__autoload['customKutrlService'] = $d . 'services/class.custom.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["custom","customKutrlService"]; } );
|
$core->addBehavior('kutrlService', function() { return ["custom","customKutrlService"]; } );
|
||||||
$__autoload['defaultKutrlService'] = $d . 'services/class.default.service.php';
|
$__autoload['defaultKutrlService'] = $d . 'services/class.default.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["default","defaultKutrlService"]; } );
|
$core->addBehavior('kutrlService', function() { return ["default","defaultKutrlService"]; } );
|
||||||
$__autoload['googlKutrlService'] = $d . 'services/class.googl.service.php';
|
//$__autoload['googlKutrlService'] = $d . 'services/class.googl.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["googl","googlKutrlService"]; } );
|
//$core->addBehavior('kutrlService', function() { return ["googl","googlKutrlService"]; } );
|
||||||
$__autoload['isgdKutrlService'] = $d . 'services/class.isgd.service.php';
|
$__autoload['isgdKutrlService'] = $d . 'services/class.isgd.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["isgd","isgdKutrlService"]; } );
|
$core->addBehavior('kutrlService', function() { return ["isgd","isgdKutrlService"]; } );
|
||||||
$__autoload['localKutrlService'] = $d . 'services/class.local.service.php';
|
$__autoload['localKutrlService'] = $d . 'services/class.local.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["local","localKutrlService"]; } );
|
$core->addBehavior('kutrlService', function() { return ["local","localKutrlService"]; } );
|
||||||
$__autoload['shorttoKutrlService'] = $d . 'services/class.shortto.service.php';
|
//$__autoload['shorttoKutrlService'] = $d . 'services/class.shortto.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["shortto","shorttoKutrlService"]; } );
|
//$core->addBehavior('kutrlService', function() { return ["shortto","shorttoKutrlService"]; } );
|
||||||
$__autoload['trimKutrlService'] = $d . 'services/class.trim.service.php';
|
//$__autoload['trimKutrlService'] = $d . 'services/class.trim.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["trim","trimKutrlService"]; } );
|
//$core->addBehavior('kutrlService', function() { return ["trim","trimKutrlService"]; } );
|
||||||
$__autoload['yourlsKutrlService'] = $d . 'services/class.yourls.service.php';
|
$__autoload['yourlsKutrlService'] = $d . 'services/class.yourls.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["yourls","yourlsKutrlService"]; } );
|
$core->addBehavior('kutrlService', function() { return ["yourls","yourlsKutrlService"]; } );
|
||||||
$__autoload['suprKutrlService'] = $d . 'services/class.supr.service.php';
|
//$__autoload['suprKutrlService'] = $d . 'services/class.supr.service.php';
|
||||||
$core->addBehavior('kutrlService', function() { return ["supr","suprKutrlService"]; } );
|
//$core->addBehavior('kutrlService', function() { return ["supr","suprKutrlService"]; } );
|
||||||
|
|
||||||
# Shorten url passed through wiki functions
|
# Shorten url passed through wiki functions
|
||||||
$__autoload['kutrlWiki'] = $d . 'lib.wiki.kutrl.php';
|
$__autoload['kutrlWiki'] = $d . 'lib.wiki.kutrl.php';
|
||||||
|
@ -10,88 +10,85 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class bilbolinksKutrlService extends kutrlService
|
class bilbolinksKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected $config = array(
|
protected $config = [
|
||||||
'id' => 'bilbolinks',
|
'id' => 'bilbolinks',
|
||||||
'name' => 'BilboLinks',
|
'name' => 'BilboLinks',
|
||||||
'home' => 'http://www.tux-planet.fr/bilbobox/'
|
'home' => 'http://www.tux-planet.fr/bilbobox/'
|
||||||
);
|
];
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$base = (string) $this->settings->kutrl_srv_bilbolinks_base;
|
$base = (string) $this->settings->kutrl_srv_bilbolinks_base;
|
||||||
if (!empty($base) && substr($base,-1,1) != '/') $base .= '/';
|
if (!empty($base) && substr($base, -1, 1) != '/') {
|
||||||
|
$base .= '/';
|
||||||
$this->config['url_api'] = $base.'api.php';
|
}
|
||||||
$this->config['url_base'] = $base;
|
$this->config['url_api'] = $base . 'api.php';
|
||||||
$this->config['url_min_len'] = 25;
|
$this->config['url_base'] = $base;
|
||||||
}
|
$this->config['url_min_len'] = 25;
|
||||||
|
}
|
||||||
public function saveSettings()
|
|
||||||
{
|
public function saveSettings()
|
||||||
$base = '';
|
{
|
||||||
if (!empty($_POST['kutrl_srv_bilbolinks_base']))
|
$base = '';
|
||||||
{
|
if (!empty($_POST['kutrl_srv_bilbolinks_base'])) {
|
||||||
$base = $_POST['kutrl_srv_bilbolinks_base'];
|
$base = $_POST['kutrl_srv_bilbolinks_base'];
|
||||||
if (substr($base,-1,1) != '/') $base .= '/';
|
if (substr($base, -1, 1) != '/') {
|
||||||
}
|
$base .= '/';
|
||||||
|
}
|
||||||
$this->settings->put('kutrl_srv_bilbolinks_base',$base);
|
}
|
||||||
}
|
$this->settings->put('kutrl_srv_bilbolinks_base', $base);
|
||||||
|
}
|
||||||
public function settingsForm()
|
|
||||||
{
|
public function settingsForm()
|
||||||
echo
|
{
|
||||||
'<p><label class="classic">'.
|
echo
|
||||||
__('Url of the service:').'<br />'.
|
'<p><label class="classic">' .
|
||||||
form::field(array('kutrl_srv_bilbolinks_base'),50,255,$this->settings->kutrl_srv_bilbolinks_base).
|
__('Url of the service:') . '<br />' .
|
||||||
'</label></p>'.
|
form::field(['kutrl_srv_bilbolinks_base'], 50, 255, $this->settings->kutrl_srv_bilbolinks_base) .
|
||||||
'<p class="form-note">'.
|
'</label></p>' .
|
||||||
__('This is the root URL of the "bilbolinks" service you want to use. Ex: "http://tux-pla.net/".').
|
'<p class="form-note">' .
|
||||||
'</p>';
|
__('This is the root URL of the "bilbolinks" service you want to use. Ex: "http://tux-pla.net/".') .
|
||||||
}
|
'</p>';
|
||||||
|
}
|
||||||
public function testService()
|
|
||||||
{
|
public function testService()
|
||||||
if (empty($this->url_base))
|
{
|
||||||
{
|
if (empty($this->url_base)) {
|
||||||
$this->error->add(__('Service is not well configured.'));
|
$this->error->add(__('Service is not well configured.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$arg = array('longurl' => urlencode($this->url_test));
|
$arg = ['longurl' => urlencode($this->url_test)];
|
||||||
if (!self::post($this->url_api,$arg,true,true))
|
if (!self::post($this->url_api, $arg, true,true)) {
|
||||||
{
|
$this->error->add(__('Service is unavailable.'));
|
||||||
$this->error->add(__('Service is unavailable.'));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
public function createHash($url, $hash = null)
|
||||||
public function createHash($url,$hash=null)
|
{
|
||||||
{
|
$arg = ['longurl' => $url];
|
||||||
$arg = array('longurl' => $url);
|
|
||||||
|
if (!($response = self::post($this->url_api, $arg, true, true))) {
|
||||||
if (!($response = self::post($this->url_api,$arg,true,true)))
|
$this->error->add(__('Service is unavailable.'));
|
||||||
{
|
return false;
|
||||||
$this->error->add(__('Service is unavailable.'));
|
}
|
||||||
return false;
|
if ($response == 'You are too speed!') {
|
||||||
}
|
$this->error->add(__('Service rate limit exceeded.'));
|
||||||
if ($response == 'You are too speed!')
|
return false;
|
||||||
{
|
}
|
||||||
$this->error->add(__('Service rate limit exceeded.'));
|
$rs = new ArrayObject();
|
||||||
return false;
|
$rs->hash = str_replace($this->url_base, '', $response);
|
||||||
}
|
$rs->url = $url;
|
||||||
|
$rs->type = $this->id;
|
||||||
$rs = new ArrayObject();
|
|
||||||
$rs->hash = str_replace($this->url_base,'',$response);
|
return $rs;
|
||||||
$rs->url = $url;
|
}
|
||||||
$rs->type = $this->id;
|
}
|
||||||
|
|
||||||
return $rs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -10,118 +10,116 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class bitlyKutrlService extends kutrlService
|
class bitlyKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected $config = array(
|
protected $config = [
|
||||||
'id' => 'bitly',
|
'id' => 'bitly',
|
||||||
'name' => 'bit.ly',
|
'name' => 'bit.ly',
|
||||||
'home' => 'http://bit.ly',
|
'home' => 'http://bit.ly',
|
||||||
|
|
||||||
'url_api' => 'http://api.bit.ly/v3/',
|
'url_api' => 'http://api.bit.ly/v3/',
|
||||||
'url_base' => 'http://bit.ly/',
|
'url_base' => 'http://bit.ly/',
|
||||||
'url_min_len' => 25
|
'url_min_len' => 25
|
||||||
);
|
];
|
||||||
|
|
||||||
private $args = array(
|
|
||||||
'format' => 'xml',
|
|
||||||
'login' => '',
|
|
||||||
'apiKey' => '',
|
|
||||||
'history' => 0
|
|
||||||
);
|
|
||||||
|
|
||||||
protected function init()
|
|
||||||
{
|
|
||||||
$this->args['login'] = $this->settings->kutrl_srv_bitly_login;
|
|
||||||
$this->args['apiKey'] = $this->settings->kutrl_srv_bitly_apikey;
|
|
||||||
$this->args['history'] = $this->settings->kutrl_srv_bitly_history ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function saveSettings()
|
|
||||||
{
|
|
||||||
$this->settings->put('kutrl_srv_bitly_login',$_POST['kutrl_srv_bitly_login']);
|
|
||||||
$this->settings->put('kutrl_srv_bitly_apikey',$_POST['kutrl_srv_bitly_apikey']);
|
|
||||||
$this->settings->put('kutrl_srv_bitly_history',isset($_POST['kutrl_srv_bitly_history']));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function settingsForm()
|
|
||||||
{
|
|
||||||
echo
|
|
||||||
'<p><label class="classic">'.__('Login:').'<br />'.
|
|
||||||
form::field(array('kutrl_srv_bitly_login'),50,255,$this->settings->kutrl_srv_bitly_login).
|
|
||||||
'</label></p>'.
|
|
||||||
'<p class="form-note">'.
|
|
||||||
sprintf(__('This is your login to sign up to %s'),$this->config['name']).
|
|
||||||
'</p>'.
|
|
||||||
'<p><label class="classic">'.__('API Key:').'<br />'.
|
|
||||||
form::field(array('kutrl_srv_bitly_apikey'),50,255,$this->settings->kutrl_srv_bitly_apikey).
|
|
||||||
'</label></p>'.
|
|
||||||
'<p class="form-note">'.
|
|
||||||
sprintf(__('This is your personnal %s API key. You can find it on your account page.'),$this->config['name']).
|
|
||||||
'</p>'.
|
|
||||||
'<p><label class="classic">'.
|
|
||||||
form::checkbox(array('kutrl_srv_bitly_history'),'1',$this->settings->kutrl_srv_bitly_history).' '.
|
|
||||||
__('Publish history').
|
|
||||||
'</label></p>'.
|
|
||||||
'<p class="form-note">'.
|
|
||||||
__('This publish all short links on your bit.ly public page.').
|
|
||||||
'</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
if (empty($this->args['login']) || empty($this->args['apiKey']))
|
|
||||||
{
|
|
||||||
$this->error->add(__('Service is not well configured.'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$args = $this->args;
|
private $args = [
|
||||||
$args['hash'] = 'WP9vc';
|
'format' => 'xml',
|
||||||
if (!($response = self::post($this->url_api.'expand',$args,true)))
|
'login' => '',
|
||||||
{
|
'apiKey' => '',
|
||||||
$this->error->add(__('Failed to call service.'));
|
'history' => 0
|
||||||
return false;
|
];
|
||||||
}
|
|
||||||
|
protected function init()
|
||||||
$rsp = simplexml_load_string($response);
|
{
|
||||||
|
$this->args['login'] = $this->settings->kutrl_srv_bitly_login;
|
||||||
$err_msg = (string) $rsp->status_txt;
|
$this->args['apiKey'] = $this->settings->kutrl_srv_bitly_apikey;
|
||||||
if ($err_msg != 'OK') {
|
$this->args['history'] = $this->settings->kutrl_srv_bitly_history ? 1 : 0;
|
||||||
$err_no = (integer) $rsp->status_code;
|
}
|
||||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
|
||||||
return false;
|
public function saveSettings()
|
||||||
}
|
{
|
||||||
return true;
|
$this->settings->put('kutrl_srv_bitly_login', $_POST['kutrl_srv_bitly_login']);
|
||||||
}
|
$this->settings->put('kutrl_srv_bitly_apikey', $_POST['kutrl_srv_bitly_apikey']);
|
||||||
|
$this->settings->put('kutrl_srv_bitly_history', isset($_POST['kutrl_srv_bitly_history']));
|
||||||
public function createHash($url,$hash=null)
|
}
|
||||||
{
|
|
||||||
$args = $this->args;
|
public function settingsForm()
|
||||||
$args['longUrl'] = $url;
|
{
|
||||||
|
echo
|
||||||
if (!($response = self::post($this->url_api.'shorten',$args,true)))
|
'<p><label class="classic">' . __('Login:') . '<br />' .
|
||||||
{
|
form::field(['kutrl_srv_bitly_login'], 50, 255, $this->settings->kutrl_srv_bitly_login) .
|
||||||
$this->error->add(__('Failed to call service.'));
|
'</label></p>' .
|
||||||
return false;
|
'<p class="form-note">' .
|
||||||
}
|
sprintf(__('This is your login to sign up to %s'), $this->config['name']) .
|
||||||
|
'</p>' .
|
||||||
$rsp = simplexml_load_string($response);
|
'<p><label class="classic">' . __('API Key:') . '<br />' .
|
||||||
|
form::field(['kutrl_srv_bitly_apikey'], 50, 255, $this->settings->kutrl_srv_bitly_apikey) .
|
||||||
$err_msg = (string) $rsp->status_txt;
|
'</label></p>' .
|
||||||
if ($err_msg != 'OK') {
|
'<p class="form-note">' .
|
||||||
$err_no = (integer) $rsp->status_code;
|
sprintf(__('This is your personnal %s API key. You can find it on your account page.'), $this->config['name']) .
|
||||||
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'),$err_no,$err_msg));
|
'</p>' .
|
||||||
return false;
|
'<p><label class="classic">' .
|
||||||
}
|
form::checkbox(['kutrl_srv_bitly_history'], '1', $this->settings->kutrl_srv_bitly_history) . ' ' .
|
||||||
|
__('Publish history') .
|
||||||
$rs = new ArrayObject();
|
'</label></p>' .
|
||||||
$rs->hash = (string) $rsp->data[0]->hash;
|
'<p class="form-note">' .
|
||||||
$rs->url = (string) $rsp->data[0]->long_url;
|
__('This publish all short links on your bit.ly public page.') .
|
||||||
$rs->type = $this->id;
|
'</p>';
|
||||||
|
}
|
||||||
return $rs;
|
|
||||||
}
|
public function testService()
|
||||||
}
|
{
|
||||||
?>
|
if (empty($this->args['login']) || empty($this->args['apiKey'])) {
|
||||||
|
$this->error->add(__('Service is not well configured.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$args = $this->args;
|
||||||
|
$args['hash'] = 'WP9vc';
|
||||||
|
if (!($response = self::post($this->url_api . 'expand', $args, true))) {
|
||||||
|
$this->error->add(__('Failed to call service.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rsp = simplexml_load_string($response);
|
||||||
|
|
||||||
|
$err_msg = (string) $rsp->status_txt;
|
||||||
|
if ($err_msg != 'OK') {
|
||||||
|
$err_no = (integer) $rsp->status_code;
|
||||||
|
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'), $err_no, $err_msg));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createHash($url, $hash = null)
|
||||||
|
{
|
||||||
|
$args = $this->args;
|
||||||
|
$args['longUrl'] = $url;
|
||||||
|
|
||||||
|
if (!($response = self::post($this->url_api . 'shorten', $args, true))) {
|
||||||
|
$this->error->add(__('Failed to call service.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rsp = simplexml_load_string($response);
|
||||||
|
|
||||||
|
$err_msg = (string) $rsp->status_txt;
|
||||||
|
if ($err_msg != 'OK') {
|
||||||
|
$err_no = (integer) $rsp->status_code;
|
||||||
|
$this->error->add(sprintf(__('An error occured with code %s and message "%s"'), $err_no, $err_msg));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rs = new ArrayObject();
|
||||||
|
$rs->hash = (string) $rsp->data[0]->hash;
|
||||||
|
$rs->url = (string) $rsp->data[0]->long_url;
|
||||||
|
$rs->type = $this->id;
|
||||||
|
|
||||||
|
return $rs;
|
||||||
|
}
|
||||||
|
}
|
@ -10,111 +10,109 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class customKutrlService extends kutrlService
|
class customKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected $config = array(
|
protected $config = [
|
||||||
'id' => 'custom',
|
'id' => 'custom',
|
||||||
'name' => 'Custom'
|
'name' => 'Custom'
|
||||||
);
|
];
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$config = unserialize(base64_decode($this->settings->kutrl_srv_custom));
|
$config = unserialize(base64_decode($this->settings->kutrl_srv_custom));
|
||||||
if (!is_array($config))
|
if (!is_array($config))
|
||||||
{
|
{
|
||||||
$config = array();
|
$config = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->config['url_api'] = !empty($config['url_api']) ? $config['url_api'] : '';
|
$this->config['url_api'] = !empty($config['url_api']) ? $config['url_api'] : '';
|
||||||
$this->config['url_base'] = !empty($config['url_base']) ? $config['url_base'] : '';
|
$this->config['url_base'] = !empty($config['url_base']) ? $config['url_base'] : '';
|
||||||
$this->config['url_param'] = !empty($config['url_param']) ? $config['url_param'] : '';
|
$this->config['url_param'] = !empty($config['url_param']) ? $config['url_param'] : '';
|
||||||
$this->config['url_encode'] = !empty($config['url_api']);
|
$this->config['url_encode'] = !empty($config['url_api']);
|
||||||
|
|
||||||
$this->config['url_min_length'] = strlen($this->url_base) + 2;
|
$this->config['url_min_length'] = strlen($this->url_base) + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveSettings()
|
|
||||||
{
|
|
||||||
$config = array(
|
|
||||||
'url_api' => $_POST['kutrl_srv_custom_url_api'],
|
|
||||||
'url_base' => $_POST['kutrl_srv_custom_url_base'],
|
|
||||||
'url_param' => $_POST['kutrl_srv_custom_url_param'],
|
|
||||||
'url_encode' => !empty($_POST['kutrl_srv_custom_url_encode'])
|
|
||||||
);
|
|
||||||
$this->settings->put('kutrl_srv_custom',base64_encode(serialize($config)));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function settingsForm()
|
|
||||||
{
|
|
||||||
$default = array(
|
|
||||||
'url_api' => '',
|
|
||||||
'url_base' => '',
|
|
||||||
'url_param' => '',
|
|
||||||
'url_encode' => true
|
|
||||||
);
|
|
||||||
$config = unserialize(base64_decode($this->settings->kutrl_srv_custom));
|
|
||||||
if (!is_array($config))
|
|
||||||
{
|
|
||||||
$config = array();
|
|
||||||
}
|
|
||||||
$config = array_merge($default,$config);
|
|
||||||
|
|
||||||
echo
|
|
||||||
'<p>'.__('You can set a configurable service.').'<br />'.
|
|
||||||
__('It consists on a simple query to an URL with only one param.').'<br />'.
|
|
||||||
__('It must respond with a http code 200 on success.').'<br />'.
|
|
||||||
__('It must returned the short URL (or only hash) in clear text.').'</p>' .
|
|
||||||
'<p><label class="classic">'.__('API URL:').'<br />'.
|
|
||||||
form::field(array('kutrl_srv_custom_url_api'),50,255,$config['url_api']).
|
|
||||||
'</label></p>'.
|
|
||||||
'<p class="form-note">'.__('Full path to API of the URL shortener. ex: "http://is.gd/api.php"').'</p>'.
|
|
||||||
'<p><label class="classic">'.__('Short URL domain:').'<br />'.
|
|
||||||
form::field(array('kutrl_srv_custom_url_base'),50,255,$config['url_base']).
|
|
||||||
'</label></p>'.
|
|
||||||
'<p class="form-note">'.__('Common part of the short URL. ex: "http://is.gd/"').'</p>'.
|
|
||||||
'<p><label class="classic">'.__('API URL param:').'<br />'.
|
|
||||||
form::field(array('kutrl_srv_custom_url_param'),50,255,$config['url_param']).
|
|
||||||
'</label></p>'.
|
|
||||||
'<p class="form-note">'.__('Param of the query. ex: "longurl"').'</p>'.
|
|
||||||
'<p><label class="classic">'.
|
|
||||||
form::checkbox(array('kutrl_srv_custom_url_encode'),'1',$config['url_encode']).' '.
|
|
||||||
__('Encode URL').
|
|
||||||
'</label></p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
if (empty($this->url_api)) return false;
|
|
||||||
|
|
||||||
$url = $this->url_encode ? urlencode($this->url_test) : $this->url_test;
|
|
||||||
$arg = array($this->url_param => $url);
|
|
||||||
if (!self::post($this->url_api,$arg,true,true))
|
|
||||||
{
|
|
||||||
$this->error->add(__('Service is unavailable.'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createHash($url,$hash=null)
|
|
||||||
{
|
|
||||||
$enc = $this->url_encode ? urlencode($url) : $url;
|
|
||||||
$arg = array($this->url_param => $enc);
|
|
||||||
|
|
||||||
if (!($response = self::post($this->url_api,$arg,true,true)))
|
|
||||||
{
|
|
||||||
$this->error->add(__('Service is unavailable.'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$rs = new ArrayObject();
|
|
||||||
$rs->hash = str_replace($this->url_base,'',$response);
|
|
||||||
$rs->url = $url;
|
|
||||||
$rs->type = $this->id;
|
|
||||||
|
|
||||||
return $rs;
|
public function saveSettings()
|
||||||
}
|
{
|
||||||
}
|
$config = [
|
||||||
?>
|
'url_api' => $_POST['kutrl_srv_custom_url_api'],
|
||||||
|
'url_base' => $_POST['kutrl_srv_custom_url_base'],
|
||||||
|
'url_param' => $_POST['kutrl_srv_custom_url_param'],
|
||||||
|
'url_encode' => !empty($_POST['kutrl_srv_custom_url_encode'])
|
||||||
|
];
|
||||||
|
$this->settings->put('kutrl_srv_custom', base64_encode(serialize($config)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settingsForm()
|
||||||
|
{
|
||||||
|
$default = [
|
||||||
|
'url_api' => '',
|
||||||
|
'url_base' => '',
|
||||||
|
'url_param' => '',
|
||||||
|
'url_encode' => true
|
||||||
|
];
|
||||||
|
$config = unserialize(base64_decode($this->settings->kutrl_srv_custom));
|
||||||
|
if (!is_array($config)) {
|
||||||
|
$config = [];
|
||||||
|
}
|
||||||
|
$config = array_merge($default, $config);
|
||||||
|
|
||||||
|
echo
|
||||||
|
'<p>' . __('You can set a configurable service.') . '<br />' .
|
||||||
|
__('It consists on a simple query to an URL with only one param.') . '<br />' .
|
||||||
|
__('It must respond with a http code 200 on success.') . '<br />' .
|
||||||
|
__('It must returned the short URL (or only hash) in clear text.') . '</p>' .
|
||||||
|
'<p><label class="classic">' . __('API URL:') . '<br />' .
|
||||||
|
form::field(['kutrl_srv_custom_url_api'], 50, 255, $config['url_api']) .
|
||||||
|
'</label></p>' .
|
||||||
|
'<p class="form-note">' . __('Full path to API of the URL shortener. ex: "http://is.gd/api.php"') . '</p>' .
|
||||||
|
'<p><label class="classic">' . __('Short URL domain:') . '<br />' .
|
||||||
|
form::field(['kutrl_srv_custom_url_base'], 50, 255, $config['url_base']) .
|
||||||
|
'</label></p>' .
|
||||||
|
'<p class="form-note">' . __('Common part of the short URL. ex: "http://is.gd/"') . '</p>' .
|
||||||
|
'<p><label class="classic">' . __('API URL param:') . '<br />' .
|
||||||
|
form::field(['kutrl_srv_custom_url_param'], 50, 255, $config['url_param']) .
|
||||||
|
'</label></p>' .
|
||||||
|
'<p class="form-note">' . __('Param of the query. ex: "longurl"') . '</p>' .
|
||||||
|
'<p><label class="classic">' .
|
||||||
|
form::checkbox(['kutrl_srv_custom_url_encode'], '1', $config['url_encode']) . ' ' .
|
||||||
|
__('Encode URL') .
|
||||||
|
'</label></p>';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testService()
|
||||||
|
{
|
||||||
|
if (empty($this->url_api)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$url = $this->url_encode ? urlencode($this->url_test) : $this->url_test;
|
||||||
|
$arg = [$this->url_param => $url];
|
||||||
|
if (!self::post($this->url_api, $arg, true, true)) {
|
||||||
|
$this->error->add(__('Service is unavailable.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createHash($url, $hash = null)
|
||||||
|
{
|
||||||
|
$enc = $this->url_encode ? urlencode($url) : $url;
|
||||||
|
$arg = array($this->url_param => $enc);
|
||||||
|
|
||||||
|
if (!($response = self::post($this->url_api, $arg, true, true))) {
|
||||||
|
$this->error->add(__('Service is unavailable.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$rs = new ArrayObject();
|
||||||
|
$rs->hash = str_replace($this->url_base, '', $response);
|
||||||
|
$rs->url = $url;
|
||||||
|
$rs->type = $this->id;
|
||||||
|
|
||||||
|
return $rs;
|
||||||
|
}
|
||||||
|
}
|
@ -10,7 +10,9 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
# nb: "default" ne veut pas dire service par défaut
|
# nb: "default" ne veut pas dire service par défaut
|
||||||
# mais service simple et rapide configuré par des constantes
|
# mais service simple et rapide configuré par des constantes
|
||||||
@ -19,73 +21,70 @@ if (!defined('DC_RC_PATH')){return;}
|
|||||||
|
|
||||||
class defaultKutrlService extends kutrlService
|
class defaultKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->config = array(
|
$this->config = [
|
||||||
'id' => 'default',
|
'id' => 'default',
|
||||||
'name' => 'Default',
|
'name' => 'Default',
|
||||||
'home' => '',
|
'home' => '',
|
||||||
|
|
||||||
'url_api' => SHORTEN_SERVICE_API,
|
'url_api' => SHORTEN_SERVICE_API,
|
||||||
'url_base' => SHORTEN_SERVICE_BASE,
|
'url_base' => SHORTEN_SERVICE_BASE,
|
||||||
'url_min_len' => strlen(SHORTEN_SERVICE_BASE) + 2,
|
'url_min_len' => strlen(SHORTEN_SERVICE_BASE) + 2,
|
||||||
|
|
||||||
'url_param' => SHORTEN_SERVICE_PARAM,
|
'url_param' => SHORTEN_SERVICE_PARAM,
|
||||||
'url_encode' => SHORTEN_SERVICE_ENCODE
|
'url_encode' => SHORTEN_SERVICE_ENCODE
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingsForm()
|
public function settingsForm()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<p class="form-note">'.
|
'<p class="form-note">' .
|
||||||
__('There is nothing to configure for this service.').
|
__('There is nothing to configure for this service.') .
|
||||||
'</p>'.
|
'</p>' .
|
||||||
'<p>'.__('This service is set to:').'</p>'.
|
'<p>' . __('This service is set to:') . '</p>' .
|
||||||
'<dl>'.
|
'<dl>' .
|
||||||
'<dt>'.__('Service name:').'</dt>'.
|
'<dt>' . __('Service name:') . '</dt>' .
|
||||||
'<dd>'.SHORTEN_SERVICE_NAME.'</dd>'.
|
'<dd>' . SHORTEN_SERVICE_NAME . '</dd>' .
|
||||||
'<dt>'.__('Full API URL:').'</dt>'.
|
'<dt>' . __('Full API URL:') . '</dt>' .
|
||||||
'<dd>'.SHORTEN_SERVICE_API.'</dd>'.
|
'<dd>' . SHORTEN_SERVICE_API . '</dd>' .
|
||||||
'<dt>'.__('Query param:').'</dt>'.
|
'<dt>' . __('Query param:') . '</dt>' .
|
||||||
'<dd>'.SHORTEN_SERVICE_PARAM.'</dd>'.
|
'<dd>' . SHORTEN_SERVICE_PARAM . '</dd>' .
|
||||||
'<dt>'.__('Short URL domain:').'</dt>'.
|
'<dt>' . __('Short URL domain:') . '</dt>' .
|
||||||
'<dd>'.SHORTEN_SERVICE_BASE.'</dd>'.
|
'<dd>' . SHORTEN_SERVICE_BASE . '</dd>' .
|
||||||
'<dt>'.__('Encode URL:').'</dt>'.
|
'<dt>' . __('Encode URL:') . '</dt>' .
|
||||||
'<dd>'.(SHORTEN_SERVICE_ENCODE ? __('yes') : __('no')).'</dd>'.
|
'<dd>' . (SHORTEN_SERVICE_ENCODE ? __('yes') : __('no')) . '</dd>' .
|
||||||
'</dl>';
|
'</dl>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testService()
|
public function testService()
|
||||||
{
|
{
|
||||||
$url = $this->url_encode ? urlencode($this->url_test) : $this->url_test;
|
$url = $this->url_encode ? urlencode($this->url_test) : $this->url_test;
|
||||||
$arg = array($this->url_param => urlencode($this->url_test));
|
$arg = array($this->url_param => urlencode($this->url_test));
|
||||||
|
|
||||||
if (!self::post($this->url_api,$arg,true,true))
|
if (!self::post($this->url_api, $arg, true, true)) {
|
||||||
{
|
$this->error->add(__('Service is unavailable.'));
|
||||||
$this->error->add(__('Service is unavailable.'));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
public function createHash($url, $hash = null)
|
||||||
public function createHash($url,$hash=null)
|
{
|
||||||
{
|
$enc = $this->url_encode ? urlencode($url) : $url;
|
||||||
$enc = $this->url_encode ? urlencode($url) : $url;
|
$arg = array($this->url_param => $url);
|
||||||
$arg = array($this->url_param => $url);
|
|
||||||
|
if (!($response = self::post($this->url_api, $arg, true, true))) {
|
||||||
if (!($response = self::post($this->url_api,$arg,true,true)))
|
$this->error->add(__('Service is unavailable.'));
|
||||||
{
|
return false;
|
||||||
$this->error->add(__('Service is unavailable.'));
|
}
|
||||||
return false;
|
|
||||||
}
|
$rs = new ArrayObject();
|
||||||
|
$rs->hash = str_replace($this->url_base, '', $response);
|
||||||
$rs = new ArrayObject();
|
$rs->url = $url;
|
||||||
$rs->hash = str_replace($this->url_base,'',$response);
|
$rs->type = $this->id;
|
||||||
$rs->url = $url;
|
|
||||||
$rs->type = $this->id;
|
return $rs;
|
||||||
|
}
|
||||||
return $rs;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -10,71 +10,70 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class googlKutrlService extends kutrlService
|
class googlKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
public $id = 'googl';
|
public $id = 'googl';
|
||||||
public $name = 'goo.gl';
|
public $name = 'goo.gl';
|
||||||
public $home = 'http://goo.gl';
|
public $home = 'http://goo.gl';
|
||||||
|
|
||||||
private $url_api = 'https://www.googleapis.com/urlshortener/v1/url';
|
private $url_api = 'https://www.googleapis.com/urlshortener/v1/url';
|
||||||
private $url_test = 'http://dotclear.jcdenis.com/go/kUtRL';
|
private $url_test = 'http://dotclear.jcdenis.com/go/kUtRL';
|
||||||
private $args = array(
|
private $args = [
|
||||||
'key' => 'AIzaSyDE1WfOMdnrnX8p51jSmVodenaNk385asc'
|
'key' => 'AIzaSyDE1WfOMdnrnX8p51jSmVodenaNk385asc'
|
||||||
);
|
];
|
||||||
private $headers = array('Content-Type: application/json');
|
private $headers = array('Content-Type: application/json');
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->url_base = 'http://goo.gl/';
|
$this->url_base = 'http://goo.gl/';
|
||||||
$this->url_min_length = 20;
|
$this->url_min_length = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testService()
|
public function testService()
|
||||||
{
|
{
|
||||||
$args = $this->args;
|
$args = $this->args;
|
||||||
$args['shortUrl'] = $this->url_base.'PLovn';
|
$args['shortUrl'] = $this->url_base . 'PLovn';
|
||||||
if (!($response = self::post($this->url_api,$args,true,true,$this->headers)))
|
if (!($response = self::post($this->url_api, $args, true, true, $this->headers))) {
|
||||||
{
|
$this->error->add(__('Failed to call service.'));
|
||||||
$this->error->add(__('Failed to call service.'));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$rsp = json_decode($response);
|
|
||||||
|
|
||||||
if (empty($rsp->status)) {
|
|
||||||
$this->error->add(__('An error occured'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createHash($url,$hash=null)
|
$rsp = json_decode($response);
|
||||||
{
|
|
||||||
$args = $this->args;
|
|
||||||
$args['longUrl'] = $url;
|
|
||||||
$args = json_encode($args);
|
|
||||||
|
|
||||||
if (!($response = self::post($this->url_api,$args,true,false,$this->headers)))
|
if (empty($rsp->status)) {
|
||||||
{
|
$this->error->add(__('An error occured'));
|
||||||
$this->error->add(__('Failed to call service.'));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
$rsp = json_decode($response);
|
|
||||||
|
public function createHash($url, $hash = null)
|
||||||
if (empty($rsp->id)) {
|
{
|
||||||
$this->error->add(__('An error occured'));
|
$args = $this->args;
|
||||||
return false;
|
$args['longUrl'] = $url;
|
||||||
}
|
$args = json_encode($args);
|
||||||
|
|
||||||
$rs = new ArrayObject();
|
if (!($response = self::post($this->url_api, $args, true, false, $this->headers))) {
|
||||||
$rs->hash = str_replace($this->url_base,'',$rsp->id);
|
$this->error->add(__('Failed to call service.'));
|
||||||
$rs->url = $rsp->longUrl;
|
return false;
|
||||||
$rs->type = $this->id;
|
}
|
||||||
|
|
||||||
return $rs;
|
$rsp = json_decode($response);
|
||||||
}
|
|
||||||
}
|
if (empty($rsp->id)) {
|
||||||
?>
|
$this->error->add(__('An error occured'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rs = new ArrayObject();
|
||||||
|
$rs->hash = str_replace($this->url_base, '', $rsp->id);
|
||||||
|
$rs->url = $rsp->longUrl;
|
||||||
|
$rs->type = $this->id;
|
||||||
|
|
||||||
|
return $rs;
|
||||||
|
}
|
||||||
|
}
|
@ -14,43 +14,40 @@ if (!defined('DC_RC_PATH')){return;}
|
|||||||
|
|
||||||
class isgdKutrlService extends kutrlService
|
class isgdKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected $config = array(
|
protected $config = [
|
||||||
'id' => 'isgd',
|
'id' => 'isgd',
|
||||||
'name' => 'is.gd',
|
'name' => 'is.gd',
|
||||||
'home' => 'http://is.gd/',
|
'home' => 'http://is.gd/',
|
||||||
|
|
||||||
'url_api' => 'http://is.gd/api.php',
|
'url_api' => 'http://is.gd/api.php',
|
||||||
'url_base' => 'http://is.gd/',
|
'url_base' => 'http://is.gd/',
|
||||||
'url_min_length' => 25
|
'url_min_length' => 25
|
||||||
);
|
];
|
||||||
|
|
||||||
public function testService()
|
public function testService()
|
||||||
{
|
{
|
||||||
$arg = array('longurl' => urlencode($this->url_test));
|
$arg = ['longurl' => urlencode($this->url_test)];
|
||||||
if (!self::post($this->url_api,$arg,true,true))
|
if (!self::post($this->url_api, $arg, true, true)) {
|
||||||
{
|
$this->error->add(__('Service is unavailable.'));
|
||||||
$this->error->add(__('Service is unavailable.'));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
public function createHash($url, $hash = null)
|
||||||
public function createHash($url,$hash=null)
|
{
|
||||||
{
|
$arg = ['longurl' => $url];
|
||||||
$arg = array('longurl' => $url);
|
|
||||||
|
if (!($response = self::post($this->url_api, $arg, true, true))) {
|
||||||
if (!($response = self::post($this->url_api,$arg,true,true)))
|
$this->error->add(__('Service is unavailable.'));
|
||||||
{
|
return false;
|
||||||
$this->error->add(__('Service is unavailable.'));
|
}
|
||||||
return false;
|
|
||||||
}
|
$rs = new ArrayObject();
|
||||||
|
$rs->hash = str_replace($this->url_base, '', $response);
|
||||||
$rs = new ArrayObject();
|
$rs->url = $url;
|
||||||
$rs->hash = str_replace($this->url_base,'',$response);
|
$rs->type = $this->id;
|
||||||
$rs->url = $url;
|
|
||||||
$rs->type = $this->id;
|
return $rs;
|
||||||
|
}
|
||||||
return $rs;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -10,262 +10,228 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class localKutrlService extends kutrlService
|
class localKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected $config = array(
|
protected $config = [
|
||||||
'id' => 'local',
|
'id' => 'local',
|
||||||
'name' => 'kUtRL',
|
'name' => 'kUtRL',
|
||||||
'home' => 'http://kutrl.fr',
|
'home' => 'http://kutrl.fr',
|
||||||
|
|
||||||
'allow_custom_hash' => true
|
'allow_custom_hash' => true
|
||||||
);
|
];
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$protocols = (string) $this->settings->kutrl_srv_local_protocols;
|
$protocols = (string) $this->settings->kutrl_srv_local_protocols;
|
||||||
$this->config['allow_protocols'] = empty($protocols) ? array() : explode(',',$protocols);
|
$this->config['allow_protocols'] = empty($protocols) ? [] : explode(',', $protocols);
|
||||||
|
|
||||||
$this->config['url_base'] = $this->core->blog->url.$this->core->url->getBase('kutrl').'/';
|
$this->config['url_base'] = $this->core->blog->url . $this->core->url->getBase('kutrl') . '/';
|
||||||
$this->config['url_min_len'] = strlen($this->url_base) + 2;
|
$this->config['url_min_len'] = strlen($this->url_base) + 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveSettings()
|
public function saveSettings()
|
||||||
{
|
{
|
||||||
$this->settings->put('kutrl_srv_local_protocols',$_POST['kutrl_srv_local_protocols'],'string');
|
$this->settings->put('kutrl_srv_local_protocols', $_POST['kutrl_srv_local_protocols'], 'string');
|
||||||
$this->settings->put('kutrl_srv_local_public',isset($_POST['kutrl_srv_local_public']),'boolean');
|
$this->settings->put('kutrl_srv_local_public', isset($_POST['kutrl_srv_local_public']), 'boolean');
|
||||||
$this->settings->put('kutrl_srv_local_css',$_POST['kutrl_srv_local_css'],'string');
|
$this->settings->put('kutrl_srv_local_css', $_POST['kutrl_srv_local_css'], 'string');
|
||||||
$this->settings->put('kutrl_srv_local_404_active',isset($_POST['kutrl_srv_local_404_active']),'boolean');
|
$this->settings->put('kutrl_srv_local_404_active', isset($_POST['kutrl_srv_local_404_active']), 'boolean');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingsForm()
|
public function settingsForm()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<div class="two-cols"><div class="col">'.
|
'<div class="two-cols"><div class="col">' .
|
||||||
|
|
||||||
'<p><strong>'.__('Settings:').'</strong></p>'.
|
'<p><strong>' . __('Settings:') . '</strong></p>' .
|
||||||
'<p><label class="classic">'.
|
'<p><label class="classic">' .
|
||||||
__('Allowed protocols:').'<br />'.
|
__('Allowed protocols:') . '<br />' .
|
||||||
form::field(array('kutrl_srv_local_protocols'),50,255,$this->settings->kutrl_srv_local_protocols).
|
form::field(['kutrl_srv_local_protocols'], 50, 255, $this->settings->kutrl_srv_local_protocols) .
|
||||||
'</label></p>'.
|
'</label></p>' .
|
||||||
|
|
||||||
'<p class="form-note">'.
|
'<p class="form-note">' .
|
||||||
__('Use comma seperated list like: "http:,https:,ftp:"').
|
__('Use comma seperated list like: "http:,https:,ftp:"') .
|
||||||
'</p>'.
|
'</p>' .
|
||||||
|
|
||||||
'<p><label class="classic">'.
|
'<p><label class="classic">' .
|
||||||
form::checkbox(array('kutrl_srv_local_public'),'1',$this->settings->kutrl_srv_local_public).' '.
|
form::checkbox(['kutrl_srv_local_public'], '1', $this->settings->kutrl_srv_local_public) . ' ' .
|
||||||
__('Enable public page for visitors to shorten links').
|
__('Enable public page for visitors to shorten links') .
|
||||||
'</label></p>'.
|
'</label></p>' .
|
||||||
|
|
||||||
'<p class="area" id="style-area"><label for="_style">'.__('CSS:').'</label>'.
|
'<p class="area" id="style-area"><label for="_style">' . __('CSS:') . '</label>' .
|
||||||
form::textarea('kutrl_srv_local_css',50,3,html::escapeHTML($this->settings->kutrl_srv_local_css),'',2).
|
form::textarea('kutrl_srv_local_css',50,3,html::escapeHTML($this->settings->kutrl_srv_local_css), '', 2) .
|
||||||
'</p>'.
|
'</p>' .
|
||||||
'<p class="form-note">'.__('You can add here special cascading style sheet. Body of page has class "dc-kutrl" and widgets have class "shortenkutrlwidget" and "rankkutrlwidget".').'</p>'.
|
'<p class="form-note">' . __('You can add here special cascading style sheet. Body of page has class "dc-kutrl" and widgets have class "shortenkutrlwidget" and "rankkutrlwidget".') . '</p>' .
|
||||||
|
|
||||||
'<p><label class="classic">'.
|
'<p><label class="classic">' .
|
||||||
form::checkbox(array('kutrl_srv_local_404_active'),'1',$this->settings->kutrl_srv_local_404_active).' '.
|
form::checkbox(['kutrl_srv_local_404_active'], '1', $this->settings->kutrl_srv_local_404_active) . ' ' .
|
||||||
__('Enable special 404 error public page for unknow urls').
|
__('Enable special 404 error public page for unknow urls') .
|
||||||
'</label></p>'.
|
'</label></p>' .
|
||||||
'<p class="form-note">'.__('If this is not activated, the default 404 page of the theme will be display.').'</p>'.
|
'<p class="form-note">' . __('If this is not activated, the default 404 page of the theme will be display.') . '</p>' .
|
||||||
|
|
||||||
'</div><div class="col">'.
|
'</div><div class="col">' .
|
||||||
|
|
||||||
'<p><strong>'.__('Note:').'</strong></p>'.
|
'<p><strong>' . __('Note:') . '</strong></p>' .
|
||||||
'<p>'.
|
'<p>' .
|
||||||
__('This service use your own Blog to shorten and serve URL.').'<br />'.
|
__('This service use your own Blog to shorten and serve URL.') . '<br />' .
|
||||||
sprintf(__('This means that with this service short links start with "%s".'),$this->url_base).
|
sprintf(__('This means that with this service short links start with "%s".'), $this->url_base) .
|
||||||
'</p>'.
|
'</p>' .
|
||||||
'<p>'.
|
'<p>' .
|
||||||
__("You can use Dotclear's plugin called myUrlHandlers to change short links prefix on your blog.");
|
__("You can use Dotclear's plugin called myUrlHandlers to change short links prefix on your blog.");
|
||||||
|
|
||||||
if (preg_match('/index\.php/',$this->url_base))
|
if (preg_match('/index\.php/', $this->url_base)) {
|
||||||
{
|
echo
|
||||||
echo
|
'<p>' .
|
||||||
'<p>'.
|
__("We recommand that you use a rewrite engine in order to remove 'index.php' from your blog's URL.") .
|
||||||
__("We recommand that you use a rewrite engine in order to remove 'index.php' from your blog's URL.").
|
'<br /><a href="http://fr.dotclear.org/documentation/2.0/usage/blog-parameters">' .
|
||||||
'<br /><a href="http://fr.dotclear.org/documentation/2.0/usage/blog-parameters">'.
|
__("You can find more about this on the Dotclear's documentation.") .
|
||||||
__("You can find more about this on the Dotclear's documentation.").
|
'</a></p>';
|
||||||
'</a></p>';
|
}
|
||||||
}
|
echo
|
||||||
echo
|
'</p>' .
|
||||||
'</p>'.
|
'<p>' . __('There are two templates delivered with kUtRL, if you do not use default theme, you may adapt them to yours.') . '<br />' .
|
||||||
'<p>'.__('There are two templates delivered with kUtRL, if you do not use default theme, you may adapt them to yours.').'<br />'.
|
__('Files are in plugin directory /default-templates, just copy them into your theme and edit them.') . '</p>' .
|
||||||
__('Files are in plugin directory /default-templates, just copy them into your theme and edit them.').'</p>'.
|
|
||||||
|
'</div></div>';
|
||||||
'</div></div>';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function testService()
|
public function testService()
|
||||||
{
|
{
|
||||||
$ap = $this->allow_protocols;
|
$ap = $this->allow_protocols;
|
||||||
if (!empty($ap))
|
if (!empty($ap)) {
|
||||||
{
|
return true;
|
||||||
return true;
|
} else {
|
||||||
}
|
$this->error->add(__('Service is not well configured.'));
|
||||||
else {
|
return false;
|
||||||
$this->error->add(__('Service is not well configured.'));
|
}
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createHash($url,$hash=null)
|
public function createHash($url, $hash = null)
|
||||||
{
|
{
|
||||||
# Create response object
|
# Create response object
|
||||||
$rs = new ArrayObject();
|
$rs = new ArrayObject();
|
||||||
$rs->type = 'local';
|
$rs->type = 'local';
|
||||||
$rs->url = $url;
|
$rs->url = $url;
|
||||||
|
|
||||||
# Normal link
|
# Normal link
|
||||||
if ($hash === null)
|
if ($hash === null) {
|
||||||
{
|
$type = 'localnormal';
|
||||||
$type = 'localnormal';
|
$rs->hash = $this->next($this->last('localnormal'));
|
||||||
$rs->hash = $this->next($this->last('localnormal'));
|
|
||||||
}
|
|
||||||
|
|
||||||
# Mixed custom link
|
# Mixed custom link
|
||||||
elseif (preg_match('/^([A-Za-z0-9]{2,})\!\!$/',$hash,$m))
|
} elseif (preg_match('/^([A-Za-z0-9]{2,})\!\!$/', $hash, $m)) {
|
||||||
{
|
$type = 'localmix';
|
||||||
$type = 'localmix';
|
$rs->hash = $m[1] . $this->next(-1, $m[1]);
|
||||||
$rs->hash = $m[1].$this->next(-1,$m[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Custom link
|
# Custom link
|
||||||
elseif (preg_match('/^[A-Za-z0-9\.\-\_]{2,}$/',$hash))
|
} elseif (preg_match('/^[A-Za-z0-9\.\-\_]{2,}$/', $hash)) {
|
||||||
{
|
if (false !== $this->log->select(null, $hash, null, 'local')) {
|
||||||
if (false !== $this->log->select(null,$hash,null,'local'))
|
$this->error->add(__('Custom short link is already taken.'));
|
||||||
{
|
return false;
|
||||||
$this->error->add(__('Custom short link is already taken.'));
|
}
|
||||||
return false;
|
$type = 'localcustom';
|
||||||
}
|
$rs->hash = $hash;
|
||||||
$type = 'localcustom';
|
|
||||||
$rs->hash = $hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Wrong char in custom hash
|
# Wrong char in custom hash
|
||||||
else
|
} else {
|
||||||
{
|
$this->error->add(__('Custom short link is not valid.'));
|
||||||
$this->error->add(__('Custom short link is not valid.'));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
# Save link
|
||||||
# Save link
|
try {
|
||||||
try {
|
$this->log->insert($rs->url, $rs->hash, $type, $rs->type);
|
||||||
$this->log->insert($rs->url,$rs->hash,$type,$rs->type);
|
return $rs;
|
||||||
return $rs;
|
} catch (Exception $e) {
|
||||||
}
|
$this->error->add(__('Failed to save link.'));
|
||||||
catch (Exception $e)
|
}
|
||||||
{
|
return false;
|
||||||
$this->error->add(__('Failed to save link.'));
|
}
|
||||||
}
|
|
||||||
return false;
|
protected function last($type)
|
||||||
}
|
{
|
||||||
|
return
|
||||||
protected function last($type)
|
false === ($rs = $this->log->select(null, null, $type, 'local')) ?
|
||||||
{
|
-1 : $rs->hash;
|
||||||
return
|
}
|
||||||
false === ($rs = $this->log->select(null,null,$type,'local')) ?
|
|
||||||
-1 : $rs->hash;
|
protected function next($last_id, $prefix = '')
|
||||||
}
|
{
|
||||||
|
if ($last_id == -1) {
|
||||||
protected function next($last_id,$prefix='')
|
$next_id = 0;
|
||||||
{
|
} else {
|
||||||
if ($last_id == -1)
|
for($x = 1; $x <= strlen($last_id); $x++) {
|
||||||
{
|
$pos = strlen($last_id) - $x;
|
||||||
$next_id = 0;
|
|
||||||
}
|
if ($last_id[$pos] != 'z') {
|
||||||
else
|
$next_id = $this->increment($last_id, $pos);
|
||||||
{
|
break;
|
||||||
for($x = 1; $x <= strlen($last_id); $x++)
|
}
|
||||||
{
|
}
|
||||||
$pos = strlen($last_id) - $x;
|
if (!isset($next_id)) {
|
||||||
|
$next_id = $this->append($last_id);
|
||||||
if ($last_id[$pos] != 'z')
|
}
|
||||||
{
|
}
|
||||||
$next_id = $this->increment($last_id,$pos);
|
return
|
||||||
break;
|
false === $this->log->select(null,$prefix . $next_id, null, 'local') ?
|
||||||
}
|
$next_id : $this->next($next_id, $prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($next_id))
|
protected function append($id)
|
||||||
{
|
{
|
||||||
$next_id = $this->append($last_id);
|
$id = str_split($id);
|
||||||
}
|
for ($x = 0; $x < count($id); $x++) {
|
||||||
}
|
$id[$x] = 0;
|
||||||
|
}
|
||||||
return
|
return implode($id) . '0';
|
||||||
false === $this->log->select(null,$prefix.$next_id,null,'local') ?
|
}
|
||||||
$next_id : $this->next($next_id,$prefix);
|
|
||||||
}
|
protected function increment($id, $pos)
|
||||||
|
{
|
||||||
protected function append($id)
|
$id = str_split($id);
|
||||||
{
|
$char = $id[$pos];
|
||||||
$id = str_split($id);
|
|
||||||
for ($x = 0; $x < count($id); $x++)
|
if (is_numeric($char)) {
|
||||||
{
|
$new_char = $char < 9 ? $char + 1 : 'a';
|
||||||
$id[$x] = 0;
|
} else {
|
||||||
}
|
$new_char = chr(ord($char) + 1);
|
||||||
return implode($id).'0';
|
}
|
||||||
}
|
$id[$pos] = $new_char;
|
||||||
|
|
||||||
protected function increment($id,$pos)
|
if ($pos != (count($id) - 1)) {
|
||||||
{
|
for ($x = ($pos + 1); $x < count($id); $x++) {
|
||||||
$id = str_split($id);
|
$id[$x] = 0;
|
||||||
$char = $id[$pos];
|
}
|
||||||
|
}
|
||||||
if (is_numeric($char))
|
return implode($id);
|
||||||
{
|
}
|
||||||
$new_char = $char < 9 ? $char + 1 : 'a';
|
|
||||||
}
|
public function getUrl($hash)
|
||||||
else
|
{
|
||||||
{
|
if (false === ($rs = $this->log->select(null, $hash, null, 'local'))) {
|
||||||
$new_char = chr(ord($char) + 1);
|
return false;
|
||||||
}
|
}
|
||||||
$id[$pos] = $new_char;
|
if (!$rs->url) { //previously removed url
|
||||||
|
return false;
|
||||||
if ($pos != (count($id) - 1))
|
}
|
||||||
{
|
$this->log->counter($rs->id, 'up');
|
||||||
for ($x = ($pos + 1); $x < count($id); $x++)
|
return $rs->url;
|
||||||
{
|
}
|
||||||
$id[$x] = 0;
|
|
||||||
}
|
public function deleteUrl($url, $delete = false)
|
||||||
}
|
{
|
||||||
|
if (false === ($rs = $this->log->select($url, null, null, 'local'))) {
|
||||||
return implode($id);
|
return false;
|
||||||
}
|
}
|
||||||
|
if ($delete) {
|
||||||
public function getUrl($hash)
|
$this->log->delete($rs->id);
|
||||||
{
|
} else {
|
||||||
if (false === ($rs = $this->log->select(null,$hash,null,'local')))
|
$this->log->clear($rs->id, '');
|
||||||
{
|
}
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
if (!$rs->url) //previously removed url
|
}
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->log->counter($rs->id,'up');
|
|
||||||
return $rs->url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deleteUrl($url,$delete=false)
|
|
||||||
{
|
|
||||||
if (false === ($rs = $this->log->select($url,null,null,'local')))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if ($delete)
|
|
||||||
{
|
|
||||||
$this->log->delete($rs->id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->log->clear($rs->id,'');
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
@ -10,47 +10,46 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class shorttoKutrlService extends kutrlService
|
class shorttoKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected $config = array(
|
protected $config = [
|
||||||
'id' => 'shortto',
|
'id' => 'shortto',
|
||||||
'name' => 'short.to',
|
'name' => 'short.to',
|
||||||
'home' => 'http://short.to',
|
'home' => 'http://short.to',
|
||||||
|
|
||||||
'url_api' => 'http://short.to/s.txt',
|
|
||||||
'url_base' => 'http://short.to/',
|
|
||||||
'url_min_len' => 25
|
|
||||||
);
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$arg = array('url' => urlencode($this->url_test));
|
|
||||||
if (!self::post($this->url_api,$arg,true,true))
|
|
||||||
{
|
|
||||||
$this->error->add(__('Service is unavailable.'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function createHash($url,$hash=null)
|
|
||||||
{
|
|
||||||
$arg = array('url' => $url);
|
|
||||||
|
|
||||||
if (!($response = self::post($this->url_api,$arg,true,true)))
|
'url_api' => 'http://short.to/s.txt',
|
||||||
{
|
'url_base' => 'http://short.to/',
|
||||||
$this->error->add(__('Service is unavailable.'));
|
'url_min_len' => 25
|
||||||
return false;
|
];
|
||||||
}
|
|
||||||
|
public function testService()
|
||||||
$rs = new ArrayObject();
|
{
|
||||||
$rs->hash = str_replace($this->url_base,'',$response);
|
$arg = ['url' => urlencode($this->url_test)];
|
||||||
$rs->url = $url;
|
if (!self::post($this->url_api, $arg, true, true)) {
|
||||||
$rs->type = $this->id;
|
$this->error->add(__('Service is unavailable.'));
|
||||||
|
return false;
|
||||||
return $rs;
|
}
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
public function createHash($url, $hash = null)
|
||||||
|
{
|
||||||
|
$arg = ['url' => $url];
|
||||||
|
|
||||||
|
if (!($response = self::post($this->url_api, $arg, true, true))) {
|
||||||
|
$this->error->add(__('Service is unavailable.'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rs = new ArrayObject();
|
||||||
|
$rs->hash = str_replace($this->url_base, '', $response);
|
||||||
|
$rs->url = $url;
|
||||||
|
$rs->type = $this->id;
|
||||||
|
|
||||||
|
return $rs;
|
||||||
|
}
|
||||||
|
}
|
@ -10,117 +10,113 @@
|
|||||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')){return;}
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
class yourlsKutrlService extends kutrlService
|
class yourlsKutrlService extends kutrlService
|
||||||
{
|
{
|
||||||
protected $config = array(
|
protected $config = [
|
||||||
'id' => 'yourls',
|
'id' => 'yourls',
|
||||||
'name' => 'YOURLS',
|
'name' => 'YOURLS',
|
||||||
'home' => 'http://yourls.org'
|
'home' => 'http://yourls.org'
|
||||||
);
|
];
|
||||||
|
|
||||||
private $args = array(
|
private $args = [
|
||||||
'username' => '',
|
'username' => '',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'format' => 'xml',
|
'format' => 'xml',
|
||||||
'action' => 'shorturl'
|
'action' => 'shorturl'
|
||||||
);
|
];
|
||||||
|
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->args['username'] = $this->settings->kutrl_srv_yourls_username;
|
$this->args['username'] = $this->settings->kutrl_srv_yourls_username;
|
||||||
$this->args['password'] = $this->settings->kutrl_srv_yourls_password;
|
$this->args['password'] = $this->settings->kutrl_srv_yourls_password;
|
||||||
|
|
||||||
$base = (string) $this->settings->kutrl_srv_yourls_base;
|
$base = (string) $this->settings->kutrl_srv_yourls_base;
|
||||||
//if (!empty($base) && substr($base,-1,1) != '/') $base .= '/';
|
//if (!empty($base) && substr($base,-1,1) != '/') $base .= '/';
|
||||||
|
|
||||||
$this->config['url_api'] = $base;
|
$this->config['url_api'] = $base;
|
||||||
$this->config['url_base'] = $base;
|
$this->config['url_base'] = $base;
|
||||||
$this->config['url_min_len'] = strlen($base)+3;
|
$this->config['url_min_len'] = strlen($base)+3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveSettings()
|
public function saveSettings()
|
||||||
{
|
{
|
||||||
$this->settings->put('kutrl_srv_yourls_username',$_POST['kutrl_srv_yourls_username']);
|
$this->settings->put('kutrl_srv_yourls_username', $_POST['kutrl_srv_yourls_username']);
|
||||||
$this->settings->put('kutrl_srv_yourls_password',$_POST['kutrl_srv_yourls_password']);
|
$this->settings->put('kutrl_srv_yourls_password', $_POST['kutrl_srv_yourls_password']);
|
||||||
$this->settings->put('kutrl_srv_yourls_base',$_POST['kutrl_srv_yourls_base']);
|
$this->settings->put('kutrl_srv_yourls_base', $_POST['kutrl_srv_yourls_base']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function settingsForm()
|
public function settingsForm()
|
||||||
{
|
{
|
||||||
echo
|
echo
|
||||||
'<p><label class="classic">'.
|
'<p><label class="classic">' .
|
||||||
__('Url of the service:').'<br />'.
|
__('Url of the service:') . '<br />' .
|
||||||
form::field(array('kutrl_srv_yourls_base'),50,255,$this->settings->kutrl_srv_yourls_base).
|
form::field(['kutrl_srv_yourls_base'], 50, 255, $this->settings->kutrl_srv_yourls_base) .
|
||||||
'</label></p>'.
|
'</label></p>' .
|
||||||
'<p class="form-note">'.
|
'<p class="form-note">' .
|
||||||
__('This is the URL of the YOURLS service you want to use. Ex: "http://www.smaller.org/api.php".').
|
__('This is the URL of the YOURLS service you want to use. Ex: "http://www.smaller.org/api.php".') .
|
||||||
'</p>'.
|
'</p>' .
|
||||||
'<p><label class="classic">'.__('Login:').'<br />'.
|
'<p><label class="classic">' . __('Login:') . '<br />' .
|
||||||
form::field(array('kutrl_srv_yourls_username'),50,255,$this->settings->kutrl_srv_yourls_username).
|
form::field(['kutrl_srv_yourls_username'], 50, 255, $this->settings->kutrl_srv_yourls_username) .
|
||||||
'</label></p>'.
|
'</label></p>' .
|
||||||
'<p class="form-note">'.
|
'<p class="form-note">' .
|
||||||
__('This is your user name to sign up to this YOURLS service.').
|
__('This is your user name to sign up to this YOURLS service.') .
|
||||||
'</p>'.
|
'</p>' .
|
||||||
'<p><label class="classic">'.__('Password:').'<br />'.
|
'<p><label class="classic">' . __('Password:') . '<br />' .
|
||||||
form::field(array('kutrl_srv_yourls_password'),50,255,$this->settings->kutrl_srv_yourls_password).
|
form::field(['kutrl_srv_yourls_password'], 50, 255, $this->settings->kutrl_srv_yourls_password) .
|
||||||
'</label></p>'.
|
'</label></p>' .
|
||||||
'<p class="form-note">'.
|
'<p class="form-note">' .
|
||||||
__('This is your password to sign up to this YOURLS service.').
|
__('This is your password to sign up to this YOURLS service.') .
|
||||||
'</p>';
|
'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testService()
|
public function testService()
|
||||||
{
|
{
|
||||||
if (empty($this->url_api))
|
if (empty($this->url_api)) {
|
||||||
{
|
$this->error->add(__('Service is not well configured.'));
|
||||||
$this->error->add(__('Service is not well configured.'));
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
$args = $this->args;
|
||||||
$args = $this->args;
|
$args['url'] = $this->url_test;
|
||||||
$args['url'] = $this->url_test;
|
|
||||||
|
if (!($response = self::post($this->url_api, $this->args, true))) {
|
||||||
if (!($response = self::post($this->url_api,$this->args,true)))
|
$this->error->add(__('Service is unavailable.'));
|
||||||
{
|
return false;
|
||||||
$this->error->add(__('Service is unavailable.'));
|
}
|
||||||
return false;
|
$rsp = @simplexml_load_string($response);
|
||||||
}
|
|
||||||
$rsp = @simplexml_load_string($response);
|
if ($rsp && $rsp->status == 'success') {
|
||||||
|
return true;
|
||||||
if ($rsp && $rsp->status == 'success')
|
}
|
||||||
{
|
$this->error->add(__('Authentication to service failed.'));
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
$this->error->add(__('Authentication to service failed.'));
|
|
||||||
return false;
|
public function createHash($url, $hash = null)
|
||||||
}
|
{
|
||||||
|
$args = $this->args;
|
||||||
public function createHash($url,$hash=null)
|
$args['url'] = $url;
|
||||||
{
|
|
||||||
$args = $this->args;
|
if (!($response = self::post($this->url_api, $args, true))) {
|
||||||
$args['url'] = $url;
|
$this->error->add(__('Service is unavailable.'));
|
||||||
|
return false;
|
||||||
if (!($response = self::post($this->url_api,$args,true)))
|
}
|
||||||
{
|
|
||||||
$this->error->add(__('Service is unavailable.'));
|
$rsp = @simplexml_load_string($response);
|
||||||
return false;
|
|
||||||
}
|
if ($rsp && $rsp->status == 'success') {
|
||||||
|
$rs = new ArrayObject();
|
||||||
$rsp = @simplexml_load_string($response);
|
$rs->hash = $rsp->url[0]->keyword;
|
||||||
|
$rs->url = $url;
|
||||||
if ($rsp && $rsp->status == 'success')
|
$rs->type = $this->id;
|
||||||
{
|
|
||||||
$rs = new ArrayObject();
|
return $rs;
|
||||||
$rs->hash = $rsp->url[0]->keyword;
|
}
|
||||||
$rs->url = $url;
|
$this->error->add(__('Unreadable service response.'));
|
||||||
$rs->type = $this->id;
|
return false;
|
||||||
|
}
|
||||||
return $rs;
|
}
|
||||||
}
|
|
||||||
$this->error->add(__('Unreadable service response.'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
Loading…
Reference in New Issue
Block a user