Initial commit.
[atbbs.git] / history.php
blob99b14ba6c8b17a679f5b491a5b8270601bc9fe6b
1 <?php
3 require('includes/header.php');
4 update_activity('history');
5 force_id();
7 if ( ! ctype_digit($_GET['p']) || $_GET['p'] < 2)
9 $current_page = 1;
10 $page_title = 'Your latest post history';
12 else
14 $current_page = $_GET['p'];
15 $page_title = 'Your post history, page #' . number_format($current_page);
18 $items_per_page = ITEMS_PER_PAGE;
19 $start_listing_at = $items_per_page * ($current_page - 1);
21 /* TOPICS */
23 $stmt = $link->prepare('SELECT id, time, replies, visits, headline FROM topics WHERE author = ? ORDER BY id DESC LIMIT ?, ?');
24 $stmt->bind_param('sii', $_SESSION['UID'], $start_listing_at, $items_per_page);
25 $stmt->execute();
26 $stmt->bind_result($topic_id, $topic_time, $topic_replies, $topic_visits, $topic_headline);
28 $topics = new table();
29 $columns = array
31 'Headline',
32 'Replies',
33 'Visits',
34 'Age ▼'
36 $topics->define_columns($columns, 'Headline');
37 $topics->add_td_class('Headline', 'topic_headline');
39 while($stmt->fetch())
41 $values = array
43 '<a href="/topic/' . $topic_id . '">' . htmlspecialchars($topic_headline) . '</a>',
44 replies($topic_id, $topic_replies),
45 format_number($topic_visits),
46 '<span class="help" title="' . format_date($topic_time) . '">' . calculate_age($topic_time) . '</span>'
49 $topics->row($values);
51 $stmt->close();
52 $num_topics_fetched = $topics->num_rows_fetched;
53 echo $topics->output('topics');
55 /* REPLIES */
57 $stmt = $link->prepare('SELECT replies.id, replies.parent_id, replies.time, replies.body, topics.headline, topics.time FROM replies INNER JOIN topics ON replies.parent_id = topics.id WHERE replies.author = ? ORDER BY id DESC LIMIT ?, ?');
58 $stmt->bind_param('sii', $_SESSION['UID'], $start_listing_at, $items_per_page);
59 $stmt->execute();
60 $stmt->bind_result($reply_id, $parent_id, $reply_time, $reply_body, $topic_headline, $topic_time);
62 $replies = new table();
63 $columns = array
65 'Reply snippet',
66 'Topic',
67 'Age ▼'
69 $replies->define_columns($columns, 'Topic');
70 $replies->add_td_class('Topic', 'topic_headline');
71 $replies->add_td_class('Reply snippet', 'reply_body_snippet');
73 while($stmt->fetch())
75 $values = array
77 '<a href="/topic/' . $parent_id . '#reply_' . $reply_id . '">' . snippet($reply_body) . '</a>',
78 '<a href="/topic/' . $parent_id . '">' . htmlspecialchars($topic_headline) . '</a> <span class="help unimportant" title="' . format_date($topic_time) . '">(' . calculate_age($topic_time) . ' old)</span>',
79 '<span class="help" title="' . format_date($reply_time) . '">' . calculate_age($reply_time) . '</span>'
82 $replies->row($values);
84 $stmt->close();
85 $num_replies_fetched = $replies->num_rows_fetched;
86 echo $replies->output('replies');
88 page_navigation('history', $current_page, $num_replies_fetched);
90 require('includes/footer.php');