Skip to content

Commit

Permalink
fix compatability PHP 8.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
lubosdz committed Nov 7, 2023
1 parent 06ae5e6 commit 75f1b9c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 42 deletions.
38 changes: 0 additions & 38 deletions CHANGELOG.md

This file was deleted.

8 changes: 4 additions & 4 deletions CaptchaExtendedAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function getVerifyCode($regenerate = false)
$codeResult = $this->generateVerifyCode();
$session[$name] = $codeResult['code'];
$session[$name.'count'] = 1;
$session[$name.'result'] = preg_replace('/\s+/', '', $codeResult['result']); // white-space ignorant
$session[$name.'result'] = preg_replace('/\s+/u', '', $codeResult['result']); // white-space ignorant
}

return $session[$name];
Expand Down Expand Up @@ -191,7 +191,7 @@ public function getVerifyResult($regenerate = false)
*/
public function generateValidationHash($result)
{
$result = preg_replace('/\s+/', '', $result);
$result = preg_replace('/\s+/u', '', $result);
$result = urlencode($result); // convert accented characters to ASCII

for ($h = 0, $i = strlen($result) - 1; $i >= 0; --$i) {
Expand All @@ -217,7 +217,7 @@ public function validate($input, $caseSensitive){
$result = $session[$key.'result'];

// input always without whitespaces
$input = preg_replace('/\s+/', '', $input);
$input = preg_replace('/\s+/u', '', (string) $input);
$valid = $caseSensitive ? strcmp($input, $result) === 0 : strcasecmp($input, $result) === 0;

// increase attempts counter, but not in case of ajax-client validation (that is always POST request having variable 'ajax')
Expand Down Expand Up @@ -324,7 +324,7 @@ protected function getCodeWords()
}

$words = file_get_contents($this->fileWords);
$words = preg_split('/\s+/', $words);
$words = preg_split('/\s+/u', $words);
$found = [];

for($i = 0; $i < count($words); ++$i){
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,51 @@ public function rules()
* also note standard properties supported by framework: `width`, `height`, `padding`, `offset`, `foreColor`, `backColor`, `transparent`, `minLength`, `maxLength`, ..

7) Enjoy! :-)


Changelog
=========

Version 1.0.5 - Nov 7, 2023
------------------------------

- PHP 8.2+ compatability
- enable unicode in REGEX by default (/u modifier)


Version 1.0.4 - Jun 30, 2021
------------------------------

- updated SK, CS words (dropped accented characters)


Version 1.0.3 - Jun 07, 2020
------------------------------

- minor compatability fix for PHP 7.4+


Version 1.0.2 - Feb 25, 2020
------------------------------

- configurable refresh parameter in URL
- updated docs


Version 1.0.1 - May 21, 2018
------------------------------

- added CS (Czech) words file
- center formula horizontaly
- updated documentation


Version 1.0.0 - March 28, 2018
------------------------------

- rework of previous extension for Yii 1.x branch
- added new options - custom character sets, resultMultiplier, randomUpperLowerCase, Imagick support
- couple of potential bugfixes e.g. calculating pixel color ranges
- full multibyte (MB) support
- added support for installation via composer

0 comments on commit 75f1b9c

Please sign in to comment.