captcha: check if gdlib is installed

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@620 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-08-11 10:09:44 +00:00
parent 04a584ffab
commit 4b33346dab
3 changed files with 9 additions and 3 deletions

View File

@ -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;

View File

@ -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");

View File

@ -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);