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:
64
file-server.php
Normal file
64
file-server.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
$input_name = 'file';
|
||||
|
||||
$allow = array();
|
||||
|
||||
$deny = array(
|
||||
'phtml', 'php', 'php3', 'php4', 'php5', 'php6', 'php7', 'phps', 'cgi', 'pl', 'asp',
|
||||
'aspx', 'shtml', 'shtm', 'htaccess', 'htpasswd', 'ini', 'log', 'sh', 'js', 'html',
|
||||
'htm', 'css', 'sql', 'spl', 'scgi', 'fcgi', 'exe'
|
||||
);
|
||||
|
||||
$path = __DIR__ . '/uploads/';
|
||||
|
||||
|
||||
$error = $success = '';
|
||||
if (!isset($_FILES[$input_name])) {
|
||||
$error = 'Файл не загружен.';
|
||||
} else {
|
||||
$file = $_FILES[$input_name];
|
||||
|
||||
if (!empty($file['error']) || empty($file['tmp_name'])) {
|
||||
$error = 'Не удалось загрузить файл.';
|
||||
} elseif ($file['tmp_name'] == 'none' || !is_uploaded_file($file['tmp_name'])) {
|
||||
$error = 'Не удалось загрузить файл.';
|
||||
} else {
|
||||
$pattern = "[^a-zа-яё0-9,~!@#%^-_\$\?\(\)\{\}\[\]\.]";
|
||||
$name = mb_eregi_replace($pattern, '-', $file['name']);
|
||||
$name = mb_ereg_replace('[-]+', '-', $name);
|
||||
$parts = pathinfo($name);
|
||||
|
||||
if (empty($name) || empty($parts['extension'])) {
|
||||
$error = 'Недопустимый тип файла';
|
||||
} elseif (!empty($allow) && !in_array(strtolower($parts['extension']), $allow)) {
|
||||
$error = 'Недопустимый тип файла';
|
||||
} elseif (!empty($deny) && in_array(strtolower($parts['extension']), $deny)) {
|
||||
$error = 'Недопустимый тип файла';
|
||||
} else {
|
||||
if (move_uploaded_file($file['tmp_name'], $path . $name)) {
|
||||
$fullpath = $_SERVER['HTTP_REFERER']. '/uploads/' . $name;
|
||||
exec("convert uploads/".$name." uploads/".$name.'_'.date('m-d-Y-H-i-s').".pdf");
|
||||
$success = '<p style="color: green">Файл «' . $name . '» успешно загружен.</p><a href="'.$fullpath.'">Скачать</a>';
|
||||
} else {
|
||||
$error = 'Не удалось загрузить файл.';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($error)) {
|
||||
$error = '<p style="color: red">' . $error . '</p>';
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'error' => $error,
|
||||
'success' => $success,
|
||||
);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($data, JSON_UNESCAPED_UNICODE);
|
||||
exit();
|
||||
|
||||
//exec("convert banner.png banner.pdf");
|
||||
|
||||
Reference in New Issue
Block a user