Really Simple CAPTCHA
Captcha images not showing with Windows/Apache/PHP (2 posts)

  1. rerainc
    Posted 3 years ago #

    I've resolved this issue internally, but wanted to post my findings here for others.

    I found that, when migrating a wordpress site from Linux to Windows webservers, my captcha images stopped displaying. I turned on WP_DEBUG and found a warning which stated that the fonts weren't being found. I traced the error back to the directory separator. Lines 40-43 on really-simple-captcha.php within the plugin files uses dirname( _FILE_ ) concatenated with a static path (which uses frontslashes). dirname( _FILE_ ) on my Windows webserver is returning the root path with backslashes. My quick fix was to wrap each dirname in a str_replace as follows:
    str_replace('\\','/', dirname( __FILE__ ))

    Thus, that block of code now looks like:
    /* Array of fonts. Randomly picked up per character */
    $this->fonts = array(
    str_replace('\\','/', dirname( __FILE__ )) . '/gentium/GenAI102.TTF',
    str_replace('\\','/', dirname( __FILE__ )) . '/gentium/GenAR102.TTF',
    str_replace('\\','/', dirname( __FILE__ )) . '/gentium/GenI102.TTF',
    str_replace('\\','/', dirname( __FILE__ )) . '/gentium/GenR102.TTF' );

    Unfortunately, that means I can't update this plugin without having to re-do this "fix". I'd love to hear if there are any better suggestions. I'd particularly be interested in knowing if there is a server configuration I can tweak to ensure that dirname always returns frontslashes.


  2. Takayuki Miyoshi
    Plugin Author

    Posted 3 years ago #

    Thank you for the information. I'll consider it for the future release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Really Simple CAPTCHA
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic