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
This commit is contained in:
40
test_predis.php
Normal file
40
test_predis.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?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";
|
||||
}
|
||||
Reference in New Issue
Block a user