if (isset($redir_data['type'])
&& (('text/html' === substr($redir_data['type'], 0, 9) || 'application/xhtml+xml' === substr($redir_data['type'], 0, 21)))
&& ($oembed_data = File_oembed::_getOembed($given_url))) {
+
+ $fo = File_oembed::staticGet('file_id', $file_id);
+
+ if (empty($fo)) {
File_oembed::saveNew($oembed_data, $file_id);
+ } else {
+ common_log(LOG_WARNING, "Strangely, a File_oembed object exists for new file $file_id", __FILE__);
+ }
}
return $x;
}
static function url($filename)
{
- $path = common_config('attachments', 'path');
+ if(common_config('site','private')) {
- if ($path[strlen($path)-1] != '/') {
- $path .= '/';
- }
+ return common_local_url('getfile',
+ array('filename' => $filename));
- if ($path[0] != '/') {
- $path = '/'.$path;
- }
+ } else {
+ $path = common_config('attachments', 'path');
- $server = common_config('attachments', 'server');
+ if ($path[strlen($path)-1] != '/') {
+ $path .= '/';
+ }
- if (empty($server)) {
- $server = common_config('site', 'server');
- }
+ if ($path[0] != '/') {
+ $path = '/'.$path;
+ }
+
+ $server = common_config('attachments', 'server');
- // XXX: protocol
+ if (empty($server)) {
+ $server = common_config('site', 'server');
+ }
- return 'http://'.$server.$path.$filename;
+ // XXX: protocol
+
+ return 'http://'.$server.$path.$filename;
+ }
}
function getEnclosure(){
function common_munge_password($password, $id)
{
+ if (is_object($id) || is_object($password)) {
+ $e = new Exception();
+ common_log(LOG_ERR, __METHOD__ . ' object in param to common_munge_password ' .
+ str_replace("\n", " ", $e->getTraceAsString()));
+ }
return md5($password . $id);
}
function common_cache_key($extra)
{
- $base_key = common_config('memcached', 'base');
-
- if (empty($base_key)) {
- $base_key = common_keyize(common_config('site', 'name'));
- }
-
- return 'statusnet:' . $base_key . ':' . $extra;
+ return Cache::key($extra);
}
function common_keyize($str)
{
- $str = strtolower($str);
- $str = preg_replace('/\s/', '_', $str);
- return $str;
+ return Cache::keyize($str);
}
function common_memcache()
{
- static $cache = null;
- if (!common_config('memcached', 'enabled')) {
- return null;
- } else {
- if (!$cache) {
- $cache = new Memcache();
- $servers = common_config('memcached', 'server');
- if (is_array($servers)) {
- foreach($servers as $server) {
- $cache->addServer($server);
- }
- } else {
- $cache->addServer($servers);
- }
- }
- return $cache;
- }
+ return Cache::instance();
}
function common_license_terms($uri)