Простой способ аутентификации человеческого запроса через apache [closed]

Я спрашиваю об этом здесь, потому что, как я понимаю, спецификация CGI заключается в том, что аутентификация должна выполняться apache, а не скриптом: http://tools.ietf.org/html/rfc3875#section-3 .

Я разместил на сайте рекламу вечеринки по случаю дня рождения. Простая html-страница, обслуживаемая apache2 на сервере ubuntu 12.04. У меня есть ссылка на страницу cgi-скрипта-Python, который просит запрашивающего отправить текстовые значения, которые будут отформатированы и переданы в электронном письме мальчику с днем ​​рождения. Какой простой способ подтвердить, что форму заполняет человек, чтобы я не допустил, чтобы именинник получал спам. Использование стандартного CGI, потому что я не ожидаю перегрузки одновременных запросов.

-2
задан 19 April 2013 в 16:34
1 ответ

The easiest and best way that I've found is to put an input form on your page that will get hidden either by javascript or by CSS. Something like:

<link href="/styles.css" rel="stylesheet" type="text/css" media="all" />
<form action="/birthday.php" method="post">
  <p>Email: <input type="text" name="email" /></p>
  <p>Name: <input type="text" name="name" /></p>
  <p>Phone: <input type="text" name="phone" /></p>
</form>

In this case, we'll use phone as our secret human verification input. In your styles.css you should have:

input[name="phone"] {
  display: none;
}

In this case, the "phone" input type will be hidden by every real human's browser and won't be submitted with the form. (Most) spambots won't load and parse the external CSS file, so you can then check the existence of the "phone" input's existence in your script:

PHP code:

if (isset($_POST['phone'])) {
  // this is spam, but don't let them know
  echo 'thanks!';
  exit;
}

99% chance you won't get spam. If you did, you could go one step further and use javascript to disable the form field:

$(function() {
  $('input[name="phone"]').hide();
});

This puts the onus on the spammer to load and parse your CSS (or javascript) file and is super easy to implement.

1
ответ дан 5 December 2019 в 21:29

Теги

Похожие вопросы