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 |
if ($down_id) $dbh->dbh_do("UPDATE news SET ord = ord + 1 WHERE (news_id = $down_id)"); |
14 |
if ($up_id) $dbh->dbh_do("UPDATE news SET ord = ord - 1 WHERE (news_id = $up_id)"); |
15 |
$empty = array("category" => "t", "limit" => 1, "offset" => 0, "npar" => 0); |
16 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
17 |
$art = array_shift($arts); |
18 |
$ed = ""; |
19 |
if ($top_edit && ($art["id"] == $ed_id || $ed_id <= 0) && $isEdit) { |
20 |
include_once("inc/newsEdit.php"); |
21 |
$ed = newsEdit(($ed_id > 0) ? $art : $empty, "top_edit"); |
22 |
} |
23 |
if ($ed && is_string($ed)) $tpl->assign("EDIT", $ed); |
24 |
else { |
25 |
if ($ed && $ed["category"] == "t") $art = $ed; |
26 |
$tpl->assign("top_id", $art["id"]); |
27 |
$tpl->assign("top_title", MyEscape($art["title"])); |
28 |
$tpl->assign("top_lead", MyEscape($art["lead"])); |
29 |
$tpl->assign("top_titlepic_url", MyEscape($art["pic_url"])); |
30 |
$tpl->assign("top_titlepic_alt", MyEscape($art["pic_alt"])); |
31 |
$tpl->assign("top_titlepic_type", $art["pic_pos"]); |
32 |
$tpl->assign("top_titlepic_width", $art["pic_w"]); |
33 |
$tpl->assign("top_titlepic_height", $art["pic_h"]); |
34 |
for ($j = 0; $j < count($art["text"]); $j++) |
35 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
36 |
$tpl->assign("top_text", $art["text"]); |
37 |
include_once("inc/links.php"); |
38 |
include_once("inc/author.php"); |
39 |
$tpl->assign("AUTHOR", GetAuthor($art["au_pic"], |
40 |
$art["au_alt"], $art["au_info"], |
41 |
$art["au_w"], $art["au_h"])); |
42 |
$tpl->assign("top_links", GetLinks($art["read"] && $art["id"], |
43 |
/* MyEscape($art["more"]) */ (count($art["text"]) <= 0) ? true : false, |
44 |
MyEscape($art["more_title"]), $art["id"], $empty["category"], |
45 |
"top", $isEdit, false, false, false)); |
46 |
} |
47 |
$menu2 = array(); |
48 |
$empty = array("category" => "w", "limit" => ($wn_edit ? 4 : 5), "offset" => 0, "npar" => 0); |
49 |
$ed = ""; |
50 |
if ($wn_edit && $ed_id <= 0 && $isEdit) { |
51 |
include_once("inc/newsEdit.php"); |
52 |
$ed = newsEdit($empty, "wn_edit", true); |
53 |
if ($ed && is_string($ed)) $tpl->assign("WN_EDIT", $ed); |
54 |
else $wn_edit = false; |
55 |
} |
56 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
57 |
$wn = array(); |
58 |
for ($i = 0; $i < count($arts); $i++) { |
59 |
$art = $arts[$i]; |
60 |
$ed = ""; |
61 |
if ($wn_edit && $art["id"] == $ed_id && $isEdit) { |
62 |
include_once("inc/newsEdit.php"); |
63 |
$art["nlimit"] = count($arts); |
64 |
$ed = newsEdit($art, "wn_edit", true); |
65 |
} |
66 |
if ($ed && is_string($ed)) array_push($wn, array("EDIT" => $ed)); |
67 |
else { |
68 |
if ($ed && $ed["category"] == "w") $art = $ed; |
69 |
for ($j = 0; $j < count($art["text"]); $j++) |
70 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
71 |
include_once("inc/links.php"); |
72 |
array_push($wn, array( |
73 |
"id" => $art["id"], |
74 |
"title" => MyEscape($art["title"]), |
75 |
"lead" => MyEscape($art["lead"]), |
76 |
"pic" => MyEscape($art["pic_url"]), |
77 |
"alt" => MyEscape($art["pic_alt"]), |
78 |
"pos" => MyEscape($art["pic_pos"]), |
79 |
"width" => MyEscape($art["pic_w"]), |
80 |
"height" => MyEscape($art["pic_h"]), |
81 |
"links" => GetLinks(($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"], |
82 |
MyEscape($art["more"]), MyEscape($art["more_title"]), |
83 |
$art["id"], $empty["category"], "wn", $isEdit, true, |
84 |
($i > 0), ($i < count($arts) - 1)), |
85 |
"text" => $art["text"] |
86 |
)); |
87 |
array_push($menu2, array( |
88 |
"pre" => "wn-", |
89 |
"cat" => $empty["category"], |
90 |
"id" => $art["id"], |
91 |
"title" => MyEscape($art["title"]), |
92 |
"url" => MyEscape($art["more"]), |
93 |
"more" => ($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"] |
94 |
)); |
95 |
} |
96 |
} |
97 |
$empty = array("category" => "p", "limit" => ($pn_edit ? 4 : 5), "offset" => 0, "npar" => 0); |
98 |
$ed = ""; |
99 |
if ($pn_edit && $ed_id <= 0 && $isEdit) { |
100 |
include_once("inc/newsEdit.php"); |
101 |
$ed = newsEdit($empty, "pn_edit", true); |
102 |
if ($ed && is_string($ed)) $tpl->assign("PN_EDIT", $ed); |
103 |
else $pn_edit = false; |
104 |
} |
105 |
$arts = newsLoad(-1, $empty["category"], $empty["limit"], $empty["offset"], $empty["npar"]); |
106 |
$pn = array(); |
107 |
for ($i = 0; $i < count($arts); $i++) { |
108 |
$art = $arts[$i]; |
109 |
$ed = ""; |
110 |
if ($pn_edit && $art["id"] == $ed_id && $isEdit) { |
111 |
include_once("inc/newsEdit.php"); |
112 |
$art["nlimit"] = count($arts); |
113 |
$ed = newsEdit($art, "pn_edit", true); |
114 |
} |
115 |
if ($ed && is_string($ed)) array_push($pn, array("EDIT" => $ed)); |
116 |
else { |
117 |
if ($ed && $ed["category"] == "p") $art = $ed; |
118 |
for ($j = 0; $j < count($art["text"]); $j++) |
119 |
$art["text"][$j]["text"] = ParseNewline(MyEscape($art["text"][$j]["text"]), true); |
120 |
include_once("inc/links.php"); |
121 |
array_push($pn, array( |
122 |
"id" => $art["id"], |
123 |
"title" => MyEscape($art["title"]), |
124 |
"lead" => MyEscape($art["lead"]), |
125 |
"pic" => MyEscape($art["pic_url"]), |
126 |
"alt" => MyEscape($art["pic_alt"]), |
127 |
"pos" => MyEscape($art["pic_pos"]), |
128 |
"width" => MyEscape($art["pic_w"]), |
129 |
"height" => MyEscape($art["pic_h"]), |
130 |
"links" => GetLinks(($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"], |
131 |
MyEscape($art["more"]), MyEscape($art["more_title"]), |
132 |
$art["id"], $empty["category"], "pn", $isEdit, true, |
133 |
($i > 0), ($i < count($arts) - 1)), |
134 |
"text" => MyEscape($art["text"]) |
135 |
)); |
136 |
array_push($menu2, array( |
137 |
"pre" => "pn-", |
138 |
"cat" => $empty["category"], |
139 |
"id" => $art["id"], |
140 |
"title" => MyEscape($art["title"]), |
141 |
"url" => MyEscape($art["more"]), |
142 |
"more" => ($art["read"] || $art["au_pic"] || $art["au_info"]) && $art["id"] |
143 |
)); |
144 |
} |
145 |
} |
146 |
$tpl->assign("wn", $wn); |
147 |
$tpl->assign("pn", $pn); |
148 |
$tpl->assign("top_edit", $top_edit); |
149 |
$tpl->assign("wn_edit", $wn_edit); |
150 |
$tpl->assign("pn_edit", $pn_edit); |
151 |
if (!$isMed) $tpl->assign("MENU2", $menu2); |
152 |
} |
153 |
$dbh->disconnect(); |
154 |
?> |