255) { $news_search = substr($news_search, 0, 255); } $xtpl->assign("SEARCH_VALUE", htmlspecialchars($news_search)); $news_search = addslashes($news_search); $search_string = ""; if ($news_search != "") { $search_string .= " AND (news.subject LIKE '%".$news_search."%' OR news.announce LIKE '%".$news_search."%' OR news.content LIKE '%".$news_search."%' ".($isShowAuthor ? "OR news_user.name LIKE '%".$news_search."%'" : "").")"; } $sSQL_cnt = "SELECT count(*) As Total FROM news LEFT JOIN news_user ON news.news_user_id = news_user.news_user_id WHERE news.publication = 1 ".$search_string; $result_cnt = mysql_query($sSQL_cnt, $link); $row = mysql_fetch_object($result_cnt); $nrows = $row -> Total; $navbar = pager($page, $pageSize, $nrows, $script_name, $news_search != "" ? "news_search=".urlencode(stripslashes($news_search)) : ""); $offset = (intval($page) - 1)*$pageSize; $sSQL = "SELECT news.news_id, DATE_FORMAT(news.issuedate,\"%d-%m-%Y\") As fissuedate, news.subject, news.announce, news.importance, news.is_add_comment, news_user.name As user_name FROM news LEFT JOIN news_user ON news.news_user_id = news_user.news_user_id WHERE news.publication = 1 ".$search_string." ORDER BY news.issuedate DESC, news.news_id DESC LIMIT $offset,$pageSize"; $result = mysql_query($sSQL, $link); $nr = mysql_num_rows($result); if ($nr == 0) { $xtpl->parse("news.content.is_comments"); $xtpl->reset("news.content.is_comments"); $xtpl->parse("news.content"); $xtpl->reset("news.content"); } while($row = mysql_fetch_array($result)) { if ($row["importance"] == 1) { $style = "importance"; } else { $style = "base"; } $rs_comments = mysql_query("SELECT count(*) FROM news_comment WHERE news_id = ".$row["news_id"], $link); $row_comments = mysql_fetch_array($rs_comments); if ($row["is_add_comment"] != 1 && $row_comments[0] == 0) { $xtpl->parse("news.content.is_comments"); $xtpl->reset("news.content.is_comments"); } else { $xtpl->assign("COMMENT_COUNT", $row_comments[0]); $xtpl->parse("news.content.is_comments"); } $xtpl->assign("SCRIPT_NAME", $script_name); $xtpl->assign("NEWS_ID", $row["news_id"]); $xtpl->assign("ISSUEDATE", $row["fissuedate"]); $xtpl->assign("SUBJECT", $row["subject"]); $xtpl->assign("AUTHOR", $isShowAuthor ? "   |  ".htmlspecialchars($row["user_name"])."" : ""); $xtpl->assign("ANNOUNCE", $row["announce"]); $xtpl->assign("STYLE", $style); $xtpl->parse("news.content"); } if ($navbar != "") { $xtpl->assign("NAVBAR", $navbar); $xtpl->parse("news.pager"); } else { $xtpl->parse("news.pager"); $xtpl->reset("news.pager"); } $xtpl->assign("SCRIPT_NAME", $script_name); $xtpl->parse("news"); $xtpl->out("news"); mysql_close($link); } function Detail() { global $link, $id, $print, $isShowAuthor; if ($print == "1") $xtpl=new XTemplate ("./templates/printable.html"); else $xtpl=new XTemplate ("./templates/news_detail.html"); $sSQL = "SELECT news.news_id, DATE_FORMAT(news.issuedate,\"%d-%m-%Y\") As fissuedate, news.subject, news.content, news.importance, news.img, news.img_description, news.is_add_comment, news_user.name As user_name FROM news LEFT JOIN news_user ON news.news_user_id = news_user.news_user_id WHERE news.publication = 1 AND news.news_id = " . $id; $result = mysql_query($sSQL, $link); $nr = mysql_num_rows($result); $row = mysql_fetch_array($result); if ($row["importance"] == 1) { $style = "importance"; } else { $style = "base"; } if ($row["img"] != "") $img = "

\"".$row["img_description"]."\"
"; if ($row["content"] != "") $content = "

".$row["content"]; $xtpl->assign("NEWS_ID", $row["news_id"]); $xtpl->assign("STYLE", $style); $xtpl->assign("ISSUEDATE", $row["fissuedate"]); $xtpl->assign("SUBJECT", $row["subject"]); $xtpl->assign("AUTHOR", $isShowAuthor ? "   |  ".htmlspecialchars($row["user_name"])."" : ""); $xtpl->assign("IMAGE", $img); $xtpl->assign("DESCRIPTION", $content); if ($print != "1") Comments(&$xtpl, $row["is_add_comment"], $nr); $xtpl->parse("news"); $xtpl->out("news"); mysql_close($link); } function Comments($xtpl, $is_add_comment, $nr) { global $link, $id, $script_name; if ($nr == 0) { $xtpl->parse("news.comments_title"); $xtpl->reset("news.comments_title"); $xtpl->parse("news.comments_add"); $xtpl->reset("news.comments_add"); $xtpl->parse("news.comments_list"); $xtpl->reset("news.comments_list"); $xtpl->parse("news.comments_list_pager"); $xtpl->reset("news.comments_list_pager"); return; } if ($is_add_comment == 1) { $xtpl->assign("BACK_URL", $script_name."?id=".$id); $xtpl->parse("news.comments_add"); } else { $xtpl->parse("news.comments_add"); $xtpl->reset("news.comments_add"); } $sSQL_cnt = "SELECT count(*) As Total FROM news_comment WHERE news_id = ".$id; $result_cnt = mysql_query($sSQL_cnt, $link); $row = mysql_fetch_object($result_cnt); $nrows = $row -> Total; if ($nrows == 0 && $is_add_comment != 1) { $xtpl->parse("news.comments_title"); $xtpl->reset("news.comments_title"); } else { $xtpl->parse("news.comments_title"); } $pageSize = 20; //кол-во комментариев на странице $page=((!isset($_GET["page"]))?"":$_GET["page"]); if ($page == "") { $page = 1; } $navbar = pager($page, $pageSize, $nrows, $script_name, "id=".$id); $offset = (intval($page) - 1)*$pageSize; $sSQL = "SELECT news_comment_id, DATE_FORMAT(issuedate,\"%d-%m-%Y %H:%i\") As fissuedate, priority, user_name, content FROM news_comment WHERE news_id = ".$id." ORDER BY issuedate LIMIT $offset,$pageSize"; $result = mysql_query($sSQL, $link); $nr = mysql_num_rows($result); if ($nr == 0) { $xtpl->parse("news.comments_list"); $xtpl->reset("news.comments_list"); } while($row = mysql_fetch_array($result)) { $xtpl->assign("NUM", $row["priority"]); $xtpl->assign("USER_NAME", $row["user_name"]); $xtpl->assign("C_ISSUEDATE", $row["fissuedate"]); $xtpl->assign("CONTENT", wordwrap_msg(nl2br($row["content"]))); $xtpl->parse("news.comments_list"); } if ($navbar != "") { $xtpl->assign("NAVBAR", $navbar); $xtpl->parse("news.comments_list_pager"); } else { $xtpl->parse("news.comments_list_pager"); $xtpl->reset("news.comments_list_pager"); } } ?>