diff options
author | redmatrix <git@macgirvin.com> | 2016-05-19 22:26:37 -0700 |
---|---|---|
committer | redmatrix <git@macgirvin.com> | 2016-05-19 22:26:37 -0700 |
commit | a2cec8899ad191b47d116f4ea124be6bd5b05472 (patch) | |
tree | b23952460e035bb37f886cb8fad5cd86c50f1291 /include/externals.php | |
parent | 014168a29bfbba69c2ba887af97e5fb290fa21c5 (diff) | |
download | volse-hubzilla-a2cec8899ad191b47d116f4ea124be6bd5b05472.tar.gz volse-hubzilla-a2cec8899ad191b47d116f4ea124be6bd5b05472.tar.bz2 volse-hubzilla-a2cec8899ad191b47d116f4ea124be6bd5b05472.zip |
daemon conversion continued...
Diffstat (limited to 'include/externals.php')
-rw-r--r-- | include/externals.php | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/include/externals.php b/include/externals.php deleted file mode 100644 index ddf44dc52..000000000 --- a/include/externals.php +++ /dev/null @@ -1,103 +0,0 @@ -<?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($argc,$argv){ - - cli_startup(); - $a = get_app(); - - - $total = 0; - $attempts = 0; - - logger('externals: startup', LOGGER_DEBUG); - - // pull in some public posts - - - while($total == 0 && $attempts < 3) { - $arr = array('url' => ''); - call_hooks('externals_url_select',$arr); - - if($arr['url']) { - $url = $arr['url']; - } - else { - $randfunc = db_getfunc('RAND'); - - // fixme this query does not deal with directory realms. - - $r = q("select site_url, site_pull from site where site_url != '%s' and site_flags != %d and site_type = %d and site_dead = 0 order by $randfunc limit 1", - dbesc(z_root()), - intval(DIRECTORY_MODE_STANDALONE), - intval(SITE_TYPE_ZOT) - ); - if($r) - $url = $r[0]['site_url']; - } - - $blacklisted = false; - - if(! check_siteallowed($url)) { - logger('blacklisted site: ' . $url); - $blacklisted = true; - } - - $attempts ++; - - // make sure we can eventually break out if somebody blacklists all known sites - - if($blacklisted) { - if($attempts > 20) - break; - $attempts --; - continue; - } - - if($url) { - if($r[0]['site_pull'] !== NULL_DATE) - $mindate = urlencode(datetime_convert('','',$r[0]['site_pull'] . ' - 1 day')); - else { - $days = get_config('externals','since_days'); - if($days === false) - $days = 15; - $mindate = urlencode(datetime_convert('','','now - ' . intval($days) . ' days')); - } - - $feedurl = $url . '/zotfeed?f=&mindate=' . $mindate; - - logger('externals: pulling public content from ' . $feedurl, LOGGER_DEBUG); - - $x = z_fetch_url($feedurl); - if(($x) && ($x['success'])) { - - q("update site set site_pull = '%s' where site_url = '%s'", - dbesc(datetime_convert()), - dbesc($url) - ); - - $j = json_decode($x['body'],true); - if($j['success'] && $j['messages']) { - $sys = get_sys_channel(); - foreach($j['messages'] as $message) { - // on these posts, clear any route info. - $message['route'] = ''; - $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message), - array(array('hash' => $sys['xchan_hash'])), false, true); - $total ++; - } - logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG); - } - } - } - } -} - -if (array_search(__file__,get_included_files())===0){ - externals_run($argc,$argv); - killme(); -} |