2016-05-20 02:42:45 +00:00
|
|
|
<?php
|
|
|
|
|
2022-02-16 04:08:28 +00:00
|
|
|
namespace Code\Daemon;
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2022-02-16 04:08:28 +00:00
|
|
|
use Code\Lib\Libzotdir;
|
|
|
|
use Code\Lib\Channel;
|
2018-06-01 02:42:13 +00:00
|
|
|
|
2022-11-27 09:15:28 +00:00
|
|
|
class Directory implements DaemonInterface
|
2021-12-03 03:01:39 +00:00
|
|
|
{
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2022-11-27 09:15:28 +00:00
|
|
|
public function run(int $argc, array $argv): void
|
2021-12-03 03:01:39 +00:00
|
|
|
{
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
if ($argc < 2) {
|
|
|
|
return;
|
|
|
|
}
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
$force = false;
|
|
|
|
$pushall = true;
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
if ($argc > 2) {
|
|
|
|
if ($argv[2] === 'force') {
|
|
|
|
$force = true;
|
|
|
|
}
|
|
|
|
if ($argv[2] === 'nopush') {
|
|
|
|
$pushall = false;
|
|
|
|
}
|
|
|
|
}
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
logger('directory update', LOGGER_DEBUG);
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2022-01-25 01:26:12 +00:00
|
|
|
$channel = Channel::from_id($argv[1]);
|
2021-12-03 03:01:39 +00:00
|
|
|
if (! $channel) {
|
|
|
|
return;
|
|
|
|
}
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// update the local directory - was optional, but now done regardless
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
Libzotdir::local_dir_update($argv[1], $force);
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
q(
|
|
|
|
"update channel set channel_dirdate = '%s' where channel_id = %d",
|
|
|
|
dbesc(datetime_convert()),
|
|
|
|
intval($channel['channel_id'])
|
|
|
|
);
|
2016-05-20 02:42:45 +00:00
|
|
|
|
2021-12-03 03:01:39 +00:00
|
|
|
// Now update all the connections
|
|
|
|
if ($pushall) {
|
|
|
|
Run::Summon([ 'Notifier','refresh_all',$channel['channel_id'] ]);
|
|
|
|
}
|
|
|
|
}
|
2016-05-20 02:42:45 +00:00
|
|
|
}
|