Captcha

CAPTCHA – filter spam bots and real users of the site who leave messages in the forms of various modules of the site, such as "Feedback", "Comments", "Feedback", "Forum", etc. Captcha can be of three types, the classic "Code" more difficult variation "reCAPTCHA", or "Q & A" when the administrator sets the question and the answer, and the user must choose the right that his message has been received on this site.

Connection

Подключаемая часть – файл modules/captcha/captcha.inc.php. В нем описан класс Captcha_inc. В модуле к объекту класса можно обратиться через переменную $this->diafan->_captcha. Экземпляр класса создается при первом вызове переменной.

Методы

string get ([string $modules = "modules"], [string $error = ""], [boolean $is_update = false]) – Выводит капчу.

  • string $modules: метка капчи
  • string $error: ошибка ввода кода, если запрос передан не через Ajax
  • boolean $is_update: капча генерируется для обновления

Example:

// in model modules/comments/comments.inc.php ask for captcha
$captcha = $this->diafan->_captcha->get("comments", '');

// output security code in the template modules/comments/views/comments.view.form.php
echo $captcha;

boolean configmodules (string $module, [integer $site_id = 0]) – Проверяет подключена ли капта в настройках модуля.

  • string $module: названием модуля
  • integer $site_id: страница сайта с подключенным модулем

string|boolean false error ([string $modules = "modules"]) – Проверяет правильность ввода капчи.

  • string $modules: метка капчи

Example:

// output security code in the template modules/comments/views/comments.view.form.php
echo $captcha;

// do ask for the security code is entered correctly when processing a request in the file modules/faq/faq.action.php
$error = $this->diafan->_captcha->error('faq');
if(
$error)
{
    
// security code is entered incorrectly
}

Questuion-Answer

List of questions

Backend "Questuion-Answer" has its own administrative interface for entering question. To add a question to fill the following fields.

Edit of question

Основные:

  • Question – Question that has to answer visitor to pass the test. The parameter has different values for different language versions of the site.
  • Published – If not checked, then the question will not participate in the inspection. The parameter has different values for different language versions of the site.
  • Do not show the answer – If checked, the user is on the site will be invited to a field to enter the correct answer.
  • Answers – Possible answers with the correct.

Settings

Settings

The module settings you can choose the backend for the CAPTCHA and enter the settings for the backend.

  • Type – Selecting filtration method spambots. Possible values:
    • Code,
    • reCAPTCHA,
    • Question-Answer.
  • Public Key for service reCAPTCHA – Parameter displayed when the field "Type" is "reCAPTCHA".
  • Private Key for service reCAPTCHA – Parameter displayed when the field "Type" is "reCAPTCHA".

Database

{captcha} – Вопросы для капчи типа Вопрос-ответ

{captcha_answers} – Варианты ответов для капчи типа Вопрос-ответ

Files

  1. modules/captcha/admin/captcha.admin.php – Редактирование вопросов для капчи;

  2. modules/captcha/admin/captcha.admin.config.php – Module settings;

  3. modules/captcha/admin/captcha.admin.inc.php – Connecting the module to the administrative part of other modules;

  4. modules/captcha/admin/js/captcha.admin.config.js – Настройка модуля, JS-сценарий;

  5. modules/captcha/admin/js/captcha.admin.js – Редактирование вопросов для капчи, JS-сценарий;

  6. modules/captcha/captcha.get.php – Генерирование изображения капчи;

  7. modules/captcha/captcha.inc.php – Подключение для работы с капчей;

  8. modules/captcha/captcha.install.php – Module installation;

  9. modules/captcha/js/captcha.get.js – JS-сценарий стандартной капчи;

  10. modules/captcha/js/captcha.get_qa.js – JS-сценарий капчи «Вопрос-Ответ»;

  11. modules/captcha/js/captcha.get_recaptcha_.js – JS-script for reCAPTCHA;

  12. modules/captcha/views/captcha.view.get.php – Шаблон стандартной капчи;

  13. modules/captcha/views/captcha.view.get_form.php – Шаблон формы стандартной капчи;

  14. modules/captcha/views/captcha.view.get_qa.php – Шаблон капчи «Вопрос-Ответ»;

  15. modules/captcha/views/captcha.view.get_qa_form.php – Шаблон формы для капчи «Вопрос-Ответ»;

  16. modules/captcha/views/captcha.view.get_recaptcha.php – Template reCAPTCHA.