szuru/scripts/find-dead-posts

33 lines
715 B
Plaintext
Raw Permalink Normal View History

2015-06-28 12:27:50 +02:00
#!/usr/bin/php
2015-03-11 10:15:01 +01:00
<?php
require_once(__DIR__
2015-06-28 12:25:35 +02:00
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'src'
. DIRECTORY_SEPARATOR . 'Bootstrap.php');
2015-03-11 10:15:01 +01:00
use Szurubooru\Injector;
use Szurubooru\Dao\PublicFileDao;
use Szurubooru\Dao\PostDao;
$publicFileDao = Injector::get(PublicFileDao::class);
$postDao = Injector::get(PostDao::class);
$paths = [];
foreach ($postDao->findAll() as $post)
{
2015-06-28 12:25:35 +02:00
$paths[] = $post->getContentPath();
$paths[] = $post->getThumbnailSourceContentPath();
2015-03-11 10:15:01 +01:00
}
$paths = array_flip($paths);
foreach ($publicFileDao->listAll() as $path)
{
2015-06-28 12:25:35 +02:00
if (dirname($path) !== 'posts')
continue;
if (!isset($paths[$path]))
{
echo $path . PHP_EOL;
flush();
}
2015-03-11 10:15:01 +01:00
}