Full refactoring of the register functionality

Refactored the user register functionality. Separated the presentation
from the business logic, added a registration-model returning json
responses with status and message. renamed db_functions to utils.php and
moved several utility methods there. The old acc_functions.php still
stays, for backward compatibility and for  the login, that will be
refactored too.