My-Little-Forum / mylittleforum

A simple PHP and MySQL based internet forum that displays the messages in classical threaded view (tree structure)
GNU General Public License v3.0
122 stars 48 forks source link

Fix failing imagerotate with 180° rotation (rare corner case) #668

Closed auge8472 closed 1 year ago

auge8472 commented 1 year ago

As reported in the project forum and documented in issue #658 it is possible, that the function imagerotate does not work with the rotation angle of exactly 180° in very rare cases. Leaving aside the fact that the concept of captchas is absolutely out of date and thinking about the current solution in modules/captcha/captcha.php it is …

  1. … IMHO not ideal to rely on a chance of 0 or 1 to try to rotate the image or not and …
  2. … to rotate the background exclusively with an angle of 180° or not (0°)

Thatswhy I replaced the rotation (with imagerotate) with a mirroring with the function imageflip, which provides three modes (horizontal, vertical and both at once) to generate the resulting image. The new solution decides if to rotate or not with a random number in the range from 0 to 5 and the criterion of the number being even or odd. The mode of the mirroring is set with a further random number in the range from 0 to 2, that selects the mode to use from an array. See therefor 972e6da9dbf4a3e3cb49fc2844bd311909a9f0ba.

Furthermore I reformatted the files modules/captcha/captcha.php and modules/captcha/captcha_image.php. See therefor de7923c31cbd5774567516573b6feb3cb9d336d3 and 1e9d98c5d6c54e8c4752178b010216c8bca1160f

auge8472 commented 1 year ago

@loesler

vihuna stated this to be successfully tested in a comment in issue #658 but with protecting the base branch of the repository here in Github, a review is mandatory.

loesler commented 1 year ago

... with protecting the base branch of the repository here in Github, a review is mandatory.

Just a general remark: I can understand this option but I already have little time to help so I do not want to use these small time frames for reviewing code.

auge8472 commented 1 year ago

I can understand this option but I already have little time to help so I do not want to use these small time frames for reviewing code.

I can fully understand you. I will check, if I can change the configuration in a apprpriate manner.