Skip to content

captcha in e107  #9

Description

@Jimmi08

Hi, you may know this is how I get this but I could forget it soon :)

image

At first - that not readable code is intention. Those fonts are used random:
image

The only readable one is, so I hardcoded it :
$secureimg['font'] = "crazy_style.ttf";

Another option is to save the needed font (they use Arial at codepen) as those 3 fonts.

Now coloring...

After header("Content-type: image/{$type}"); in secure_img_handler.php or look for imagettftext in that file

		if(!empty($fontFile))
		{
			$text = $code;  //just not mess variables
		        $font_size = $secureimg['size'];
			$y = $secureimg['y']; 
			$height = 35;  //where is this set?  it is height of image, very hard to centered vertically, 
			$font = $fontFile;
  
			for ($i = 0; $i < strlen($text); $i++)
			{
				// Set a random text color
				$text_color = imagecolorallocate($image, rand(0, 255), rand(0, 255), rand(0, 255));

				// Calculate the position to display the current character
				$x = $i * $font_size * 0.9; 
                                // 0.9  - control the spacing, but width of image is defined somewhere so 1.1 is max
				$y = $height / 2 + $font_size / 2;

				// Add the current character to the image
				imagettftext($image, $font_size, 0, $x, $y, $text_color, $font, $text[$i]);
			}
			//original code
			//imagettftext($image, $secureimg['size'],$secureimg['angle'], $secureimg['x'], $secureimg['y'], $text_color, $fontFile, $code);
		}
		else
		{
			imagestring ($image, 5, 12, 2, $code, $text_color);
		}

it is in the render() method and it can be overridden with the plugin (I used it in recaptcha plugin) - to avoid the change of core files.
But those available fonts are real issue.

I will wait for reactions to your topic on e107, But the spams know to read very easy captcha. There should be next way - like to use fake email field or similar stuff.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions