src="<?php echo $realProfileImagePathXS; ?>"
                 srcset="<?php echo $realProfileImagePath; ?> 1024w, <?php echo $realProfileImagePathSM; ?> 512w, <?php echo $realProfileImagePathXS; ?> 128w"
                 alt="Profile image" />
            <?php if($isViewingSelf) { ?>
            <button class="btn btn-default col-xs-12 col-md-6 col-lg-3" id="expose-uploader">
              Change Profile Image
            </button>
            <?php } ?>
          </div>

          <?php echo getElement("name", $viewUser->getName(), "row", true); ?>
          <?php
             $dateCreated = date("d F Y", $userdata["creation"]);
             echo getElement("user since", $dateCreated, "row", true); ?>
          <?php echo getElement("email", $viewUser->getUsername(), "row", true); ?>
          <?php echo getElement("phone", $viewUser->getPhone(), "row from-base-profile"); ?>
          <?php echo getElement("twitter", $social["twitter"], "row social twitter"); ?>
          <?php echo getElement("google plus", $social["google_plus"], "row social google_plus"); ?>
          <?php echo getElement("linkedin", $social["linkedin"], "row social linkedin"); ?>
          <?php echo getElement("facebook", $social["facebook"], "row social facebook"); ?>
        </div>
        <div id="institution-profile" class="col-xs-12 col-md-6 profile-region" data-source="institution">
          <h3>Institution Information</h3>
          <?php echo getElement("institution", $place["name"]); ?>
          <?php echo getElement("department", $place["department"]); ?>
          <div class="profile-data address">
            <address
               data-number="<?php echo $place['street_number']; ?>"
               data-street="<?php echo $place['street']; ?>"
               data-country="<?php echo $place['country_code']; ?>"
               data-zip="<?php echo $place['zip']; ?>"
    $deferredScriptBlock = "<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'></script>\n<script type='text/javascript' src='" . $relative_path . "js/loadJQuery.js'></script>\n<script type='text/javascript'>\nvar loadLast = function () {\n    try {\n        {$deferredJS}\n    }\n    catch (e)\n    {\n        console.error(\"Couldn't load deferred calls\");\n    }\n}\n</script>";
    header("Refresh: 2; url=" . $baseurl);
    ob_end_flush();
    $login_output .= "<h1>Logging out ...</h1>" . $deferredScriptBlock;
}
try {
    $logged_in = $user->validateUser($_COOKIE[$cookielink]);
    if (!$user->has2FA() && $require_two_factor === true && !isset($_REQUEST['2fa']) && $logged_in && $_REQUEST['q'] != 'logout') {
        # If require two factor is on, always force it post login
        header("Refresh: 0; url=" . $self_url . "?2fa=t");
        $deferredJS .= "\nwindow.location.href=\"" . $self_url . "?2fa=t\";";
        ob_end_flush();
    }
    # This should only show when there isn't two factor enabled ...
    $twofactor = $user->has2FA() ? "Remove two-factor authentication" : "Add two-factor authentication";
    $phone_verify_template = "<form id='verify_phone' onsubmit='event.preventDefault();'>\n  <input type='tel' id='phone' name='phone' value='" . $user->getPhone() . "' readonly='readonly'/>\n  <input type='hidden' id='username' name='username' value='" . $user->getUsername() . "'/>\n  <button id='verify_phone_button' class='btn btn-primary'>Verify Phone Now</button>\n  <p>\n    <small>\n      <a href='#' id='verify_later'>\n        Verify Later\n      </a>\n    </small>\n  </p>\n</form>";
    try {
        $needPhone = !$user->canSMS();
        $deferredJS .= "console.log('Needs phone? '," . strbool($needPhone) . "," . DBHelper::staticSanitize($user->getPhone()) . ");\n";
        $altPhone = "<p>Congratulations! Your phone number is verified.</p>";
    } catch (Exception $e) {
        $needPhone = false;
        $deferredJS .= "console.warn('An exception was thrown checking for SMS-ability:','" . $e->getMessage() . "');\n";
        $altPhone = "<p>You don't have a phone number registered with us. Please go to account settings and add a phone number.</p>";
    }
    $verifyphone_link = $needPhone ? "<li><a href='?q=verify'>Verify Phone</a></li>" : null;
    $phone_verify_form = $needPhone ? $phone_verify_template : $altPhone;
} catch (Exception $e) {
    # There have been no cookies set.
    $logged_in = false;
    $twofactor = "Please log in.";