Upd
This commit is contained in:
1 parent
c7ceebde08
commit
34dd004a06
50 files changed
+20222
-11637
No files matched your search
+6
-13
@@ -3,11 +3,10 @@
|
||||
* Harvey Monster Team Page — contact form endpoint.
|
||||
* Production: https://harveymonsterteam.ru/api/contact.php
|
||||
*
|
||||
* Contract: POST JSON {name, contact, message, budget?, website?}
|
||||
* Contract: POST JSON {name, contact, message, website?}
|
||||
* - name: required, 2–100 chars
|
||||
* - contact: required, Telegram @handle or email, ≤200 chars
|
||||
* - contact: required, any channel (telegram / email / phone / VK), 2–200 chars
|
||||
* - message: required, 10–4000 chars
|
||||
* - budget: optional, ≤100 chars
|
||||
* - website: honeypot — must be empty (bots fill it)
|
||||
* Responses: JSON {ok:bool, message|error:string}
|
||||
* - 200 ok / 400 bad JSON / 405 wrong method / 422 validation / 429 rate limit / 500 upstream
|
||||
@@ -82,7 +81,6 @@ if (!is_array($body)) {
|
||||
$name = trim((string) ($body['name'] ?? ''));
|
||||
$contact = trim((string) ($body['contact'] ?? ''));
|
||||
$message = trim((string) ($body['message'] ?? ''));
|
||||
$budget = trim((string) ($body['budget'] ?? ''));
|
||||
$honey = trim((string) ($body['website'] ?? ''));
|
||||
|
||||
if ($honey !== '') {
|
||||
@@ -92,17 +90,13 @@ if ($honey !== '') {
|
||||
if (u_len($name) < 2 || u_len($name) > 100) {
|
||||
json_out(422, false, 'Укажите имя (2–100 символов).');
|
||||
}
|
||||
$isEmail = filter_var($contact, FILTER_VALIDATE_EMAIL) !== false;
|
||||
$isTg = preg_match('/^@[A-Za-z0-9_]{3,32}$/', $contact) === 1;
|
||||
if ((!$isEmail && !$isTg) || u_len($contact) > 200) {
|
||||
json_out(422, false, 'Способ связи: @telegram или email.');
|
||||
// Канал связи не ограничен форматом (telegram, email, телефон, VK) — только длина + экранирование.
|
||||
if (u_len($contact) < 2 || u_len($contact) > 200) {
|
||||
json_out(422, false, 'Укажите предпочтительное средство связи (2–200 символов).');
|
||||
}
|
||||
if (u_len($message) < 10 || u_len($message) > 4000) {
|
||||
json_out(422, false, 'Опишите задачу (10–4000 символов).');
|
||||
}
|
||||
if (u_len($budget) > 100) {
|
||||
json_out(422, false, 'Бюджет: не более 100 символов.');
|
||||
}
|
||||
|
||||
if (rate_limited($_SERVER['REMOTE_ADDR'] ?? '0.0.0.0')) {
|
||||
json_out(429, false, 'Слишком много запросов. Попробуйте через 10 минут.');
|
||||
@@ -114,8 +108,7 @@ $esc = function (string $s): string {
|
||||
|
||||
$text = "🛎 Новое сообщение с harveymonsterteam.ru\n"
|
||||
. "Имя: {$esc($name)}\n"
|
||||
. "Связь: {$esc($contact)}\n"
|
||||
. 'Бюджет: ' . ($budget !== '' ? $esc($budget) : '—') . "\n\n"
|
||||
. "Связь: {$esc($contact)}\n\n"
|
||||
. $esc($message);
|
||||
|
||||
$ctx = stream_context_create([
|
||||
|
||||
Reference in new issue
Block a user