Zeile 26 | Zeile 26 |
---|
$max_angle = 30;
$mybb->input['imagehash'] = $mybb->get_input('imagehash');
|
$max_angle = 30;
$mybb->input['imagehash'] = $mybb->get_input('imagehash');
|
if($mybb->input['imagehash'] == "test") { $imagestring = "MyBB"; } elseif($mybb->input['imagehash'])
| if($mybb->input['imagehash'])
|
{ $query = $db->simple_select("captcha", "*", "imagehash='".$db->escape_string($mybb->get_input('imagehash'))."' AND used=0", array("limit" => 1)); $regimage = $db->fetch_array($query);
| { $query = $db->simple_select("captcha", "*", "imagehash='".$db->escape_string($mybb->get_input('imagehash'))."' AND used=0", array("limit" => 1)); $regimage = $db->fetch_array($query);
|
Zeile 72 | Zeile 68 |
---|
if(count($ttf_fonts) > 0) { $use_ttf = 1;
|
if(count($ttf_fonts) > 0) { $use_ttf = 1;
|
} else {
| } else {
|
$use_ttf = 0;
|
$use_ttf = 0;
|
}
| }
|
// Check for GD >= 2, create base image if(gd_version() >= 2)
| // Check for GD >= 2, create base image if(gd_version() >= 2)
|
Zeile 84 | Zeile 80 |
---|
$im = imagecreatetruecolor($img_width, $img_height); } else
|
$im = imagecreatetruecolor($img_width, $img_height); } else
|
{
| {
|
$im = imagecreate($img_width, $img_height);
|
$im = imagecreate($img_width, $img_height);
|
}
| }
|
// No GD support, die. if(!$im) { die("No GD support.");
|
// No GD support, die. if(!$im) { die("No GD support.");
|
}
| }
|
// Fill the background with white $bg_color = imagecolorallocate($im, 255, 255, 255); imagefill($im, 0, 0, $bg_color);
// Draw random circles, squares or lines?
|
// Fill the background with white $bg_color = imagecolorallocate($im, 255, 255, 255); imagefill($im, 0, 0, $bg_color);
// Draw random circles, squares or lines?
|
$to_draw = my_rand(0, 2);
| $to_draw = rand(0, 2);
|
if($to_draw == 1) { draw_circles($im);
| if($to_draw == 1) { draw_circles($im);
|
Zeile 131 | Zeile 127 |
---|
/** * Draws a random number of lines on the image. *
|
/** * Draws a random number of lines on the image. *
|
* @param resource The image.
| * @param resource $im The image.
|
*/ function draw_lines(&$im)
|
*/ function draw_lines(&$im)
|
{ global $img_width, $img_height;
| { global $img_width, $img_height;
|
for($i = 10; $i < $img_width; $i += 10)
|
for($i = 10; $i < $img_width; $i += 10)
|
{ $color = imagecolorallocate($im, my_rand(150, 255), my_rand(150, 255), my_rand(150, 255));
| { $color = imagecolorallocate($im, rand(150, 255), rand(150, 255), rand(150, 255));
|
imageline($im, $i, 0, $i, $img_height, $color);
|
imageline($im, $i, 0, $i, $img_height, $color);
|
}
| }
|
for($i = 10; $i < $img_height; $i += 10) {
|
for($i = 10; $i < $img_height; $i += 10) {
|
$color = imagecolorallocate($im, my_rand(150, 255), my_rand(150, 255), my_rand(150, 255));
| $color = imagecolorallocate($im, rand(150, 255), rand(150, 255), rand(150, 255));
|
imageline($im, 0, $i, $img_width, $i, $color); } }
| imageline($im, 0, $i, $img_width, $i, $color); } }
|
Zeile 152 | Zeile 148 |
---|
/** * Draws a random number of circles on the image. *
|
/** * Draws a random number of circles on the image. *
|
* @param resource The image.
| * @param resource $im The image.
|
*/ function draw_circles(&$im)
|
*/ function draw_circles(&$im)
|
{ global $img_width, $img_height;
| { global $img_width, $img_height;
|
$circles = $img_width*$img_height / 100; for($i = 0; $i <= $circles; ++$i)
|
$circles = $img_width*$img_height / 100; for($i = 0; $i <= $circles; ++$i)
|
{ $color = imagecolorallocate($im, my_rand(180, 255), my_rand(180, 255), my_rand(180, 255)); $pos_x = my_rand(1, $img_width); $pos_y = my_rand(1, $img_height); $circ_width = ceil(my_rand(1, $img_width)/2); $circ_height = my_rand(1, $img_height); imagearc($im, $pos_x, $pos_y, $circ_width, $circ_height, 0, my_rand(200, 360), $color); } }
| { $color = imagecolorallocate($im, rand(180, 255), rand(180, 255), rand(180, 255)); $pos_x = rand(1, $img_width); $pos_y = rand(1, $img_height); $circ_width = ceil(rand(1, $img_width)/2); $circ_height = rand(1, $img_height); imagearc($im, $pos_x, $pos_y, $circ_width, $circ_height, 0, rand(200, 360), $color); } }
|
/** * Draws a random number of dots on the image. *
|
/** * Draws a random number of dots on the image. *
|
* @param resource The image.
| * @param resource $im The image.
|
*/ function draw_dots(&$im) { global $img_width, $img_height;
|
*/ function draw_dots(&$im) { global $img_width, $img_height;
|
|
|
$dot_count = $img_width*$img_height/5; for($i = 0; $i <= $dot_count; ++$i)
|
$dot_count = $img_width*$img_height/5; for($i = 0; $i <= $dot_count; ++$i)
|
{ $color = imagecolorallocate($im, my_rand(200, 255), my_rand(200, 255), my_rand(200, 255)); imagesetpixel($im, my_rand(0, $img_width), my_rand(0, $img_height), $color); } }
| { $color = imagecolorallocate($im, rand(200, 255), rand(200, 255), rand(200, 255)); imagesetpixel($im, rand(0, $img_width), rand(0, $img_height), $color); } }
|
/** * Draws a random number of squares on the image. *
|
/** * Draws a random number of squares on the image. *
|
* @param resource The image.
| * @param resource $im The image.
|
*/ function draw_squares(&$im) { global $img_width, $img_height;
|
*/ function draw_squares(&$im) { global $img_width, $img_height;
|
|
|
$square_count = 30; for($i = 0; $i <= $square_count; ++$i) {
|
$square_count = 30; for($i = 0; $i <= $square_count; ++$i) {
|
$color = imagecolorallocate($im, my_rand(150, 255), my_rand(150, 255), my_rand(150, 255)); $pos_x = my_rand(1, $img_width); $pos_y = my_rand(1, $img_height); $sq_width = $sq_height = my_rand(10, 20);
| $color = imagecolorallocate($im, rand(150, 255), rand(150, 255), rand(150, 255)); $pos_x = rand(1, $img_width); $pos_y = rand(1, $img_height); $sq_width = $sq_height = rand(10, 20);
|
$pos_x2 = $pos_x + $sq_height; $pos_y2 = $pos_y + $sq_width; imagefilledrectangle($im, $pos_x, $pos_y, $pos_x2, $pos_y2, $color);
| $pos_x2 = $pos_x + $sq_height; $pos_y2 = $pos_y + $sq_width; imagefilledrectangle($im, $pos_x, $pos_y, $pos_x2, $pos_y2, $color);
|
Zeile 212 | Zeile 208 |
---|
/** * Writes text to the image. *
|
/** * Writes text to the image. *
|
* @param resource The image. * @param string The string to be written
| * @param resource $im The image. * @param string $string The string to be written * * @return bool False if string is empty, true otherwise
|
*/ function draw_string(&$im, $string) {
| */ function draw_string(&$im, $string) {
|
Zeile 232 | Zeile 230 |
---|
if($use_ttf) { // Select a random font size
|
if($use_ttf) { // Select a random font size
|
$font_size = my_rand($min_size, $max_size);
| $font_size = rand($min_size, $max_size);
|
// Select a random font $font = array_rand($ttf_fonts); $font = $ttf_fonts[$font];
// Select a random rotation
|
// Select a random font $font = array_rand($ttf_fonts); $font = $ttf_fonts[$font];
// Select a random rotation
|
$rotation = my_rand($min_angle, $max_angle);
| $rotation = rand($min_angle, $max_angle);
|
// Set the colour
|
// Set the colour
|
$r = my_rand(0, 200); $g = my_rand(0, 200); $b = my_rand(0, 200);
| $r = rand(0, 200); $g = rand(0, 200); $b = rand(0, 200);
|
$color = imagecolorallocate($im, $r, $g, $b);
// Fetch the dimensions of the character being added
| $color = imagecolorallocate($im, $r, $g, $b);
// Fetch the dimensions of the character being added
|
Zeile 258 | Zeile 256 |
---|
$pos_y = ceil(($img_height-$string_height/2));
// Draw a shadow
|
$pos_y = ceil(($img_height-$string_height/2));
// Draw a shadow
|
$shadow_x = my_rand(-3, 3) + $pos_x; $shadow_y = my_rand(-3, 3) + $pos_y;
| $shadow_x = rand(-3, 3) + $pos_x; $shadow_y = rand(-3, 3) + $pos_y;
|
$shadow_color = imagecolorallocate($im, $r+20, $g+20, $b+20); imagefttext($im, $font_size, $rotation, $shadow_x, $shadow_y, $shadow_color, $font, $string[$i], array());
| $shadow_color = imagecolorallocate($im, $r+20, $g+20, $b+20); imagefttext($im, $font_size, $rotation, $shadow_x, $shadow_y, $shadow_color, $font, $string[$i], array());
|
Zeile 274 | Zeile 272 |
---|
// Calculate character offsets $pos_x = $spacing / 4 + $i * $spacing;
|
// Calculate character offsets $pos_x = $spacing / 4 + $i * $spacing;
|
$pos_y = $img_height / 2 - $string_height -10 + my_rand(-3, 3);
| $pos_y = $img_height / 2 - $string_height -10 + rand(-3, 3);
|
// Create a temporary image for this character if(gd_version() >= 2)
| // Create a temporary image for this character if(gd_version() >= 2)
|
Zeile 290 | Zeile 288 |
---|
imagecolortransparent($temp_im, $bg_color);
// Set the colour
|
imagecolortransparent($temp_im, $bg_color);
// Set the colour
|
$r = my_rand(0, 200); $g = my_rand(0, 200); $b = my_rand(0, 200);
| $r = rand(0, 200); $g = rand(0, 200); $b = rand(0, 200);
|
$color = imagecolorallocate($temp_im, $r, $g, $b);
// Draw a shadow
|
$color = imagecolorallocate($temp_im, $r, $g, $b);
// Draw a shadow
|
$shadow_x = my_rand(-1, 1); $shadow_y = my_rand(-1, 1);
| $shadow_x = rand(-1, 1); $shadow_y = rand(-1, 1);
|
$shadow_color = imagecolorallocate($temp_im, $r+50, $g+50, $b+50); imagestring($temp_im, 5, 1+$shadow_x, 1+$shadow_y, $string[$i], $shadow_color);
| $shadow_color = imagecolorallocate($temp_im, $r+50, $g+50, $b+50); imagestring($temp_im, 5, 1+$shadow_x, 1+$shadow_y, $string[$i], $shadow_color);
|
Zeile 308 | Zeile 306 |
---|
imagedestroy($temp_im); } }
|
imagedestroy($temp_im); } }
|
| return true;
|
}
| }
|