<?php
2 /*-------------------------------------------------------+
3 | <span style="border-bottom: 1px dotted black;">PHP</span>-Fusion Content Management System
4 | Copyright (C) 2002 - 2011 Nick Jones
5 | <a href='http://www.php-fusion.co.uk/' target='_blank'><span style='color:005C5B'>http://www.php-fusion.co.uk/</span></a>
6 +--------------------------------------------------------+
7 | Filename: news.php
8 | Author: Nick Jones (Digitanium)
9 +--------------------------------------------------------+
10 | This program is released as free software under the
11 | Affero GPL license. You can redistribute it and/or
12 | modify it under the terms of this license which you
13 | can read by viewing the included agpl.txt or online
14 | at <a href='http://www.gnu.org/licenses/agpl.html.' target='_blank'><span style='color:005C5B'>www.gnu.org/licenses/agpl.html.</span></a> Removal of this
15 | copyright header is strictly prohibited without
16 | written permission from the original author(s).
17 +--------------------------------------------------------*/
18 require_once "maincore.php";
19 require_once THEMES."templates/header.php";
20
21 // Predefined variables, do not edit these values
22 $i = 0;
23
24 // Number of news displayed
25 $items_per_page = $settings['newsperpage'];
26
27 add_to_title($locale['global_200'].$locale['global_077']);
28
29 if (!isset($_GET['readmore']) || !isnum($_GET['readmore'])) {
30 $rows = dbcount(
31 "(news_id)",
32 DB_NEWS,
33 groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().")
34 AND (news_end='0'||news_end>=".time().")
35 AND news_draft='0'"
36 );
37 if (!isset($_GET['rowstart']) || !isnum($_GET['rowstart'])) { $_GET['rowstart'] = 0; }
38 if ($rows) {
39 $result = dbquery(
40 "SELECT tn.*, tc.*, tu.user_id, tu.user_name, tu.user_status
41 FROM ".DB_NEWS." tn
42 LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
43 LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
44 WHERE ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().")
45 AND (news_end='0'||news_end>=".time().") AND news_draft='0'
46 GROUP BY news_id
47 ORDER BY news_sticky DESC, news_datestamp DESC LIMIT ".$_GET['rowstart'].",".$items_per_page
48 );
49 $numrows = dbrows($result);
50 while ($data = dbarray($result)) {
51 $i++;
52 $comments = dbcount("(comment_id)", DB_COMMENTS." WHERE comment_type='N' AND comment_hidden='0' AND comment_item_id='".$data['news_id']."'");
53 $news_cat_image = "";
54 $news_subject = "<a name='news_".$data['news_id']."' id='news_".$data['news_id']."'></a>".stripslashes($data['news_subject']);
55 $news_cat_image = "<a href='".($settings['news_image_link'] == 0 ? "news_cats.php?cat_id=".$data['news_cat']
56 : FUSION_SELF."?readmore=".$data['news_id'] )."'>";
57 if ($data['news_image_t2'] && $settings['news_image_frontpage'] == 0) {
58 $news_cat_image .= "<img src='".IMAGES_N_T.$data['news_image_t2']."' alt='".$data['news_subject']."' class='news-category' /></a>";
59 } elseif ($data['news_cat_image']) {
60 $news_cat_image .= "<img src='".get_image("nc_".$data['news_cat_name'])."' alt='".$data['news_cat_name']."' class='news-category' /></a>";
61 } else {
62 $news_cat_image = "";
63 }
64 $news_news = $data['news_breaks'] == "y" ? nl2br(stripslashes($data['news_news'])) : stripslashes($data['news_news']);
65
66 $news_info = array(
67 "news_id" => $data['news_id'],
68 "user_id" => $data['user_id'],
69 "user_name" => $data['user_name'],
70 "user_status" => $data['user_status'],
71 "news_date" => $data['news_datestamp'],
72 "cat_id" => $data['news_cat'],
73 "cat_name" => $data['news_cat_name'],
74 "cat_image" => $news_cat_image,
75 "news_subject" => $data['news_subject'],
76 "news_ext" => $data['news_extended'] ? "y" : "n",
77 "news_reads" => $data['news_reads'],
78 "news_comments" => $comments,
79 "news_allow_comments" => $data['news_allow_comments'],
80 "news_sticky" => $data['news_sticky']
81 );
82
83 echo "<!--news_prepost_".$i."-->\n";
84 render_news($news_subject, $news_news, $news_info);
85 }
86 echo "<!--sub_news_idx-->\n";
87 if ($rows > $items_per_page) echo "<div align='center'
style=';margin-top:5px;'>\n".makepagenav($_GET['rowstart'],$items_per_page,$rows,3)."\n</div>\n";
88 } else {
89 opentable($locale['global_077']);
90 echo "<div style='text-align:center'><br />\n".$locale['global_078']."<br /><br />\n</div>\n";
91 closetable();
92 }
93 } else {
94 $result = dbquery(
95 "SELECT tn.*, tc.*, tu.user_id, tu.user_name, tu.user_status FROM ".DB_NEWS." tn
96 LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
97 LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
98 WHERE ".groupaccess('news_visibility')." AND news_id='".$_GET['readmore']."' AND news_draft='0'
99 LIMIT 1"
100 );
101 if (dbrows($result)) {
102 include INCLUDES."comments_include.php";
103 include INCLUDES."ratings_include.php";
104 $data = dbarray($result);
105 if (!isset($_POST['post_comment']) && !isset($_POST['post_rating'])) {
106 $result2 = dbquery("UPDATE ".DB_NEWS." SET news_reads=news_reads+1 WHERE news_id='".$_GET['readmore']."'");
107 $data['news_reads']++;
108 }
109 $news_cat_image = "";
110 $news_subject = $data['news_subject'];
111 if ($data['news_image_t1'] && $settings['news_image_readmore'] == "0") {
112 $img_size = @getimagesize(IMAGES_N.$data['news_image']);
113 $news_cat_image = "<a href=\"javascript:;\"
onclick=\"window.open('".IMAGES_N.$data['news_image']."','','scrollbars=yes,toolbar=no,status=no,resizable=yes,width=".($img_size[0]+20).",height
=".($img_size[1]+20)."')\"><img src='".IMAGES_N_T.$data['news_image_t1']."' alt='".$data['news_subject']."' class='news-category' /></a>";
114 } elseif ($data['news_cat_image']) {
115 $news_cat_image = "<a href='news_cats.php?cat_id=".$data['news_cat']."'><img src='".get_image("nc_".$data['news_cat_name'])."'
alt='".$data['news_cat_name']."' class='news-category' /></a>";
116 }
117 $news_news = stripslashes($data['news_extended'] ? $data['news_extended'] : $data['news_news']);
118 if ($data['news_breaks'] == "y") { $news_news = nl2br($news_news); }
119 $news_info = array(
120 "news_id" => $data['news_id'],
121 "user_id" => $data['user_id'],
122 "user_name" => $data['user_name'],
123 "user_status" => $data['user_status'],
124 "news_date" => $data['news_datestamp'],
125 "cat_id" => $data['news_cat'],
126 "cat_name" => $data['news_cat_name'],
127 "cat_image" => $news_cat_image,
128 "news_subject" => $data['news_subject'],
129 "news_ext" => "n",
130 "news_reads" => $data['news_reads'],
131 "news_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='N' AND comment_item_id='".$data['news_id']."' AND comment_hidden='0'"),
132 "news_allow_comments" => $data['news_allow_comments'],
133 "news_sticky" => $data['news_sticky']
134 );
135 add_to_title($locale['global_201'].$news_subject);
136 echo "<!--news_pre_readmore-->";
137 render_news($news_subject, $news_news, $news_info);
138 echo "<!--news_sub_readmore-->";
139 if ($data['news_allow_comments']) { showcomments("N", DB_NEWS, "news_id", $_GET['readmore'], FUSION_SELF."?readmore=".$_GET['readmore']); }
140 if ($data['news_allow_ratings']) { showratings("N", $_GET['readmore'], FUSION_SELF."?readmore=".$_GET['readmore']); }
141 } else {
142 redirect(FUSION_SELF);
143 }
144 }
145
146 require_once THEMES."templates/footer.php";
147 ?>
Į viršų
apacia