/[health_html]/inc/pgKnjiznica2-medinfo.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/pgKnjiznica2-medinfo.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Fri Oct 12 09:22:02 2001 UTC (17 years, 6 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Added Kalendar dogaanja to PLIVAmed.net. Moved HTTP auth to external .htaccess files. Other bugfixes.

1 <?php
2 include("inc/conn.php");
3 include_once("inc/search.php");
4 function MyCmp1($a, $b) { return MyCompare($a["naslov"], $b["naslov"]); }
5 function MyCmp2($a, $b) { return MyCompare($a["l"], $b["l"]); }
6 $fields = array(
7 "broj" => array("dbname" => "broj", "caption" => "Broj èasopisa"),
8 "mjesec" => array("dbname" => "mjesec", "caption" => "Mjesec izdanja"),
9 "godina" => array("dbname" => "godina", "caption" => "Godina izdanja"),
10 "naslov" => array("dbname" => "naslov", "caption" => "Naslov èlanka"),
11 "tekst" => array("dbname" => "clanak", "caption" => "Tekst èlanka"),
12 "ref" => array("dbname" => "referenca", "caption" => "Referenca")
13 );
14 if (!$id) {
15 list($srch, $qry_1, $qry_2) = Search($fields, array("broj", "mjesec", "godina", "naslov", "tekst", "ref"), array(), "naslov");
16 # Win1250 -> ISO8859-2
17 if ($qry_1) $qry_1 = strtr($qry_1, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
18 if ($qry_2) $qry_2 = strtr($qry_2, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
19 $tpl->assign("index", $index);
20 $tpl->assign("srch", ($qry_1 || $qry_2) ? true : false);
21 $tpl->assign("SEARCH", $srch);
22 }
23 if (!$index && !$srch) $index = 1;
24 $letters = Slova();
25 if (!$id && ($index || ($qry_1 || $qry_2))) {
26 $prvo_slovo = "UPPER(SUBSTRING(naslov FROM 1 FOR 1))";
27 $sql = "SELECT medinfo_id, $prvo_slovo AS prvo_slovo, naslov FROM medinfo";
28 $uvjet = array();
29 if ($index && $index != 1) {
30 if ($index == '@') for ($i = 0; $i < count($letters); $i++) array_push($uvjet, "($prvo_slovo <> '".$letters[$i]."')");
31 else array_push($uvjet, "($prvo_slovo = '".MyUpper($index)."')");
32 }
33 if ($qry_1) array_push($uvjet, "($qry_1)");
34 $uvjet = implode(" AND ", $uvjet);
35 if ($uvjet) $sql .= " WHERE $uvjet";
36 $sql .= " ORDER BY prvo_slovo, naslov";
37 $sth = $dbh->prepare($sql);
38 if (!$sth) error("Cannot prepare query: \"$sql\"");
39 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
40 $slova = array();
41 $clanci = array();
42 unset($staro_slovo);
43 while ($row = $sth->fetchrow_array()) {
44 list($id2, $fl, $naslov) = $row;
45 if (!isset($staro_slovo)) $staro_slovo = $fl;
46 if (!($qry_1 || $qry_2) && $staro_slovo != $fl) {
47 usort($clanci, "MyCmp1");
48 array_push($slova, array("l" => $staro_slovo, "clanci" => $clanci));
49 $staro_slovo = $fl;
50 $clanci = array();
51 }
52 array_push($clanci, array("id" => $id2, "naslov" => MyEscape($naslov)));
53 }
54 $sth->finish();
55 if (count($clanci) > 0) {
56 usort($clanci, "MyCmp1");
57 array_push($slova, array("l" => $staro_slovo, "clanci" => $clanci));
58 }
59 usort($slova, "MyCmp2");
60 $records = 0;
61 for ($i = 0; $i < count($slova); $i++) $records += count($slova[$i]["clanci"]);
62 $tpl->assign("records", $records);
63 $tpl->assign("slova", $slova);
64 $tpl->assign("stype", $stype);
65 }
66 if ($id) {
67 $sql = "SELECT broj, mjesec, godina, naslov, clanak, referenca, url FROM medinfo WHERE (medinfo_id = $id)";
68 $sth = $dbh->prepare($sql);
69 if (!$sth) error("Cannot prepare query: \"$sql\"");
70 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
71 $row = $sth->fetchrow_array();
72 $sth->finish();
73 list($broj, $mjesec, $godina, $naslov, $tekst, $ref, $url) = $row;
74 $tpl->assign("broj", MyEscape($broj));
75 $tpl->assign("mjesec", MyEscape($mjesec));
76 $tpl->assign("godina", MyEscape($godina));
77 $tpl->assign("naslov", MyEscape($naslov));
78 $tpl->assign("referenca", MyEscape($ref));
79 $tpl->assign("url", MyEscape($url));
80 $tpl->assign("tekst", ParseNewline(MyEscape($tekst), false));
81 }
82 $tpl->assign("letters", $letters);
83 $tpl->assign("ID", $id);
84 $dbh->disconnect();
85 array_push($PATH, "LIJEÈNIÈKI VJESNIK");
86 ?>

  ViewVC Help
Powered by ViewVC 1.1.26