aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-09-28 17:13:11 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-09-28 17:13:11 -0700
commite5f47cd14b9dd97385d93c2610e05d959e526ce8 (patch)
tree9863fff105662540bc6e18b8fac5dbb156e5d0f3 /include
parentdbeae16dc142c3bc832718b0c29eefd6a82033d6 (diff)
downloadvolse-hubzilla-e5f47cd14b9dd97385d93c2610e05d959e526ce8.tar.gz
volse-hubzilla-e5f47cd14b9dd97385d93c2610e05d959e526ce8.tar.bz2
volse-hubzilla-e5f47cd14b9dd97385d93c2610e05d959e526ce8.zip
create site records for all queued sites and check for death
Diffstat (limited to 'include')
-rw-r--r--include/deliver.php19
-rw-r--r--include/dir_fns.php13
-rw-r--r--include/queue.php16
-rw-r--r--include/zot.php8
4 files changed, 47 insertions, 9 deletions
diff --git a/include/deliver.php b/include/deliver.php
index 82a1ac6df..62a4ac482 100644
--- a/include/deliver.php
+++ b/include/deliver.php
@@ -53,16 +53,33 @@ function deliver_run($argv, $argc) {
continue;
}
}
+ else {
+
+ // zot sites should all have a site record, unless they've been dead for as long as
+ // your site has existed. Since we don't know for sure what these sites are,
+ // call them unknown
+
+ q("insert into site (site_url, site_update, site_dead, site_type) values ('%s','%s',0,%d) ",
+ dbesc($base),
+ dbesc(datetime_convert()),
+ intval(($r[0]['outq_driver'] === 'post' ?) SITE_TYPE_NOTZOT : SITE_TYPE_UNKNOWN)
+ );
+ }
}
}
// "post" queue driver - used for diaspora and friendica-over-diaspora communications.
if($r[0]['outq_driver'] === 'post') {
+
+
$result = z_post_url($r[0]['outq_posturl'],$r[0]['outq_msg']);
if($result['success'] && $result['return_code'] < 300) {
logger('deliver: queue post success to ' . $r[0]['outq_posturl'], LOGGER_DEBUG);
-
+ q("update site set site_update = '%s', site_dead = 0 where site_url = '%s' "),
+ dbesc(datetime_convert()),
+ dbesc($site_url)
+ );
q("update dreport set status = '%s', dreport_time = '%s' where dreport_queue = '%s' limit 1",
dbesc('accepted for delivery'),
dbesc(datetime_convert()),
diff --git a/include/dir_fns.php b/include/dir_fns.php
index 38c92dd94..e466b7404 100644
--- a/include/dir_fns.php
+++ b/include/dir_fns.php
@@ -151,16 +151,18 @@ function sync_directories($dirmode) {
$realm = get_directory_realm();
if ($realm == DIRECTORY_REALM) {
- $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and ( site_realm = '%s' or site_realm = '') ",
+ $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_type = %d and ( site_realm = '%s' or site_realm = '') ",
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
+ intval(SITE_TYPE_ZOT),
dbesc($realm)
);
} else {
- $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_realm like '%s' ",
+ $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_realm like '%s' and site_type = %d ",
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
dbesc(z_root()),
- dbesc(protect_sprintf('%' . $realm . '%'))
+ dbesc(protect_sprintf('%' . $realm . '%')),
+ intval(SITE_TYPE_ZOT)
);
}
@@ -187,9 +189,10 @@ function sync_directories($dirmode) {
intval($r[0]['site_valid'])
);
- $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s'",
+ $r = q("select * from site where (site_flags & %d) > 0 and site_url != '%s' and site_type = %d ",
intval(DIRECTORY_MODE_PRIMARY|DIRECTORY_MODE_SECONDARY),
- dbesc(z_root())
+ dbesc(z_root()),
+ intval(SITE_TYPE_ZOT)
);
}
if (! $r)
diff --git a/include/queue.php b/include/queue.php
index 7d2ad3b2d..18c8c5fa2 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -22,6 +22,22 @@ function queue_run($argv, $argc){
logger('queue: start');
+
+ $r = q("select outq_posturl from outq where outq_created < %s - INTERVAL %s",
+ db_utcnow(), db_quoteinterval('3 DAY')
+ );
+ if($r) {
+ foreach($r as $rr) {
+ $site_url = '';
+ $h = parse_url($rr['outq_posturl']);
+ $desturl = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '');
+ q("update site set site_dead = 1 where site_dead = 0 and site_url = '%s' and site_update < %s - INTERVAL %s",
+ dbesc($desturl),
+ db_utcnow(), db_quoteinterval('1 MONTH')
+ );
+ }
+ }
+
$r = q("DELETE FROM outq WHERE outq_created < %s - INTERVAL %s",
db_utcnow(), db_quoteinterval('3 DAY')
);
diff --git a/include/zot.php b/include/zot.php
index 0c6a2f368..7c9bdca97 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2743,7 +2743,7 @@ function import_site($arr, $pubkey) {
// logger('import_site: input: ' . print_r($arr,true));
// logger('import_site: stored: ' . print_r($siterecord,true));
- $r = q("update site set site_dead = 0, site_location = '%s', site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s', site_realm = '%s'
+ $r = q("update site set site_dead = 0, site_location = '%s', site_flags = %d, site_access = %d, site_directory = '%s', site_register = %d, site_update = '%s', site_sellpage = '%s', site_realm = '%s', site_type = %d
where site_url = '%s'",
dbesc($site_location),
intval($site_directory),
@@ -2753,6 +2753,7 @@ function import_site($arr, $pubkey) {
dbesc(datetime_convert()),
dbesc($sellpage),
dbesc($site_realm),
+ intval(SITE_TYPE_ZOT),
dbesc($url)
);
if(! $r) {
@@ -2769,7 +2770,7 @@ function import_site($arr, $pubkey) {
}
else {
$update = true;
- $r = q("insert into site ( site_location, site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage, site_realm )
+ $r = q("insert into site ( site_location, site_url, site_access, site_flags, site_update, site_directory, site_register, site_sellpage, site_realm, site_type )
values ( '%s', '%s', %d, %d, '%s', '%s', %d, '%s', '%s' )",
dbesc($site_location),
dbesc($url),
@@ -2779,7 +2780,8 @@ function import_site($arr, $pubkey) {
dbesc($directory_url),
intval($register_policy),
dbesc($sellpage),
- dbesc($site_realm)
+ dbesc($site_realm),
+ intval(SITE_TYPE_ZOT)
);
if(! $r) {
logger('import_site: record create failed. ' . print_r($arr,true));