diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php index 8f3c4c2a..84d1aff0 100644 --- a/src/messenger/webim/client.php +++ b/src/messenger/webim/client.php @@ -24,6 +24,7 @@ require_once('libs/chat.php'); require_once('libs/operator.php'); require_once('libs/groups.php'); require_once('libs/expand.php'); +require_once('libs/captcha.php'); loadsettings(); if($settings['enablessl'] == "1" && $settings['forcessl'] == "1") { @@ -66,7 +67,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['showcaptcha'] = $settings["enablecaptcha"] == "1" && can_show_captcha() ? "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 2e30501a..a2c70df1 100644 --- a/src/messenger/webim/leavemessage.php +++ b/src/messenger/webim/leavemessage.php @@ -22,6 +22,7 @@ require_once('libs/common.php'); require_once('libs/chat.php'); require_once('libs/expand.php'); +require_once('libs/captcha.php'); $errors = array(); $page = array(); @@ -62,7 +63,7 @@ if( !$email ) { } loadsettings(); -if($settings["enablecaptcha"] == "1") { +if($settings["enablecaptcha"] == "1" && can_show_captcha()) { $captcha = getparam('captcha'); $original = $_SESSION['captcha']; if(empty($original) || empty($captcha) || $captcha != $original) { @@ -75,7 +76,7 @@ if( count($errors) > 0 ) { $page['formname'] = topage($visitor_name); $page['formemail'] = $email; $page['formmessage'] = topage($message); - $page['showcaptcha'] = $settings["enablecaptcha"] == "1" ? "1" : ""; + $page['showcaptcha'] = $settings["enablecaptcha"] == "1" && can_show_captcha() ? "1" : ""; $page['info'] = topage($info); setup_logo(); expand("styles", getchatstyle(), "leavemessage.tpl"); diff --git a/src/messenger/webim/libs/captcha.php b/src/messenger/webim/libs/captcha.php index f87494e0..d7be0399 100644 --- a/src/messenger/webim/libs/captcha.php +++ b/src/messenger/webim/libs/captcha.php @@ -15,6 +15,10 @@ Copyright 2006 WebCheatSheet.com */ +function can_show_captcha() { + return extension_loaded("gd"); +} + function gen_captcha() { $md5_hash = md5(rand(0,9999)); return substr($md5_hash, 15, 5);