diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/RedDAV/RedFile.php | 2 | ||||
-rw-r--r-- | include/bbcode.php | 1 | ||||
-rw-r--r-- | include/follow.php | 27 | ||||
-rwxr-xr-x | include/items.php | 20 | ||||
-rw-r--r-- | include/network.php | 5 | ||||
-rwxr-xr-x | include/oembed.php | 32 | ||||
-rw-r--r-- | include/photos.php | 18 |
7 files changed, 68 insertions, 37 deletions
diff --git a/include/RedDAV/RedFile.php b/include/RedDAV/RedFile.php index 0a021b5ed..d4eb6812a 100644 --- a/include/RedDAV/RedFile.php +++ b/include/RedDAV/RedFile.php @@ -167,7 +167,7 @@ class RedFile extends DAV\Node implements DAV\IFile { if($is_photo) { require_once('include/photos.php'); $args = array( 'resource_id' => $this->data['hash'], 'album' => $album, 'os_path' => $f, 'filename' => $r[0]['filename'], 'getimagesize' => $gis ); - $p = photo_upload($c[0],$this->auth->observer,$args); + $p = photo_upload($c[0],get_app()->get_observer(),$args); } // update the folder's lastmodified timestamp diff --git a/include/bbcode.php b/include/bbcode.php index 66b63d395..66bf6b5ec 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -12,6 +12,7 @@ require_once('include/hubloc.php'); function tryoembed($match) { $url = ((count($match) == 2) ? $match[1] : $match[2]); + $o = oembed_fetch_url($url); if ($o->type == 'error') diff --git a/include/follow.php b/include/follow.php index 9430feac6..960138743 100644 --- a/include/follow.php +++ b/include/follow.php @@ -129,19 +129,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) } } else { - if(! ($is_http)) { - if(! intval(get_config('system','diaspora_enabled'))) { - $result['message'] = t('Protocol disabled.'); - return $result; - } - - $allowed = get_pconfig($uid,'system','diaspora_allowed'); - - if(! intval($allowed)) { - $result['message'] = t('Protocol blocked for this channel.'); - return $result; - } - } $their_perms = 0; $xchan_hash = ''; @@ -158,8 +145,15 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) } elseif($is_http) { $r = discover_by_url($url); + $r['allowed'] = intval(get_config('system','feed_contacts')); } if($r) { + $r['channel_id'] = $uid; + call_hooks('follow_allow',$r); + if(! $r['allowed']) { + $result['message'] = t('Protocol disabled.'); + return $result; + } $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' limit 1", dbesc($url), dbesc($url) @@ -199,10 +193,6 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) if($is_http) { - if(! intval(get_config('system','feed_contacts'))) { - $result['message'] = t('Protocol disabled.'); - return $result; - } $r = q("select count(*) as total from abook where abook_account = %d and abook_feed = 1 ", intval($aid) @@ -261,8 +251,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) ); if($r) { $result['abook'] = $r[0]; - if($is_red) - proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']); + proc_run('php', 'include/notifier.php', 'permission_update', $result['abook']['abook_id']); } $arr = array('channel_id' => $uid, 'abook' => $result['abook']); diff --git a/include/items.php b/include/items.php index 30cde0745..c1b50da22 100755 --- a/include/items.php +++ b/include/items.php @@ -159,7 +159,7 @@ function filter_insecure($channel_id, $arr) { $ret = array(); - if((! intval(get_config($channel_id, 'system', 'filter_insecure_collections'))) || (! $arr)) + if((! intval(get_pconfig($channel_id, 'system', 'filter_insecure_collections'))) || (! $arr)) return $arr; $str = ''; @@ -3338,6 +3338,9 @@ function check_item_source($uid, $item) { if($r[0]['src_channel_xchan'] === $item['owner_xchan']) return false; + + // since we now have connection filters with more features, the source filter is redundant and can probably go away + if(! $r[0]['src_patt']) return true; @@ -3352,10 +3355,10 @@ function check_item_source($uid, $item) { foreach($words as $word) { if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*'))) + if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return true; } - elseif((strpos($word,'/') === 0) && preg_match($word,$body)) + elseif((strpos($word,'/') === 0) && preg_match($word,$text)) return true; elseif(stristr($text,$word) !== false) return true; @@ -3380,6 +3383,9 @@ function post_is_importable($item,$abook) { return true; require_once('include/html2plain.php'); + + unobscure($item); + $text = prepare_text($item['body'],$item['mimetype']); $text = html2plain($text); @@ -3399,10 +3405,10 @@ function post_is_importable($item,$abook) { $word = trim($word); if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*'))) + if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return false; } - elseif((strpos($word,'/') === 0) && preg_match($word,$body)) + elseif((strpos($word,'/') === 0) && preg_match($word,$text)) return false; elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0)) return false; @@ -3418,10 +3424,10 @@ function post_is_importable($item,$abook) { $word = trim($word); if(substr($word,0,1) === '#' && $tags) { foreach($tags as $t) - if(($t['type'] == TERM_HASHTAG) && ((substr($t,1) === substr($word,1)) || (substr($word,1) === '*'))) + if(($t['type'] == TERM_HASHTAG) && (($t['term'] === substr($word,1)) || (substr($word,1) === '*'))) return true; } - elseif((strpos($word,'/') === 0) && preg_match($word,$body)) + elseif((strpos($word,'/') === 0) && preg_match($word,$text)) return true; elseif((strpos($word,'lang=') === 0) && ($lang) && (strcasecmp($lang,trim(substr($word,5))) == 0)) return true; diff --git a/include/network.php b/include/network.php index 5d01b7eba..ef92e0132 100644 --- a/include/network.php +++ b/include/network.php @@ -1068,6 +1068,11 @@ function discover_by_webbie($webbie) { } } + $arr = array('address' => $webbie, 'success' => false); + call_hooks('discover_by_webbie', $arr); + if($arr['success']) + return true; + $result = array(); $network = null; $diaspora = false; diff --git a/include/oembed.php b/include/oembed.php index 0628afaa9..e50d34c7d 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -2,6 +2,35 @@ function oembed_replacecb($matches){ $embedurl=$matches[1]; + + // implements a personal embed white/black list for logged in members + if(local_channel()) { + if(($x = get_pconfig(local_channel(),'system','embed_deny'))) { + $l = explode("\n",$x); + if($l) { + foreach($l as $ll) { + if(trim($ll) && strpos($embedurl,trim($ll)) !== false) + return '<a href="' . $embedurl . '">' . $embedurl . '</a>'; + } + } + } + if(($x = get_pconfig(local_channel(),'system','embed_allow'))) { + $found = false; + $l = explode("\n",$x); + if($l) { + foreach($l as $ll) { + if(trim($ll) && strpos($embedurl,trim($ll)) !== false) { + $found = true; + break; + } + } + } + if(! $found) { + return '<a href="' . $embedurl . '">' . $embedurl . '</a>'; + } + } + } + $j = oembed_fetch_url($embedurl); $s = oembed_format_object($j); return $s; @@ -95,7 +124,8 @@ function oembed_fetch_url($embedurl){ Cache::set($a->videowidth . $embedurl,$txt); } - + + $j = json_decode($txt); $j->embedurl = $embedurl; return $j; diff --git a/include/photos.php b/include/photos.php index dced14705..46d4b810c 100644 --- a/include/photos.php +++ b/include/photos.php @@ -34,16 +34,16 @@ function photo_upload($channel, $observer, $args) { */ $album = $args['album']; - $newalbum = $args['newalbum']; +// $newalbum = $args['newalbum']; - logger('photo_upload: album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); +// logger('photo_upload: album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); - if(! $album) { - if($newalbum) - $album = $newalbum; - else - $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y-m'); - } +// if(! $album) { +// if($newalbum) +// $album = $newalbum; +// else +// $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y-m'); +// } if(intval($args['visible']) || $args['visible'] === 'true') $visible = 1; @@ -355,7 +355,7 @@ function photos_albums_list($channel, $observer) { $ret['albums'] = array(); foreach($albums as $k => $album) { $entry = array( - 'text' => $album['album'], + 'text' => (($album['album']) ? $album['album'] : '/'), 'total' => $album['total'], 'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']), 'urlencode' => urlencode($album['album']), |