<?php
/**
 * Copy CrestChimney Logo to Final Location
 * Run this via web browser to copy the logo with proper permissions
 */

$source_file = __DIR__ . '/uploads/CrestChimney-Logo-W-1024x160.png';
$dest_file = dirname(__DIR__) . '/wp-content/uploads/2022/05/CrestChimney-Logo-W-1024x160.png';
$dest_dir = dirname($dest_file);

// Check if source exists
if (!file_exists($source_file)) {
    die("Error: Source file not found: $source_file");
}

// Create destination directory if it doesn't exist
if (!is_dir($dest_dir)) {
    if (!mkdir($dest_dir, 0755, true)) {
        die("Error: Could not create directory: $dest_dir");
    }
}

// Copy the file
if (copy($source_file, $dest_file)) {
    // Try to set proper permissions
    @chmod($dest_file, 0644);
    echo "Success! Logo copied to: $dest_file<br>";
    echo "File size: " . filesize($dest_file) . " bytes<br>";
    echo "<a href='/wp-content/uploads/2022/05/CrestChimney-Logo-W-1024x160.png'>View Logo</a>";
} else {
    die("Error: Could not copy file. Please check permissions.");
}
?>
