aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-09-28 17:15:34 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-09-28 17:15:34 -0700
commit3b53cd56ef151586024cb99742a91d4a75afdb5b (patch)
treef0d02417d5cac33bb1d7999bbeefd11848b18d7f /include
parent6368b093375d50f929b0a419834299e6b62e274e (diff)
parent30e88a4f6b38e1d51ebcd97ac4b81c29f9ce4823 (diff)
downloadvolse-hubzilla-3b53cd56ef151586024cb99742a91d4a75afdb5b.tar.gz
volse-hubzilla-3b53cd56ef151586024cb99742a91d4a75afdb5b.tar.bz2
volse-hubzilla-3b53cd56ef151586024cb99742a91d4a75afdb5b.zip
Merge branch 'deadsite'
Diffstat (limited to 'include')
-rw-r--r--include/checksites.php5
-rw-r--r--include/deliver.php19
-rw-r--r--include/dir_fns.php13
-rw-r--r--include/externals.php5
-rw-r--r--include/hubloc.php4
-rw-r--r--include/queue.php16
-rw-r--r--include/zot.php8
7 files changed, 56 insertions, 14 deletions
diff --git a/include/checksites.php b/include/checksites.php
index e14837255..e9c08c202 100644
--- a/include/checksites.php
+++ b/include/checksites.php
@@ -25,8 +25,9 @@ function checksites_run($argv, $argc){
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')
+ $r = q("select * from site where site_dead = 0 and site_update < %s - INTERVAL %s and site_type = %d $sql_options ",
+ db_utcnow(), db_quoteinterval($days . ' DAY'),
+ intval(SITE_TYPE_ZOT)
);
if(! $r)
diff --git a/include/deliver.php b/include/deliver.php
index 82a1ac6df..86fc90b3f 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/externals.php b/include/externals.php
index 3b6d170d5..18c034bb2 100644
--- a/include/externals.php
+++ b/include/externals.php
@@ -28,9 +28,10 @@ function externals_run($argv, $argc){
}
else {
$randfunc = db_getfunc('RAND');
- $r = q("select site_url, site_pull from site where site_url != '%s' and site_flags != %d order by $randfunc limit 1",
+ $r = q("select site_url, site_pull from site where site_url != '%s' and site_flags != %d and site_type = %d order by $randfunc limit 1",
dbesc(z_root()),
- intval(DIRECTORY_MODE_STANDALONE)
+ intval(DIRECTORY_MODE_STANDALONE),
+ intval(SITE_TYPE_ZOT)
);
if($r)
$url = $r[0]['site_url'];
diff --git a/include/hubloc.php b/include/hubloc.php
index 674a3885f..a1171b0e2 100644
--- a/include/hubloc.php
+++ b/include/hubloc.php
@@ -16,7 +16,9 @@ function is_matrix_url($url) {
function prune_hub_reinstalls() {
- $r = q("select site_url from site where true");
+ $r = q("select site_url from site where site_type = %d",
+ intval(SITE_TYPE_ZOT)
+ );
if($r) {
foreach($r as $rr) {
$x = q("select count(*) as t, hubloc_sitekey, max(hubloc_connected) as c from hubloc where hubloc_url = '%s' group by hubloc_sitekey order by c",
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));