Lighttpd conf file added for lighttpd webservers
[atbbs.git] / profile.php
blobf354bb4e80916b1ea9e1fdb44e4ab2fd46670116
1 <?php
3 require('includes/header.php');
5 // If you're not a mod, fuck off.
6 if( ! $moderator && ! $administrator)
8 add_error('You are not wise enough.', true);
11 // Demand UID.
12 if( ! isset($_GET['uid']))
14 add_error('No UID specified.', true);
17 // Demand a _valid_ UID, fetch first_seen, IP address, and hostname.
18 $uid_exists = $link->prepare('SELECT first_seen, ip_address FROM users WHERE uid = ?');
19 $uid_exists->bind_param('s', $_GET['uid']);
20 $uid_exists->execute();
21 $uid_exists->store_result();
22 if($uid_exists->num_rows < 1)
24 add_error('There is no such user.', true);
26 $uid_exists->bind_result($id_first_seen, $id_ip_address);
27 $uid_exists->fetch();
28 $uid_exists->close();
30 $id_hostname = @gethostbyaddr($id_ip_address);
31 if($id_hostname === $id_ip_address)
33 $id_hostname = false;
37 // Check if banned.
38 $check_uid_ban = $link->prepare('SELECT filed FROM uid_bans WHERE uid = ?');
39 $check_uid_ban->bind_param('s', $_GET['uid']);
40 $check_uid_ban->execute();
41 $check_uid_ban->store_result();
42 if($check_uid_ban->num_rows > 0)
44 $banned = true;
46 $check_uid_ban->close();
48 // Fetch number of topics and replies.
49 $query = "SELECT count(*) FROM topics WHERE author = '" . $link->real_escape_string($_GET['uid']) . "';";
50 $query .= "SELECT count(*) FROM replies WHERE author = '" . $link->real_escape_string($_GET['uid']) . "';";
52 $link->multi_query($query);
53 do {
54 $result = $link->store_result();
55 while ($row = $result->fetch_row())
57 $statistics[] = $row[0];
59 $result->free();
60 } while ($link->next_result());
62 $id_num_topics = $statistics[0];
63 $id_num_replies = $statistics[1];
65 // Now print everything.
66 $page_title = 'Profile of poster ' . $_GET['uid'];
67 dummy_form();
69 echo '<p>First seen <strong class="help" title="' . format_date($id_first_seen) . '">' . calculate_age($id_first_seen) . ' ago</strong> using the IP address <strong><a href="/IP_address/' . $id_ip_address . '">' . $id_ip_address . '</a></strong> (';
70 //If there's a valid host name ...
71 if($id_hostname)
73 echo 'host name <strong>' . $id_hostname . '</strong>';
75 else
77 echo 'no valid host name';
79 echo '), has started <strong>' . $id_num_topics . '</strong> existing topic' . ($id_num_topics == 1 ? '' : 's') . ' and posted <strong>' . $id_num_replies . '</strong> existing repl' . ($id_num_replies == 1 ? 'y' : 'ies') . '.</p>';
80 if($banned)
82 echo '<p>This poster is currently <strong>banned</strong>.';
84 echo '<ul class="menu">';
85 if( ! $banned)
87 echo '<li><a href="/ban_poster/' . $_GET['uid'] . '" onclick="return submitDummyForm(\'/ban_poster/' . $_GET['uid'] . '\', \'id\', \'' . $_GET['uid'] . '\', \'Really ban this poster?\');">Ban ID</a></li>';
89 else
91 echo '<li><a href="/unban_poster/' . $_GET['uid'] . '" onclick="return submitDummyForm(\'/unban_poster/' . $_GET['uid'] . '\', \'id\', \'' . $_GET['uid'] . '\', \'Really unban this poster?\');">Unban ID</a></li>';
93 echo '<li><a href="/nuke_ID/' . $_GET['uid'] . '" onclick="return submitDummyForm(\'/nuke_ID/' . $_GET['uid'] . '\', \'id\', \'' . $_GET['uid'] . '\', \'Really delete all topics and replies by this poster?\');">Delete all posts</a></li>';
94 echo '</ul>';
96 if($id_num_topics > 0)
98 echo '<h4 class="section">Topics</h4>';
100 $stmt = $link->prepare('SELECT id, time, replies, visits, headline, author_ip FROM topics WHERE author = ? ORDER BY id DESC');
101 $stmt->bind_param('s', $_GET['uid']);
102 $stmt->execute();
103 $stmt->bind_result($topic_id, $topic_time, $topic_replies, $topic_visits, $topic_headline, $topic_ip_address);
105 $topics = new table();
106 $columns = array
108 'Headline',
109 'IP address',
110 'Replies',
111 'Visits',
112 'Age ▼'
114 $topics->define_columns($columns, 'Headline');
115 $topics->add_td_class('Headline', 'topic_headline');
117 while($stmt->fetch())
119 $values = array
121 '<a href="/topic/' . $topic_id . '">' . htmlspecialchars($topic_headline) . '</a>',
122 '<a href="/IP_address/' . $topic_ip_address . '">' . $topic_ip_address . '</a>',
123 replies($topic_id, $topic_replies),
124 format_number($topic_visits),
125 '<span class="help" title="' . format_date($topic_time) . '">' . calculate_age($topic_time) . '</span>'
128 $topics->row($values);
130 $stmt->close();
131 echo $topics->output();
134 if($id_num_replies > 0)
136 echo '<h4 class="section">Replies</h4>';
138 $stmt = $link->prepare('SELECT replies.id, replies.parent_id, replies.time, replies.body, replies.author_ip, topics.headline, topics.time FROM replies INNER JOIN topics ON replies.parent_id = topics.id WHERE replies.author = ? ORDER BY id DESC');
139 $stmt->bind_param('s', $_GET['uid']);
140 $stmt->execute();
141 $stmt->bind_result($reply_id, $parent_id, $reply_time, $reply_body, $reply_ip_address, $topic_headline, $topic_time);
143 $replies = new table();
144 $columns = array
146 'Reply snippet',
147 'Topic',
148 'IP address',
149 'Age ▼'
151 $replies->define_columns($columns, 'Topic');
152 $replies->add_td_class('Topic', 'topic_headline');
153 $replies->add_td_class('Reply snippet', 'reply_body_snippet');
155 while($stmt->fetch())
157 $values = array
159 '<a href="/topic/' . $parent_id . '#reply_' . $reply_id . '">' . snippet($reply_body) . '</a>',
160 '<a href="/topic/' . $parent_id . '">' . htmlspecialchars($topic_headline) . '</a> <span class="help unimportant" title="' . format_date($topic_time) . '">(' . calculate_age($topic_time) . ' old)</span>',
161 '<a href="/IP_address/' . $reply_ip_address . '">' . $reply_ip_address . '</a>',
162 '<span class="help" title="' . format_date($reply_time) . '">' . calculate_age($reply_time) . '</span>'
165 $replies->row($values);
167 $stmt->close();
168 echo $replies->output();
171 if($trash = show_trash($_GET['uid']))
173 echo '<h4 class="section">Trash</h4>' . $trash;
176 require('includes/footer.php');