Support » Plugin: Really Simple CAPTCHA » Captcha images not showing with Windows/Apache/PHP

  • 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.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Captcha images not showing with Windows/Apache/PHP’ is closed to new replies.