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 @@
-
-/*
- This is PHP file that generates CAPTCHA image for the How to Create CAPTCHA Protection using PHP and AJAX Tutorial
-
- You may use this code in your own projects as long as this
- copyright is left in place. All code is provided AS-IS.
- This code is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- For the rest of the code visit http://www.WebCheatSheet.com
-
- Copyright 2006 WebCheatSheet.com
-
-*/
-
-//Start the session so we can store what the security code actually is
-session_start();
-
-//Send a generated image to the browser
-create_image();
-exit();
-
-function create_image()
-{
- //Let's generate a totally random string using md5
- $md5_hash = md5(rand(0,999));
- //We don't need a 32 character long string so we trim it down to 5
- $security_code = substr($md5_hash, 15, 5);
-
- //Set the session to store the security code
- $_SESSION["security_code"] = $security_code;
-
- //Set the image width and height
- $width = 100;
- $height = 20;
-
- //Create the image resource
- $image = ImageCreate($width, $height);
-
- //We are making three colors, white, black and gray
- $white = ImageColorAllocate($image, 255, 255, 255);
- $black = ImageColorAllocate($image, 0, 0, 0);
- $grey = ImageColorAllocate($image, 204, 204, 204);
-
- //Make the background black
- ImageFill($image, 0, 0, $black);
-
- //Add randomly generated string in white to the image
- ImageString($image, 3, 30, 3, $security_code, $white);
-
- //Throw in some lines to make it a little bit harder for any bots to break
- ImageRectangle($image,0,0,$width-1,$height-1,$grey);
- imageline($image, 0, $height/2, $width, $height/2, $grey);
- imageline($image, $width/2, 0, $width/2, $height, $grey);
-
- //Tell the browser what kind of file is come in
- header("Content-Type: image/jpeg");
-
- //Output the newly created image in jpeg format
- ImageJpeg($image);
-
- //Free up resources
- ImageDestroy($image);
-}
+
+/*
+ This is PHP file that generates CAPTCHA image for the How to Create CAPTCHA
+ Protection using PHP and AJAX Tutorial
+
+ You may use this code in your own projects as long as this
+ copyright is left in place. All code is provided AS-IS.
+ This code is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ For the rest of the code visit http://www.WebCheatSheet.com
+
+ Copyright 2006 WebCheatSheet.com
+*/
+
+function gen_captcha() {
+ $md5_hash = md5(rand(0,9999));
+ return substr($md5_hash, 15, 5);
+}
+
+function draw_captcha($security_code) {
+
+ //Set the image width and height
+ $width = 100;
+ $height = 25;
+
+ //Create the image resource
+ $image = ImageCreate($width, $height);
+ imageantialias($image, true);
+
+ //We are making three colors, white, black and gray
+ $white = ImageColorAllocate($image, 255, 255, 255);
+ $black = ImageColorAllocate($image, 15, 50, 15);
+ $grey = ImageColorAllocate($image, 204, 204, 204);
+ $ellipsec = ImageColorAllocate($image, 0, 100, 60);
+
+ //Make the background black
+ ImageFill($image, 0, 0, $black);
+ imagefilledellipse($image, 56,15,30,17, $ellipsec);
+
+ //Add randomly generated string in white to the image
+ ImageString($image, 5, 30, 4, $security_code, $white);
+
+ //Throw in some lines to make it a little bit harder for any bots to break
+ ImageRectangle($image,0,0,$width-1,$height-1,$grey);
+ imageline($image, 0, $height/2+3, $width, $height/2+5, $grey);
+ imageline($image, $width/2-14, 0, $width/2+7, $height, $grey);
+
+
+ //Tell the browser what kind of file is come in
+ header("Content-Type: image/jpeg");
+
+ //Output the newly created image in jpeg format
+ ImageJpeg($image);
+
+ //Free up resources
+ ImageDestroy($image);
+}
+
?>
\ 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}