/[health_html]/inc/util.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

Annotation of /inc/util.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Tue Sep 25 15:38:04 2001 UTC (22 years, 5 months ago) by ravilov
Branch: MAIN
Changes since 1.2: +71 -4 lines
Major changes. Too numeruous to mention all here.

1 ravilov 1.1 <?php
2     function MyQuote($str) {
3     global $dbh;
4     if (!$dbh) return "'$str'";
5     return $dbh->quote($str);
6     }
7    
8     function MyMove($src, $dest) {
9     $cmd = "mv -f '".EscapeShellCmd($src)."' '".EscapeShellCmd($dest)."'";
10     return exec($cmd);
11     }
12    
13     function MyDelete($src) {
14     @unlink($src);
15     }
16    
17 ravilov 1.2 function PicSize($pic, $dir = "") {
18 ravilov 1.1 $ret = array(0, 0);
19     if ($pic) {
20 ravilov 1.2 if (!$dir) {
21     global $syspicdir;
22     $dir = $syspicdir;
23     }
24 ravilov 1.3 @$size = GetImageSize("$dir/$pic");
25 ravilov 1.1 $ret = array($size[0], $size[1]);
26     }
27     return $ret;
28     }
29    
30 ravilov 1.3 function PicResize($w, $h, $maxsize = 80) {
31     if ($w && $h && $w > $maxsize) {
32     $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 ravilov 1.1 ?>

  ViewVC Help
Powered by ViewVC 1.1.26