aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorHabeas Codice <habeascodice@federated.social>2014-11-21 15:39:14 -0800
committerHabeas Codice <habeascodice@federated.social>2014-11-21 15:39:14 -0800
commitcf739c0361cce7f1c454a0e52809fba99cb40e84 (patch)
treeff75671dc4075cef1b35553680222fc166cdb401 /mod
parentb224f8056cbf9b41994b44e48a7ad154976d1c88 (diff)
parentf17ef6aa90bc283e122a88e627cb464f065af2a6 (diff)
downloadvolse-hubzilla-cf739c0361cce7f1c454a0e52809fba99cb40e84.tar.gz
volse-hubzilla-cf739c0361cce7f1c454a0e52809fba99cb40e84.tar.bz2
volse-hubzilla-cf739c0361cce7f1c454a0e52809fba99cb40e84.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mod')
-rw-r--r--mod/home.php146
-rw-r--r--mod/update_home.php38
2 files changed, 174 insertions, 10 deletions
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