Fixes #1140 Captcha doesn't show up after too many failed login attempts

#1140

I updated some files to make use of the new `get_user_by_username()` function (no sure how those were missed).
Where does $user['loginattempts'] come from? $user defined some lines above doesn't contain this key. Also why do you (int) an integer value coming from the database?