<?php
header('Content-Type: text/plain; charset=utf-8');

echo "PHP Version: " . PHP_VERSION . "\n";
echo "SAPI: " . php_sapi_name() . "\n";
echo "extension_loaded('redis'): " . (extension_loaded('redis') ? 'YES' : 'NO') . "\n";
echo "class_exists('Redis'): " . (class_exists('Redis') ? 'YES' : 'NO') . "\n";

if (class_exists('Redis')) {
    try {
        $redis = new Redis();
        $host = 'crm.clientright.ru';
        $port = 6379;
        $connected = @$redis->connect($host, $port, 2);
        if ($connected) {
            echo "Redis connection: SUCCESS\n";
            $ping = $redis->ping();
            echo "Redis ping: " . var_export($ping, true) . "\n";
        } else {
            echo "Redis connection: FAILED\n";
        }
    } catch (Exception $e) {
        echo "Redis error: " . $e->getMessage() . "\n";
    }
} else {
    echo "Redis class not available\n";
    echo "Loaded extensions:\n";
    $extensions = get_loaded_extensions();
    foreach ($extensions as $ext) {
        if (stripos($ext, 'redis') !== false) {
            echo "  - $ext\n";
        }
    }
}
