TOPIC:

captcha image is not seen on my website from PHP version 7.3, 7.4, 8.0 2 years 6 months ago #256567

  • Topic Author
  • Bushka
  • Offline
  • New Member
  • New Member
  • Registered
  • Posts: 1
  • Thanks: 0
captcha image is not working, once the php version is upgraded to 7.4 no captcha image is seen. can you please help? Below is the code that does not work in php versions 7.3 onwards till 8.0

<?php
session_start();

/*
* File: CaptchaSecurityImages.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 03/08/06
* Updated: 07/02/07
* Requirements: PHP 4/5 with GD and FreeType libraries
* Link: www.white-hat-web-design.co.uk/blog/php-...cha-security-images/

*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* www.gnu.org/licenses/gpl.html
*
*/

class CaptchaSecurityImages {

var $font = 'monofont.ttf';

function generateCode($characters) {

/* list all possible characters, similar looking characters and vowels have been removed */
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$code = '';
$i = 0;
while ($i < $characters) {
$code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
$i++;
}

return $code;
}

function CaptchaSecurityImages($width='120',$height='40',$characters='6') {

$code = $this->generateCode($characters);
/* font size will be 75% of the image height */
$font_size = $height * 0.75;
$image = imagecreate($width, $height) or die('Cannot initialize new GD image stream');
/* set the colours */

$background_color = imagecolorallocate($image, 255, 255, 255);
$text_color = imagecolorallocate($image, 0, 100, 0);
$noise_color = imagecolorallocate($image, 34, 139, 34);
/* generate random dots in background */

for( $i=0; $i<($width*$height)/3; $i++ ) {

imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color);
}

/* generate random lines in background */
for( $i=0; $i<($width*$height)/150; $i++ ) {

imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color);
}

/* create textbox and add text */
$textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
$x = ($width - $textbox[4])/2;
$y = ($height - $textbox[5])/2;
imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function');
/* output captcha image to browser */

header('Content-Type: image/jpeg');
imagejpeg($image);
imagedestroy($image);
$_SESSION = $code;
}

}

$width = isset($_GET) && $_GET < 600 ? $_GET : '120';

$height = isset($_GET) && $_GET < 200 ? $_GET : '40';

$characters = isset($_GET) && $_GET > 2 ? $_GET : '6';

$captcha = new CaptchaSecurityImages($width,$height,$characters);

?>

Please Log in or Create an account to join the conversation.

captcha image is not seen on my website from PHP version 7.3, 7.4, 8.0 2 years 5 months ago #256584

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Registered
  • Posts: 12079
  • Thanks: 788
Hi,

captcha image is not shown in breezingforms?
Which version of breezingforms are you using?

Regards,
Tihana

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.044 seconds

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Subscribe to news and updates!

Special Offer

Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!

Live Support Chat Opened!

Join our Discord chat here and enter the Crosstec channels to receive live support and talk directly to the team!