aboutsummaryrefslogtreecommitdiffstats
path: root/include/externals.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-03-27 15:35:29 -0700
committerfriendica <info@friendica.com>2014-03-27 15:35:29 -0700
commita0674af4169a8c929c89887d4e7796b21ee55a91 (patch)
tree1b3e673a0acbbf07377871c5c09015fc2abf44ba /include/externals.php
parent7b24b78af949f2645459e4698ee2f96a17becef4 (diff)
downloadvolse-hubzilla-a0674af4169a8c929c89887d4e7796b21ee55a91.tar.gz
volse-hubzilla-a0674af4169a8c929c89887d4e7796b21ee55a91.tar.bz2
volse-hubzilla-a0674af4169a8c929c89887d4e7796b21ee55a91.zip
firehose fixes and optimisations. In particular get rid of the unresponsive script warning when trying to load updates (sine they aren't our posts, we can't check for unseen, hence we can't really load updates). Also make the url selection pluggable.
Diffstat (limited to 'include/externals.php')
-rw-r--r--include/externals.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/include/externals.php b/include/externals.php
new file mode 100644
index 000000000..48aeaf6b3
--- /dev/null
+++ b/include/externals.php
@@ -0,0 +1,54 @@
+<?php /** @file */
+
+require_once('boot.php');
+require_once('include/cli_startup.php');
+require_once('include/zot.php');
+require_once('include/identity.php');
+
+function externals_run($argv, $argc){
+
+ cli_startup();
+ $a = get_app();
+
+
+ // pull in some public posts
+
+ $arr = array('url' => '');
+ call_hooks('externals_url_select',$arr);
+
+ if($arr['url']) {
+ $url = $arr['url'];
+ }
+ else {
+ $r = q("select site_url from site where site_url != '%s' order by rand() limit 1",
+ dbesc(z_root())
+ );
+ if($r)
+ $url = $r[0]['site_url'];
+ }
+
+ if($url) {
+ $feedurl = $url . '/zotfeed?f=&mindate=' . urlencode(datetime_convert('','','now - 15 days'));
+ $x = z_fetch_url($feedurl);
+
+ if(($x) && ($x['success'])) {
+ $total = 0;
+ $j = json_decode($x['body'],true);
+ if($j['success'] && $j['messages']) {
+ $sys = get_sys_channel();
+ foreach($j['messages'] as $message) {
+ $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message),
+ array(array('hash' => $sys['xchan_hash'])), false, true);
+ $total ++;
+ }
+ logger('import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG);
+ }
+ }
+ }
+
+}
+
+if (array_search(__file__,get_included_files())===0){
+ externals_run($argv,$argc);
+ killme();
+}