123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- if (!defined('SMF'))
- die('Hacking attempt...');
- function PrintTopic()
- {
- global $topic, $txt, $scripturl, $context, $user_info;
- global $board_info, $smcFunc, $modSettings;
-
- if (empty($topic))
- redirectexit();
-
- $context['robot_no_index'] = true;
-
- $request = $smcFunc['db_query']('', '
- SELECT m.poster_time, IFNULL(mem.real_name, m.poster_name) AS poster_name
- FROM {db_prefix}messages AS m
- LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
- WHERE m.id_topic = {int:current_topic}
- ORDER BY m.id_msg
- LIMIT 1',
- array(
- 'current_topic' => $topic,
- )
- );
-
- if ($smcFunc['db_num_rows']($request) == 0)
- redirectexit();
- $row = $smcFunc['db_fetch_assoc']($request);
- $smcFunc['db_free_result']($request);
-
- loadTemplate('Printpage');
- $context['template_layers'] = array('print');
- $context['board_name'] = $board_info['name'];
- $context['category_name'] = $board_info['cat']['name'];
- $context['poster_name'] = $row['poster_name'];
- $context['post_time'] = timeformat($row['poster_time'], false);
- $context['parent_boards'] = array();
- foreach ($board_info['parent_boards'] as $parent)
- $context['parent_boards'][] = $parent['name'];
-
- $request = $smcFunc['db_query']('', '
- SELECT subject, poster_time, body, IFNULL(mem.real_name, poster_name) AS poster_name
- FROM {db_prefix}messages AS m
- LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
- WHERE m.id_topic = {int:current_topic}' . ($modSettings['postmod_active'] && !allowedTo('approve_posts') ? '
- AND (m.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR m.id_member = {int:current_member}') . ')' : '') . '
- ORDER BY m.id_msg',
- array(
- 'current_topic' => $topic,
- 'is_approved' => 1,
- 'current_member' => $user_info['id'],
- )
- );
- $context['posts'] = array();
- while ($row = $smcFunc['db_fetch_assoc']($request))
- {
-
- censorText($row['subject']);
- censorText($row['body']);
- $context['posts'][] = array(
- 'subject' => $row['subject'],
- 'member' => $row['poster_name'],
- 'time' => timeformat($row['poster_time'], false),
- 'timestamp' => forum_time(true, $row['poster_time']),
- 'body' => parse_bbc($row['body'], 'print'),
- );
- if (!isset($context['topic_subject']))
- $context['topic_subject'] = $row['subject'];
- }
- $smcFunc['db_free_result']($request);
-
- $context['canonical_url'] = $scripturl . '?topic=' . $topic . '.0';
- }
- ?>
|