ElkArte Community

Project Support => Support => Topic started by: smilieman on May 14, 2020, 02:13:40 am

Title: Cannot Get Vertification Captcha Working
Post by: smilieman on May 14, 2020, 02:13:40 am
Good Morning!

I have installed Elkhart locally on Xampp (windows) to test prior to installing with my webhost. However, I am having trouble getting the Registration Verification Captcha to work (like it is on the Elkhart Community site).

Config -> Anti-Spam -> Require verification on registration page is enabled.

I also had the "Stop Spammer" Plugin installed, but uninstalled that in case it was having an impact. PHP GD library is installed.

There is obviously something I am missing here.....

Any help is appreciated.
Many thanks

P.S. Not going to be using Google's reCaptcha!
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on May 17, 2020, 01:56:22 pm
Further to my query, I have now installed ElkArte to a local Debian Linux virtual server to establish whether there was an issue not displaying the captcha under Xampp/Windows.

However, still no luck.

Not wanting to use Google's reCaptcha I am trying to install a similar CAPTCHA solution that ElkArte use on their registration screen (see attachment). I am now thinking that this is not inherent within ElkArts standard installation, but I cannot find a package that will provide this either.

I would appreciate any pointers.

Many thanks
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on May 17, 2020, 03:31:17 pm
Ok, so I have located the issue.

I downloaded and installed v1.1.5 and now have access to the CAPTCHA configuration in Configuration -> Security and Moderation -> Anti-Spam. The section "Configure Verification Methods" is completely missing in v1.1.6

Is this intentional, or a bug?

Cheers  ;)
Title: Re: Cannot Get Vertification Captcha Working (Nearly!)
Post by: smilieman on May 18, 2020, 09:07:16 am
Following on...

Through my investigations this morning I have found that the loading of the captcha as a verification control, is missing in 1.1.6.

Adding the missing line, enables the captcha, as below:

File: sources/subs/VerificationControls.class.php - Lines 22 - 27

'known_verifications' array missing 'captcha'

Code: [Select]
function loadVerificationControls()
{
$known_verifications = array(
  'questions',
  'emptyfield'
);

change to add captcha:
   
Code: [Select]
$known_verifications = array(
  'captcha',
  'questions',
  'emptyfield'
);

Captcha is now available and works with the following issues:

I have noticed also that the message in the admin panel is missing from themes/default/languages/english/ManageSettings.english.php

If it was intentional that graphic captcha be removed, then I would have suspected all of the code and javascript related to this to also be removed. This makes me think that maybe it was either temporary, or an error?

I cannot find any release notes for 1.1.6, so I can't check whether this is the case.

Also, I have checked sources/subs/Graphics.subs.php, with regard to the size of the captcha, to see if there are any differences between v1.1.5 and 1.1.6, but I cannot see any significant changes relating to font/images size.

I have both versions installed on the same server with the same PHP version & GD library version.

I am just trying to understand this and get captcha working in 1.1.6, with my extremely limited knowledge. The other concern that I would have is if the enabling of the captcha will break anything else, if of course it has been deliberately disabled.

Many thanks

(PHP 7.4.5, GD 2.2.4, Debian: 9.12)
Title: Re: Cannot Get Vertification Captcha Working
Post by: radu81 on May 18, 2020, 10:07:12 am
Thanks for your report.
I don't have a clean 1.1.6 install to test it right now, but I will do it tonight, if I remember correctly installing the Google Capthca add-on will remove the default captcha. Are you sure you didn't install first the Google add-on?
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on May 18, 2020, 10:55:47 am
Thanks for your reply.

Yes I am sure! There is no way I want to use Google stuff.

With further work I seemed to have now fixed the sizing issue.

In 1.1.6 there is a new check in sources/subs/Graphics.subs.php on lines 1034-1035:

Code: [Select]
if (!checkGD())
   return false;

This code was not present in 1.1.5 and commenting this out (or removing it) fixes the sizing issue nicely.

As far as the refresh goes, this didn't work in 1.1.5. Instead of the captcha contents being changed (letters), these stay the same regardless and it is only the styling that changes.

For now, this is sufficient for me to work with. However, it would be nice to know whether this will break anything somewhere else - I guess time will tell. I will be going live this week! :-)

I hope this helps.

Peace.
Title: Re: Cannot Get Vertification Captcha Working
Post by: radu81 on May 18, 2020, 03:08:23 pm
Quote from: smilieman – However, it would be nice to know whether this will break anything somewhere else - I guess time will tell.
 I'd say @emanuele‍ can give us more info ;)
Title: Re: Cannot Get Vertification Captcha Working
Post by: emanuele on May 20, 2020, 02:23:56 am
Sounds like a bug somewhere...
Okay, this evening no hair cut, but elk coding I guess.
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on May 20, 2020, 05:22:55 am
No! Haircut first!  ;D
Title: Re: Cannot Get Vertification Captcha Working
Post by: emanuele on May 20, 2020, 04:00:57 pm
Well, no joy with the hairs, I couldn't confirm today for tomorrow, so I hope the spot of tomorrow will still be available tomorrow morning for tomorrow afternoon. xD

For now tried to fix the other issue, this goes to tomorrow morning.
Title: Re: Cannot Get Vertification Captcha Working
Post by: emanuele on May 30, 2020, 11:06:44 am
@smilieman sorry for the long silence.
Could you try running this little script and tell me what it gives you?
Code: [Select]
<?php
echo '<pre>';
var_dump(get_extension_funcs('gd'));
echo '</pre>';
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on June 02, 2020, 01:07:45 pm
Hi Emanuele,

No worries. Ran the code, got this:

Code: [Select]
array(106) {
  [0]=>
  string(7) "gd_info"
  [1]=>
  string(8) "imagearc"
  [2]=>
  string(12) "imageellipse"
  [3]=>
  string(9) "imagechar"
  [4]=>
  string(11) "imagecharup"
  [5]=>
  string(12) "imagecolorat"
  [6]=>
  string(18) "imagecolorallocate"
  [7]=>
  string(16) "imagepalettecopy"
  [8]=>
  string(21) "imagecreatefromstring"
  [9]=>
  string(17) "imagecolorclosest"
  [10]=>
  string(20) "imagecolorclosesthwb"
  [11]=>
  string(20) "imagecolordeallocate"
  [12]=>
  string(17) "imagecolorresolve"
  [13]=>
  string(15) "imagecolorexact"
  [14]=>
  string(13) "imagecolorset"
  [15]=>
  string(21) "imagecolortransparent"
  [16]=>
  string(16) "imagecolorstotal"
  [17]=>
  string(19) "imagecolorsforindex"
  [18]=>
  string(9) "imagecopy"
  [19]=>
  string(14) "imagecopymerge"
  [20]=>
  string(18) "imagecopymergegray"
  [21]=>
  string(16) "imagecopyresized"
  [22]=>
  string(11) "imagecreate"
  [23]=>
  string(20) "imagecreatetruecolor"
  [24]=>
  string(16) "imageistruecolor"
  [25]=>
  string(23) "imagetruecolortopalette"
  [26]=>
  string(23) "imagepalettetotruecolor"
  [27]=>
  string(17) "imagesetthickness"
  [28]=>
  string(14) "imagefilledarc"
  [29]=>
  string(18) "imagefilledellipse"
  [30]=>
  string(18) "imagealphablending"
  [31]=>
  string(14) "imagesavealpha"
  [32]=>
  string(23) "imagecolorallocatealpha"
  [33]=>
  string(22) "imagecolorresolvealpha"
  [34]=>
  string(22) "imagecolorclosestalpha"
  [35]=>
  string(20) "imagecolorexactalpha"
  [36]=>
  string(18) "imagecopyresampled"
  [37]=>
  string(11) "imagerotate"
  [38]=>
  string(9) "imageflip"
  [39]=>
  string(14) "imageantialias"
  [40]=>
  string(9) "imagecrop"
  [41]=>
  string(13) "imagecropauto"
  [42]=>
  string(10) "imagescale"
  [43]=>
  string(11) "imageaffine"
  [44]=>
  string(23) "imageaffinematrixconcat"
  [45]=>
  string(20) "imageaffinematrixget"
  [46]=>
  string(21) "imagesetinterpolation"
  [47]=>
  string(12) "imagesettile"
  [48]=>
  string(13) "imagesetbrush"
  [49]=>
  string(13) "imagesetstyle"
  [50]=>
  string(18) "imagecreatefrompng"
  [51]=>
  string(19) "imagecreatefromwebp"
  [52]=>
  string(18) "imagecreatefromgif"
  [53]=>
  string(19) "imagecreatefromjpeg"
  [54]=>
  string(19) "imagecreatefromwbmp"
  [55]=>
  string(18) "imagecreatefromxbm"
  [56]=>
  string(18) "imagecreatefromxpm"
  [57]=>
  string(17) "imagecreatefromgd"
  [58]=>
  string(18) "imagecreatefromgd2"
  [59]=>
  string(22) "imagecreatefromgd2part"
  [60]=>
  string(18) "imagecreatefrombmp"
  [61]=>
  string(18) "imagecreatefromtga"
  [62]=>
  string(8) "imagepng"
  [63]=>
  string(9) "imagewebp"
  [64]=>
  string(8) "imagegif"
  [65]=>
  string(9) "imagejpeg"
  [66]=>
  string(9) "imagewbmp"
  [67]=>
  string(7) "imagegd"
  [68]=>
  string(8) "imagegd2"
  [69]=>
  string(8) "imagebmp"
  [70]=>
  string(12) "imagedestroy"
  [71]=>
  string(17) "imagegammacorrect"
  [72]=>
  string(9) "imagefill"
  [73]=>
  string(18) "imagefilledpolygon"
  [74]=>
  string(20) "imagefilledrectangle"
  [75]=>
  string(17) "imagefilltoborder"
  [76]=>
  string(14) "imagefontwidth"
  [77]=>
  string(15) "imagefontheight"
  [78]=>
  string(14) "imageinterlace"
  [79]=>
  string(9) "imageline"
  [80]=>
  string(13) "imageloadfont"
  [81]=>
  string(12) "imagepolygon"
  [82]=>
  string(16) "imageopenpolygon"
  [83]=>
  string(14) "imagerectangle"
  [84]=>
  string(13) "imagesetpixel"
  [85]=>
  string(11) "imagestring"
  [86]=>
  string(13) "imagestringup"
  [87]=>
  string(7) "imagesx"
  [88]=>
  string(7) "imagesy"
  [89]=>
  string(12) "imagesetclip"
  [90]=>
  string(12) "imagegetclip"
  [91]=>
  string(15) "imagedashedline"
  [92]=>
  string(12) "imagettfbbox"
  [93]=>
  string(12) "imagettftext"
  [94]=>
  string(11) "imageftbbox"
  [95]=>
  string(11) "imagefttext"
  [96]=>
  string(10) "imagetypes"
  [97]=>
  string(9) "jpeg2wbmp"
  [98]=>
  string(8) "png2wbmp"
  [99]=>
  string(10) "image2wbmp"
  [100]=>
  string(16) "imagelayereffect"
  [101]=>
  string(8) "imagexbm"
  [102]=>
  string(15) "imagecolormatch"
  [103]=>
  string(11) "imagefilter"
  [104]=>
  string(16) "imageconvolution"
  [105]=>
  string(15) "imageresolution"
}
Title: Re: Cannot Get Vertification Captcha Working
Post by: emanuele on June 05, 2020, 01:13:13 pm
hmm...
That's odd, because checkGD reads:
Code: [Select]
function checkGD()
{
global $gd2;

// Check to see if GD is installed and what version.
if (($extensionFunctions = get_extension_funcs('gd')) === false)
return false;

// Also determine if GD2 is installed and store it in a global.
$gd2 = in_array('imagecreatetruecolor', $extensionFunctions) && function_exists('imagecreatetruecolor');

return true;
}

so, since get_extension_funcs returns something, it should evaluate to false, meaning it returns true and removing the bits you have removed should not make any difference.

Try something slightly different, run this:
Code: [Select]
<?php
function checkGD()
{
global $gd2;

// Check to see if GD is installed and what version.
if (($extensionFunctions = get_extension_funcs('gd')) === false)
return false;

// Also determine if GD2 is installed and store it in a global.
$gd2 = in_array('imagecreatetruecolor', $extensionFunctions) && function_exists('imagecreatetruecolor');

return true;
}

global $gd2;
if (!checkGD())
echo "not gd\n";
else
echo "yes gd\n";

and see what the result is.
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on June 06, 2020, 11:50:03 am
Ok, so nothing is returned in a browser.... but from the command line we get

yes gd

 :)
Title: Re: Cannot Get Vertification Captcha Working
Post by: emanuele on June 11, 2020, 12:01:01 pm
Then I have the feeling you are using two different versions of php, one for the CLI and one for apache...
Aaaand this is something I have no idea how to solve, server config is out of my league.
Title: Re: Cannot Get Vertification Captcha Working
Post by: badmonkey on June 11, 2020, 12:23:49 pm
Quote from: smilieman – Ok, so nothing is returned in a browser.... but from the command line we get

yes gd

 :)
 
 The correct way to verify is in the elk site's ACP > Server Settings > PHP Info. This page will display info for the php version used by the site. Like eman says, it's possible your server has multiple php versions installed. Once the correct version is identified, also note in the same page the gd info. We can help walk you through the extension install, if need be. 
Title: Re: Cannot Get Vertification Captcha Working
Post by: ahrasis on June 11, 2020, 08:19:17 pm
I'd say he doesn't have gd install for its web site php as the browser returns with nothing but I agree you should check in details as advised by @badmonkey.

If you have multiple php in your server, ensure the one you assigned to your web site has gd installed.
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on June 13, 2020, 11:47:59 am
Well, that may be more up my street then!  I shall take a look, however I am getting the same issues on 3 different installations - 2 local (Windows & Debian) and one on my web host (Linux).

I shall confirm versions and run the code on all 3 see if anything pops out!

Cheers
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on June 14, 2020, 11:29:52 am
Ok, so here's the verdict - I ran the script on all:

Webhost: phpinfo(): PHP 7.2.31, with gd support (2.1.0 compat.) - yes gd function exists

Local Windows:  phpinfo(): PHP 7.3.1,  with gd support (2.1.0 compat.) - yes gd function exists

Local Debian:   phpinfo(): PHP 7.4.5   with gd support (headers v2.2.5, library v2.24) - blank in browser, 'yes gd' (terminal window)
 - you correctly stated that there could be 2 PHP versions on this system, there are:
 
Code: [Select]
# apt show php -a

shows
    - php7.4
    - php7.0 - dependancy package for php7.4

To save confusion, I shall forget using the Debian local install as this could cause confusion.

Hope this helps put things into perspective - sorry for confusing things.

Cheers
Title: Re: Cannot Get Vertification Captcha Working
Post by: emanuele on June 17, 2020, 12:50:35 pm
And running the script from https://www.elkarte.net/community/index.php?topic=5790.msg40890#msg40890 gives always the same result?
So nothing?

But... wait a moment, now that I re-read your reply I got a bit "worried":
Quote from: smilieman – Ok, so nothing is returned in a browser....
So you get an empty page, not even the "not gd"?
In that case, then, the problem could be different, it may be that get_extension_funcs is not provided by your php (or disabled for security?) and that part fails even before completing...

Could you please try this calling the script from your browser?
Code: [Select]
<?php

if (function_exists('get_extension_funcs'))
echo 'We have the function';
else
echo 'No joy, sorry';
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on June 19, 2020, 06:48:58 am
Ok, so it turns out that the reason for nothing appearing in the browser was due to file-system permissions, where apache didn't have the right permissions to the folder, on the test system that I built - rookie error  :(  !  - This is now resolved and I now have browser output.

So, checkGD() on all installations - Win XAMPP, Debian & Webhost, now gives:
Code: [Select]
yes gd function exists

and, get_extension_funcs returns:
Code: [Select]
We have the function

So, worry not my friend  :)

So I take it that we now know that GD in installed, active and functional?

Cheers
Title: Re: Cannot Get Vertification Captcha Working
Post by: emanuele on June 21, 2020, 04:59:35 pm
Quote(PHP 7.4.5, GD 2.2.4, Debian: 9.12)
This.

1.1.x doesn't support properly 7.3 and above.
7.2 should work fine.

That said, the code has something buggy anyway, for example the admin panel for the captcha is broken. :-\
Title: Re: Cannot Get Vertification Captcha Working
Post by: smilieman on July 17, 2020, 09:53:46 am
Sooooo.....

Referring to the comment in one of my early posts as to whether the code I commented would actually break anything (https://www.elkarte.net/community/index.php?topic=5790.msg40858#msg40858).....

Do we know if it would actually break anything?

I haven't come across any issues yet and everything seems to work fine, so hopefully it is ok....

Cheers