mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 23:55:19 +00:00
fix all other occurences of db_quoteinterval()
This commit is contained in:
parent
33e034f7d4
commit
42a88ca015
17 changed files with 58 additions and 58 deletions
|
@ -303,8 +303,8 @@ function mark_orphan_hubsxchans()
|
||||||
|
|
||||||
|
|
||||||
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_deleted = 0
|
$r = q("update hubloc set hubloc_deleted = 1 where hubloc_deleted = 0
|
||||||
and hubloc_network in ('nomad','zot6') and hubloc_connected != '0001-01-01 00:00:00' hubloc_connected < %s - interval %s",
|
and hubloc_network in ('nomad','zot6') and hubloc_connected != '0001-01-01 00:00:00' and hubloc_connected < %s - %s",
|
||||||
db_utcnow(), db_quoteinterval('36 day')
|
db_utcnow(), db_quoteinterval('36 day', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
$r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_deleted = 1 and hubloc_orphancheck = 0");
|
$r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_deleted = 1 and hubloc_orphancheck = 0");
|
||||||
|
@ -589,9 +589,9 @@ function random_profile()
|
||||||
for ($i = 0; $i < $retryrandom; $i++) {
|
for ($i = 0; $i < $retryrandom; $i++) {
|
||||||
$r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where
|
$r = q("select xchan_url, xchan_hash from xchan left join hubloc on hubloc_hash = xchan_hash where
|
||||||
xchan_hidden = 0 and xchan_network in ('nomad','zot6') and xchan_deleted = 0 and hubloc_deleted = 0
|
xchan_hidden = 0 and xchan_network in ('nomad','zot6') and xchan_deleted = 0 and hubloc_deleted = 0
|
||||||
and hubloc_connected > %s - interval %s order by $randfunc limit 1",
|
and hubloc_connected > %s - %s order by $randfunc limit 1",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('30 day')
|
db_quoteinterval('30 day', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$r) {
|
if (!$r) {
|
||||||
|
|
|
@ -554,11 +554,11 @@ function update_birthdays()
|
||||||
|
|
||||||
$r = q(
|
$r = q(
|
||||||
"SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
|
"SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
|
||||||
WHERE abook_dob > %s + interval %s and abook_dob < %s + interval %s",
|
WHERE abook_dob > %s + %s and abook_dob < %s + %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('7 day'),
|
db_quoteinterval('7 day', true),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('14 day')
|
db_quoteinterval('14 day', true)
|
||||||
);
|
);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
foreach ($r as $rr) {
|
foreach ($r as $rr) {
|
||||||
|
|
|
@ -3504,8 +3504,8 @@ function item_expire($uid,$days,$comment_days = 7) {
|
||||||
|
|
||||||
$r = q("SELECT id FROM item
|
$r = q("SELECT id FROM item
|
||||||
WHERE uid = %d
|
WHERE uid = %d
|
||||||
AND created < %s - INTERVAL %s
|
AND created < %s - %s
|
||||||
AND commented < %s - INTERVAL %s
|
AND commented < %s - %s
|
||||||
AND item_retained = 0
|
AND item_retained = 0
|
||||||
AND item_thread_top = 1
|
AND item_thread_top = 1
|
||||||
AND resource_type = ''
|
AND resource_type = ''
|
||||||
|
@ -3513,9 +3513,9 @@ function item_expire($uid,$days,$comment_days = 7) {
|
||||||
$sql_extra $item_normal LIMIT $expire_limit ",
|
$sql_extra $item_normal LIMIT $expire_limit ",
|
||||||
intval($uid),
|
intval($uid),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval(intval($days) . ' DAY'),
|
db_quoteinterval(intval($days) . ' DAY', true),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval(intval($comment_days) . ' DAY')
|
db_quoteinterval(intval($comment_days) . ' DAY', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (! $r) {
|
if (! $r) {
|
||||||
|
|
|
@ -33,9 +33,9 @@ class Checksites implements DaemonInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q(
|
$r = q(
|
||||||
"select * from site where site_dead = 0 and site_update < %s - INTERVAL %s and site_type = %d $sql_options ",
|
"select * from site where site_dead = 0 and site_update < %s - %s and site_type = %d $sql_options ",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval($days . ' DAY'),
|
db_quoteinterval($days . ' DAY', true),
|
||||||
intval(SITE_TYPE_ZOT)
|
intval(SITE_TYPE_ZOT)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -42,17 +42,17 @@ class Cron_daily implements DaemonInterface
|
||||||
// expire any read notifications over a month old
|
// expire any read notifications over a month old
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"delete from notify where seen = 1 and created < %s - INTERVAL %s",
|
"delete from notify where seen = 1 and created < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('60 DAY')
|
db_quoteinterval('60 DAY', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// expire any unread notifications over a year old
|
// expire any unread notifications over a year old
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"delete from notify where seen = 0 and created < %s - INTERVAL %s",
|
"delete from notify where seen = 0 and created < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('1 YEAR')
|
db_quoteinterval('1 YEAR', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// expire old delivery reports
|
// expire old delivery reports
|
||||||
|
@ -63,17 +63,17 @@ class Cron_daily implements DaemonInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"delete from dreport where dreport_time < %s - INTERVAL %s",
|
"delete from dreport where dreport_time < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval($keep_reports . ' DAY')
|
db_quoteinterval($keep_reports . ' DAY', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// delete accounts that did not submit email verification within 3 days
|
// delete accounts that did not submit email verification within 3 days
|
||||||
|
|
||||||
$r = q(
|
$r = q(
|
||||||
"select * from register where password = 'verify' and created < %s - INTERVAL %s",
|
"select * from register where password = 'verify' and created < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('3 DAY')
|
db_quoteinterval('3 DAY', true)
|
||||||
);
|
);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
foreach ($r as $rv) {
|
foreach ($r as $rv) {
|
||||||
|
|
|
@ -35,11 +35,11 @@ class Cron_weekly implements DaemonInterface
|
||||||
|
|
||||||
$r = q(
|
$r = q(
|
||||||
"select channel_id from channel where channel_removed = 1 and
|
"select channel_id from channel where channel_removed = 1 and
|
||||||
channel_deleted > %s - INTERVAL %s and channel_deleted < %s - INTERVAL %s",
|
channel_deleted > %s - %s and channel_deleted < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('21 DAY'),
|
db_quoteinterval('21 DAY', true),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('10 DAY')
|
db_quoteinterval('10 DAY', true)
|
||||||
);
|
);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
foreach ($r as $rv) {
|
foreach ($r as $rv) {
|
||||||
|
@ -50,9 +50,9 @@ class Cron_weekly implements DaemonInterface
|
||||||
// get rid of ancient poco records
|
// get rid of ancient poco records
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"delete from xlink where xlink_updated < %s - INTERVAL %s and xlink_static = 0 ",
|
"delete from xlink where xlink_updated < %s - %s and xlink_static = 0 ",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('14 DAY')
|
db_quoteinterval('14 DAY', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check for dead sites
|
// Check for dead sites
|
||||||
|
|
|
@ -21,9 +21,9 @@ class Expire implements DaemonInterface
|
||||||
// so notifications should have been delivered.
|
// so notifications should have been delivered.
|
||||||
|
|
||||||
$pending_deletes = q(
|
$pending_deletes = q(
|
||||||
"select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - INTERVAL %s",
|
"select id from item where item_deleted = 1 and item_pending_remove = 0 and changed < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('4 DAY')
|
db_quoteinterval('4 DAY', true)
|
||||||
);
|
);
|
||||||
if ($pending_deletes) {
|
if ($pending_deletes) {
|
||||||
foreach ($pending_deletes as $item) {
|
foreach ($pending_deletes as $item) {
|
||||||
|
|
|
@ -38,9 +38,9 @@ class Importdoc implements DaemonInterface
|
||||||
}
|
}
|
||||||
// remove old files that weren't updated (indicates they were most likely deleted).
|
// remove old files that weren't updated (indicates they were most likely deleted).
|
||||||
$i = q(
|
$i = q(
|
||||||
"select * from item where item_type = 5 and edited < %s - INTERVAL %s",
|
"select * from item where item_type = 5 and edited < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('14 DAY')
|
db_quoteinterval('14 DAY', true)
|
||||||
);
|
);
|
||||||
if ($i) {
|
if ($i) {
|
||||||
foreach ($i as $iv) {
|
foreach ($i as $iv) {
|
||||||
|
|
|
@ -167,10 +167,10 @@ class Onepoll implements DaemonInterface
|
||||||
|
|
||||||
$r = q(
|
$r = q(
|
||||||
"SELECT xlink_id from xlink
|
"SELECT xlink_id from xlink
|
||||||
where xlink_xchan = '%s' and xlink_updated > %s - INTERVAL %s and xlink_static = 0 limit 1",
|
where xlink_xchan = '%s' and xlink_updated > %s - %s and xlink_static = 0 limit 1",
|
||||||
intval($contact['xchan_hash']),
|
intval($contact['xchan_hash']),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('7 DAY')
|
db_quoteinterval('7 DAY', true)
|
||||||
);
|
);
|
||||||
if (! $r) {
|
if (! $r) {
|
||||||
Socgraph::poco_load($contact['xchan_hash'], $contact['xchan_connurl']);
|
Socgraph::poco_load($contact['xchan_hash'], $contact['xchan_connurl']);
|
||||||
|
|
|
@ -18,27 +18,27 @@ class Queue implements DaemonInterface
|
||||||
// delete all queue items more than 3 days old
|
// delete all queue items more than 3 days old
|
||||||
// but first mark these sites dead if we haven't heard from them in a month
|
// but first mark these sites dead if we haven't heard from them in a month
|
||||||
|
|
||||||
$oldqItems = q("select outq_posturl from outq where outq_created < %s - INTERVAL %s",
|
$oldqItems = q("select outq_posturl from outq where outq_created < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('3 DAY')
|
db_quoteinterval('3 DAY', true)
|
||||||
);
|
);
|
||||||
if ($oldqItems) {
|
if ($oldqItems) {
|
||||||
foreach ($oldqItems as $qItem) {
|
foreach ($oldqItems as $qItem) {
|
||||||
$h = parse_url($qItem['outq_posturl']);
|
$h = parse_url($qItem['outq_posturl']);
|
||||||
$site_url = $h['scheme'] . '://' . $h['host'] . (($h['port']) ? ':' . $h['port'] : '');
|
$site_url = $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",
|
q("update site set site_dead = 1 where site_dead = 0 and site_url = '%s' and site_update < %s - %s",
|
||||||
dbesc($site_url),
|
dbesc($site_url),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('1 MONTH')
|
db_quoteinterval('1 MONTH', true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
logger('Removing ' . count($oldqItems) . ' old queue entries');
|
logger('Removing ' . count($oldqItems) . ' old queue entries');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
q("DELETE FROM outq WHERE outq_created < %s - INTERVAL %s",
|
q("DELETE FROM outq WHERE outq_created < %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('3 DAY')
|
db_quoteinterval('3 DAY', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
$deliveries = [];
|
$deliveries = [];
|
||||||
|
|
|
@ -181,11 +181,11 @@ class Activity
|
||||||
|
|
||||||
$site_url = unparse_url(['scheme' => $parsed['scheme'], 'host' => $parsed['host'], 'port' => ((array_key_exists('port', $parsed) && intval($parsed['port'])) ? $parsed['port'] : 0)]);
|
$site_url = unparse_url(['scheme' => $parsed['scheme'], 'host' => $parsed['host'], 'port' => ((array_key_exists('port', $parsed) && intval($parsed['port'])) ? $parsed['port'] : 0)]);
|
||||||
q(
|
q(
|
||||||
"update site set site_update = '%s' where site_url = '%s' and site_update < %s - INTERVAL %s",
|
"update site set site_update = '%s' where site_url = '%s' and site_update < %s - %s",
|
||||||
dbesc(Time::convert()),
|
dbesc(Time::convert()),
|
||||||
dbesc($site_url),
|
dbesc($site_url),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('1 DAY')
|
db_quoteinterval('1 DAY', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
// check for a valid signature, but only if this is not an actor object. If it is signed, it must be valid.
|
// check for a valid signature, but only if this is not an actor object. If it is signed, it must be valid.
|
||||||
|
|
|
@ -1181,10 +1181,10 @@ class Channel
|
||||||
|
|
||||||
$r = q(
|
$r = q(
|
||||||
"select * from item where item_wall = 1 and item_deleted = 0 and uid = %d
|
"select * from item where item_wall = 1 and item_deleted = 0 and uid = %d
|
||||||
and created > %s - INTERVAL %s and resource_type = '' order by created",
|
and created > %s - %s and resource_type = '' order by created",
|
||||||
intval($channel_id),
|
intval($channel_id),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('3 MONTH')
|
db_quoteinterval('3 MONTH', true)
|
||||||
);
|
);
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$ret['item'] = [];
|
$ret['item'] = [];
|
||||||
|
|
|
@ -168,9 +168,9 @@ class Chatroom
|
||||||
|
|
||||||
if (intval($x[0]['cr_expire'])) {
|
if (intval($x[0]['cr_expire'])) {
|
||||||
$r = q(
|
$r = q(
|
||||||
"delete from chat where created < %s - INTERVAL %s and chat_room = %d",
|
"delete from chat where created < %s - %s and chat_room = %d",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval(intval($x[0]['cr_expire']) . ' MINUTE'),
|
db_quoteinterval(intval($x[0]['cr_expire']) . ' MINUTE', true),
|
||||||
intval($x[0]['cr_id'])
|
intval($x[0]['cr_id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,9 +118,9 @@ class Socgraph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
q(
|
q(
|
||||||
"delete from xchat where xchat_edited < %s - INTERVAL %s and xchat_xchan = '%s' ",
|
"delete from xchat where xchat_edited < %s - %s and xchat_xchan = '%s' ",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('7 DAY'),
|
db_quoteinterval('7 DAY', true),
|
||||||
dbesc($xchan)
|
dbesc($xchan)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -241,10 +241,10 @@ class Socgraph {
|
||||||
logger("poco_load: loaded $total entries", LOGGER_DEBUG);
|
logger("poco_load: loaded $total entries", LOGGER_DEBUG);
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - INTERVAL %s and xlink_static = 0",
|
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - %s and xlink_static = 0",
|
||||||
dbesc($xchan),
|
dbesc($xchan),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('7 DAY')
|
db_quoteinterval('7 DAY', true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,10 +344,10 @@ class Socgraph {
|
||||||
logger("ap_poco_load: loaded $total entries", LOGGER_DEBUG);
|
logger("ap_poco_load: loaded $total entries", LOGGER_DEBUG);
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - INTERVAL %s and xlink_static = 0",
|
"delete from xlink where xlink_xchan = '%s' and xlink_updated < %s - %s and xlink_static = 0",
|
||||||
dbesc($xchan),
|
dbesc($xchan),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('7 DAY')
|
db_quoteinterval('7 DAY', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -70,10 +70,10 @@ class Verify
|
||||||
public static function purge(string $type, string $interval): void
|
public static function purge(string $type, string $interval): void
|
||||||
{
|
{
|
||||||
q(
|
q(
|
||||||
"delete from verify where vtype = '%s' and created < ( %s - INTERVAL %s )",
|
"delete from verify where vtype = '%s' and created < ( %s - %s )",
|
||||||
dbesc($type),
|
dbesc($type),
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval($interval)
|
db_quoteinterval($interval, true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,9 +135,9 @@ class Ping extends Controller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
q(
|
q(
|
||||||
"delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ",
|
"delete from chatpresence where cp_last < %s - %s and cp_client != 'auto' ",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('3 MINUTE')
|
db_quoteinterval('3 MINUTE', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,9 @@ class Register extends Controller
|
||||||
$max_dailies = intval(get_config('system', 'max_daily_registrations'));
|
$max_dailies = intval(get_config('system', 'max_daily_registrations'));
|
||||||
if ($max_dailies) {
|
if ($max_dailies) {
|
||||||
$r = q(
|
$r = q(
|
||||||
"select count(account_id) as total from account where account_created > %s - INTERVAL %s",
|
"select count(account_id) as total from account where account_created > %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('1 day')
|
db_quoteinterval('1 day', true)
|
||||||
);
|
);
|
||||||
if ($r && intval($r[0]['total']) >= $max_dailies) {
|
if ($r && intval($r[0]['total']) >= $max_dailies) {
|
||||||
notice(t('Maximum daily site registrations exceeded. Please try again tomorrow.') . EOL);
|
notice(t('Maximum daily site registrations exceeded. Please try again tomorrow.') . EOL);
|
||||||
|
@ -240,9 +240,9 @@ class Register extends Controller
|
||||||
$max_dailies = intval(get_config('system', 'max_daily_registrations'));
|
$max_dailies = intval(get_config('system', 'max_daily_registrations'));
|
||||||
if ($max_dailies) {
|
if ($max_dailies) {
|
||||||
$r = q(
|
$r = q(
|
||||||
"select count(account_id) as total from account where account_created > %s - INTERVAL %s",
|
"select count(account_id) as total from account where account_created > %s - %s",
|
||||||
db_utcnow(),
|
db_utcnow(),
|
||||||
db_quoteinterval('1 day')
|
db_quoteinterval('1 day', true)
|
||||||
);
|
);
|
||||||
if ($r && $r[0]['total'] >= $max_dailies) {
|
if ($r && $r[0]['total'] >= $max_dailies) {
|
||||||
logger('max daily registrations exceeded.');
|
logger('max daily registrations exceeded.');
|
||||||
|
|
Loading…
Reference in a new issue