Index: openacs-4/packages/captcha/captcha.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/captcha/captcha.info,v diff -u -r1.1.2.3 -r1.1.2.4 --- openacs-4/packages/captcha/captcha.info 13 Jul 2023 13:12:31 -0000 1.1.2.3 +++ openacs-4/packages/captcha/captcha.info 13 Oct 2023 06:27:19 -0000 1.1.2.4 @@ -9,7 +9,7 @@ f f - + Antonio Pisano A captcha implementation for the template system 2022-06-26 @@ -22,13 +22,16 @@ work on macOS 0 - + - + - + Index: openacs-4/packages/captcha/tcl/captcha-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/captcha/tcl/captcha-procs.tcl,v diff -u -r1.1.2.6 -r1.1.2.7 --- openacs-4/packages/captcha/tcl/captcha-procs.tcl 29 Aug 2023 14:10:37 -0000 1.1.2.6 +++ openacs-4/packages/captcha/tcl/captcha-procs.tcl 13 Oct 2023 06:27:19 -0000 1.1.2.7 @@ -143,6 +143,35 @@ close $wfd } +ad_proc -private captcha::backend {} { + @return the captcha backend used to generate the image +} { + set backend [::parameter::get_global_value \ + -package_key captcha \ + -parameter backend \ + -default tclgd] + if {$backend eq "tclgd"} { + try { + package require tclgd + } on error {errmsg} { + ad_log warning \ + "Cannot load tclgd library:" \ + $errmsg \ + "Falling back to convert implementation." + set backend "convert" + } + } + + if {$backend eq "convert"} { + set convert [::util::which convert] + if {$convert eq ""} { + error {'tclgd' or 'convert' command not available.} + } + } + + return $backend +} + ad_proc -private captcha::image::generate { {-size 150x50} -text @@ -163,17 +192,7 @@ text the image represents) and checksum (a checksum for the image to use for matching). } { - try { - package require tclgd - } on error {errmsg} { - set convert [::util::which convert] - if {$convert eq ""} { - error {'tclgd' or 'convert' command not available.} - } - set backend convert - } on ok {d} { - set backend tclgd - } + set backend [::captcha::backend] if {![regexp -nocase {^(\d+)x(\d+)$} $size m width height]} { error {Invalid size}