1 |
<?php |
<?php |
2 |
|
function get_sections($nid, &$text, $par = 0) { |
3 |
|
global $dbh; |
4 |
|
if (!isset($nid)) return array(); |
5 |
|
if (!$par) $par = "NULL"; |
6 |
|
$sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos, hl, pic_title FROM paragraphs, par_levels WHERE (news_id = $nid) AND (level = level_id) AND (parent = $par)"; |
7 |
|
$sth = $dbh->prepare($sql); |
8 |
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
9 |
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
10 |
|
while ($row = $sth->fetchrow_array()) { |
11 |
|
$subs = get_sections($nid, $text, $row[0]); |
12 |
|
list($w, $h) = PicSize($row[5]); |
13 |
|
array_push($text, array( |
14 |
|
"id" => $row[0], |
15 |
|
"text" => $row[1], |
16 |
|
"title" => $row[2], |
17 |
|
"level" => $row[3], |
18 |
|
"class" => $row[4], |
19 |
|
"pic" => str_replace("+", "%20", urlencode($row[5])), |
20 |
|
"alt" => $row[6], |
21 |
|
"pos" => $row[7], |
22 |
|
"hl" => $row[8], |
23 |
|
"exp" => $row[9], |
24 |
|
"subs" => $subs, |
25 |
|
"w" => $w, |
26 |
|
"h" => $h |
27 |
|
)); |
28 |
|
} |
29 |
|
$sth->finish(); |
30 |
|
} |
31 |
function newsLoad($id, $cat = "", $limit = 0, $offset = 0, $npar = 1) { |
function newsLoad($id, $cat = "", $limit = 0, $offset = 0, $npar = 1) { |
32 |
global $dbh, $spec, $isMed; |
global $dbh, $spec, $isMed; |
33 |
$arts = array(); |
$arts = array(); |
34 |
if (!$offset) $offset = 0; |
if (!$offset) $offset = 0; |
35 |
$sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_change, author_pic, author_alt, author_info, ord FROM news".($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)"; |
$sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_change, author_pic, author_alt, author_info, ord FROM news".(isset($cat)?", cat_news":"").($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)"; |
36 |
if ($cat) $sql .= " AND (category = '$cat')"; |
if ($id > 0) $sql .= " AND (news.news_id = $id)"; |
|
/* |
|
|
$sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_change, author_pic, author_alt, author_info, ord FROM news".($cat?", cat_news":"").($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)"; |
|
37 |
if ($cat) $sql .= " AND ((category = '$cat') OR ((cat_news.cat_id = '$cat') AND (cat_news.news_id = news.news_id)))"; |
if ($cat) $sql .= " AND ((category = '$cat') OR ((cat_news.cat_id = '$cat') AND (cat_news.news_id = news.news_id)))"; |
|
*/ |
|
38 |
if ($spec) $sql .= " AND (spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec)"; |
if ($spec) $sql .= " AND (spec_news.news_id = news.news_id) AND (spec_news.spec_id = $spec)"; |
|
if ($id > 0) $sql .= " AND (news_id = $id)"; |
|
39 |
$sql .= " ORDER BY d_change DESC"; |
$sql .= " ORDER BY d_change DESC"; |
40 |
if ($limit) $sql .= " LIMIT $limit OFFSET $offset"; |
if ($limit) $sql .= " LIMIT $limit OFFSET $offset"; |
|
#echo "[$sql]<BR>\n"; |
|
41 |
$sth = $dbh->prepare($sql); |
$sth = $dbh->prepare($sql); |
42 |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
43 |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
47 |
$art["pic_alt"], $art["pic_pos"], $art["more"], |
$art["pic_alt"], $art["pic_pos"], $art["more"], |
48 |
$art["more_title"], $date, $art["au_pic"], |
$art["more_title"], $date, $art["au_pic"], |
49 |
$art["au_alt"], $art["au_info"], $ord) = $row; |
$art["au_alt"], $art["au_info"], $ord) = $row; |
50 |
list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic"]); |
list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic_url"]); |
51 |
$art["more_new"] = strstr($art["more"], "://") ? true : false; |
$art["more_new"] = strstr($art["more"], "://") ? true : false; |
52 |
global $sysaupicdir; |
global $sysaupicdir; |
53 |
list($art["au_w"], $art["au_h"]) = PicSize($art["au_pic"], $sysaupicdir); |
list($art["au_w"], $art["au_h"]) = PicSize($art["au_pic"], $sysaupicdir); |
54 |
$art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"])); |
$art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"])); |
55 |
$art["au_pic"] = str_replace("+", "%20", urlencode($art["au_pic"])); |
$art["au_pic"] = str_replace("+", "%20", urlencode($art["au_pic"])); |
56 |
$text = array(); |
$art["text"] = array(); |
57 |
if (isset($art["id"])) { |
if ($art["id"]) get_sections($art["id"], $art["text"]); |
|
$sql = "SELECT paragraph_id, text, title, level, class, pic, alt, pos, hl FROM paragraphs, par_levels WHERE (news_id = ".$art["id"].") AND (level = level_id)"; |
|
|
$sth2 = $dbh->prepare($sql); |
|
|
if (!$sth2) error("Cannot prepare query: \"$sql\""); |
|
|
if (!$sth2->execute()) error("Cannot execute query: \"$sql\""); |
|
|
while ($row = $sth2->fetchrow_array()) { |
|
|
list($w, $h) = PicSize($row[5]); |
|
|
array_push($text, array( |
|
|
"id" => $row[0], |
|
|
"text" => $row[1], |
|
|
"title" => $row[2], |
|
|
"level" => $row[3], |
|
|
"class" => $row[4], |
|
|
"pic" => str_replace("+", "%20", urlencode($row[5])), |
|
|
"alt" => $row[6], |
|
|
"pos" => $row[7], |
|
|
"hl" => $row[8], |
|
|
"w" => $w, |
|
|
"h" => $h |
|
|
)); |
|
|
} |
|
|
$sth2->finish(); |
|
|
} |
|
|
$art["text"] = $text; |
|
58 |
$art["order"] = $ord; |
$art["order"] = $ord; |
59 |
$art["read"] = (count($art["text"]) > $npar) ? true : false; |
$art["read"] = (count($art["text"]) > $npar) ? true : false; |
60 |
$art["category"] = $cat; |
$art["category"] = $cat; |
105 |
MyEscape($art["text"][$i]["text"]), false), true); |
MyEscape($art["text"][$i]["text"]), false), true); |
106 |
$art["text"][$i]["hl"] = ParseNewline(convert_html( |
$art["text"][$i]["hl"] = ParseNewline(convert_html( |
107 |
MyEscape($art["text"][$i]["hl"]), false), true); |
MyEscape($art["text"][$i]["hl"]), false), true); |
108 |
|
$art["text"][$i]["exp"] = ParseNewline(convert_html( |
109 |
|
MyEscape($art["text"][$i]["exp"]), false), true); |
110 |
|
if ($art["text"][$i]["hl"]) $art["text"][$i]["hl"] = GetHighlight($art["text"][$i]["hl"]); |
111 |
} |
} |
112 |
$tpl->assign("text", $art["text"]); |
$tpl->assign("text", $art["text"]); |
113 |
$tpl->assign("cat", $art["category"]); |
$tpl->assign("cat", $art["category"]); |
114 |
|
global $PATH; |
115 |
|
if (is_array($PATH)) array_push($PATH, |
116 |
|
MyUpper(MyEscape(convert_html($art["title"])))); |
117 |
} |
} |
118 |
?> |
?> |