if ($validator->validateUsername($username) == false) { throw new EmptyDataException("wrong_username_pattern"); } if ($userdata->getUsername() != $username) { /** * Look if user with entered username already exists */ if (!empty($userBiz->checkUserByUsername($username))) { throw new UserExistsException("username_exists"); } } if ($userdata->getEmail() != $email) { /** * Look if user with entered e-mail already exists */ if (!empty($userBiz->checkUserByEmail($email))) { throw new UserExistsException("email_exists"); } } /** * Upload image */ if (isset($_FILES['user_image']) && !empty($_FILES['user_image']['name'])) { $file = $_FILES['user_image']; /** * File properties */ $file_name = $file['name']; $file_tmp = $file['tmp_name']; $file_size = $file['size']; $file_error = $file['error'];
if ($validator->validatePassword($_SESSION['savedData']['password']) == false) { throw new EmptyDataException("wrong_password_pattern"); } if ($validator->validateUsername($_SESSION['savedData']['username']) == false) { throw new EmptyDataException("wrong_username_pattern"); } /** * Look if user with entered username already exists */ if (!empty($userBiz->checkUserByUsername($_SESSION['savedData']['username']))) { throw new UserExistsException("username_exists"); } /** * Look if user with entered e-mail already exists */ if (!empty($userBiz->checkUserByEmail($_SESSION['savedData']['email']))) { throw new UserExistsException("email_exists"); } $userImage = "default.jpg"; if (isset($_FILES['userImage']) && !empty($_FILES['userImage']['name'])) { $file = $_FILES['userImage']; /** * File properties */ $file_name = $file['name']; $file_tmp = $file['tmp_name']; $file_size = $file['size']; $file_error = $file['error']; /** * Work out the file extension * If move_uploaded_file gives permission error, 'cd' to 'userimages' folder and give it wright permissions: 'chmod 0777 userimages' (both machines)