Login Captcha

geovasilakos wrote on Wednesday, March 14, 2012:

Hi,

I’m trying to incorporate a captcha mechanism (http://www.phpcaptcha.org/) at OpenEMR Login screens. I did it successfuly for the insite patient portal but i can’t manage it to work for the main site.

So far I have set the input and image fields at the login form. I tried the following code both at openemr/library/auth.inc and interface/main/main_screen.php without success :

session_start();
include_once ‘path/to/openemr/securimage/securimage.php’;
$securimage = new Securimage();

if ($securimage->check($_POST) == false) {
    echo "Wrong captcha code! : ".$_POST;
    exit();
}

When I have the above code at auth.inc I always get the "Wrong captcha code: " and the code I entered.

When I have it at the top of main_screen.php it works as expected but after the successful login all the frames have the “Site ID is missing from session data!”. If I move the include_once("…/globals.php"); before the captcha check, I always get  the "Wrong captcha code: " and the code I entered.

With some debuging I found that in the cases of always failure, the $securimage->getCode() function returns nothing instead of the expected captcha text. You can browse the Securimage class here : here

Can someone help me with this?