SO 1-final
[specialops1.git] / pref.php
blob68be0cacc607b41b8c4819c3402396bf4d861db5
1 <?php
2 require ('config.php');
3 require ('extfuncs.inc.php');
4 $level_restriction = INACTIVE_USER;
5 $require_login = true;
7 if (
8 isset ($_POST['submit'])
9 && (strlen ($_POST['email']) <= 50)
10 && (strlen ($_POST['email2']) <= 50)
11 && (strlen ($_POST['im']) <= 50)
12 && (strlen ($_POST['sig']) <= 255)
13 && (strlen ($_POST['quote']) <= 255)
16 $quote = ($userinfo['level'] < ADMIN ? htmlentities ($_POST['quote']) : nl2br ($_POST['quote']));
17 $logintimer = ($_POST['logintimer'] >= 60 && $_POST['logintimer'] <= 3600) ? intval ($_POST['logintimer']) : 10;
18 $ppp = ($_POST['ppp'] >= 5 && $_POST['ppp'] <= 150) ? intval ($_POST['ppp']) : 35;
19 $tpp = ($_POST['tpp'] >= 5 && $_POST['tpp'] <= 100) ? intval ($_POST['tpp']) : 35;
21 foreach (array ('postlayout', 'timezone', 'hidepoll') as $varname)
22 $$varname = intval ($_POST[$varname]);
23 foreach (array ('sig', 'quote', 'email', 'email2', 'im', 'timeformat') as $varname)
24 $$varname = mysql_real_escape_string ($_POST[$varname]);
26 $prefs = ($userinfo['viewdisp'] | 0x17f) - 0x17f; //(127+256)
27 $prefs += (int) isset ($_POST['topic_views']);
28 $prefs += (int) isset ($_POST['view_time']) * 2;
29 $prefs += (int) isset ($_POST['showonline']) * 4;
30 $prefs += (int) isset ($_POST['altstyles']) * 8;
31 $prefs += (int) isset ($_POST['dst']) * 16;
32 $prefs += intval ($_POST['postlayout']) * 32;
33 $prefs += (int) isset ($_POST['css_special']) * 64;
34 $prefs += (int) (isset ($_POST['invisible']) && $userinfo['level'] >= ELI_USER) * 256;
36 mysql_query ('UPDATE `users` SET
37 `email` = \''.htmlentities ($email).'\',
38 `email2` = \''.htmlentities ($email2).'\',
39 `AIM` = \''.htmlentities ($im).'\',
40 `sig` = \''.htmlentities ($sig).'\',
41 `quote` = \''.$quote.'\',
42 `viewdisp` = '.$prefs.',
43 `timezone` = '.$timezone.',
44 `timeformat` = \''.$timeformat.'\',
45 `logintimer` = '.$logintimer.',
46 `hidepoll` = '.$hidepoll.',
47 `ppp` = '.$ppp.',
48 `tpp` = '.$tpp.'
49 WHERE `userid` = '.$userinfo['userid'].' LIMIT 1'
51 $userinfo = mysql_fetch_assoc (mysql_query ('SELECT * FROM `users` WHERE `userid` = '.$userinfo['userid']));
52 $updated = true;
53 $userinfo['timeoffset'] = ($userinfo['timezone'] + (bool) ($userinfo['viewdisp'] & 16)) * 3600;
56 $page_name = 'User Settings';
57 require ('top.inc.php');
59 if (isset ($updated))
60 echo '<div class="alert">Preferences updated.</div>
63 $userinfo['quote'] = str_replace ('<br />', '', $userinfo['quote']);
65 echo '<form method="post" action="'.urlpath(2).'">
66 <h2>Display Options</h2>
67 <dl>
68 <dt>Topic list</dt>
69 <dd>Show <input type="text" name="tpp" value="'.$userinfo['tpp'].'" maxlength="3" size="3"/> topics per page (5-100)</dd>
71 <dd><input type="checkbox" name="topic_views"'.($userinfo['viewdisp'] & 1 ? ' checked="checked"' : '').' id="topic_views"/>
72 <label for="topic_views">Show number of views for each topic</label></dd>
74 <dd><input type="checkbox" name="view_time"'.($userinfo['viewdisp'] & 2 ? ' checked="checked"' : '').' id="view_time"/>
75 <label for="view_time">Show date of last view for each topic</label></dd>
78 <dt>Message list</dt>
79 <dd>Show <input type="text" name="ppp" value="'.$userinfo['ppp'].'" maxlength="3" size="3"/> posts per page (5-150)</dd>
82 <dt>Post page (buttons)</dt>
83 <dd><input type="radio" name="postlayout"'.($userinfo['viewdisp'] & 32 ? '' : ' checked="checked"').' id="postlayout1" value="0"/>
84 <label for="postlayout1">[Post] [Preview]</label></dd>
86 <dd><input type="radio" name="postlayout"'.($userinfo['viewdisp'] & 32 ? ' checked="checked"' : '').' id="postlayout2" value="1"/>
87 <label for="postlayout2">[Preview] [Post]</label></dd>
90 <dt>Poll</dt>
91 <dd><input type="radio" name="hidepoll"'.($userinfo['hidepoll'] == 0 ? ' checked="checked"' : '').' id="hide_poll" value="0"/>
92 <label for="hide_poll">Always hide poll</label></dd>
94 <dd><input type="radio" name="hidepoll"'.($userinfo['hidepoll'] == 1 ? ' checked="checked"' : '').' id="show_poll" value="1"/>
95 <label for="show_poll">Always show poll</label></dd>
97 <dd><input type="radio" name="hidepoll"'.($userinfo['hidepoll'] == 2 ? ' checked="checked"' : '').' id="autohide_poll" value="2"/>
98 <label for="autohide_poll">Hide if already voted</label></dd>
101 <dt>Time display</dt>
102 <dd>Timezone offset: <select name="timezone">';
103 for ($hour = -12; $hour <= 13; $hour++)
104 echo '<option value="'.$hour.'"'.($userinfo['timezone'] == $hour ? ' selected="selected"' : '').'>GMT '.($hour > 0 ? '+' : '').($hour ? $hour : '').'</option>'."\n";
105 echo '</select></dd>
107 <dd><input type="checkbox" name="dst"'.($userinfo['viewdisp'] & 16 ? ' checked="checked"' : '').' id="dst"/>
108 <label for="dst">Adjust time automatically for DST/BST</label></dd>
110 <dd>Displayed <a href="http://php.net/date">date/time format</a>:
111 <input type="text" name="timeformat" value="'.$userinfo['timeformat'].'" maxlength="30"/></dd>
113 <dd>Current settings: '.date2 (time()).'</dd>
116 <dt>Other</dt>
117 <dd>Show users as online for
118 <input type="text" name="logintimer" value="'.$userinfo['logintimer'].'" maxlength="4" style="width:4em"/> seconds idle (60-3600)</dd>
120 <dd><input type="checkbox" name="showonline"'.($userinfo['viewdisp'] & 4 ? ' checked="checked"' : '').' id="showonline"/>
121 <label for="showonline">Show online users in menubar</label></dd>
123 <dd><input type="checkbox" name="altstyles"'.($userinfo['viewdisp'] & 8 ? ' checked="checked"' : '').' id="altstyles"/>
124 <label for="altstyles">Enable alternate CSS</label></dd>
126 <dd><input type="checkbox" name="css_special"'.($userinfo['viewdisp'] & 64 ? ' checked="checked"' : '').' id="css_special"/>
127 <label for="css_special">Enable extended CSS</label></dd>
129 '.($userinfo['level'] >= ELI_USER ? '<dd><input type="checkbox" name="invisible"'.($userinfo['viewdisp'] & 256 ? ' checked="checked"' : '').' id="invisible"/>
130 <label for="invisible">Invisible login mode</label></dd>' : '').'
131 </dl>
134 <h2>Profile</h2>
135 <ul class="plain-list">
136 <li>Private Email (not publicly displayed, max 50 chars): <input type="text" name="email" value="'.$userinfo['email'].'" maxlength="50"/></li>
138 <li>Public Email (visible to logged in users, max 50 chars): <input type="text" name="email2" value="'.$userinfo['email2'].'" maxlength="50"/></li>
140 <li>IM screenname (visible to logged in users, max 50 chars): <input type="text" name="im" value="'.$userinfo['AIM'].'" maxlength="50"/></li>
142 <li>Signature (max 255 chars): <textarea name="sig" rows="4" cols="80" style="width: 100%">'.$userinfo['sig'].'</textarea></li>
144 <li>Quote (shown in userinfo, max 255 chars): <textarea name="quote" rows="4" cols="80" style="width: 100%">'.$userinfo['quote'].'</textarea></li>
145 </ul>
148 <div class="c3"><input type="submit" name="submit" value="Save Settings" accesskey="s"/> <small>(Alt+S)</small></div>
149 </form>';
151 require ('foot.php');