/[health_html]/inc/newsShow.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /inc/newsShow.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations)
Tue Oct 2 16:18:09 2001 UTC (22 years, 6 months ago) by ravilov
Branch: MAIN
Changes since 1.9: +3 -1 lines
Users can now pick their username/password on registration (PLIVAmed). Other bugfixes.

1 <?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) {
32 global $dbh, $spec, $isMed;
33 $arts = array();
34 if (!$offset) $offset = 0;
35 $sql = "SELECT DISTINCT news.news_id, title, lead, title_pic, title_alt, title_pos, url, url_title, d_orig, author_pic, author_alt, author_info, ord FROM news".(isset($cat)?", cat_news":"").($spec?", spec_news":"")." WHERE (".($isMed?"":"NOT ")."plivamed)";
36 if ($id > 0) $sql .= " AND (news.news_id = $id)";
37 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)";
39 $sql .= " ORDER BY d_orig DESC";
40 if ($limit) $sql .= " LIMIT $limit OFFSET $offset";
41 $sth = $dbh->prepare($sql);
42 if (!$sth) error("Cannot prepare query: \"$sql\"");
43 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
44 while ($row = $sth->fetchrow_array()) {
45 $art = array();
46 list($art["id"], $art["title"], $art["lead"], $art["pic_url"],
47 $art["pic_alt"], $art["pic_pos"], $art["more"],
48 $art["more_title"], $art["date"], $art["au_pic"],
49 $art["au_alt"], $art["au_info"], $ord) = $row;
50 list($art["pic_w"], $art["pic_h"]) = PicSize($art["pic_url"]);
51 $art["more_new"] = strstr($art["more"], "://") ? true : false;
52 global $sysaupicdir;
53 list($art["au_w"], $art["au_h"]) = PicSize($art["au_pic"], $sysaupicdir);
54 $art["pic_url"] = str_replace("+", "%20", urlencode($art["pic_url"]));
55 $art["au_pic"] = str_replace("+", "%20", urlencode($art["au_pic"]));
56 $art["text"] = array();
57 if ($art["id"]) get_sections($art["id"], $art["text"]);
58 $art["order"] = $ord;
59 $art["read"] = (count($art["text"]) > $npar) ? true : false;
60 $art["category"] = $cat;
61 $art["limit"] = $limit;
62 $art["offset"] = $offset;
63 $art["npar"] = $npar;
64 array_push($arts, $art);
65 }
66 $sth->finish();
67 $foo = true;
68 while ($foo) {
69 $foo = false;
70 for ($i = 0; $i < count($arts); $i++) {
71 if ($arts[$i]["order"] == 0) continue;
72 $j = ($i + $arts[$i]["order"]);
73 $j %= count($arts);
74 if ($j < 0) $j += count($arts);
75 if ($i == $j) continue;
76 $foo = true;
77 $tmp = $arts[$j];
78 $arts[$j] = $arts[$i];
79 $arts[$i] = $tmp;
80 $arts[$j]["order"] = 0;
81 }
82 }
83 return $arts;
84 }
85
86 function newsShow($art) {
87 global $fname, $tpl;
88 $fname = "show.tpl";
89 $tpl->assign("title", MyEscape(convert_html($art["title"])));
90 $tpl->assign("lead", MyEscape(convert_html($art["lead"]), false));
91 $tpl->assign("titlepic_url", MyEscape(convert_html($art["pic_url"])));
92 $tpl->assign("titlepic_alt", MyEscape(convert_html($art["pic_alt"])));
93 $tpl->assign("titlepic_type", $art["pic_pos"]);
94 $tpl->assign("title_url", MyEscape(convert_html($art["more"])));
95 $tpl->assign("title_url_new", $art["more_new"]);
96 $tpl->assign("title_url_title", MyEscape(convert_html($art["more_title"])));
97 $tpl->assign("titlepic_width", $art["pic_w"]);
98 $tpl->assign("titlepic_height", $art["pic_h"]);
99 $tpl->assign("date", strftime("%d.%m.%Y.", strtotime($art["date"])));
100 include_once("author.php");
101 $tpl->assign("AUTHOR", GetAuthor($art["au_pic"],
102 $art["au_alt"], $art["au_info"],
103 $art["au_w"], $art["au_h"]));
104 for ($i = 0; $i < count($art["text"]); $i++) {
105 $art["text"][$i]["text"] = ParseNewline(convert_html(
106 MyEscape($art["text"][$i]["text"]), false), true);
107 $art["text"][$i]["hl"] = ParseNewline(convert_html(
108 MyEscape($art["text"][$i]["hl"]), false), true);
109 $art["text"][$i]["exp"] = ParseNewline(convert_html(
110 MyEscape($art["text"][$i]["exp"]), false), true);
111 if ($art["text"][$i]["hl"]) $art["text"][$i]["hl"] = GetHighlight($art["text"][$i]["hl"]);
112 if ($art["text"][$i]["level"]) $art["text"][$i]["level2"] = (($art["text"][$i]["level"] - 1) * 15) + 2;
113 }
114 $tpl->assign("text", $art["text"]);
115 $tpl->assign("cat", $art["category"]);
116 global $PATH;
117 if (is_array($PATH)) array_push($PATH,
118 MyUpper(MyEscape(convert_html($art["title"]))));
119 }
120 ?>

  ViewVC Help
Powered by ViewVC 1.1.26