Jump to content
MakeWebGames

2 Issues; Captcha and BotBattle


dwandswforlife

Recommended Posts

Just so you all know where I am at with the game development; I have successfully configured it to my host and I am able to log in and play, but that is only because I am the admin. Unfortunately, the first issue I am having is that when attempting to register, such as a new member/guest, the captcha image is not loading.

Here is the captcha page code in case it helps;

 

<?php
define('IN_EZRPG', true);

require_once('init.php');

//$code_length = rand(5,6);
$code_length = 4;
$rand_start = mt_rand(0, 250);
$font = 'static/fonts/Capture_it.ttf';
$fontSize = 30;
$padding = 10;

$l1 = strtoupper(createKey(1, 1));
$l2 = strtoupper(createKey(1, 1));
$l3 = strtoupper(createKey(1, 1));
$l4 = strtoupper(createKey(1, 1));
$verify_string = $l1 . ' ' . $l2 . ' ' . $l3 . ' ' . $l4;
$real_string = $l1 . $l2 . $l3 . $l4;
$verify_code = sha1(strtoupper($real_string) . SECRET_KEY);

$_SESSION['verify_code'] = $verify_code;

function makeRBGColor($color, $image)
{
   $color = str_replace("#", "", $color);
   $red = hexdec(substr($color, 0, 2));
   $green = hexdec(substr($color, 2, 2));
   $blue = hexdec(substr($color, 4, 2));
   $out = ImageColorAllocate($image, $red, $green, $blue);
   return $out;
}

$wordBox = imageftbbox($fontSize, 0, $font, $verify_string);

$wordBoxWidth = $wordBox[2];
$wordBoxHeight = $wordBox[1] + abs($wordBox[7]);

$containerWidth = $wordBoxWidth + ($padding * 2);
$containerHeight = $wordBoxHeight + ($padding * 2);

$textX = $padding;
$textY = $containerHeight - $padding;

$captchaImage = imagecreate($containerWidth, $containerHeight);

$red = randColor();
$green = randColor();
$blue = randColor();
$backgroundColor = ImageColorAllocate($captchaImage, $red, $green, $blue);

$rred = 255-$red;
$rgreen = 255-$green;
$rblue = 255-$blue;
$textColor = ImageColorAllocate($captchaImage, $rred, $rgreen, $rblue);

imagefttext($captchaImage, $fontSize, 0, $textX, $textY, $textColor, $font, $verify_string);

$angle = mt_rand(-3, 3);
$captchaImage = imagerotate($captchaImage, $angle, $backgroundColor);


$line = ImageColorAllocate($captchaImage, $rred, $rgreen, $rblue);

for($i = 0; $i < 10; $i++)
{
   $xStart = mt_rand(0, $containerWidth);
   $yStart = mt_rand(0, $containerHeight);
   $xEnd = mt_rand(0, $containerWidth);
   $yEnd = mt_rand(0, $containerHeight);
   imageline($captchaImage, $xStart, $yStart, $xEnd, $yEnd, $line);
}


imagefilter($captchaImage, IMG_FILTER_CONTRAST, 1);
//imagefilter($captchaImage, IMG_FILTER_BRIGHTNESS, 10);

//imagefilter($captchaImage, IMG_FILTER_EDGEDETECT);
imagefilter($captchaImage, IMG_FILTER_GAUSSIAN_BLUR);

header('Content-Type:image/png');
ImagePNG($captchaImage);
?>

 

The second issue I am having is with the BotBattle module. I have placed it into the 'modules' directory. I've attempted to go to the http://www.yoursitehere.com/index.php?mod=BotBattle&act=install link to install the BotBattle module and it doesn't bring up anything; it only seems to bring me back to the index page. Of course I change the 'yoursitehere.com' part to my own address.

The link to the code is here;

http://ezrpg.uaktech.net/archives/showthread.php?tid=3

Edited by dwandswforlife
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...