function wpcf7_init_captcha() { static $captcha = null; if ($captcha) { return $captcha; } if (class_exists('ReallySimpleCaptcha')) { $captcha = new ReallySimpleCaptcha(); } else { return false; } $dir = trailingslashit(wpcf7_captcha_tmp_dir()); $captcha->tmp_dir = $dir; if (is_callable(array($captcha, 'make_tmp_dir'))) { $result = $captcha->make_tmp_dir(); if (!$result) { return false; } return $captcha; } if (wp_mkdir_p($dir)) { $htaccess_file = $dir . '.htaccess'; if (file_exists($htaccess_file)) { return $captcha; } if ($handle = @fopen($htaccess_file, 'w')) { fwrite($handle, 'Order deny,allow' . "\n"); fwrite($handle, 'Deny from all' . "\n"); fwrite($handle, '<Files ~ "^[0-9A-Za-z]+\\.(jpeg|gif|png)$">' . "\n"); fwrite($handle, ' Allow from all' . "\n"); fwrite($handle, '</Files>' . "\n"); fclose($handle); } } else { return false; } return $captcha; }