21 |
global $syspicdir; |
global $syspicdir; |
22 |
$dir = $syspicdir; |
$dir = $syspicdir; |
23 |
} |
} |
24 |
@$size = GetImageSize($dir."/".$pic); |
@$size = GetImageSize("$dir/$pic"); |
25 |
$ret = array($size[0], $size[1]); |
$ret = array($size[0], $size[1]); |
26 |
} |
} |
27 |
return $ret; |
return $ret; |
28 |
} |
} |
29 |
|
|
30 |
$isEdit = stristr($PHP_SELF, "/edit/") ? true : false; |
function PicResize($w, $h, $maxsize = 80) { |
31 |
$isMed = stristr($PHP_SELF, "/med/") ? true : false; |
if ($w && $h && $w > $maxsize) { |
32 |
header("Content-Type: text/html; charset=ISO-8859-2"); |
$ratio = ($w / $h); |
33 |
|
$w = intval($maxsize); |
34 |
|
$h = intval($w / $ratio); |
35 |
|
} |
36 |
|
return array($w, $h); |
37 |
|
} |
38 |
|
|
39 |
|
function GetLinks($read, $more, $more_title, $id, $cat, $name, $edit, $updown = false, $up = false, $down = false) { |
40 |
|
$t = new Smarty(); |
41 |
|
global $section, $section_menu, $spec; |
42 |
|
$t->assign("section", $section); |
43 |
|
$t->assign("section_menu", $section_menu); |
44 |
|
$t->assign("spec", $spec); |
45 |
|
$t->assign("id", $id); |
46 |
|
$t->assign("cat", $cat); |
47 |
|
$t->assign("name", $name); |
48 |
|
$t->assign("read", $read && !strstr($more, "?")); |
49 |
|
$t->assign("more", /* $more */ strstr($more, "?") ? $more : ""); |
50 |
|
$t->assign("more_new", strstr($more, "://") ? true : false); |
51 |
|
$t->assign("more_title", $more_title); |
52 |
|
$t->assign("edit", $edit); |
53 |
|
$t->assign("updown", $updown); |
54 |
|
$t->assign("up", $up); |
55 |
|
$t->assign("down", $down); |
56 |
|
return $t->fetch("links.tpl"); |
57 |
|
} |
58 |
|
|
59 |
|
function GetHighlight($hl) { |
60 |
|
$tp = new Smarty(); |
61 |
|
$tp->assign("hl", $hl); |
62 |
|
return $tp->fetch("highlight.tpl"); |
63 |
|
} |
64 |
|
|
65 |
|
function Auth($user = "", $pwd = "") { |
66 |
|
global $PMusername, $PMpassword; |
67 |
|
if (!$user) $user = $PMusername; |
68 |
|
if (!$pwd) $pwd = $PMpassword; |
69 |
|
if (!$user) return 1; |
70 |
|
global $dbh; |
71 |
|
$connected = $dbh ? true : false; |
72 |
|
if (!$connected) include("inc/conn.php"); |
73 |
|
$sql = "SELECT username, password FROM users WHERE (username = '$user')"; |
74 |
|
$sth = $dbh->prepare($sql); |
75 |
|
if (!$sth) return 4; |
76 |
|
if (!$sth->execute()) return 5; |
77 |
|
$row = $sth->fetchrow_array(); |
78 |
|
$sth->finish(); |
79 |
|
if (!$connected) $dbh->disconnect(); |
80 |
|
list($u, $p) = $row; |
81 |
|
if ($u != $user) return 2; |
82 |
|
if ($p != $pwd) return 3; |
83 |
|
return 0; |
84 |
|
} |
85 |
|
|
86 |
|
Header("Content-Type: text/html; charset=ISO-8859-2"); |
87 |
|
$ME = "http".($HTTPS?"s":"")."://".$HTTP_HOST."/".$PHP_SELF; |
88 |
|
$isEdit = stristr($ME, "/edit/") ? true : false; |
89 |
|
$isMed = stristr($ME, "med") || stristr($ME, "pm") ? true : false; |
90 |
|
if ($isEdit) { |
91 |
|
if ($PHP_AUTH_USER != "test" && $PHP_AUTH_PW != "test") { |
92 |
|
Header("WWW-Authenticate: Basic realm=\"PLIVA".($isMed?"med.net":"zdravlje.hr")."\""); |
93 |
|
Header("HTTP/1.0 401 Unauthorized"); |
94 |
|
echo "Sorry, you are not allowed to edit the site.\n"; |
95 |
|
exit; |
96 |
|
} |
97 |
|
} |
98 |
|
$isReg = $isMed ? false : true; |
99 |
|
if (!$isReg) $isReg = (Auth() == 0) ? true : false; |
100 |
?> |
?> |