aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-01-15 15:49:22 +0000
committerMario <mario@mariovavti.com>2021-01-15 15:49:22 +0000
commit583d3b5580dcaacdfb466e50db0b86d00cd81745 (patch)
tree58b5f3c3ad0871bdd5e4e420885981febb1adaae /Zotlabs
parent43e36637217518601a2bc4421f750dba74f20222 (diff)
downloadvolse-hubzilla-583d3b5580dcaacdfb466e50db0b86d00cd81745.tar.gz
volse-hubzilla-583d3b5580dcaacdfb466e50db0b86d00cd81745.tar.bz2
volse-hubzilla-583d3b5580dcaacdfb466e50db0b86d00cd81745.zip
whitespace
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Cron.php126
1 files changed, 63 insertions, 63 deletions
diff --git a/Zotlabs/Daemon/Cron.php b/Zotlabs/Daemon/Cron.php
index 1e65f6191..e8fa3244f 100644
--- a/Zotlabs/Daemon/Cron.php
+++ b/Zotlabs/Daemon/Cron.php
@@ -6,14 +6,14 @@ use Zotlabs\Lib\Libsync;
class Cron {
- static public function run($argc,$argv) {
+ static public function run($argc, $argv) {
- $maxsysload = intval(get_config('system','maxloadavg'));
- if($maxsysload < 1)
+ $maxsysload = intval(get_config('system', 'maxloadavg'));
+ if ($maxsysload < 1)
$maxsysload = 50;
- if(function_exists('sys_getloadavg')) {
+ if (function_exists('sys_getloadavg')) {
$load = sys_getloadavg();
- if(intval($load[0]) > $maxsysload) {
+ if (intval($load[0]) > $maxsysload) {
logger('system: load ' . $load . ' too high. Cron deferred to next scheduled run.');
return;
}
@@ -21,18 +21,18 @@ class Cron {
// Check for a lockfile. If it exists, but is over an hour old, it's stale. Ignore it.
$lockfile = 'store/[data]/cron';
- if((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
- && (! get_config('system','override_cron_lockfile'))) {
+ if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 3600))
+ && (!get_config('system', 'override_cron_lockfile'))) {
logger("cron: Already running");
return;
}
-
+
// Create a lockfile. Needs two vars, but $x doesn't need to contain anything.
$x = '';
file_put_contents($lockfile, $x);
logger('cron: start');
-
+
// run queue delivery process in the background
Master::Summon(array('Queue'));
@@ -47,7 +47,7 @@ class Cron {
db_utcnow(),
db_quoteinterval('3 MINUTE')
);
-
+
// expire any expired mail
q("delete from mail where expires > '%s' and expires < %s ",
@@ -55,7 +55,7 @@ class Cron {
db_utcnow()
);
- $interval = get_config('system','delivery_interval', 3);
+ $interval = get_config('system', 'delivery_interval', 3);
// expire any expired items
@@ -63,15 +63,15 @@ class Cron {
and item_deleted = 0 ",
db_utcnow()
);
- if($r) {
+ if ($r) {
require_once('include/items.php');
- foreach($r as $rr) {
- drop_item($rr['id'],false,(($rr['item_wall']) ? DROPITEM_PHASE1 : DROPITEM_NORMAL));
- if($rr['item_wall']) {
+ foreach ($r as $rr) {
+ drop_item($rr['id'], false, (($rr['item_wall']) ? DROPITEM_PHASE1 : DROPITEM_NORMAL));
+ if ($rr['item_wall']) {
// The notifier isn't normally invoked unless item_drop is interactive.
- Master::Summon( [ 'Notifier', 'drop', $rr['id'] ] );
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ Master::Summon(['Notifier', 'drop', $rr['id']]);
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
}
@@ -83,9 +83,9 @@ class Cron {
dbesc(NULL_DATE),
db_utcnow()
);
- if($r) {
+ if ($r) {
require_once('include/security.php');
- foreach($r as $rr) {
+ foreach ($r as $rr) {
atoken_delete($rr['atoken_id']);
}
}
@@ -95,33 +95,33 @@ class Cron {
// or dead entries.
$r = q("select channel_id from channel where channel_dirdate < %s - INTERVAL %s and channel_removed = 0",
- db_utcnow(),
+ db_utcnow(),
db_quoteinterval('30 DAY')
);
- if($r) {
- foreach($r as $rr) {
- Master::Summon(array('Directory',$rr['channel_id'],'force'));
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ if ($r) {
+ foreach ($r as $rr) {
+ Master::Summon(array('Directory', $rr['channel_id'], 'force'));
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
-
+
// Clean expired photos from cache
-
+
$r = q("SELECT DISTINCT xchan, content FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
intval(PHOTO_CACHE),
db_utcnow(),
- db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY')
+ db_quoteinterval(get_config('system', 'active_expire_days', '30') . ' DAY')
);
- if($r) {
+ if ($r) {
q("DELETE FROM photo WHERE photo_usage = %d AND expires < %s - INTERVAL %s",
intval(PHOTO_CACHE),
db_utcnow(),
- db_quoteinterval(get_config('system','active_expire_days', '30') . ' DAY')
+ db_quoteinterval(get_config('system', 'active_expire_days', '30') . ' DAY')
);
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$file = dbunescbin($rr['content']);
- if(is_file($file)) {
+ if (is_file($file)) {
@unlink($file);
@rmdir(dirname($file));
logger('info: deleted cached photo file ' . $file, LOGGER_DEBUG);
@@ -135,29 +135,29 @@ class Cron {
$r = q("select id from item where item_delayed = 1 and created <= %s and created > '%s' ",
db_utcnow(),
- dbesc(datetime_convert('UTC','UTC','now - 2 days'))
+ dbesc(datetime_convert('UTC', 'UTC', 'now - 2 days'))
);
- if($r) {
- foreach($r as $rr) {
+ if ($r) {
+ foreach ($r as $rr) {
$x = q("update item set item_delayed = 0 where id = %d",
intval($rr['id'])
);
- if($x) {
+ if ($x) {
$z = q("select * from item where id = %d",
intval($rr['id'])
);
- if($z) {
+ if ($z) {
xchan_query($z);
$sync_item = fetch_post_tags($z);
Libsync::build_sync_packet($sync_item[0]['uid'],
- [
- 'item' => [ encode_item($sync_item[0],true) ]
+ [
+ 'item' => [encode_item($sync_item[0], true)]
]
);
}
- Master::Summon(array('Notifier','wall-new',$rr['id']));
- if($interval)
- @time_sleep_until(microtime(true) + (float) $interval);
+ Master::Summon(array('Notifier', 'wall-new', $rr['id']));
+ if ($interval)
+ @time_sleep_until(microtime(true) + (float)$interval);
}
}
}
@@ -170,27 +170,27 @@ class Cron {
require_once('include/attach.php');
attach_upgrade();
- $abandon_days = intval(get_config('system','account_abandon_days'));
- if($abandon_days < 1)
+ $abandon_days = intval(get_config('system', 'account_abandon_days'));
+ if ($abandon_days < 1)
$abandon_days = 0;
-
+
// once daily run birthday_updates and then expire in background
// FIXME: add birthday updates, both locally and for xprof for use
// by directory servers
- $d1 = intval(get_config('system','last_expire_day'));
- $d2 = intval(datetime_convert('UTC','UTC','now','d'));
+ $d1 = intval(get_config('system', 'last_expire_day'));
+ $d2 = intval(datetime_convert('UTC', 'UTC', 'now', 'd'));
// Allow somebody to staggger daily activities if they have more than one site on their server,
// or if it happens at an inconvenient (busy) hour.
- $h1 = intval(get_config('system','cron_hour'));
- $h2 = intval(datetime_convert('UTC','UTC','now','G'));
+ $h1 = intval(get_config('system', 'cron_hour'));
+ $h2 = intval(datetime_convert('UTC', 'UTC', 'now', 'G'));
- if(($d2 != $d1) && ($h1 == $h2)) {
+ if (($d2 != $d1) && ($h1 == $h2)) {
Master::Summon(array('Cron_daily'));
}
@@ -199,14 +199,14 @@ class Cron {
$r = q("select xchan_photo_l, xchan_hash from xchan where xchan_photo_l != '' and xchan_photo_m = ''
and xchan_photo_date < %s - INTERVAL %s",
- db_utcnow(),
+ db_utcnow(),
db_quoteinterval('1 DAY')
);
- if($r) {
+ if ($r) {
require_once('include/photo/photo_driver.php');
- foreach($r as $rr) {
+ foreach ($r as $rr) {
$photos = import_xchan_photo($rr['xchan_photo_l'], $rr['xchan_hash'], false, true);
- $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'
+ $x = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s'
where xchan_hash = '%s'",
dbesc($photos[0]),
dbesc($photos[1]),
@@ -220,18 +220,18 @@ class Cron {
// pull in some public posts
- $disable_discover_tab = get_config('system','disable_discover_tab') || get_config('system','disable_discover_tab') === false;
- if(! $disable_discover_tab)
+ $disable_discover_tab = get_config('system', 'disable_discover_tab') || get_config('system', 'disable_discover_tab') === false;
+ if (!$disable_discover_tab)
Master::Summon(array('Externals'));
$generation = 0;
- $restart = false;
+ $restart = false;
- if(($argc > 1) && ($argv[1] == 'restart')) {
- $restart = true;
+ if (($argc > 1) && ($argv[1] == 'restart')) {
+ $restart = true;
$generation = intval($argv[2]);
- if(! $generation)
+ if (!$generation)
return;
}
@@ -241,10 +241,10 @@ class Cron {
// TODO check to see if there are any cronhooks before wasting a process
- if(! $restart)
+ if (!$restart)
Master::Summon(array('Cronhooks'));
- set_config('system','lastcron',datetime_convert());
+ set_config('system', 'lastcron', datetime_convert());
//All done - clear the lockfile
@unlink($lockfile);