summaryrefslogtreecommitdiff
path: root/classes/File_redirection.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@controlyourself.ca>2009-06-23 07:29:43 -0700
committerEvan Prodromou <evan@controlyourself.ca>2009-06-23 07:29:43 -0700
commita21a9f26c5f0eb034ea389659dd63ffad400de5b (patch)
treee314cb9cd4280481931bc814eeb013f2a672fa2b /classes/File_redirection.php
parente2becdb25138350170b58ae8f0d1ecd715533cf5 (diff)
append uploads to content rather than showing them double
Diffstat (limited to 'classes/File_redirection.php')
-rw-r--r--classes/File_redirection.php70
1 files changed, 5 insertions, 65 deletions
diff --git a/classes/File_redirection.php b/classes/File_redirection.php
index edd915c1e..c173017e2 100644
--- a/classes/File_redirection.php
+++ b/classes/File_redirection.php
@@ -25,21 +25,20 @@ require_once INSTALLDIR.'/classes/File_oembed.php';
define('USER_AGENT', 'Laconica user agent / file probe');
-
/**
* Table Definition for file_redirection
*/
-class File_redirection extends Memcached_DataObject
+class File_redirection extends Memcached_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */
public $__table = 'file_redirection'; // table name
public $url; // varchar(255) primary_key not_null
- public $file_id; // int(4)
- public $redirections; // int(4)
- public $httpcode; // int(4)
+ public $file_id; // int(4)
+ public $redirections; // int(4)
+ public $httpcode; // int(4)
public $modified; // timestamp() not_null default_CURRENT_TIMESTAMP
/* Static get */
@@ -48,8 +47,6 @@ class File_redirection extends Memcached_DataObject
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
-
-
function _commonCurl($url, $redirs) {
$curlh = curl_init();
curl_setopt($curlh, CURLOPT_URL, $url);
@@ -86,8 +83,6 @@ class File_redirection extends Memcached_DataObject
return $url;
}
-
-
$curlh = File_redirection::_commonCurl($short_url, $redirs);
// Don't include body in output
curl_setopt($curlh, CURLOPT_NOBODY, true);
@@ -143,62 +138,7 @@ class File_redirection extends Memcached_DataObject
}
function _userMakeShort($long_url, $user) {
- if (empty($user)) {
- // common current user does not find a user when called from the XMPP daemon
- // therefore we'll set one here fix, so that XMPP given URLs may be shortened
- $user->urlshorteningservice = 'ur1.ca';
- }
- $curlh = curl_init();
- curl_setopt($curlh, CURLOPT_CONNECTTIMEOUT, 20); // # seconds to wait
- curl_setopt($curlh, CURLOPT_USERAGENT, 'Laconica');
- curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
-
- switch($user->urlshorteningservice) {
- case 'ur1.ca':
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url_service = new LilUrl;
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case '2tu.us':
- $short_url_service = new TightUrl;
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case 'ptiturl.com':
- require_once INSTALLDIR.'/lib/Shorturl_api.php';
- $short_url_service = new PtitUrl;
- $short_url = $short_url_service->shorten($long_url);
- break;
-
- case 'bit.ly':
- curl_setopt($curlh, CURLOPT_URL, 'http://bit.ly/api?method=shorten&long_url='.urlencode($long_url));
- $short_url = current(json_decode(curl_exec($curlh))->results)->hashUrl;
- break;
-
- case 'is.gd':
- curl_setopt($curlh, CURLOPT_URL, 'http://is.gd/api.php?longurl='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'snipr.com':
- curl_setopt($curlh, CURLOPT_URL, 'http://snipr.com/site/snip?r=simple&link='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'metamark.net':
- curl_setopt($curlh, CURLOPT_URL, 'http://metamark.net/api/rest/simple?long_url='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- case 'tinyurl.com':
- curl_setopt($curlh, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url='.urlencode($long_url));
- $short_url = curl_exec($curlh);
- break;
- default:
- $short_url = false;
- }
-
- curl_close($curlh);
-
+ $short_url = common_shorten_url($long_url);
if ($short_url) {
$short_url = (string)$short_url;
// store it