code style
This commit is contained in:
parent
0dc9ab7576
commit
0a2094f069
|
@ -48,7 +48,11 @@ class YourlsProxy
|
|||
*/
|
||||
public function __construct(Configuration $conf, $link)
|
||||
{
|
||||
if (strpos($link, $conf->getKey('basepath') . '/?') !== false) {
|
||||
if (strpos($link, $conf->getKey('basepath') . '/?') === false) {
|
||||
$this->_error = 'Trying to shorten a URL not pointing to our PrivateBin instance.';
|
||||
return;
|
||||
}
|
||||
|
||||
// Init the CURL session
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $conf->getKey("apiurl", "yourls"));
|
||||
|
@ -65,24 +69,22 @@ class YourlsProxy
|
|||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
if (!($data === FALSE) && is_string($data))
|
||||
{
|
||||
$data = json_decode( $data, true);
|
||||
if ($data === false || !is_string($data)) {
|
||||
$this->_error = 'Error calling YOURLS. Probably a configuration issue, like wrong or missing "apiurl" or "signature".';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_null($data) && array_key_exists('statusCode', $data)
|
||||
&& array_key_exists('shorturl', $data) && ($data['statusCode'] == 200))
|
||||
{
|
||||
$data = json_decode($data, true);
|
||||
if (
|
||||
!is_null($data) &&
|
||||
array_key_exists('statusCode', $data) &&
|
||||
array_key_exists('shorturl', $data) &&
|
||||
$data['statusCode'] == 200
|
||||
) {
|
||||
$this->_url = $data['shorturl'];
|
||||
$opSuccess = TRUE;
|
||||
} else {
|
||||
$this->_error = 'Error parsing YOURLS response.';
|
||||
}
|
||||
} else {
|
||||
$this->_error = 'Error calling YOURLS. Probably a configuration issue, like wrong or missing "apiurl" or "signature".';
|
||||
}
|
||||
} else {
|
||||
$this->_error = 'Trying to shorten a URL not pointing to our PrivateBin instance.';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue