From 00d895e41ce69bb97d81c2e62f4e215794bf6201 Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Sat, 18 Jul 2009 13:54:45 +0000 Subject: [PATCH] improved captcha, rename files git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@588 c66351dc-e62f-0410-b875-e3a5c0b9693f --- src/messenger/webim/captcha.php | 23 ++++ src/messenger/webim/client.php | 1 + src/messenger/webim/leavemessage.php | 15 ++- .../{create_image.php => libs/captcha.php} | 125 +++++++++--------- src/messenger/webim/libs/common.php | 1 + src/messenger/webim/locales/en/properties | 2 +- src/messenger/webim/locales/ru/properties | 1 + .../styles/default/templates/leavemessage.tpl | 17 +-- .../original/templates/leavemessage.tpl | 38 +++--- .../simplicity/templates/leavemessage.tpl | 10 +- 10 files changed, 129 insertions(+), 104 deletions(-) create mode 100644 src/messenger/webim/captcha.php rename src/messenger/webim/{create_image.php => libs/captcha.php} (59%) mode change 100755 => 100644 diff --git a/src/messenger/webim/captcha.php b/src/messenger/webim/captcha.php new file mode 100644 index 00000000..f875384b --- /dev/null +++ b/src/messenger/webim/captcha.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php index 3e03470f..46741c6d 100644 --- a/src/messenger/webim/client.php +++ b/src/messenger/webim/client.php @@ -59,6 +59,7 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { setup_logo(); $page['formname'] = topage(getgetparam('name')); $page['formemail'] = topage($email); + $page['showcaptcha'] = $settings["enablecaptcha"] == "1" ? "1" : ""; $page['info'] = topage($info); expand("styles", getchatstyle(), "leavemessage.tpl"); exit; diff --git a/src/messenger/webim/leavemessage.php b/src/messenger/webim/leavemessage.php index ac28ce1a..8088f565 100644 --- a/src/messenger/webim/leavemessage.php +++ b/src/messenger/webim/leavemessage.php @@ -35,23 +35,28 @@ if( !$email ) { $errors[] = wrong_field("form.field.email"); } } -if ( ($_REQUEST["txtCaptcha"] == $_SESSION["security_code"]) && - (!empty($_REQUEST["txtCaptcha"]) && !empty($_SESSION["security_code"])) ) { -} else { - $errors[] = no_field('errors.captcha'); + +loadsettings(); +if($settings["enablecaptcha"] == "1") { + $captcha = getparam('captcha'); + $original = $_SESSION['captcha']; + if(empty($original) || empty($captcha) || $captcha != $original) { + $errors[] = getlocal('errors.captcha'); + } + unset($_SESSION['captcha']); } if( count($errors) > 0 ) { $page['formname'] = topage($visitor_name); $page['formemail'] = $email; $page['formmessage'] = topage($message); + $page['showcaptcha'] = $settings["enablecaptcha"] == "1" ? "1" : ""; $page['info'] = topage($info); setup_logo(); expand("styles", getchatstyle(), "leavemessage.tpl"); exit; } -loadsettings(); $message_locale = $settings['left_messages_locale']; if(!locale_exists($message_locale)) { $message_locale = $home_locale; diff --git a/src/messenger/webim/create_image.php b/src/messenger/webim/libs/captcha.php old mode 100755 new mode 100644 similarity index 59% rename from src/messenger/webim/create_image.php rename to src/messenger/webim/libs/captcha.php index 7a38c7d5..40b08646 --- a/src/messenger/webim/create_image.php +++ b/src/messenger/webim/libs/captcha.php @@ -1,66 +1,61 @@ - \ No newline at end of file diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index ef96a855..5417b54f 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -574,6 +574,7 @@ $settings = array( 'surveyaskgroup' => '1', 'surveyaskmessage' => '0', 'enablepopupnotification' => '0', + 'enablecaptcha' => '1', 'online_timeout' => 30, /* Timeout (in seconds) when online operator becomes offline */ 'updatefrequency_operator' => 2, diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index eb1f6cb6..d091e1e5 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -103,6 +103,7 @@ content.logoff=Log out of the system. data.saved=Changes saved demo.chat.question=There are so many browsers to choose from. Which one(s) do you recommend? demo.chat.welcome=Hello, how may I help you? +errors.captcha=The letters you typed don't match the letters that were shown in the picture. errors.failed.uploading.file=Error uploading file "{0}": {1}. errors.file.move.error=Error moving file errors.file.size.exceeded=Uploaded file size exceeded @@ -113,7 +114,6 @@ errors.prefix=
  • errors.required=Please fill "{0}". errors.suffix=
  • errors.wrong_field=Please fill "{0}" correctly. -errors.captcha=Captcha is incorrect! features.saved=Features activated form.field.address.description=Ex: 12.23.45.123 or todo.com form.field.address=Visitor's Address diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index 1f77174e..4365460d 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -103,6 +103,7 @@ content.logoff= data.saved=Изменения сохранены demo.chat.question=Посоветуйте мне, пожалуйста, хороший браузер? demo.chat.welcome=Здравствуйте! Чем я могу Вам помочь? +errors.captcha=Введенные символы не соответствуют изображению. errors.failed.uploading.file=Ошибка выгрузки файла "{0}": {1}. errors.file.move.error=Ошибка копирования файла errors.file.size.exceeded=Превышен допустимый размер файла diff --git a/src/messenger/webim/styles/default/templates/leavemessage.tpl b/src/messenger/webim/styles/default/templates/leavemessage.tpl index 3fa278cd..0776a907 100644 --- a/src/messenger/webim/styles/default/templates/leavemessage.tpl +++ b/src/messenger/webim/styles/default/templates/leavemessage.tpl @@ -113,21 +113,16 @@ ${endif:errors} ${msg:form.field.message}: - - - - - - - - - - - + + +${if:showcaptcha} + + +${endif:showcaptcha} diff --git a/src/messenger/webim/styles/original/templates/leavemessage.tpl b/src/messenger/webim/styles/original/templates/leavemessage.tpl index d5b0df8c..03e4230b 100644 --- a/src/messenger/webim/styles/original/templates/leavemessage.tpl +++ b/src/messenger/webim/styles/original/templates/leavemessage.tpl @@ -60,34 +60,36 @@ ${endif:errors}
    - + - - - + + + - - - + + + + - - - - - + + + - - - +${if:showcaptcha} + + + + + - +${endif:showcaptcha}
    ${msg:leavemessage.descr}${msg:leavemessage.descr}
    ${msg:form.field.email}:${msg:form.field.email}:
    ${msg:form.field.name}:${msg:form.field.name}:
    ${msg:form.field.message}:
    - -
    ${msg:form.field.message}:
    + +
    diff --git a/src/messenger/webim/styles/simplicity/templates/leavemessage.tpl b/src/messenger/webim/styles/simplicity/templates/leavemessage.tpl index 33fc4c67..88285854 100644 --- a/src/messenger/webim/styles/simplicity/templates/leavemessage.tpl +++ b/src/messenger/webim/styles/simplicity/templates/leavemessage.tpl @@ -48,10 +48,12 @@ ${msg:form.field.message}: - - - - +${if:showcaptcha} + + + + +${endif:showcaptcha}