1 |
<?php |
<?php |
2 |
|
$ME = "http".($HTTPS?"s":"")."://".$HTTP_HOST.$PHP_SELF; |
3 |
|
|
4 |
function MyQuote($str) { |
function MyQuote($str) { |
5 |
global $dbh; |
global $dbh; |
6 |
if (!$dbh) return "'$str'"; |
if (!$dbh) return "'$str'"; |
13 |
} |
} |
14 |
|
|
15 |
function MyDelete($src) { |
function MyDelete($src) { |
16 |
@unlink($src); |
# @unlink($src); |
17 |
} |
} |
18 |
|
|
19 |
function PicSize($pic, $dir = "") { |
function PicSize($pic, $dir = "") { |
64 |
return $tp->fetch("highlight.tpl"); |
return $tp->fetch("highlight.tpl"); |
65 |
} |
} |
66 |
|
|
67 |
|
function GenerateUsername($ime, $prezime) { |
68 |
|
global $dbh; |
69 |
|
$replace_from = "¹šðè澞©ŠÐÈÆ®Ž "; |
70 |
|
$replace_to = "ssdcczzSSDCCZZ_"; |
71 |
|
$ime = strtolower(ereg_replace('[^A-Za-z0-9]', "", |
72 |
|
strtr($ime, $replace_from, $replace_to))); |
73 |
|
$prezime = strtolower(ereg_replace('[^A-Za-z0-9]', "", |
74 |
|
strtr($prezime, $replace_from, $replace_to))); |
75 |
|
$cnt = 1; |
76 |
|
while ($cnt <= strlen($ime)) { |
77 |
|
$username = substr($ime, 0, $cnt++).$prezime; |
78 |
|
$sql = "SELECT username FROM users WHERE username = '$username'"; |
79 |
|
$sth = $dbh->prepare($sql); |
80 |
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
81 |
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
82 |
|
$row = $sth->fetchrow_array(); |
83 |
|
$sth->finish(); |
84 |
|
if (!$row) break; |
85 |
|
} |
86 |
|
if ($cnt > strlen($ime)) { |
87 |
|
$username2 = $username; |
88 |
|
$cnt = 1; |
89 |
|
while (true) { |
90 |
|
$username = $username.($cnt++); |
91 |
|
$sql = "SELECT username FROM users WHERE username = '$username'"; |
92 |
|
$sth = $dbh->prepare($sql); |
93 |
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
94 |
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
95 |
|
$row = $sth->fetchrow_array(); |
96 |
|
$sth->finish(); |
97 |
|
if (!$row) break; |
98 |
|
} |
99 |
|
} |
100 |
|
return $username; |
101 |
|
} |
102 |
|
|
103 |
|
function GeneratePassword($length = 8) { |
104 |
|
$chars = preg_split('//', "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); |
105 |
|
array_shift($chars); |
106 |
|
array_pop($chars); |
107 |
|
$password = ""; |
108 |
|
for ($i = 0; $i < $length; $i++) $password .= $chars[rand(0, count($chars))]; |
109 |
|
return $password; |
110 |
|
} |
111 |
|
|
112 |
function Auth($user = "", $pwd = "") { |
function Auth($user = "", $pwd = "") { |
113 |
|
global $ME,$HTTP_USER_AGENT,$REMOTE_ADDR; |
114 |
|
// DEBUG: |
115 |
|
if (stristr($ME, "test.plivamed.net")) return 0; |
116 |
|
// User-Agent: should be mnoGoSearch, but in version 3.1.19 |
117 |
|
// it's UdmSearch so we match just search |
118 |
|
if (strstr($HTTP_USER_AGENT, "Search") && strstr($REMOTE_ADDR, "10.254.1.")) return 0; |
119 |
global $PMusername, $PMpassword; |
global $PMusername, $PMpassword; |
120 |
if (!$user) $user = $PMusername; |
if (!$user) $user = $PMusername; |
121 |
if (!$pwd) $pwd = $PMpassword; |
if (!$pwd) $pwd = $PMpassword; |
137 |
} |
} |
138 |
|
|
139 |
Header("Content-Type: text/html; charset=ISO-8859-2"); |
Header("Content-Type: text/html; charset=ISO-8859-2"); |
|
$ME = "http".($HTTPS?"s":"")."://".$HTTP_HOST."/".$PHP_SELF; |
|
140 |
$isEdit = stristr($ME, "/edit/") ? true : false; |
$isEdit = stristr($ME, "/edit/") ? true : false; |
141 |
$isMed = stristr($ME, "med") || stristr($ME, "pm") ? true : false; |
$isMed = stristr($ME, "med") || stristr($ME, "pm") ? true : false; |
142 |
if ($isEdit) { |
if ($isEdit) { |