From afd8b2ddf25d3486d200f9da8ff3cd74131a1df4 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Nov 2014 15:34:49 -0800 Subject: random photo widget --- include/widgets.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 74bdb5d74..7193850ef 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -810,7 +810,61 @@ function widget_photo($arr) { $o .= ''; + . ' src="' . $url . '" alt="' . t('photo/image') . '" />'; + + $o .= ''; + + return $o; +} + + +function widget_photo_rand($arr) { + + require_once('include/photos.php'); + $style = $zrl = false; + $params = ''; + if(array_key_exists('album',$arr) && isset($arr['album'])) + $album = $arr['album']; + else + $album = ''; + + $channel_id = get_app()->profile_uid; + if(! $channel_id) + return ''; + + $scale = ((array_key_exists('scale',$arr)) ? intval($arr['scale']) : 0); + + $ret = photos_list_photos(array('channel_id' => $channel_id),get_app()->get_observer(),$album); + + $filtered = array(); + if($ret['success'] && $ret['photos']) + foreach($ret['photos'] as $p) + if($p['scale'] == $scale) + $filtered[] = $p['src']; + + if($filtered) { + $e = mt_rand(0,count($filtered)-1); + $url = $filtered[$e]; + } + + if(strpos($url,'http') !== 0) + return ''; + + if(array_key_exists('style',$arr) && isset($arr['style'])) + $style = $arr['style']; + + // ensure they can't sneak in an eval(js) function + + if(strpos($style,'(') !== false) + return ''; + + $url = zid($url); + + $o = '
'; + + $o .= '' . t('photo/image') . ''; $o .= '
'; -- cgit v1.2.3 From e74a3926feacbb3005a9f6dbbd6e54931a43ffba Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Nov 2014 17:38:41 -0800 Subject: yet another option for the homepage --- include/ItemObject.php | 4 ++-- include/conversation.php | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/ItemObject.php b/include/ItemObject.php index f6f7c0fba..6037daa7a 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -88,7 +88,7 @@ class Item extends BaseObject { || strlen($item['deny_cid']) || strlen($item['deny_gid'])))) ? t('Private Message') : false); - $shareable = ((($conv->get_profile_owner() == local_user()) && ($item['item_private'] != 1)) ? true : false); + $shareable = ((($conv->get_profile_owner() == local_user() && local_user()) && ($item['item_private'] != 1)) ? true : false); // allow an exemption for sharing stuff from your private feeds if($item['author']['xchan_network'] === 'rss') @@ -288,7 +288,7 @@ class Item extends BaseObject { 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''), 'tagger' => ((feature_enabled($conv->get_profile_owner(),'commtag')) ? $tagger : ''), 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''), - 'bookmark' => (($conv->get_profile_owner() == local_user() && $has_bookmarks) ? t('Save Bookmarks') : ''), + 'bookmark' => (($conv->get_profile_owner() == local_user() && local_user() && $has_bookmarks) ? t('Save Bookmarks') : ''), 'addtocal' => (($has_event) ? t('Add to Calendar') : ''), 'drop' => $drop, 'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''), diff --git a/include/conversation.php b/include/conversation.php index 96864c29a..6db9d3ce4 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -885,15 +885,18 @@ function item_photo_menu($item){ $vsrc_link = ""; $follow_url = ""; - if(local_user()) { + + $local_user = local_user(); + + if($local_user) { $ssl_state = true; if(! count($a->contacts)) - load_contact_links(local_user()); + load_contact_links($local_user); $channel = $a->get_channel(); $channel_hash = (($channel) ? $channel['channel_hash'] : ''); } - if((local_user()) && local_user() == $item['uid']) { + if(($local_user) && $local_user == $item['uid']) { $vsrc_link = 'javascript:viewsrc(' . $item['id'] . '); return false;'; if($item['parent'] == $item['id'] && $channel && ($channel_hash != $item['author_xchan'])) { $sub_link = 'javascript:dosubthread(' . $item['id'] . '); return false;'; @@ -901,12 +904,13 @@ function item_photo_menu($item){ } $profile_link = chanlink_hash($item['author_xchan']); - $pm_url = $a->get_baseurl($ssl_state) . '/mail/new/?f=&hash=' . $item['author_xchan']; + if($item['uid'] > 0) + $pm_url = $a->get_baseurl($ssl_state) . '/mail/new/?f=&hash=' . $item['author_xchan']; if($a->contacts && array_key_exists($item['author_xchan'],$a->contacts)) $contact = $a->contacts[$item['author_xchan']]; else - if(local_user() && $item['author']['xchan_addr']) + if($local_user && $item['author']['xchan_addr']) $follow_url = z_root() . '/follow/?f=&url=' . $item['author']['xchan_addr']; if($contact) { -- cgit v1.2.3 From 695abdcbd0350b95930bf9624a906524d25b47fe Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Nov 2014 18:29:28 -0800 Subject: directory: don't try and sync a directory update that points to a hubloc we already know is dead and buried. --- include/onedirsync.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/onedirsync.php b/include/onedirsync.php index 09c4c9d9a..cc7f9f22d 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -41,7 +41,7 @@ function onedirsync_run($argv, $argc){ intval(UPDATE_FLAGS_UPDATED) ); if($x) { - $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and not ( ud_flags & %d )>0 and ud_date < '%s' ", + $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), intval(UPDATE_FLAGS_UPDATED), @@ -50,6 +50,23 @@ function onedirsync_run($argv, $argc){ return; } + // ignore doing an update if this ud_addr refers to a known dead hubloc + + $h = q("select * from hubloc where hubloc_addr = '%s' limit 1", + dbesc($r[0]['ud_addr']) + ); + if($h && $h[0]['hubloc_status'] & HUBLOC_OFFLINE) { + $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ", + intval(UPDATE_FLAGS_UPDATED), + dbesc($r[0]['ud_addr']), + intval(UPDATE_FLAGS_UPDATED), + dbesc($x[0]['ud_date']) + ); + + return; + } + + update_directory_entry($r[0]); return; -- cgit v1.2.3 From bf04568ef08923676f1b97f1324cea5ad6d2b322 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Nov 2014 18:36:48 -0800 Subject: more directory tuning to ignore things we already know we can't possibly update --- include/onedirsync.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/onedirsync.php b/include/onedirsync.php index cc7f9f22d..a1450e183 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -55,7 +55,7 @@ function onedirsync_run($argv, $argc){ $h = q("select * from hubloc where hubloc_addr = '%s' limit 1", dbesc($r[0]['ud_addr']) ); - if($h && $h[0]['hubloc_status'] & HUBLOC_OFFLINE) { + if(($h) && ($h[0]['hubloc_status'] & HUBLOC_OFFLINE)) { $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), @@ -66,6 +66,11 @@ function onedirsync_run($argv, $argc){ return; } + // we might have to pull this out some day, but for now update_directory_entry() + // runs zot_finger() and is kind of zot specific + + if($h && $h[0]['hubloc_network'] !== 'zot') + return; update_directory_entry($r[0]); -- cgit v1.2.3 From 03a457ed83c0cee5e8a766fa6394c18966688068 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Nov 2014 18:44:16 -0800 Subject: more logging for zot_feed anomalies --- include/items.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 00edeabdd..477b5197e 100755 --- a/include/items.php +++ b/include/items.php @@ -4286,6 +4286,8 @@ function zot_feed($uid,$observer_xchan,$arr) { $mindate = dbesc($mindate); logger('zot_feed: requested for uid ' . $uid . ' from observer ' . $observer_xchan, LOGGER_DEBUG); + if($message_id) + logger('message_id: ' . $message_id,LOGGER_DEBUG); if(! perm_is_allowed($uid,$observer_xchan,'view_stream')) { logger('zot_feed: permission denied.'); -- cgit v1.2.3 From f17ef6aa90bc283e122a88e627cb464f065af2a6 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Nov 2014 19:33:08 -0800 Subject: allow the photo_rand widget to access photos from any channel (useful if the widget is used in sys-generated pages). You still need permission. --- include/widgets.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/widgets.php b/include/widgets.php index 7193850ef..076a8fa91 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -828,7 +828,11 @@ function widget_photo_rand($arr) { else $album = ''; - $channel_id = get_app()->profile_uid; + $channel_id = 0; + if(array_key_exists('channel_id',$arr) && intval($arr['channel_id'])) + $channel_id = intval($arr['channel_id']); + if(! $channel_id) + $channel_id = get_app()->profile_uid; if(! $channel_id) return ''; -- cgit v1.2.3