Exemplo n.º 1
0
}
$errorUsername = -1;
//If username exists already value = -1
$errorPasswordRepeat = -1;
//If password and password2 are not equal value = -1
$errordeviceID = -1;
unset($arr);
unset($errordeviceID, $errorUsername, $errorPasswordRepeat);
if ($loginstatusrequestflag == 1) {
    $username = $_POST["username"];
    $password = $_POST["password"];
    $password2 = $_POST["passwordRepeat"];
    $deviceID = $_POST["deviceID"];
    $authent = new authentification();
    $xmlhandler = new xmlhandler();
    if ($authent->deviceID_verification($deviceID, "deviceID.xml")) {
        $errordeviceID = 0;
    }
    if (trim($password) == trim($password2)) {
        $errorPasswordRepeat = 0;
    }
    if ($xmlhandler->searchdoubleuser(trim($username), 'userdata.xml')) {
        $errorUsername = 0;
    }
    if ($errorPasswordRepeat == 0 && $errorUsername == 0 && $errordeviceID == 0) {
        $passwordencrypt = $authent->encryptpwd($password);
        $deviceID_hash = $authent->hash_sha256($deviceID);
        $xmlhandler->addnewuser($username, $passwordencrypt, $deviceID_hash, 'userdata.xml');
    }
}
$arr = array('errorUsername' => $errorUsername, 'errorPasswordRepeat' => $errorPasswordRepeat, 'errorDeviceID' => $errordeviceID, 'loginflag' => $loginflag);