<?
require_once(SERVER_ROOT.'/classes/twofa.class.php');
$UserID = $_REQUEST['userid'];
if (!is_number($UserID)) {
  error(404);
}

$DB->query("
  SELECT
    m.Username,
    m.TwoFactor,
    m.PublicKey,
    m.Email,
    m.IRCKey,
    m.Paranoia,
    i.Info,
    i.Avatar,
    i.StyleID,
    i.StyleURL,
    i.SiteOptions,
    i.UnseededAlerts,
    p.Level AS Class,
    i.InfoTitle
  FROM users_main AS m
    JOIN users_info AS i ON i.UserID = m.ID
    LEFT JOIN permissions AS p ON p.ID = m.PermissionID
  WHERE m.ID = ?", $UserID);
list($Username, $TwoFactor, $PublicKey, $Email, $IRCKey, $Paranoia, $Info, $Avatar, $StyleID, $StyleURL, $SiteOptions, $UnseededAlerts, $Class, $InfoTitle) = $DB->next_record(MYSQLI_NUM, [5, 10]);

$TwoFA = new TwoFactorAuth();

$Email = apcu_exists('DBKEY') ? Crypto::decrypt($Email) : '[Encrypted]';

if ($UserID != $LoggedUser['ID'] && !check_perms('users_edit_profiles', $Class)) {
  error(403);
}

$Paranoia = json_decode($Paranoia, true);
if (!is_array($Paranoia)) {
  $Paranoia = [];
}

function paranoia_level($Setting) {
  global $Paranoia;
  // 0: very paranoid; 1: stats allowed, list disallowed; 2: not paranoid
  return (in_array($Setting . '+', $Paranoia)) ? 0 : (in_array($Setting, $Paranoia) ? 1 : 2);
}

function display_paranoia($FieldName) {
  $Level = paranoia_level($FieldName);
  print "\t\t\t\t\t<label><input type=\"checkbox\" name=\"p_{$FieldName}_c\"".checked($Level >= 1).' onchange="AlterParanoia()" /> Show count</label>'."&nbsp;&nbsp;\n";
  print "\t\t\t\t\t<label><input type=\"checkbox\" name=\"p_{$FieldName}_l\"".checked($Level >= 2).' onchange="AlterParanoia()" /> Show list</label>'."\n";
}

function checked($Checked) {
  return ($Checked ? ' checked="checked"' : '');
}

if ($SiteOptions) {
  $SiteOptions = json_decode($SiteOptions, true) ?? [];
} else {
  $SiteOptions = [];
}

View::show_header("$Username &gt; Settings", 'user,password_validate,validate,cssgallery,preview_paranoia,bbcode,user_settings,donor_titles');



$DonorRank = Donations::get_rank($UserID);
$DonorIsVisible = Donations::is_visible($UserID);

if ($DonorIsVisible === null) {
  $DonorIsVisible = true;
}

extract(Donations::get_enabled_rewards($UserID));
$Rewards = Donations::get_rewards($UserID);
$ProfileRewards = Donations::get_profile_rewards($UserID);
$DonorTitles = Donations::get_titles($UserID);

echo $Val->GenerateJS('userform');
?>
<div class="thin">
  <div class="header">
    <h2><?=Users::format_username($UserID, false, false, false)?> &gt; Settings</h2>
  </div>
  <form class="edit_form" name="user" id="userform" method="post" autocomplete="off">
  <div class="sidebar settings_sidebar">
    <div class="box box2" id="settings_sections">
      <div class="head">
        <strong>Sections</strong>
      </div>
      <ul class="nobullet">
        <li data-gazelle-section-id="all_settings">
          <h2><a href="#" class="tooltip" title="View the full list of user settings.">All Settings</a></h2>
        </li>
        <li data-gazelle-section-id="site_appearance_settings">
          <h2><a href="#" class="tooltip" title="These settings change the visual style of the entire site.">Site Appearance Settings</a></h2>
        </li>
        <li data-gazelle-section-id="torrent_settings">
          <h2><a href="#" class="tooltip" title="These settings change how torrents are searched for, grouped, displayed, and downloaded.">Torrent Settings</a></h2>
        </li>
        <li data-gazelle-section-id="community_settings">
          <h2><a href="#" class="tooltip" title="These settings change how interactions with other users are formatted, grouped, and displayed.">Community Settings</a></h2>
        </li>
        <li data-gazelle-section-id="notification_settings">
          <h2><a href="#" class="tooltip" title="These settings change the format and types of notifications you receive.">Notification Settings</a></h2>
        </li>
        <li data-gazelle-section-id="personal_settings">
          <h2><a href="#" class="tooltip" title="These settings alter the appearance of your profile and posts.">Personal Settings</a></h2>
        </li>
        <li data-gazelle-section-id="paranoia_settings">
          <h2><a href="#" class="tooltip" title="These settings allow you to display or hide different categories of information from your profile.">Paranoia Settings</a></h2>
        </li>
        <li data-gazelle-section-id="access_settings">
          <h2><a href="#" class="tooltip" title="These settings control your login and access details for <?=SITE_NAME?>, the site's IRC network, and the tracker.">Access Settings</a></h2>
        </li>
        <li data-gazelle-section-id="live_search">
          <input type="text" id="settings_search" placeholder="Live Search" />
        </li>
        <li>
          <input type="submit" id="submit" value="Save profile" />
        </li>
      </ul>
    </div>
  </div>
  <div class="main_column">
    <div>
      <input type="hidden" name="action" value="take_edit" />
      <input type="hidden" name="userid" value="<?=$UserID?>" />
      <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
    </div>
    <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="site_appearance_settings">
      <tr class="colhead_dark">
        <td colspan="2">
          <strong>Site Appearance Settings</strong>
        </td>
      </tr>
      <tr id="site_style_tr">
        <td class="label tooltip" title="Selecting a stylesheet will change <?=SITE_NAME?>'s visual appearance."><strong>Stylesheet</strong></td>
        <td>
          <select name="stylesheet" id="stylesheet">
<?  foreach ($Stylesheets as $Style) { ?>
            <option value="<?=($Style['ID'])?>"<?=$Style['ID'] == $StyleID ? ' selected="selected"' : ''?>><?=($Style['ProperName'])?></option>
<?  } ?>
          </select>&nbsp;&nbsp;
          <a data-toggle-target="#css_gallery" class="brackets">Show gallery</a>
          <div id="css_gallery" class="hidden">
<?  foreach ($Stylesheets as $Style) { ?>
            <div class="preview_wrapper">
              <div class="preview_image" name="<?=($Style['Name'])?>">
                <img src="<?=STATIC_SERVER.'stylespreview/thumb_'.$Style['Name'].'.png'?>" alt="<?=$Style['Name']?>" />
                <p class="preview_name">
                  <label><input type="radio" name="stylesheet_gallery" value="<?=($Style['ID'])?>" /> <?=($Style['ProperName'])?></label>
                </p>
              </div>
            </div>
<?  } ?>
          </div>
        </td>
      </tr>
      <tr id="style_additions_tr" class="<?=($Stylesheets[$LoggedUser['StyleID']]['Additions'][0] ?? false)?'':'hidden'?>">
        <td class="label tooltip" title="Select changes that you want made to your chosen stylesheet"><strong>Stylesheet additions</strong></td>
        <td> <?
          foreach($Stylesheets as $Style) {
            $StyleAdditions = explode('|', $Style['Additions']);
            ?> <ul class="nobullet style_addition<?=$Style['ID']==$Stylesheets[$LoggedUser['StyleID']]['ID']?'':' hidden'?>" id="style_addition_<?=$Style['Name']?>"> <?
            foreach($StyleAdditions as $i => $Addition) {
              if ($Addition) { ?>
                <li>
                <input type="checkbox" name="style_additions[]" value="<?=$Addition?>" id="addition_<?=$Addition?>"<?=(in_array($Addition, $SiteOptions['StyleAdditions']??[])?' checked="checked"':'')?>>
                  <label for="addition_<?=$Addition?>"><?=explode('|', $Style['ProperAdditions'])[$i]?></label>
                </li>
           <? }
            }
            ?> </ul> <?
          }
        ?> </td>
      </tr>
      <tr id="site_extstyle_tr">
        <td class="label tooltip" title="Providing a link to an externally-hosted stylesheet will override your default stylesheet selection."><strong>External stylesheet URL</strong></td>
        <td>
          <input type="text" size="40" name="styleurl" id="styleurl" value="<?=display_str($StyleURL)?>" />
        </td>
      </tr>
<?  if (check_perms('users_mod')) { ?>
      <tr id="site_autostats_tr">
        <td class="label tooltip" title="This is a staff-only feature to bypass the &quot;Show stats&quot; button for seeding, leeching, snatched, and downloaded stats on profile pages."><strong>Profile stats</strong></td>
        <td>
          <label>
            <input type="checkbox" name="autoload_comm_stats"<?Format::selected('AutoloadCommStats', 1, 'checked', $SiteOptions);?> />
            Automatically fetch the snatch and peer stats on profile pages.
          </label>
        </td>
      </tr>
<?  } ?>
    </table>
    <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="torrent_settings">
      <tr class="colhead_dark">
        <td colspan="2">
          <strong>Torrent Settings</strong>
        </td>
      </tr>
<?  if (check_perms('site_advanced_search')) { ?>
      <tr id="tor_searchtype_tr">
        <td class="label tooltip" title="This option allows you to choose whether the default torrent search menu will be basic (fewer options) or advanced (more options)."><strong>Default search type</strong></td>
        <td>
          <ul class="options_list nobullet">
            <li>
              <input type="radio" name="searchtype" id="search_type_simple" value="0"<?=$SiteOptions['SearchType'] == 0 ? ' checked="checked"' : ''?> />
              <label for="search_type_simple">Simple</label>
            </li>
            <li>
              <input type="radio" name="searchtype" id="search_type_advanced" value="1"<?=$SiteOptions['SearchType'] == 1 ? ' checked="checked"' : ''?> />
              <label for="search_type_advanced">Advanced</label>
            </li>
          </ul>
        </td>
      </tr>
<?  } ?>
      <tr id="tor_group_tr">
        <td class="label tooltip" title="Enabling torrent grouping will place multiple formats of the same torrent group together beneath a common header."><strong>Torrent grouping</strong></td>
        <td>
          <div class="option_group">
            <input type="checkbox" name="disablegrouping" id="disablegrouping"<?=$SiteOptions['DisableGrouping2'] == 0 ? ' checked="checked"' : ''?> />
            <label for="disablegrouping">Enable torrent grouping</label>
          </div>
        </td>
      </tr>
      <tr id="tor_gdisp_search_tr">
        <td class="label tooltip" title="In torrent search results and on artist pages, &quot;open&quot; will expand torrent groups by default, and &quot;closed&quot; will collapse torrent groups by default."><strong>Torrent group display</strong></td>
        <td>
          <div class="option_group">
            <ul class="options_list nobullet">
              <li>
                <input type="radio" name="torrentgrouping" id="torrent_grouping_open" value="0"<?=$SiteOptions['TorrentGrouping'] == 0 ? ' checked="checked"' : ''?> />
                <label for="torrent_grouping_open">Open</label>
              </li>
              <li>
                <input type="radio" name="torrentgrouping" id="torrent_grouping_closed" value="1"<?=$SiteOptions['TorrentGrouping'] == 1 ? ' checked="checked"' : ''?> />
                <label for="torrent_grouping_closed">Closed</label>
              </li>
            </ul>
          </div>
        </td>
      </tr>
      <tr id="tor_snatched_tr">
        <td class="label tooltip" title="Enabling the snatched torrents indicator will display &quot;Snatched!&quot; next to torrents you've snatched."><strong>Snatched torrents indicator</strong></td>
        <td>
          <input type="checkbox" name="showsnatched" id="showsnatched"<?=!empty($SiteOptions['ShowSnatched']) ? ' checked="checked"' : ''?> />
          <label for="showsnatched">Enable snatched torrents indicator</label>
        </td>
      </tr>
      <tr id="tor_magnet_tr">
        <td class="label tooltip" title="Magnet links should only be used on clients with DHT disabled globally"><strong>Magnet links</strong></td>
        <td>
          <input type="checkbox" name="showmagnets" id="showmagnets"<?=!empty($SiteOptions['ShowMagnets']) ? ' checked="checked"' : '' ?> />
          <label for="showmagnets">Show magnet links</label>
        </td>
      </tr>
<? /* ?>
      <tr>
        <td class="label"><strong>Collage album art view</strong></td>
        <td>
          <select name="hidecollage" id="hidecollage">
            <option value="0"<?=$SiteOptions['HideCollage'] == 0 ? ' selected="selected"' : ''?>>Show album art</option>
            <option value="1"<?=$SiteOptions['HideCollage'] == 1 ? ' selected="selected"' : ''?>>Hide album art</option>
          </select>
        </td>
        </tr>
<? */ ?>
      <tr id="tor_cover_tor_tr">
        <td class="label tooltip" title="Enabling cover artwork for torrents will show cover artwork next to torrent information. Enabling additional cover artwork will display all additional cover artwork as well."><strong>Cover art (torrents)</strong></td>
        <td>
          <ul class="options_list nobullet">
            <li>
              <input type="hidden" name="coverart" value="" />
              <input type="checkbox" name="coverart" id="coverart"<?=!isset($SiteOptions['CoverArt']) || $SiteOptions['CoverArt'] ? ' checked="checked"' : ''?> />
              <label for="coverart">Enable cover artwork</label>
            </li>
            <li>
              <input type="checkbox" name="show_extra_covers" id="show_extra_covers"<?=$SiteOptions['ShowExtraCovers'] ? ' checked="checked"' : ''?> />
              <label for="show_extra_covers">Enable additional cover artwork</label>
            </li>
          </ul>
        </td>
      </tr>
      <tr id="tor_cover_coll_tr">
        <td class="label tooltip" title="This option allows you to change the number of album covers to display within a single collection page."><strong>Cover art (collections)</strong></td>
        <td>
          <select name="collagecovers" id="collagecovers">
            <option value="10"<?=$SiteOptions['CollageCovers'] == 10 ? ' selected="selected"' : ''?>>10</option>
            <option value="25"<?=($SiteOptions['CollageCovers'] == 25 || !isset($SiteOptions['CollageCovers'])) ? ' selected="selected"' : ''?>>25 (default)</option>
            <option value="50"<?=$SiteOptions['CollageCovers'] == 50 ? ' selected="selected"' : ''?>>50</option>
            <option value="100"<?=$SiteOptions['CollageCovers'] == 100 ? ' selected="selected"' : ''?>>100</option>
            <option value="1000000"<?=$SiteOptions['CollageCovers'] == 1000000 ? ' selected="selected"' : ''?>>All</option>
            <option value="0"<?=($SiteOptions['CollageCovers'] === 0 || (!isset($SiteOptions['CollageCovers']) && $SiteOptions['HideCollage'])) ? ' selected="selected"' : ''?>>None</option>
          </select>
          covers per page
        </td>
      </tr>
      <tr id="tor_showfilt_tr">
        <td class="label tooltip" title="Displaying filter controls will show torrent filtering options in the torrent search menu by default. Displaying filters for official tags will list clickable filters for official tags in the torrent search menu by default."><strong>Torrent search filters</strong></td>
        <td>
          <ul class="options_list nobullet">
            <li>
              <input type="checkbox" name="showtfilter" id="showtfilter"<?=(!isset($SiteOptions['ShowTorFilter']) || $SiteOptions['ShowTorFilter'] ? ' checked="checked"' : '')?> />
              <label for="showtfilter">Display filter controls</label>
            </li>
            <li>
              <input type="checkbox" name="showtags" id="showtags"<? Format::selected('ShowTags', 1, 'checked', $SiteOptions); ?> />
              <label for="showtags">Display official tag filters</label>
            </li>
          </ul>
        </td>
      </tr>
      <tr id="tor_autocomp_tr">
        <td class="label tooltip" title="Autocomplete will try to predict the word or phrase that you're typing. Selecting &quot;Everywhere&quot; will enable autocomplete on artist and tag fields across the site. Selecting &quot;Searches only&quot; will enable autocomplete in searches."><strong>Autocompletion</strong></td>
        <td>
          <select name="autocomplete">
            <option value="0"<?=empty($SiteOptions['AutoComplete']) ? ' selected="selected"' : ''?>>Everywhere</option>
            <option value="2"<?=$SiteOptions['AutoComplete'] === 2 ? ' selected="selected"' : ''?>>Searches only</option>
            <option value="1"<?=$SiteOptions['AutoComplete'] === 1 ? ' selected="selected"' : ''?>>Disable</option>
          </select>
        </td>
      </tr>
      <tr id="tor_hidequestionable_tr">
        <td class="label tooltip" title="Prevent torrents with these tags from showing up on the torrent search page"><strong>Content Filtering</strong></td>
        <td>
          <ul class="nobullet">
            <li>
              <input type="checkbox" name="hide_lolicon" id="hide_lolicon"<?=($SiteOptions['HideLolicon']) ? ' checked="checked"' : ''?> />
              <label for="hide_lolicon">Hide results with Lolicon, Shotacon, or Toddlercon</label>
            </li>
            <li>
              <input type="checkbox" name="hide_scat" id="hide_scat"<?=($SiteOptions['HideScat']) ? ' checked="checked"' : ''?> />
              <label for="hide_scat">Hide results with Scat</label>
            </li>
            <li>
              <input type="checkbox" name="hide_snuff" id="hide_snuff"<?=($SiteOptions['HideSnuff']) ? ' checked="checked"' : ''?> />
              <label for="hide_snuff">Hide results with Snuff</label>
            </li>
          </ul>
        </td>
      </tr>
    </table>
    <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="community_settings">
      <tr class="colhead_dark">
        <td colspan="2">
          <strong>Community Settings</strong>
        </td>
      </tr>
      <tr id="comm_ppp_tr">
        <td class="label tooltip" title="This option allows you to set the desired number of displayed posts per page within forum threads."><strong>Posts per page (forums)</strong></td>
        <td>
          <select name="postsperpage" id="postsperpage">
            <option value="25"<?=$SiteOptions['PostsPerPage'] == 25 ? ' selected="selected"' : ''?>>25 (default)</option>
            <option value="50"<?=$SiteOptions['PostsPerPage'] == 50 ? ' selected="selected"' : ''?>>50</option>
            <option value="100"<?=$SiteOptions['PostsPerPage'] == 100 ? ' selected="selected"' : ''?>>100</option>
          </select>
          posts per page
        </td>
      </tr>
      <tr id="comm_inbsort_tr">
        <td class="label tooltip" title="This option will force unread private messages to be listed first."><strong>Inbox sorting</strong></td>
        <td>
          <input type="checkbox" name="list_unread_pms_first" id="list_unread_pms_first"<?=!empty($SiteOptions['ListUnreadPMsFirst']) ? ' checked="checked"' : ''?> />
          <label for="list_unread_pms_first">List unread private messages first</label>
        </td>
      </tr>
      <tr id="comm_emot_tr">
        <td class="label tooltip" title="Emoticons are small images which replace traditional text-based &quot;smileys&quot; like :) or :("><strong>Emoticons</strong></td>
        <td>
          <input type="checkbox" name="disablesmileys" id="disablesmileys"<?=!empty($SiteOptions['DisableSmileys']) ? ' checked="checked"' : ''?> />
          <label for="disablesmileys">Disable emoticons</label>
        </td>
      </tr>
      <tr id="comm_avatars_tr">
        <td class="label tooltip" title="This option allows you to disable all avatars or show all avatars with a placeholder for users without avatars." data-title-plain="This option allows you to disable all avatars or show all avatars with a placeholder for users without avatars."><strong>Avatar display (posts)</strong></td>
        <td>
          <select name="disableavatars" id="disableavatars">
            <option value="1"<?=$SiteOptions['DisableAvatars'] == 1 ? ' selected="selected"' : ''?>>Disable avatars</option>
            <option value="0"<?=$SiteOptions['DisableAvatars'] == 0 ? ' selected="selected"' : ''?>>Show avatars</option>
          </select>
        </td>
      </tr>
      <tr id="comm_autosave_tr">
        <td class="label tooltip" title="As you add text to a post or reply, this text is automatically saved. If you stop and return to your post at a later time (e.g. accidentally clicking a link and then pressing the &quot;Back&quot; button in your browser), the text will remain. This option allows you to disable this feature."><strong>Auto-save reply text</strong></td>
        <td>
          <input type="checkbox" name="disableautosave" id="disableautosave"<?=!empty($SiteOptions['DisableAutoSave']) ? ' checked="checked"' : ''?> />
          <label for="disableautosave">Disable text auto-saving</label>
        </td>
      </tr>
      <tr id="comm_badge_tr">
        <td class="label tooltip" title="Select up to 5 badges to display next to your username."><strong>Displayed Badges</strong></td>
        <td>
<?  $Badges = Badges::get_badges($UserID);
    if (empty($Badges)) {
      ?><span>You have no badges :(</span><?
    } else {
      $Count = 0;
      foreach ($Badges as $BadgeID => $Displayed) {
        ?><input type="checkbox" name="badges[]" class="badge_checkbox" value="<?=$BadgeID?>" <?=($Displayed)?"checked ":""?>/><?=Badges::display_badge($BadgeID, true)?><?
        $Count++;
        echo ($Count % 8) ? '' : '<br>';
      }
    }
?>
        </td>
      </tr>
    </table>
    <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="notification_settings">
      <tr class="colhead_dark">
        <td colspan="2">
          <strong>Notification Settings</strong>
        </td>
      </tr>
      <tr id="notif_autosubscribe_tr">
        <td class="label tooltip" title="Enabling this will automatically subscribe you to any thread you post in."><strong>Automatic thread subscriptions</strong></td>
        <td>
          <input type="checkbox" name="autosubscribe" id="autosubscribe"<?=!empty($SiteOptions['AutoSubscribe']) ? ' checked="checked"' : ''?> />
          <label for="autosubscribe">Enable automatic thread subscriptions</label>
        </td>
      </tr>
      <tr id="notif_unseeded_tr">
        <td class="label tooltip" title="Enabling this will send you a PM alert before your uploads are deleted for being unseeded."><strong>Unseeded torrent alerts</strong></td>
        <td>
          <input type="checkbox" name="unseededalerts" id="unseededalerts"<?=checked($UnseededAlerts)?> />
          <label for="unseededalerts">Enable unseeded torrent alerts</label>
        </td>
      </tr>
      <? NotificationsManagerView::render_settings(NotificationsManager::get_settings($UserID)); ?>
    </table>
    <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="personal_settings">
      <tr class="colhead_dark">
        <td colspan="2">
          <strong>Personal Settings</strong>
        </td>
      </tr>
      <tr id="pers_avatar_tr">
        <td class="label tooltip_interactive" title="Please link to an avatar which does not exceed 512 kiB in size or 600 pixels in height" data-title-plain="Please link to an avatar which does not exceed 512 kiB in size or 600 pixels in height"><strong>Avatar URL</strong></td>
        <td>
          <input type="text" size="50" name="avatar" id="avatar" value="<?=display_str($Avatar)?>" />
        </td>
      </tr>
<?  if ($HasSecondAvatar) { ?>
      <tr id="pers_avatar2_tr">
        <td class="label tooltip_interactive" title="Congratulations! You've unlocked this option by reaching Special Rank #2. Thanks for donating. Your normal avatar will &quot;flip&quot; to this one when someone runs their mouse over the image. Please link to an avatar which follows the &lt;a href=&quot;rules.php&quot;&gt;site rules&lt;/a&gt;. The avatar width should be 150 pixels and will be resized if necessary." data-title-plain="Congratulations! You've unlocked this option by reaching Special Rank #2. Thanks for donating. Your normal avatar will &quot;flip&quot; to this one when someone runs their mouse over the image. Please link to an avatar which follows the site rules. The avatar width should be 150 pixels and will be resized if necessary."><strong>Second avatar URL</strong></td>
        <td>
          <input type="text" size="50" name="second_avatar" id="second_avatar" value="<?=$Rewards['SecondAvatar']?>" />
        </td>
      </tr>
<?  }
  if ($HasAvatarMouseOverText) { ?>
      <tr id="pers_avatarhover_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #3. Thanks for donating. Text you enter in this field will appear when someone mouses over your avatar. All text should follow site rules. 200 character limit."><strong>Avatar mouseover text</strong></td>
        <td>
          <input type="text" size="50" name="avatar_mouse_over_text" id="avatar_mouse_over_text" value="<?=$Rewards['AvatarMouseOverText']?>" />
        </td>
      </tr>
<?  }
  if ($HasDonorIconMouseOverText) { ?>
      <tr id="pers_donorhover_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #2. Thanks for donating. Text you enter in this field will appear when someone mouses over your donor icon. All text should follow site rules. 200 character limit."><strong>Donor icon mouseover text</strong></td>
        <td>
          <input type="text" size="50" name="donor_icon_mouse_over_text" id="donor_icon_mouse_over_text" value="<?=$Rewards['IconMouseOverText']?>" />
        </td>
      </tr>
<?  }
  if ($HasDonorIconLink) { ?>
      <tr id="pers_donorlink_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #4. Thanks for donating. Links you enter in this field will be accessible when your donor icon is clicked. All links should follow site rules."><strong>Donor icon link</strong></td>
        <td>
          <input type="text" size="50" name="donor_icon_link" id="donor_icon_link" value="<?=$Rewards['CustomIconLink']?>" />
        </td>
      </tr>
<?  }
  if ($HasCustomDonorIcon) { ?>
      <tr id="pers_donoricon_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #5. Thanks for donating. Please link to an icon which you'd like to replace your default donor icon with. Icons must be 15 pixels wide by 13 pixels tall. Icons of any other size will be automatically resized."><strong>Custom donor icon URL</strong></td>
        <td>
          <input type="text" size="50" name="donor_icon_custom_url" id="donor_icon_custom_url" value="<?=$Rewards['CustomIcon']?>" />
        </td>
      </tr>
<?  }
  if ($HasDonorForum) { ?>
      <tr id="pers_donorforum_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #5. Thanks for donating. You may select a prefix and suffix which will be used in the Donor Forum you now have access to."><strong>Donor forum honorific</strong></td>
        <td>
          <div class="field_div">
            <label><strong>Prefix:</strong> <input type="text" size="30" maxlength="30" name="donor_title_prefix" id="donor_title_prefix" value="<?=$DonorTitles['Prefix']?>" /></label>
          </div>
          <div class="field_div">
            <label><strong>Suffix:</strong> <input type="text" size="30" maxlength="30" name="donor_title_suffix" id="donor_title_suffix" value="<?=$DonorTitles['Suffix']?>" /></label>
          </div>
          <div class="field_div">
            <label><strong>Hide comma:</strong> <input type="checkbox" id="donor_title_comma" name="donor_title_comma"<?=!$DonorTitles['UseComma'] ? ' checked="checked"' : '' ?> /></label>
          </div>
          <strong>Preview:</strong> <span id="donor_title_prefix_preview"></span><?=$Username?><span id="donor_title_comma_preview">, </span><span id="donor_title_suffix_preview"></span>
        </td>
      </tr>
<?  } ?>
      <tr id="pers_proftitle_tr">
        <td class="label tooltip" title="You can customize your profile information with text and BBCode. Entering a title will label your profile information section. Unlock additional profile info boxes via Donor Ranks."><strong>Profile title 1</strong></td>
        <td><input type="text" size="50" name="profile_title" id="profile_title" value="<?=display_str($InfoTitle)?>" />
        </td>
      </tr>
      <tr id="pers_profinfo_tr">
        <td class="label tooltip" title="You can customize your profile information with text and BBCode. Entering a title will label your profile information section. Unlock additional profile info boxes via Donor Ranks."><strong>Profile info 1</strong></td>
        <td><?php $textarea = new TEXTAREA_PREVIEW('info', 'info', display_str($Info), 40, 8); ?></td>
      </tr>
      <!-- Excuse this numbering confusion, we start numbering our profile info/titles at 1 in the donor_rewards table -->
<?  if ($HasProfileInfo1) { ?>
      <tr id="pers_proftitle2_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #2. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile title 2</strong></td>
        <td><input type="text" size="50" name="profile_title_1" id="profile_title_1" value="<?=display_str($ProfileRewards['ProfileInfoTitle1'])?>" />
        </td>
      </tr>
      <tr id="pers_profinfo2_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #2. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile info 2</strong></td>
        <td><?php $textarea = new TEXTAREA_PREVIEW('profile_info_1', 'profile_info_1', display_str($ProfileRewards['ProfileInfo1']), 40, 8); ?></td>
      </tr>
<?  }
  if ($HasProfileInfo2) { ?>
      <tr id="pers_proftitle3_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #3. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile title 3</strong></td>
        <td><input type="text" size="50" name="profile_title_2" id="profile_title_2" value="<?=display_str($ProfileRewards['ProfileInfoTitle2'])?>" />
        </td>
      </tr>
      <tr id="pers_profinfo3_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #3. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile info 3</strong></td>
        <td><?php $textarea = new TEXTAREA_PREVIEW('profile_info_2', 'profile_info_2', display_str($ProfileRewards['ProfileInfo2']), 40, 8); ?></td>
      </tr>
<?  }
  if ($HasProfileInfo3) { ?>
      <tr id="pers_proftitle4_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #4. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile title 4</strong></td>
        <td><input type="text" size="50" name="profile_title_3" id="profile_title_3" value="<?=display_str($ProfileRewards['ProfileInfoTitle3'])?>" />
        </td>
      </tr>
      <tr id="pers_profinfo4_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #4. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile info 4</strong></td>
        <td><?php $textarea = new TEXTAREA_PREVIEW('profile_info_3', 'profile_info_3', display_str($ProfileRewards['ProfileInfo3']), 40, 8); ?></td>
      </tr>
<?  }
  if ($HasProfileInfo4) { ?>
      <tr id="pers_proftitle5_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #5. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile title 5</strong></td>
        <td><input type="text" size="50" name="profile_title_4" id="profile_title_4" value="<?=display_str($ProfileRewards['ProfileInfoTitle4'])?>" />
        </td>
      </tr>
      <tr id="pers_profinfo5_tr">
        <td class="label tooltip" title="Congratulations! You've unlocked this option by reaching Donor Rank #5. Thanks for donating. You can customize your profile information with text and BBCode. Entering a title will label your profile information section."><strong>Profile info 5</strong></td>
        <td><?php $textarea = new TEXTAREA_PREVIEW('profile_info_4', 'profile_info_4', display_str($ProfileRewards['ProfileInfo4']), 40, 8); ?></td>
      </tr>
<?  } ?>
    </table>
    <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="paranoia_settings">
      <tr class="colhead_dark">
        <td colspan="2">
          <strong>Paranoia Settings</strong>
        </td>
      </tr>
      <tr>
        <td class="label">&nbsp;</td>
        <td>
          <p><strong>Select the profile elements you wish to display to other users.</strong></p>
          <p>For example, if you select "Show count" for "Requests (filled)", the number of requests you have filled will be visible. If you select "Show bounty", the amount of request bounty you have received will be visible. If you select "Show list", the full list of requests you have filled will be visible.</p>
          <p><span class="warning">Note: Paranoia has nothing to do with your security on this site. These settings only determine if others can view your site activity. Some information will remain available in the site log.</span></p>
        </td>
      </tr>
      <tr id="para_lastseen_tr">
        <td class="label tooltip" title="Enable this to allow others to see when your most recent site activity occurred."><strong>Recent activity</strong></td>
        <td>
          <label><input type="checkbox" name="p_lastseen"<?=checked(!in_array('lastseen', $Paranoia))?> /> Last seen</label>
        </td>
      </tr>
      <tr id="para_presets_tr">
        <td class="label"><strong>Presets</strong></td>
        <td>
          <input type="button" onclick="ParanoiaResetOff();" value="Show everything" />
          <input type="button" onclick="ParanoiaResetStats();" value="Show stats only" />
          <!--<input type="button" onclick="ParanoiaResetOn();" value="Show nothing" />-->
        </td>
      </tr>
      <tr id="para_donations_tr">
        <td class="label"><strong>Donations</strong></td>
        <td>
          <input type="checkbox" id="p_donor_stats" name="p_donor_stats" onchange="AlterParanoia();"<?=$DonorIsVisible ? ' checked="checked"' : ''?> />
          <label for="p_donor_stats">Show donor stats</label>
          <input type="checkbox" id="p_donor_heart" name="p_donor_heart" onchange="AlterParanoia();"<?=checked(!in_array('hide_donor_heart', $Paranoia))?> />
          <label for="p_donor_heart">Show donor heart</label>
        </td>
      </tr>
      <tr id="para_stats_tr">
        <td class="label tooltip" title="These settings control the display of your uploaded data amount, downloaded data amount, and ratio."><strong>Statistics</strong></td>
        <td>
<?
$UploadChecked = checked(!in_array('uploaded', $Paranoia));
$DownloadChecked = checked(!in_array('downloaded', $Paranoia));
$RatioChecked = checked(!in_array('ratio', $Paranoia));
?>
          <label><input type="checkbox" name="p_uploaded" onchange="AlterParanoia();"<?=$UploadChecked?> /> Uploaded</label>&nbsp;&nbsp;
          <label><input type="checkbox" name="p_downloaded" onchange="AlterParanoia();"<?=$DownloadChecked?> /> Downloaded</label>&nbsp;&nbsp;
          <label><input type="checkbox" name="p_ratio" onchange="AlterParanoia();"<?=$RatioChecked?> /> Ratio</label>
        </td>
      </tr>
      <tr id="para_reqratio_tr">
        <td class="label"><strong>Required Ratio</strong></td>
        <td>
          <label><input type="checkbox" name="p_requiredratio"<?=checked(!in_array('requiredratio', $Paranoia))?> /> Required Ratio</label>
        </td>
      </tr>
      <tr id="para_comments_tr">
        <td class="label"><strong>Comments (torrents)</strong></td>
        <td>
<? display_paranoia('torrentcomments'); ?>
        </td>
      </tr>
      <tr id="para_collstart_tr">
        <td class="label"><strong>Collections (started)</strong></td>
        <td>
<? display_paranoia('collages'); ?>
        </td>
      </tr>
      <tr id="para_collcontr_tr">
        <td class="label"><strong>Collections (contributed to)</strong></td>
        <td>
<? display_paranoia('collagecontribs'); ?>
        </td>
      </tr>
      <tr id="para_reqfill_tr">
        <td class="label"><strong>Requests (filled)</strong></td>
        <td>
<?
$RequestsFilledCountChecked = checked(!in_array('requestsfilled_count', $Paranoia));
$RequestsFilledBountyChecked = checked(!in_array('requestsfilled_bounty', $Paranoia));
$RequestsFilledListChecked = checked(!in_array('requestsfilled_list', $Paranoia));
?>
          <label><input type="checkbox" name="p_requestsfilled_count" onchange="AlterParanoia();"<?=$RequestsFilledCountChecked?> /> Show count</label>&nbsp;&nbsp;
          <label><input type="checkbox" name="p_requestsfilled_bounty" onchange="AlterParanoia();"<?=$RequestsFilledBountyChecked?> /> Show bounty</label>&nbsp;&nbsp;
          <label><input type="checkbox" name="p_requestsfilled_list" onchange="AlterParanoia();"<?=$RequestsFilledListChecked?> /> Show list</label>
        </td>
      </tr>
      <tr id="para_reqvote_tr">
        <td class="label"><strong>Requests (voted for)</strong></td>
        <td>
<?
$RequestsVotedCountChecked = checked(!in_array('requestsvoted_count', $Paranoia));
$RequestsVotedBountyChecked = checked(!in_array('requestsvoted_bounty', $Paranoia));
$RequestsVotedListChecked = checked(!in_array('requestsvoted_list', $Paranoia));
?>
          <label><input type="checkbox" name="p_requestsvoted_count" onchange="AlterParanoia();"<?=$RequestsVotedCountChecked?> /> Show count</label>&nbsp;&nbsp;
          <label><input type="checkbox" name="p_requestsvoted_bounty" onchange="AlterParanoia();"<?=$RequestsVotedBountyChecked?> /> Show bounty</label>&nbsp;&nbsp;
          <label><input type="checkbox" name="p_requestsvoted_list" onchange="AlterParanoia();"<?=$RequestsVotedListChecked?> /> Show list</label>
        </td>
      </tr>
      <tr id="para_upltor_tr">
        <td class="label"><strong>Uploaded torrents</strong></td>
        <td>
<? display_paranoia('uploads'); ?>
        </td>
      </tr>
      <tr id="para_uplunique_tr">
        <td class="label"><strong>Uploaded torrents (unique groups)</strong></td>
        <td>
<? display_paranoia('uniquegroups'); ?>
        </td>
      </tr>
      <tr id="para_torseed_tr">
        <td class="label"><strong>Torrents (seeding)</strong></td>
        <td>
<? display_paranoia('seeding'); ?>
        </td>
      </tr>
      <tr id="para_torleech_tr">
        <td class="label"><strong>Torrents (leeching)</strong></td>
        <td>
<? display_paranoia('leeching'); ?>
        </td>
      </tr>
      <tr id="para_torsnatch_tr">
        <td class="label"><strong>Torrents (snatched)</strong></td>
        <td>
<? display_paranoia('snatched'); ?>
        </td>
      </tr>
      <tr id="para_torsubscr_tr">
        <td class="label tooltip" title="This option allows other users to subscribe to your torrent uploads."><strong>Torrents (upload subscriptions)</strong></td>
        <td>
          <label><input type="checkbox" name="p_notifications"<?=checked(!in_array('notifications', $Paranoia))?> /> Allow torrent upload subscriptions</label>
        </td>
      </tr>
<?
$DB->query("
  SELECT COUNT(UserID)
  FROM users_info
  WHERE Inviter = ?", $UserID);
list($Invited) = $DB->next_record();
?>
      <tr id="para_invited_tr">
        <td class="label tooltip" title="This option controls the display of your <?=SITE_NAME?> invitees."><strong>Invitees</strong></td>
        <td>
          <label><input type="checkbox" name="p_invitedcount"<?=checked(!in_array('invitedcount', $Paranoia))?> /> Show count</label>
        </td>
      </tr>
<?
$DB->query("
  SELECT COUNT(ArtistID)
  FROM torrents_artists
  WHERE UserID = ?", $UserID);
list($ArtistsAdded) = $DB->next_record();
?>
      <tr id="para_artistsadded_tr">
        <td class="label tooltip" title="This option controls the display of the artists you have added to torrent groups on the site. This number includes artists added via the torrent upload form, as well as artists added via the &quot;Add artists&quot; box on torrent group pages."><strong>Artists added</strong></td>
        <td>
          <label><input type="checkbox" name="p_artistsadded"<?=checked(!in_array('artistsadded', $Paranoia))?> /> Show count</label>
        </td>
      </tr>
      <tr id="para_preview_tr">
        <td></td>
        <td><a href="#" id="preview_paranoia" class="brackets">Preview paranoia</a></td>
      </tr>
    </table>
    <table cellpadding="6" cellspacing="1" border="0" width="100%" class="layout border user_options" id="access_settings">
      <tr class="colhead_dark">
        <td colspan="2">
          <strong>Access Settings</strong>
        </td>
      </tr>
      <tr id="acc_2fa_tr">
        <td class="label tooltip" title="This page contains 2FA, U2F, and PGP settings"><strong>Account Security</strong></td>
        <td><a href="user.php?action=2fa">Click here to view additional account security options</a></td>
      </tr>
      <tr id="acc_currentpassword_tr">
        <td class="label"><strong>Current Password</strong></td>
        <td>
          <div class="field_div">
            <input type="password" size="40" name="cur_pass" id="cur_pass" maxlength="307200" value="" />
          </div>
          <strong class="important_text">When changing any of the settings below, you must enter your current password in this field before saving your changes</strong>
        </td>
      </tr>
      <tr id="acc_resetpk_tr">
        <td class="label tooltip_interactive" title="For information about the function of your passkey, please &lt;a href=&quot;<?=site_url()?>wiki.php?action=article&amp;amp;name=Passkey&quot;&gt;read this wiki article&lt;/a&gt;." data-title-plain="For information about the function of your passkey, please read the &quot;Passkey&quot; wiki article."><strong>Reset passkey</strong></td>
        <td>
          <div class="field_div">
            <label><input type="checkbox" name="resetpasskey" id="resetpasskey" />
            Reset your passkey?</label>
          </div>
          <p class="min_padding">Any active torrents must be downloaded again to continue leeching/seeding.</p>
        </td>
      </tr>
      <tr id="acc_irckey_tr">
        <td class="label"><strong>IRC key</strong></td>
        <td>
          <div class="field_div">
            <input type="text" size="50" name="irckey" id="irckey" value="<?=display_str($IRCKey)?>" />
          </div>
          <p class="min_padding">This key will be used when authenticating with <?=BOT_NICK?> on the <a href="wiki.php?action=article&amp;name=IRC">site's IRC network</a>. <span style="white-space: nowrap;">Please note:</span></p>
          <ul>
            <li>This value is stored in plaintext and should not be your password.</li>
            <li>IRC keys must be between 6 and 32 characters.</li>
          </ul>
        </td>
      </tr>
      <tr id="acc_email_tr">
        <td class="label tooltip" title="This is the email address you want associated with your <?=SITE_NAME?> account. It will be used if you forget your password or if an alert needs to be sent to you."><strong>Email address</strong></td>
        <td>
          <div class="field_div">
            <input type="email" size="50" name="email" id="email" value="<?=display_str($Email)?>" />
          </div>
        </td>
      </tr>
      <tr id="acc_password_tr">
        <td class="label"><strong>Password</strong></td>
        <td>
          <div class="field_div">
            <label>New password:<br />
            <input type="password" size="40" name="new_pass_1" id="new_pass_1" maxlength="307200" value="" /> <strong id="pass_strength"></strong></label>
          </div>
          <div class="field_div">
            <label>Confirm new password:<br />
            <input type="password" size="40" name="new_pass_2" id="new_pass_2" maxlength="307200" value="" /> <strong id="pass_match"></strong></label>
          </div>
          <div class="setting_description">
            Any password of 6 characters or longer will be accepted, but a strong password:
            <ul>
              <li>is 8 characters or longer</li>
              <li>contains at least 1 lowercase and uppercase letter</li>
              <li>contains at least a number or symbol</li>
            </ul>
          </div>
        </td>
      </tr>
    </table>
  </div>
  </form>
</div>
<? View::show_footer(); ?>
