<?php
require __DIR__ . '/../../app/bootstrap.php';
require __DIR__ . '/../../app/database.php';
require_login();

try {
    $result = repair_legacy_article_cover_paths(true);
    redirect('/admin/content/list.php?fix_cover_status=success&fix_cover_count=' . urlencode((string)(isset($result['fixed_count']) ? (int)$result['fixed_count'] : 0)) . '&fix_republish_count=' . urlencode((string)(isset($result['republished_count']) ? (int)$result['republished_count'] : 0)));
} catch (Exception $e) {
    redirect('/admin/content/list.php?fix_cover_status=error&fix_cover_message=' . urlencode($e->getMessage()));
}
