streams/Code/Daemon/Cache_embeds.php

40 lines
869 B
PHP
Raw Normal View History

2020-03-26 00:48:27 +00:00
<?php
2019-01-29 23:18:35 +00:00
2022-02-16 04:08:28 +00:00
namespace Code\Daemon;
2019-01-29 23:18:35 +00:00
2022-11-27 09:15:28 +00:00
class Cache_embeds implements DaemonInterface
2021-12-03 03:01:39 +00:00
{
2019-01-29 23:18:35 +00:00
2022-08-21 07:36:09 +00:00
/**
2022-11-27 09:15:28 +00:00
* @param int $argc
* @param array $argv
2022-08-21 07:36:09 +00:00
* @return void
*/
2022-11-27 09:15:28 +00:00
public function run(int $argc, array $argv): void
2021-12-03 03:01:39 +00:00
{
if (! $argc == 2) {
return;
}
2019-01-29 23:18:35 +00:00
2021-12-03 03:01:39 +00:00
$c = q(
"select body, html, created from item where id = %d ",
dbesc(intval($argv[1]))
);
2019-01-29 23:18:35 +00:00
2021-12-03 03:01:39 +00:00
if (! $c) {
return;
}
2019-01-29 23:18:35 +00:00
2021-12-03 03:01:39 +00:00
$item = array_shift($c);
2019-01-29 23:18:35 +00:00
2021-12-03 03:01:39 +00:00
$cache_expire = intval(get_config('system', 'default_expire_days'));
if ($cache_expire <= 0) {
$cache_expire = 60;
}
2022-09-04 22:39:58 +00:00
$cache_enable = !(($cache_expire) && ($item['created'] < datetime_convert('UTC', 'UTC', 'now - ' . $cache_expire . ' days')));
2019-01-29 23:18:35 +00:00
2021-12-03 03:01:39 +00:00
$s = bbcode($item['body']);
2022-10-20 20:00:55 +00:00
sslify($s, $cache_enable);
2021-12-03 03:01:39 +00:00
}
2019-01-29 23:18:35 +00:00
}