<?php
// OPcache diagnostic and reset script
echo "=== OPcache Status ===\n";

if (function_exists('opcache_get_status')) {
    $status = opcache_get_status();
    echo "OPcache enabled: Yes\n";
    echo "OPcache caching: " . ($status['opcache_enabled'] ? 'Yes' : 'No') . "\n";
    echo "Memory usage: " . ($status['memory_usage']['used_memory'] / 1024 / 1024) . " MB\n";
    echo "Cached files: " . $status['opcache_statistics']['num_cached_scripts'] . "\n";
} else {
    echo "OPcache functions not available\n";
}

if (function_exists('opcache_reset')) {
    echo "\n=== Trying to reset OPcache ===\n";
    if (@opcache_reset()) {
        echo "OPcache reset successful!\n";
    } else {
        echo "OPcache reset failed (may need web server restart)\n";
    }
} else {
    echo "\nOPcache reset function not available\n";
}

// List some cached files to confirm
if (function_exists('opcache_get_status')) {
    $status = opcache_get_status();
    if (!empty($status['scripts'])) {
        echo "\n=== Cached mobile templates ===\n";
        foreach (array_keys($status['scripts']) as $file) {
            if (strpos($file, 'mobile') !== false) {
                echo basename($file) . "\n";
            }
        }
    }
}

echo "\nTimestamp: " . date('Y-m-d H:i:s') . "\n";
