root/news.php

Revision 321, 2.8 kB (checked in by Nafania, 1 year ago)

--

Line 
1 <?php</span>
2 <span class="code-lang">$root_path = './';
3 require ($root_path . 'include/config.php');
4 require ($root_path . 'include/bbcode/bbcode.lib.php');
5 require ($root_path . 'include/functions_post.php');
6
7 $userdata = session_pagestart($user_ip);
8 init_userprefs($userdata);
9
10 $action = request_var('action', '');
11 $id = request_var('id', 0);</span>
12 <span class="code-lang">
13 switch ( $action ) {
14     default:
15         $sql = 'SELECT n.*, u.name
16                 FROM ' . NEWS_TABLE . ' n, ' . USERS_TABLE . ' u
17                 WHERE n.userid = u.uid AND n.id = ' . $id;
18         $result = $db->sql_query($sql);
19         if ( !$row = $db->sql_fetchrow($result) ) {
20             trigger_error( sprintf($lang['invalid_id'], $id) );
21         }
22
23         $bb_code = new bbcode($row['body']);
24         $row['body'] = $bb_code->get_html();
25
26         $template->assign_vars(array(
27             'NEWS_TITLE' => $row['title'],
28             'NEWS_TEXT' => $row['body'],
29             'NEWS_ADDED' => create_date($row['added']),
30             'NEWS_AUTHOR' => $row['name'],
31             'NEWS_COMMENTS_COUNT' => $row['news_comments'],
32         ));
33
34         $sql = 'SELECT checkcomm_view_status FROM ' . COMMENTS_NOTIFY_TABLE . ' WHERE checkcomm_userid = ' . $userdata['uid'] . ' AND checkcomm_type = ' . TYPE_NEWS . ' AND checkcomm_for_id = ' . $id;
35         $result = $db->sql_query( $sql );
36         $checkcomm = $db->sql_fetchrow( $result );
37         $db->sql_freeresult( $result );
38         if ( $checkcomm ) {
39             if ( !$checkcomm['checkcomm_view_status'] ) {
40                 $sql_priority = ( $db_type == 'mysql' ) ? ' LOW_PRIORITY' : '';
41                 $sql = 'UPDATE' . $sql_priority . ' ' . COMMENTS_NOTIFY_TABLE . ' SET  checkcomm_view_status = ' . VIEW_STATUS_VIEWED . ', checkcomm_notify_status = ' . NOTIFY_STATUS_UN_NOTIFIED . ' WHERE checkcomm_userid = ' . $userdata['uid'] . ' AND checkcomm_type = ' . TYPE_NEWS . ' AND checkcomm_for_id = ' . $id;
42                 $db->sql_query($sql);
43             }
44             $check_action = 'comment.php?type=' . TYPE_NEWS . '&amp;action=checkoff&amp;tid=' . $id;
45             $check_title = $lang['checkcomm_off'];
46         }
47         else {
48             $check_action = 'comment.php?type=' . TYPE_NEWS . '&amp;action=check&amp;tid=' . $id;
49             $check_title = $lang['checkcomm_on'];
50         }
51
52
53         if ( $row['news_comments'] ) {
54             list($pagertop, $pagerbottom, $offset, $limit) = pager( $config['posts_per_page'], $row['news_comments'], 'news.php?id=' . $id . '&amp;' );
55
56             commenttable(TYPE_NEWS, $id, $row['userid'], $offset, $limit);
57         }
58         else {
59             $pagertop = $pagerbottom = '';
60         }
61
62         set_tracking(TYPE_NEWS, $id);
63
64         $template->assign_vars(array(
65             'U_ADD_COMMENT' => append_sid($root_path . 'comment.php?type=' . TYPE_NEWS . '&amp;action=add&amp;tid=' . $id ),
66             'U_CHECK' => append_sid($check_action),
67             'CHECK_TITLE' => $check_title,
68             'PAGERTOP' => $pagertop,
69             'PAGERBOTTOM' => $pagerbottom
70         ));
71
72         stdhead($row['title']);
73         $template->set_filenames(array(
74             'body' => 'news_view_body.html'
75         ));
76         stdfoot();
77     break;
78 }
79
80 ?>
Note: See TracBrowser for help on using the browser.