aboutsummaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2012-02-13 09:46:42 +0100
committerFabio Comuni <fabrix.xm@gmail.com>2012-02-13 09:46:42 +0100
commit850560519a4bbe9949368933e115f767aeb90b73 (patch)
tree6f162b4b0130a5f829d40f7ebd9d18442ad18921 /library
parent16d3bc9deb5cb80f438a53f1bf483c79351674af (diff)
parent85c831bcbf6f4cc2793d91e4e3fb3da5828a3f60 (diff)
downloadvolse-hubzilla-850560519a4bbe9949368933e115f767aeb90b73.tar.gz
volse-hubzilla-850560519a4bbe9949368933e115f767aeb90b73.tar.bz2
volse-hubzilla-850560519a4bbe9949368933e115f767aeb90b73.zip
Merge remote-tracking branch 'friendica/master' into mobile
Diffstat (limited to 'library')
-rwxr-xr-xlibrary/slinky.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/library/slinky.php b/library/slinky.php
index 51432c3f5..cae1f755f 100755
--- a/library/slinky.php
+++ b/library/slinky.php
@@ -153,7 +153,7 @@ class Slinky {
public function set_service_from_url( $url = false ) {
if ( !$url )
$url = $this->url;
-
+
$host = parse_url( $url, PHP_URL_HOST );
switch ( str_replace( 'www.', '', $host ) ) {
case 'bit.ly':
@@ -181,6 +181,11 @@ class Slinky {
$this->service = new Slinky_Fongs();
break;
}
+ case $this->get( 'yourls-url' ):
+ if ( class_exists( 'Slinky_YourLS' ) ) {
+ $this->service = new Slinky_YourLS();
+ break;
+ }
case 'micurl.com':
if ( class_exists( 'Slinky_Micurl' ) ) {
$this->service = new Slinky_Micurl();
@@ -574,6 +579,31 @@ class Slinky_Fongs extends Slinky_Service {
}
}
+// yourls
+class Slinky_YourLS extends Slinky_Service {
+ function url_is_short( $url ) {
+ return stristr( $url, 'shit.li/' );
+ }
+
+ function url_is_long( $url ) {
+ return !stristr( $url, 'shit.li/' );
+ }
+
+ function make_short( $url ) {
+ echo $this->get( 'username' );
+ $use_ssl = $this->get( 'ssl' );
+ if ( $use_ssl )
+ $use_ssl = 's';
+ else
+ $use_ssl = '';
+ $result = $this->url_get( 'http'. $use_ssl . '://' . $this->get( 'yourls-url' ) . '/yourls-api.php?username=' . $this->get( 'username' ) . '&password=' . $this->get( 'password' ) . '&action=shorturl&format=simple&url=' . urlencode( $url ) );
+ if ( 1 != $result && 2 != $result )
+ return $result;
+ else
+ return $url;
+ }
+}
+
// Micu.rl
class Slinky_Micurl extends Slinky_Service {
function url_is_short( $url ) {