Files
erv-ticket-dev/test_predis.php
Fedor 2c516362df feat: Secure SMS verification with Redis (Predis)
- Added Predis library for Redis connection (no PHP extension required)
- Server-side SMS code generation and storage in Redis
- Rate limiting and brute-force protection
- Integration with n8n webhook for SMS sending
- Environment variables moved to .env file
- Fixed policy verification endpoint
- Added file-based fallback if Redis unavailable
2026-01-15 15:40:13 +03:00

41 lines
1.2 KiB
PHP

<?php
header('Content-Type: text/plain; charset=utf-8');
require_once __DIR__ . '/env_loader.php';
require_once __DIR__ . '/vendor/autoload.php';
$host = env('REDIS_HOST', 'crm.clientright.ru');
$port = (int)env('REDIS_PORT', 6379);
$password = env('REDIS_PASSWORD', '');
echo "PHP Version: " . PHP_VERSION . "\n";
echo "SAPI: " . php_sapi_name() . "\n";
echo "Подключение к Redis через Predis: $host:$port\n\n";
try {
$options = [
'scheme' => 'tcp',
'host' => $host,
'port' => $port,
'timeout' => 3.0,
];
if (!empty($password)) {
$options['password'] = $password;
}
$redis = new Predis\Client($options);
$pong = $redis->ping();
echo "Ping: $pong\n";
// Тест записи/чтения
$testKey = 'test:predis:web:' . time();
$redis->setex($testKey, 10, 'hello from web');
$val = $redis->get($testKey);
echo "Тест записи/чтения: $val\n";
$redis->del($testKey);
echo "\n✅ SUCCESS: Redis через Predis работает из веб-сервера!\n";
} catch (Exception $e) {
echo "❌ ERROR: " . $e->getMessage() . "\n";
}