Files
XC_VM/src/cli/CronJobs/TmpCronJob.php
T
Divarion-D 738973c5db docs(php): add standardized file headers across codebase
- Add @author, @copyright, @link, @version, @license to 399 PHP files
- MERGE mode: inject metadata into 243 existing docblocks (preserving docs)
- INSERT mode: create new docblocks for 156 files without headers
- Skip 3 files that already had correct headers
- Exclude third-party libs (TMDb, mobiledetect, Dropbox, etc.)
- Exclude bin/, ministra/, content/, tmp/, resources/, module views
- Update tools/add_headers.php to v2 with MERGE strategy
2026-04-05 22:38:36 +03:00

76 lines
2.1 KiB
PHP

<?php
/**
* TmpCronJob — tmp cron job
*
* @package XC_VM_CLI_CronJobs
* @author Divarion_D <https://github.com/Divarion-D>
* @copyright 2025-2026 Vateron Media
* @link https://github.com/Vateron-Media/XC_VM
* @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
*/
require_once __DIR__ . '/../CronTrait.php';
class TmpCronJob implements CommandInterface {
use CronTrait;
public function getName(): string {
return 'cron:tmp';
}
public function getDescription(): string {
return 'Cron: cleanup temporary files and stale playlists';
}
public function execute(array $rArgs): int {
if (!$this->assertRunAsXcVm()) {
return 1;
}
global $db;
$db->close_mysql();
$this->setProcessTitle('XC_VM[TMP]');
$this->acquireCronLock();
$rTmpPaths = array(
TMP_PATH, CRONS_TMP_PATH, DIVERGENCE_TMP_PATH,
FLOOD_TMP_PATH, MINISTRA_TMP_PATH, SIGNALS_TMP_PATH, LOGS_TMP_PATH
);
foreach ($rTmpPaths as $rTmpPath) {
if (!is_dir($rTmpPath)) {
@mkdir($rTmpPath, 0775, true);
continue;
}
foreach (scandir($rTmpPath) as $rFile) {
$fullPath = $rTmpPath . '/' . $rFile;
if ($rFile === '.' || $rFile === '..') {
continue;
}
if (is_file($fullPath) && time() - filemtime($fullPath) >= 600 && stripos($rFile, 'ministra_') === false) {
unlink($fullPath);
}
}
}
foreach (scandir(PLAYLIST_PATH) as $rFile) {
$fullPath = rtrim(PLAYLIST_PATH, '/') . '/' . $rFile;
if ($rFile === '.' || $rFile === '..') {
continue;
}
if (is_file($fullPath)) {
if (SettingsManager::getAll()['cache_playlists'] <= time() - filemtime($fullPath)) {
unlink($fullPath);
}
}
}
clearstatcache();
@unlink($this->rIdentifier);
return 0;
}
}