1 |
<?php |
2 |
include_once("inc/conn.php"); |
3 |
include_once("inc/newsShow.php"); |
4 |
if ($show) { |
5 |
$arts = newsLoad($id, $cat); |
6 |
newsShow(array_shift($arts)); |
7 |
} else { |
8 |
if ($del_id) { |
9 |
include_once("inc/newsDelete.php"); |
10 |
newsDelete($del_id); |
11 |
unset($top_edit, $wn_edit, $pn_edit); |
12 |
} |
13 |
$cat = "c"; |
14 |
if ($down_id) $dbh->dbh_do("UPDATE news SET ord = ord + 1 WHERE (news_id = $down_id)"); |
15 |
if ($up_id) $dbh->dbh_do("UPDATE news SET ord = ord - 1 WHERE (news_id = $up_id)"); |
16 |
if (!$offset) $offset = 0; |
17 |
$empty = array("category" => $cat, "limit" => 11, "offset" => $offset, "npar" => 1); |
18 |
if ($top_edit && $ed_id <= 0) { |
19 |
include_once("inc/newsEdit.php"); |
20 |
$ed = newsEdit($empty, "top_edit"); |
21 |
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
22 |
else $top_edit = false; |
23 |
} |
24 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
25 |
$a2 = array(); |
26 |
$lm = count($arts); |
27 |
if ($lm > $empty["limit"]) $lm = $empty["limit"]; |
28 |
for ($i = 0; $i < $lm; $i++) { |
29 |
$art = $arts[$i]; |
30 |
$ed = ""; |
31 |
if ($top_edit && ($art["id"] == $ed_id)) { |
32 |
include_once("inc/newsEdit.php"); |
33 |
$ed = newsEdit($art, "top_edit"); |
34 |
} |
35 |
if ($ed && is_string($ed)) array_push($a2, array("EDIT" => $ed)); |
36 |
else { |
37 |
if ($ed && $ed["category"] == $cat) $art = $ed; |
38 |
for ($j = 0; $j < count($art["text"]); $j++) |
39 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
40 |
include_once("inc/links.php"); |
41 |
array_push($a2, array( |
42 |
"id" => $art["id"], |
43 |
"title" => MyEscape($art["title"]), |
44 |
"lead" => MyEscape($art["lead"]), |
45 |
"titlepic_url" => MyEscape($art["pic_url"]), |
46 |
"titlepic_alt" => MyEscape($art["pic_alt"]), |
47 |
"titlepic_type" => $art["pic_pos"], |
48 |
"titlepic_width" => $art["pic_w"], |
49 |
"titlepic_height" => $art["pic_h"], |
50 |
"text" => $art["text"], |
51 |
"links" => GetLinks($art["read"] && $art["id"], |
52 |
MyEscape($art["more"]), $art["id"], |
53 |
$empty["category"], "top", $isEdit, true, |
54 |
($i > 0), ($i < count($arts) - 1)) |
55 |
)); |
56 |
} |
57 |
} |
58 |
$tpl->assign("top", $a2); |
59 |
$tpl->assign("cat", $cat); |
60 |
$tpl->assign("next", (count($arts) > 10) ? ($offset + 10) : 0); |
61 |
$tpl->assign("prev", ($offset > 0) ? ($offset - 10) : false); |
62 |
} |
63 |
$dbh->disconnect(); |
64 |
?> |