SO 1-final
[specialops1.git] / prefs.php
blobbafb83fd8de015312c9e800b917ee1b6ff1cb6c8
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'], $_POST['public_email'], $_POST['private_email'], $_POST['sig'], $_POST['quote'])
9 && (strlen($_POST['public_email']) <= 50)
10 && (strlen($_POST['private_email']) <= 50)
11 && (strlen($_POST['sig']) <= 255)
12 && (strlen($_POST['quote']) <= 255)
13 ) {
14 $msgs_page = $_POST['msgs_page'] >= 5 && $_POST['msgs_page'] <= 150 ? intval($_POST['msgs_page']) : 35;
15 $topics_page = $_POST['topics_page'] >= 5 && $_POST['topics_page'] <= 150 ? intval($_POST['topics_page']) : 35;
17 mysql_query ('UPDATE `users` SET
18 `public_email` = \''.mysql_real_escape_string(htmlspecialchars($_POST['public_email'])).'\',
19 `private_email` = \''.mysql_real_escape_string(htmlspecialchars($_POST['private_email'])).'\',
20 `sig` = \''.mysql_real_escape_string(htmlspecialchars($_POST['sig'])).'\',
21 `quote` = \''.mysql_real_escape_string(htmlspecialchars($_POST['quote'])).'\',
22 `dateformat` = \''.mysql_real_escape_string($_POST['dateformat']).'\',
23 `timezone` = '.intval($_POST['timezone']).',
24 `msgs_page` = '.$msgs_page.',
25 `topics_page` = '.$topics_page.'
26 WHERE `user` = '.$userinfo['user'].' LIMIT 1'
28 $userinfo = mysql_fetch_assoc(mysql_query('SELECT * FROM `users` WHERE `user` = '.$userinfo['user']));
29 $updated = true;
32 $page_name = 'User Settings';
33 require 'top.inc.php';
35 if ( isset($updated) )
36 echo '<div class="alert">Preferences updated.</div>',"\n";
38 $userinfo['quote'] = str_replace('<br />', '', $userinfo['quote']);
40 echo '<form method="post" action="',$_SERVER['PHP_SELF'],URL_STRING,'">
41 <table>
42 <caption><h3>Display Options</h3></caption>
43 <thead><tr><th>Setting</th><th>Value</th></tr></thead>
44 <tbody>
45 <tr><td>Topics per page</td>
46 <td>Show <input type="text" name="topics_page" value="'.$userinfo['topics_page'].'" size="3"/> (5-100)</td></tr>
47 <tr><td>Messages per page</td>
48 <td>Show <input type="text" name="msgs_page" value="'.$userinfo['msgs_page'].'" size="3"/> (5-150)</td></tr>
50 <tr><td>Timezone offset</td>
51 <td><select name="timezone">',"\n";
52 for ($hour = -12; $hour <= 13; $hour++)
53 echo "\t",'<option value="',$hour,'"',( $userinfo['timezone'] == $hour ? ' selected="selected"' : '' ),'>',
54 ( $hour > 0 ? '+' : '' ),$hour,"</option>\n";
55 echo '</select></td></tr>
57 <tr><td>Displayed <a href="http://php.net/date">date/time format</a><br/>
58 <small>(Leave blank for default)</small></td>
59 <td><input type="text" name="dateformat" value="',$userinfo['dateformat'],'" maxlength="30"/><br/>
60 <small>Date/time according to current settings: ',date2(time()),'</small></td></tr>
61 </tbody>
62 </table>
64 <table>
65 <caption><h3>Profile</h3></caption>
66 <thead><tr><th>Setting</th><th>Value</th></tr></thead>
67 <tbody>
68 <tr><td>Private email<br/>
69 <small>(Not publicly displayed, max 50 chars)</small></td>
70 <td><input type="text" name="private_email" value="',$userinfo['private_email'],'" maxlength="50"/></td></tr>
71 <tr><td>Public Email<br/>
72 <small>(visible to logged in users, max 50 chars)</small></td>
73 <td><input type="text" name="public_email" value="',$userinfo['public_email'],'" maxlength="50"/></td></tr>
74 <tr><td>Signature<br/>
75 <small>(max 255 chars)</small></td>
76 <td><textarea name="sig" rows="4" cols="80" style="width: 100%">',$userinfo['sig'],'</textarea></td></tr>
78 <tr><td>Quote<br/>
79 <small>(shown in userinfo, max 255 chars)</td>
80 <td><textarea name="quote" rows="4" cols="80" style="width:100%">',
81 str_replace('<br />', '', $userinfo['quote']),'</textarea></td></tr>
82 </tbody>
83 </table>
85 <p class="c3"><input type="submit" name="submit" value="Save Settings (S)" accesskey="s"/></p>
86 </form>';
88 footer();