exit(page_renderer::render_main("Error - $settings->sitename","<p>Since you aren't logged in, you can't change your preferences. This is because stored preferences are tied to each registered user account. You can login <a href='?action=login&returnto=".rawurlencode("?action=user-preferences")."'>here</a>.</p>"));
$content.="\t<img class='avatar' src='?action=avatar&user=".urlencode($env->user)."&size=256' title='Your current avatar - click to upload a new one' />\n";
$content.="<figcaption>Upload a new avatar</figcaption>\n";
$content.=" <p><small>Used to send you notifications etc. Never shared with anyone except $settings->admindetails_name, $settings->sitename's administrator.</small></p>\n";
$content.=" <p>Email verification status: <strong>".(empty($env->user_data->emailAddressVerified)?"not ":"")."verified</strong> <small><em>(Email address verification is required in order to receive emails (other than the verification email itself, of course). Click the link in the verification email sent to you to verify your address, or change it here to get another verification email - changing it to the same email address is ok)</em></small></p>";
exit(page_renderer::render_main("Error Saving Preferences - $settings->sitename","<p>You aren't logged in, so you can't save your preferences. Try <a href='?action=login&returnto=".rawurlencode("?action=user-preferences")."'>logging in</a> first.</p>"));
exit(page_renderer::render_main("Error Saving Email Address - $settings->sitename","<p>The email address you supplied (<code>{$_POST['email-address']}</code>) is too long. Email addresses can only be 320 characters long. <a href='javascript:window.history.back();'>Go back</a>."));
exit(page_renderer::render_main("Server error sending verification code - $settings->sitename","<p>$settings->sitename tried to send you an email to verify your email address, but was unable to do so. The changes to your settings have not been saved. Please contact $settings->admindetails_name, whose email address can be found at the bottom of this page.</p>"));
exit(page_renderer::render_main("Error Saving Preferences - $settings->sitename","<p>$settings->sitename had some trouble saving your preferences! Please contact $settings->admindetails_name, $settings->sitename's administrator and tell them about this error if it still occurs in 5 minutes. They can be contacted by email at this address: ".hide_email($settings->admindetails_email).".</p>"));
exit(page_renderer::render_main("Preferences Saved Successfully - $settings->sitename","<p>Your preferences have been saved successfully! You could go back your <a href='?action=user-preferences'>preferences page</a>, or on to the <a href='?page=".rawurlencode($settings->defaultpage)."'>$settings->defaultpage</a>.</p>
exit(page_renderer::render_main("Not logged in - $settings->sitename","<p>You aren't logged in, so you can't verify your email address. Try <a href='?action=login&returnto=".rawurlencode("?action=email-address-verify&code=".($_GET["code"]??""))."'>logging in</a>.</p>"));
}
if($env->user_data->emailAddressVerified){
header("x-status: success");
exit(page_renderer::render_main("Already verified - $settings->sitename","<p>Your email address is already verified, so you don't need to verify it again.</p>\n<p> <a href='index.php'>Go to the main page</a>.</p>"));
}
if(empty($_GET["code"])){
http_response_code(400);
header("x-status: failed");
header("x-problem: no-code-specified");
exit(page_renderer::render_main("No verification code specified - $settings->sitename","<p>No verification code specified. Do so with the <code>code</code> GET parameter.</p>"));
exit(page_renderer::render_main("Verification code incorrect","<p>That verification code was incorrect. Try specifying another one, or going to your <a href='?action=user-preferences'>user preferences</a> and changing your email address to re-send another code (changing it to the same email address is ok).</p>"));
exit(page_renderer::render_main("Server error - $settings->sitename","<p>Your verification code was correct, but $settings->sitename was unable to update your user details because it failed to write the changes to disk. Please contact $settings->admindetails_name, whose email address can be found at the bottom of the page.</p>"));
exit(page_renderer::render_main("Email Address Verified - $settings->sitename","<p>Your email address was verified successfully. <a href='index.php'>Go to the main page</a>, or to your <a href='?action=user-preferences'>user preferences</a> to make further changes.</p>"));
exit(page_renderer::render_main("Password mismatch - $settings->sitename","<p>Error: You typed your current password incorrectly! <a href='javascript:history.back();'>Go back</a>.</p>"));
exit(page_renderer::render_main("Error Saving Password - $settings->sitename","<p>While you entered your old password correctly, $settings->sitename encountered an error whilst saving your password to disk! Your password has not been changed. Please contact $settings->admindetails_name for assistance (you can find their email address at the bottom of this page)."));
exit(page_renderer::render_main("Password Changed Successfully","<p>You password was changed successfully. <a href='?action=user-preferences'>Go back to the user preferences page</a>.</p>"));
exit(base64_decode("iVBORw0KGgoAAAANSUhEUgAAAFAAAABQAQMAAAC032DuAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAABBJREFUGBljGAWjYBTQDQAAA3AAATXTgHYAAAAASUVORK5CYII="));// TODO: Refactor out into a separate function
add_help_section("910-user-preferences","User Preferences","<p>As you are logged in, $settings->sitename lets you configure a selection of personal preferences. These can be viewed and tweaked to you liking over on the <a href='?action=user-preferences'>preferences page</a>, which can be accessed at any time by clicking the cog icon (it looks something like this: <a href='?action=user-preferences'>$settings->user_preferences_button_text</a>), though the administrator of $settings->sitename ($settings->admindetails_name) may have changed its appearance.</p>");
add_help_section("915-avatars","Avatars","<p>$settings->sitename allows you to upload an avatar and have it displayed next to your name. If you don't have an avatar uploaded yet, then $settings->sitename will take a <a href='https://www.techopedia.com/definition/19744/hash-function'>hash</a> of your email address and ask <a href='https://gravatar.com'>Gravatar</a> for for your Gravatar instead. If you haven't told $settings->sitename what your email address is either, a hash of your username is used instead. If you don't have a gravatar, then $settings->sitename asks Gravatar for an identicon instead.</p>
<p>Youravataron$settings->sitenamecurrentlylookslikethis:<imgclass='avatar'src='?action=avatar&user=" . urlencode($env->user) . "'/>" . ($settings->upload_enabled ? "-youcanuploadanewonebygoingtoyour<ahref='?action=user-preferences'>preferences</a>,or<ahref='?action=upload&avatar=yes'/>clickinghere</a>." : ",but$settings->sitenamecurrentlyhasuploadsdisabled,soyoucan't upload a new one directly to $settings->sitename. You can, however, set your email address in your <a href='?action=user-preferences'>preferences</a> and <a href='https://en.gravatar.com/'>createaGravatar</a>,andthenitshouldshowuphereon$settings->sitenameshortly.") . "</p>");