diff options
author | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2015-09-18 18:51:39 +0200 |
---|---|---|
committer | Haakon Meland Eriksen <haakon.eriksen@far.no> | 2015-09-18 18:51:39 +0200 |
commit | ce28760c2a7319f3cdc25c39a62582b722e91006 (patch) | |
tree | 802f64d3988fc14a277c79ee5192693a4202b502 /include/checksites.php | |
parent | 438cb1d7e0f1518dd35a3a377dfd9a9fd885f80c (diff) | |
parent | 87c8cf489210136958d2e0b44e4c3ca48c1ff8af (diff) | |
download | volse-hubzilla-ce28760c2a7319f3cdc25c39a62582b722e91006.tar.gz volse-hubzilla-ce28760c2a7319f3cdc25c39a62582b722e91006.tar.bz2 volse-hubzilla-ce28760c2a7319f3cdc25c39a62582b722e91006.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'include/checksites.php')
-rw-r--r-- | include/checksites.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/checksites.php b/include/checksites.php new file mode 100644 index 000000000..e14837255 --- /dev/null +++ b/include/checksites.php @@ -0,0 +1,61 @@ +<?php /** @file */ + +require_once('boot.php'); +require_once('include/cli_startup.php'); +require_once('include/zot.php'); +require_once('include/hubloc.php'); + + + +function checksites_run($argv, $argc){ + + + cli_startup(); + $a = get_app(); + + logger('checksites: start'); + + if(($argc > 1) && ($argv[1])) + $site_id = $argv[1]; + + if($site_id) + $sql_options = " and site_url = '" . dbesc($argv[1]) . "' "; + + $days = intval(get_config('system','sitecheckdays')); + if($days < 1) + $days = 30; + + $r = q("select * from site where site_dead = 0 and site_update < %s - INTERVAL %s $sql_options ", + db_utcnow(), db_quoteinterval($days . ' DAY') + ); + + if(! $r) + return; + + foreach($r as $rr) { + if(! strcasecmp($rr['site_url'],z_root())) + continue; + + $x = ping_site($rr['site_url']); + if($x['success']) { + logger('checksites: ' . $rr['site_url']); + q("update site set site_update = '%s' where site_url = '%s' ", + dbesc(datetime_convert()), + dbesc($rr['site_url']) + ); + } + else { + logger('marking dead site: ' . $x['message']); + q("update site set site_dead = 1 where site_url = '%s' ", + dbesc($rr['site_url']) + ); + } + } + + return; +} + +if (array_search(__file__,get_included_files())===0){ + checksites_run($argv,$argc); + killme(); +} |