#1 2023-12-21 16:59:37

OpenPicture
Member
2023-12-19
57

[Plugin] Crypto Captcha

Hello,

I have the following error with the extension Crypto Captcha in Piwigo 140.0 with PHP 8.1:

PHP Fatal error:  Array and string offset access syntax with curly braces is no longer supported in /plugins/CryptograPHP/securimage/securimage.php on line 2202

Here is the line 2202 :
for($i = 0; $i < $length; ++$i) {
    $letter    = $code['display']{$i};
    $letters[] = $letter;
}

I replaced the code with:

for ($i = 0; $i < $length; ++$i) {
    $letter    = $code['display'][$i];
    $letters[] = $letter;
}

and the error dispappeared.

But there are more errors with PHP 8.1 (in PHP 7.4, there is no error):

PHP Deprecated:  Implicit conversion from float 61.54649236782528 to int loses precision in /plugins/CryptograPHP/securimage/securimage.php on line 2061 :

Here is the line 2061 :
for ($i = 0; $i < $n; ++ $i) {
     $x = $x0 + $i * $dx + $amp * $dy * sin($k * $i * $step + $phi);
     $y = $y0 + $i * $dy - $amp * $dx * sin($k * $i * $step + $phi);
     imagefilledrectangle($this->im, $x, $y, $x + $lwid, $y + $lwid, $this->gdlinecolor);
}

Could you help with this one?

Offline

 

#2 2023-12-27 15:05:00

OpenPicture
Member
2023-12-19
57

Re: [Plugin] Crypto Captcha

Would anyone here have time to say something about this or maybe help resolve the issue with this plugin?

Offline

 

#3 2023-12-27 21:00:24

OpenPicture
Member
2023-12-19
57

Re: [Plugin] Crypto Captcha

When I switch on and off in admin/Plugins the Crypto Captcha plugin I also get the following error:

PHP Deprecated:  Using php-function "trim" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /include/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114
PHP Deprecated:  Using php-function "strtolower" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /include/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114
PHP Deprecated:  Using php-function "md5" as a modifier is deprecated and will be removed in a future release. Use Smarty::registerPlugin to explicitly register a custom modifier. in /include/smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php on line 114

Offline

 

#4 2024-02-06 23:13:03

rocket
Translation Team
2012-07-06
13

Re: [Plugin] Crypto Captcha

Hi! Did you resolve this issue?
In my case there are no errors in logs at all. It just not rendering on user registration page.

Offline

 

#5 2024-11-05 18:40:03

OpenPicture
Member
2023-12-19
57

Re: [Plugin] Crypto Captcha

I finally managed to get Crypto Captcha (Version 2.2.1) working with Bootstrap Darkroom, Piwigo 15.0 and PHP 8.2.

So far it works with no errors for registering as a new user and adding comments.

You can test it yourself here:

https://konscht.com/artists/

Last edited by OpenPicture (2024-11-05 18:41:38)

Offline

 

#6 2024-11-07 14:41:18

OpenPicture
Member
2023-12-19
57

Re: [Plugin] Crypto Captcha

I tested the modification for 2 days now and got no error.

Therefore for those who would like to use Crypto Captcha (Version 2.2.1) with Bootstrap Darkroom 15.a, Piwigo 15.0 and PHP 8.2, I'll share the code with you:

1. in /plugins/CryptograPHP/securimage/securimage.php on line 2202" (line 2201-2204) simply replace the curly braces {} with square brackets []:

Code:

for($i = 0; $i < $length; ++$i) {
                $letter    = $code['display']{$i};
                $letters[] = $letter;
            }".

with

Code:

for($i = 0; $i < $length; ++$i) {
    $letter    = $code['display'][$i]; // Change {$i} to [$i]
    $letters[] = $letter;
}

.

2.  in /plugins/CryptograPHP/securimage/securimage.php add these properties within the class at the beginning of the Securimage class definition, because of deprecated code error on line 1196 and 2362:

Code:

class Securimage
{
    // Define properties to prevent deprecated dynamic property errors
    public $code_entered = '';
    public $correct_code = false;
   // The rest of the class remains unchanged...

3.  in /plugins/CryptograPHP/include/picture.inc.php replace the whole code with:

Code:

<?php
defined('CRYPTO_PATH') or die('Hacking attempt!');

// Enable error reporting
// error_reporting(E_ALL);
// ini_set('display_errors', 1);

// Include the common CAPTCHA setup file
$conf['cryptographp']['template'] = 'comment';
include(CRYPTO_PATH.'include/common.inc.php');

// Register event handlers
add_event_handler('loc_end_picture', 'add_crypto');
add_event_handler('loc_end_picture_info_comments', 'add_crypto');
add_event_handler('user_comment_check', 'check_crypto', EVENT_HANDLER_PRIORITY_NEUTRAL, 2);

function add_crypto()
{
    global $template;
    
    // Log to confirm the function is being called
    // error_log("add_crypto function called.");
    
    // Use the prefilter to insert CAPTCHA in comments
    $template->set_prefilter('picture', 'prefilter_crypto');
    $template->set_prefilter('picture_info_comments', 'prefilter_crypto');
}

function prefilter_crypto($content)
{
    // Adjust to match the comment text area placeholder exactly
    $search = '<textarea class="form-control" name="content" id="contentid" rows="5" cols="50">{$comment_add.CONTENT}</textarea>';
    $replacement = $search . "\n{\$CRYPTO.parsed_content}";

    // Log if the search string is found for easier debugging
    if (strpos($content, $search) === false) {
        error_log("Search string '{$search}' not found in template.");
    } else {
        error_log("Search string found, applying replacement.");
    }

    return str_replace($search, $replacement, $content);
}

function check_crypto($action, $comment)
{
    global $conf, $page;

    // Include the securimage class
    include_once(CRYPTO_PATH . 'securimage/securimage.php');
    $securimage = new Securimage();

    // Perform CAPTCHA validation
    if (empty($_POST['captcha_code']) || $securimage->check($_POST['captcha_code']) == false) {
        $page['errors'][] = l10n('Invalid Captcha. Please try again.');
        
        // Ensure it rejects the comment by returning 'reject'
        return 'reject';
    }

    // If CAPTCHA is valid, proceed normally
    return $action;
}

4. in /plugins/CryptograPHP/template/register.tpl at the beginning I added a <br>:

Code:

</li>
<li><br>
  <span class="property">

5. in /plugins/CryptograPHP/template/comment.tpl at the beginning I added a <br>:

Code:

<br><p><label>

Offline

 

#7 2025-02-14 11:41:18

jheinitz
Member
2015-02-16
24

Re: [Plugin] Crypto Captcha

Hello!

I followed your suggestions, but still don't get it working. I finally figured out that my setup is running, when I use PHP 8.1 while it is not working with PHP 8.2.

Any ideas?

@OpenPicture, do you really use PHP 8.2 with your setup?

Thanks and kind regards

Jens

Last edited by jheinitz (2025-02-14 11:41:49)

Offline

 

#8 2025-02-14 16:57:30

OpenPicture
Member
2023-12-19
57

Re: [Plugin] Crypto Captcha

Hello Jens,

Here is my environment with the activated plugin list:

Environment:

Piwigo 15.2.0 Check for upgrade
Installed on 26 November 2016, 8 years 2 months 2 weeks 4 days ago
Operating system: Linux
PHP: 8.2.27 (Show info) [2025-02-14 15:45:15]
MySQL: 8.0.40-cll-lve [2025-02-15 04:45:15]
Graphics Library: ImageMagick ImageMagick 6.9.13-17
Cache size 1772.65 Mo   calculated 1 month ago Refresh

Activated plugin list 34:

Add < head > element
Change who added photo
Charlie's content 3.5
Check Uploads
Community
Crypto Captcha
Edit Filename
Embedded Videos
Extended Description
Grum Plugins Classes.3
GThumb+
Header Manager
Language Switch
Language Switch Menubar
LocalFiles Editor
Media Icon
Meta Open Graph
Most Commented
Permalink Generator
Perso Footer
Personal Favicon
Personal Plugin
Photo Update
Posted Date Changer
PWG Stuffs
Rotate Image
RV Thumb Scroller
SmartAlbums
Smilies Support
Stop Spammers
Thumbnail Tooltip
Update Album
user delete photo
User Tags

Maybe that there is a conflict with another plugin?

You can see it working here with the comment and register section: https://konscht.com/artists/

What errors are you encountering under PHP 8.2?

Could you give me the link to your site?

Offline

 

#9 2025-02-15 21:46:51

jheinitz
Member
2015-02-16
24

Re: [Plugin] Crypto Captcha

Hello!

I finally get it working. I need to implement some changes to securimage.php taken from version 4.0.2. I opened a Pull Request on GitHub even with knowing that it is currently not maintained.

Here is the Link to the GitHub PR: https://github.com/Piwigo/Piwigo-Crypto-Captcha/pull/6

Links to my Galleries:
Production site still using PHP 7.4: https://ebo-eisenbahn.de
Test site using PHP 8.2: https://debian.ebo-eisenbahn.de

I'm also struggling with the Guestbook Plugin. This is not compatible with PHP 8.1 and PHP 8.2. Are you using it?

Kind regards

Jens

Offline

 

#10 2025-02-16 22:53:32

OpenPicture
Member
2023-12-19
57

Re: [Plugin] Crypto Captcha

Hello Jens,

I'm glad that you got Crypto Captcha running under PHP 8.2.

Thank you for the links to your websites, which I also really like and also for giving me the link to Crypto Captcha, where I'll take a closer look at the whole thing.

I haven't looked into the Guestbook plugin yet, but I'll try it out in the near future.

Best regards,

OpenPicture

Last edited by OpenPicture (2025-02-16 22:55:20)

Offline

 

#11 2025-12-10 15:48:21

OpenPicture
Member
2023-12-19
57

Re: [Plugin] Crypto Captcha

Hello Jens,

I updated the Crypto Captcha plugin so that it's compatible with Piwigo 16.1 and PHP 8.4. I have added a Captcha option to the Login form. It should now also work with the Contactform and Guestbook plugins together with the Bootstrap Darkroom theme.

You can check it here: Login to my Website.

There is a pull request from my Github account: Modified Crypto Captcha on Github to the Piwigo team.

Best regards,

OpenPicture

Last edited by OpenPicture (2025-12-10 15:49:49)

Offline

 

Board footer

Powered by FluxBB

github linkedin newsletter Piwigo.org © 2002-2026 · Contact