--- inc/util.php 2001/09/26 13:04:28 1.4 +++ inc/util.php 2001/10/27 16:54:50 1.11 @@ -13,7 +13,7 @@ } function MyDelete($src) { - # @unlink($src); + #@unlink($src); } function PicSize($pic, $dir = "") { @@ -38,32 +38,103 @@ return array($w, $h); } - function GetLinks($read, $more, $more_title, $id, $cat, $name, $edit, $updown = false, $up = false, $down = false) { + function GetLinks($read, $more, $more_title, $id, $cat, $name, $updown = false, $up = false, $down = false, $prikazi = true, $related = false) { $t = new Smarty(); - global $section, $section_menu, $spec; + global $section, $section_menu, $section_menu2, $spec, $isMed, $isEdit, $offset; $t->assign("section", $section); $t->assign("section_menu", $section_menu); + $t->assign("section_menu2", $section_menu2); $t->assign("spec", $spec); + $t->assign("offset", $offset); $t->assign("id", $id); $t->assign("cat", $cat); + $t->assign("med", $isMed); + $m = "more"; + if ($cat == "t" || $cat == "3") $m = "tmore"; + if ($cat == "w") $m = "wmore"; + if ($cat == "p") $m = "pmore"; + $t->assign("m", $m); $t->assign("name", $name); - $t->assign("read", $read && !strstr($more, "?")); + $t->assign("read", ($read || $related) ? $read : ""); $t->assign("more", /* $more */ strstr($more, "?") ? $more : ""); $t->assign("more_new", strstr($more, "://") ? true : false); $t->assign("more_title", $more_title); - $t->assign("edit", $edit); + $t->assign("edit", $isEdit); $t->assign("updown", $updown); $t->assign("up", $up); $t->assign("down", $down); + $t->assign("prikazi", $prikazi); + $t->assign("related", $related); return $t->fetch("links.tpl"); } + function GetRead($id, $ct = "") { + global $section, $section_menu, $section_menu2, $spec, $offset, $cat, $acat, $acat2; + $tmp = array(); + if ($section) array_push($tmp, "section=$section"); + if ($section_menu) array_push($tmp, "section_menu=$section_menu"); + if ($section_menu2) array_push($tmp, "section_menu=$section_menu2"); + if ($spec) array_push($tmp, "spec=$spec"); + if ($offset) array_push($tmp, "offset=$offset"); + if ($acat) array_push($tmp, "acat=$acat"); + if ($acat2) array_push($tmp, "acat2=$acat2"); + if (!$ct) $ct = $cat; + if ($ct) array_push($tmp, "cat=$ct"); + array_push($tmp, "id=$id"); + array_push($tmp, "show=1"); + return "?".HTMLSpecialChars(implode("&", $tmp)); + } + function GetHighlight($hl) { $tp = new Smarty(); $tp->assign("hl", $hl); return $tp->fetch("highlight.tpl"); } + function GetAuthor($pic = "", $alt = "", $info = "", $width = 0, $height = 0, $cv = 0) { + $t = new Smarty(); + global $aupicdir; + $t->assign("aupicdir", "$aupicdir/"); + $t->assign("url", $pic); + $t->assign("alt", $alt); + $info = nl2br($info); + if ($cv) { + $info = str_replace("{", "", $info); + $info = str_replace("}", "", $info); + } else { + $info = str_replace("{", "", $info); + $info = str_replace("}", "", $info); + } + $t->assign("info", $info); + $t->assign("width", $width); + $t->assign("height", $hight); + return $t->fetch("author.tpl"); + } + + function GetSemafor() { + global $dbh; + $conn = $dbh ? true : false; + if (!$conn) include("inc/conn.php"); + $sql = "SELECT stanje, trave, korov, stabla, date, prikazi_date FROM semafor ORDER BY date DESC LIMIT 1"; + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + $row = $sth->fetchrow_array(); + $sth->finish(); + if (!$conn) $dbh->disconnect(); + $t = new Smarty(); + if ($row) { + list($stanje, $trave, $korov, $stabla, $date, $prik) = $row; + if ($prik[0] == "f" || $prik[0] == "F") unset($prik); + $t->assign("stabla", $stabla); + $t->assign("trave", $trave); + $t->assign("korov", $korov); + $t->assign("msg", $stanje); + $t->assign("date", $prik && $date ? strftime("%d.%m.%y.", strtotime($date)) : ""); + } + return $t->fetch("semafor-table.tpl"); + } + function GenerateUsername($ime, $prezime) { global $dbh; $replace_from = "¹šðè澞©ŠÐÈÆ®Ž "; @@ -109,10 +180,16 @@ return $password; } + $isEdit = stristr($ME, "/edit/") ? true : false; + # $isMed = stristr($ME, "med") || stristr($ME, "pm") ? true : false; + include_once("_site.php"); // This should define $isMed. + function Auth($user = "", $pwd = "") { global $ME,$HTTP_USER_AGENT,$REMOTE_ADDR; + global $isEdit; + if ($isEdit) return 0; // DEBUG: - if (stristr($ME, "test.plivamed.net")) return 0; + #if (stristr($ME, "test.plivamed.net")) return 0; // User-Agent: should be mnoGoSearch, but in version 3.1.19 // it's UdmSearch so we match just search if (strstr($HTTP_USER_AGENT, "Search") && strstr($REMOTE_ADDR, "10.254.1.")) return 0; @@ -137,16 +214,16 @@ } Header("Content-Type: text/html; charset=ISO-8859-2"); - $isEdit = stristr($ME, "/edit/") ? true : false; - $isMed = stristr($ME, "med") || stristr($ME, "pm") ? true : false; +/* if ($isEdit) { - if ($PHP_AUTH_USER != "test" && $PHP_AUTH_PW != "test") { + if ($PHP_AUTH_USER != "editor" && $PHP_AUTH_PW != "jokkvpr") { Header("WWW-Authenticate: Basic realm=\"PLIVA".($isMed?"med.net":"zdravlje.hr")."\""); Header("HTTP/1.0 401 Unauthorized"); echo "Sorry, you are not allowed to edit the site.\n"; exit; } } +*/ $isReg = $isMed ? false : true; if (!$isReg) $isReg = (Auth() == 0) ? true : false; ?>