diff options
-rw-r--r-- | doc/Widgets.md | 7 | ||||
-rw-r--r-- | include/ItemObject.php | 4 | ||||
-rw-r--r-- | include/conversation.php | 14 | ||||
-rwxr-xr-x | include/items.php | 2 | ||||
-rw-r--r-- | include/onedirsync.php | 24 | ||||
-rw-r--r-- | include/widgets.php | 60 | ||||
-rw-r--r-- | mod/home.php | 146 | ||||
-rw-r--r-- | mod/update_home.php | 38 | ||||
-rw-r--r-- | view/js/main.js | 2 |
9 files changed, 277 insertions, 20 deletions
diff --git a/doc/Widgets.md b/doc/Widgets.md index dcf8dfb48..2c5625156 100644 --- a/doc/Widgets.md +++ b/doc/Widgets.md @@ -85,3 +85,10 @@ Some/many of these widgets have restrictions which may restrict the type of page * style - CSS style string <br /> <br /> +* photo_rand - display a random photo from one of your photo albums. Photo permissions are honoured + * args: + * album - album name (very strongly recommended if you have lots of photos) + * scale - typically 0 (original size), 1 (640px), or 2 (320px) + * style - CSS style string +<br /> <br /> + 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) { 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.'); diff --git a/include/onedirsync.php b/include/onedirsync.php index 09c4c9d9a..a1450e183 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,28 @@ 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; + } + + // 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]); return; diff --git a/include/widgets.php b/include/widgets.php index 74bdb5d74..076a8fa91 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -810,7 +810,65 @@ function widget_photo($arr) { $o .= '<img ' . (($zrl) ? ' class="zrl" ' : '') . (($style) ? ' style="' . $style . '"' : '') - . ' src="' . $url . '" />'; + . ' src="' . $url . '" alt="' . t('photo/image') . '" />'; + + $o .= '</div>'; + + 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 = 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 ''; + + $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 = '<div class="widget">'; + + $o .= '<img class="zrl" ' + . (($style) ? ' style="' . $style . '"' : '') + . ' src="' . $url . '" alt="' . t('photo/image') . '" />'; $o .= '</div>'; diff --git a/mod/home.php b/mod/home.php index a1a68710f..57f7478f1 100644 --- a/mod/home.php +++ b/mod/home.php @@ -31,7 +31,7 @@ function home_init(&$a) { } -function home_content(&$a) { +function home_content(&$a, $update = 0, $load = false) { $o = ''; @@ -95,16 +95,142 @@ function home_content(&$a) { $o .= file_get_contents('home.html'); } else { - - // If there's nothing special happening, just spit out a login box - $sitename = get_config('system','sitename'); if($sitename) $o .= '<h1>' . sprintf( t("Welcome to %s") ,$sitename) . '</h1>'; - if (! $a->config['system']['no_login_on_homepage']) - $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); + + if(intval(get_config('system','block_public')) && (! local_user()) && (! remote_user())) { + // If there's nothing special happening, just spit out a login box + + if (! $a->config['system']['no_login_on_homepage']) + $o .= login(($a->config['system']['register_policy'] == REGISTER_CLOSED) ? 0 : 1); + return $o; + } + else { + + if(! $update) { + + $maxheight = get_config('system','home_divmore_height'); + if(! $maxheight) + $maxheight = 75; + + $o .= '<div id="live-home"></div>' . "\r\n"; + $o .= "<script> var profile_uid = " . ((intval(local_user())) ? local_user() : (-1)) + . "; var profile_page = " . $a->pager['page'] + . "; divmore_height = " . intval($maxheight) . "; </script>\r\n"; + + $a->page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),array( + '$baseurl' => z_root(), + '$pgtype' => 'home', + '$uid' => ((local_user()) ? local_user() : '0'), + '$gid' => '0', + '$cid' => '0', + '$cmin' => '0', + '$cmax' => '99', + '$star' => '0', + '$liked' => '0', + '$conv' => '0', + '$spam' => '0', + '$fh' => '1', + '$nouveau' => '0', + '$wall' => '0', + '$list' => '0', + '$page' => (($a->pager['page'] != 1) ? $a->pager['page'] : 1), + '$search' => '', + '$order' => 'comment', + '$file' => '', + '$cats' => '', + '$dend' => '', + '$mid' => '', + '$dbegin' => '' + )); + } + + if($update && ! $load) { + // only setup pagination on initial page view + $pager_sql = ''; + } + else { + $a->set_pager_itemspage(20); + $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval($a->pager['itemspage']), intval($a->pager['start'])); + } + + require_once('include/identity.php'); + $sys = get_sys_channel(); + $uids = " and item.uid = " . intval($sys['channel_id']) . " "; + $a->data['firehose'] = intval($sys['channel_id']); + + $page_mode = 'list'; + + $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : ''); + + if($update && $_SESSION['loadtime']) + $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + if($load) + $simple_update = ''; + + //logger('update: ' . $update . ' load: ' . $load); + + if($update) { + + $ordering = "commented"; + + if($load) { + + $_SESSION['loadtime'] = datetime_convert(); + + // Fetch a page full of parent items for this page + + $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + left join abook on item.author_xchan = abook.abook_xchan + WHERE true $uids AND item.item_restrict = 0 + AND item.parent = item.id + and ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) + $sql_extra3 $sql_extra $sql_nets + ORDER BY $ordering DESC $pager_sql ", + intval(ABOOK_FLAG_BLOCKED) + ); + + } + + // Then fetch all the children of the parents that are on this page + $parents_str = ''; + $update_unseen = ''; + + if($r) { + + $parents_str = ids_to_querystr($r,'item_id'); + + $items = q("SELECT item.*, item.id AS item_id FROM item + WHERE true $uids AND item.item_restrict = 0 + AND item.parent IN ( %s ) + $sql_extra ", + dbesc($parents_str) + ); + + xchan_query($items,true,(-1)); + $items = fetch_post_tags($items,true); + $items = conv_sort($items,$ordering); + } + else { + $items = array(); + } + + } + + // fake it + $mode = ('network'); + + $o .= conversation($a,$items,$mode,$update,$page_mode); + + if(($items) && (! $update)) + $o .= alt_pager($a,count($items)); + + return $o; + + } + call_hooks('home_content',$o); + return $o; } - - call_hooks('home_content',$o); - return $o; -} + +}
\ No newline at end of file diff --git a/mod/update_home.php b/mod/update_home.php new file mode 100644 index 000000000..c139682e1 --- /dev/null +++ b/mod/update_home.php @@ -0,0 +1,38 @@ +<?php + +// See update_profile.php for documentation + +require_once('mod/home.php'); + +function update_home_content(&$a) { + + $profile_uid = ((intval($_GET['p'])) ? intval($_GET['p']) : (-1)); + $load = (((argc() > 1) && (argv(1) == 'load')) ? 1 : 0); + header("Content-type: text/html"); + echo "<!DOCTYPE html><html><body>\r\n"; + echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '<div>' : '<section>'); + + $text = home_content($a,$profile_uid, $load); + $pattern = "/<img([^>]*) src=\"([^\"]*)\"/"; + $replace = "<img\${1} dst=\"\${2}\""; + $text = preg_replace($pattern, $replace, $text); + + if(! $load) { + $replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />'; + $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i"; + $text = preg_replace($pattern, $replace, $text); + $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i"; + $text = preg_replace($pattern, $replace, $text); + $pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i"; + $text = preg_replace($pattern, $replace, $text); + $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i"; + $text = preg_replace($pattern, $replace, $text); + } + + echo str_replace("\t",' ',$text); + echo ((array_key_exists('msie',$_GET) && $_GET['msie'] == 1) ? '</div>' : '</section>'); + echo "</body></html>\r\n"; +// logger('update_home: ' . $text); + killme(); + +}
\ No newline at end of file diff --git a/view/js/main.js b/view/js/main.js index 8939f4a09..04e43f72e 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -343,7 +343,7 @@ if($('#live-network').length) { src = 'network'; liveUpdate(); } if($('#live-channel').length) { src = 'channel'; liveUpdate(); } - if($('#live-community').length) { src = 'community'; liveUpdate(); } + if($('#live-home').length) { src = 'home'; liveUpdate(); } if($('#live-display').length) { src = 'display'; liveUpdate(); } if($('#live-search').length) { src = 'search'; liveUpdate(); } |