1 |
dpavlin |
1.1 |
<?php |
2 |
|
|
include("inc/stuff.php"); |
3 |
dpavlin |
1.3 |
mt_srand(time()); |
4 |
dpavlin |
1.1 |
$pages = array( |
5 |
|
|
0 => "main.php", |
6 |
|
|
1 => "OpciPodaci.php", |
7 |
|
|
2 => "UPlivi.php", |
8 |
|
|
3 => "IzvanPlive.php", |
9 |
|
|
4 => "Dodiplomski.php", |
10 |
|
|
5 => "Poslijediplomski.php", |
11 |
|
|
6 => "Obrazovanje.php", |
12 |
|
|
7 => "TecajeviManagementa.php", |
13 |
|
|
8 => "OstaliTecajevi.php", |
14 |
|
|
9 => "StraniJezici.php", |
15 |
|
|
10 => "RadSRacunalom.php", |
16 |
|
|
11 => "Nagrade.php", |
17 |
|
|
12 => "Radovi.php", |
18 |
|
|
13 => "StrucniSkupovi.php", |
19 |
|
|
14 => "OMeni.php", |
20 |
|
|
15 => "Overview.php", |
21 |
|
|
100 => "NovaAplikacija.php", |
22 |
|
|
200 => "NovaUstanova.php", |
23 |
|
|
300 => "NoviTecaj.php" |
24 |
|
|
); |
25 |
|
|
function isparam($param) { |
26 |
|
|
eval('global $'.$param.', $'.$param.'_x, $'.$param.'_y;'); |
27 |
|
|
if (eval('return isset($'.$param.') || isset($'.$param.'_x) || isset($'.$param.'_y);')) { |
28 |
dpavlin |
1.3 |
# eval('unset($'.$param.'); unset($'.$param.'_x); unset($'.$param.'_y);'); |
29 |
dpavlin |
1.1 |
return true; |
30 |
|
|
} |
31 |
|
|
return false; |
32 |
|
|
} |
33 |
|
|
function CalcPage($script) { |
34 |
|
|
global $pages; |
35 |
|
|
$script = basename($script); |
36 |
|
|
$pg = 0; |
37 |
|
|
reset($pages); |
38 |
|
|
while (list($var, $val) = each($pages)) |
39 |
|
|
if ($val == $script) $pg = $var; |
40 |
|
|
return $pg; |
41 |
|
|
} |
42 |
|
|
function HTML_escape($str) { |
43 |
|
|
$oldstr = $str; # KLUDGY!!! |
44 |
|
|
$str = eregi_replace("\<BR\>", "\n", $str); # KLUDGY!!! |
45 |
|
|
$foo = ($str != $oldstr); # KLUDGY!!! |
46 |
|
|
$str = str_replace("&", "&", $str); |
47 |
|
|
$str = str_replace("<", "<", $str); |
48 |
|
|
$str = str_replace(">", ">", $str); |
49 |
|
|
$str = str_replace("\"", """, $str); |
50 |
|
|
if ($foo) $str = ereg_replace("\n", "<BR>", $str); # KLUDGY!!! |
51 |
|
|
return $str; |
52 |
|
|
} |
53 |
|
|
$CRO_Win = "ÈÆÐèæð"; |
54 |
|
|
$CRO_ISO = "ÈƩЮèæ¹ð¾"; |
55 |
|
|
function ISO_Win($str) { |
56 |
|
|
global $CRO_ISO, $CRO_Win; |
57 |
|
|
return strtr($str, $CRO_ISO, $CRO_Win); |
58 |
|
|
} |
59 |
|
|
function Win_ISO($str) { |
60 |
|
|
global $CRO_ISO, $CRO_Win; |
61 |
|
|
return strtr($str, $CRO_Win, $CRO_ISO); |
62 |
|
|
} |
63 |
dpavlin |
1.3 |
function YearFix(&$y) { |
64 |
|
|
if (isset($y) && ereg("^[0-9]+$", $y) && $y < 1900) |
65 |
|
|
if ($y <= 40) $y += 2000; else $y += 1900; |
66 |
|
|
} |
67 |
|
|
function &DateCheck($str) { |
68 |
|
|
if (!$str) return 0; |
69 |
|
|
$tmp = split("\s*[/.-]\s*", $str); |
70 |
|
|
YearFix($tmp[2]); |
71 |
|
|
# PHP ima problema sa godinama prije 1902... |
72 |
|
|
if ($tmp[2] < 1902) return 0; |
73 |
|
|
if (!checkdate($tmp[1], $tmp[0], $tmp[2])) return 0; |
74 |
|
|
$tmp = sprintf("%04d-%02d-%02d", $tmp[2], $tmp[1], $tmp[0]); |
75 |
|
|
$tmp = getdate(strtotime($tmp)); |
76 |
|
|
return array($tmp["mday"], $tmp["mon"], $tmp["year"]); |
77 |
|
|
} |
78 |
|
|
function &ParseDate($str) { |
79 |
dpavlin |
1.1 |
if (!$str) return $str; |
80 |
dpavlin |
1.3 |
$str = str_replace("/", "-", $str); |
81 |
dpavlin |
1.1 |
$tmp = split("[\.\-]", $str); |
82 |
|
|
$fnd = false; |
83 |
|
|
for ($i = 0; $i < count($tmp); $i++) |
84 |
|
|
if ($tmp[$i] + 0) $fnd = true; |
85 |
|
|
if (!$fnd) return $str; |
86 |
|
|
return getdate(strtotime($str)); |
87 |
|
|
} |
88 |
dpavlin |
1.3 |
function ComposeDate($dt) { |
89 |
|
|
list($d, $m, $y) = $dt; |
90 |
dpavlin |
1.1 |
return sprintf("%04d-%02d-%02d", $y, $m, $d); |
91 |
|
|
} |
92 |
|
|
function Compose() { |
93 |
dpavlin |
1.3 |
global $_composed; |
94 |
|
|
if (!$_composed) { |
95 |
|
|
global $sifra, $language; |
96 |
|
|
$chars = preg_split("//", "ABCDEFGHIJKLMNOPQRSTUVW". |
97 |
|
|
"XYZabcdefghijklmnopqrstuvwxyz0123456789", |
98 |
|
|
0, PREG_SPLIT_NO_EMPTY); |
99 |
|
|
$salt = ""; |
100 |
|
|
for ($i = 0; $i < CRYPT_SALT_LENGTH; $i++) |
101 |
|
|
$salt .= $chars[mt_rand(0, count($chars) - 1)]; |
102 |
|
|
$enc = substr(crypt($sifra, $salt), CRYPT_SALT_LENGTH); |
103 |
|
|
$lang_1 = $language[0]; |
104 |
|
|
$lang_2 = $language[1]; |
105 |
|
|
$salt_1 = substr($salt, 0, CRYPT_SALT_LENGTH / 2); |
106 |
|
|
$salt_2 = substr($salt, CRYPT_SALT_LENGTH / 2); |
107 |
|
|
$_composed = implode("|", array($sifra, |
108 |
|
|
$enc.$lang_1.$salt_1.$lang_2.$salt_2)); |
109 |
|
|
$_composed = str_replace("/", "!", $_composed); |
110 |
|
|
} |
111 |
|
|
return $_composed; |
112 |
dpavlin |
1.1 |
} |
113 |
|
|
function Decompose($str) { |
114 |
|
|
global $sifra, $language; |
115 |
dpavlin |
1.3 |
$str = str_replace("!", "/", $str); |
116 |
|
|
list($sifra, $lang) = explode("|", $str); |
117 |
|
|
$enc = substr($lang, 0, -(CRYPT_SALT_LENGTH + 2)); |
118 |
|
|
$lang = substr($lang, strlen($enc)); |
119 |
|
|
$lang_1 = $lang[0]; |
120 |
|
|
$salt_1 = substr($lang, 1, CRYPT_SALT_LENGTH / 2); |
121 |
|
|
$lang_2 = $lang[(CRYPT_SALT_LENGTH / 2) + 1]; |
122 |
|
|
$salt_2 = substr($lang, (CRYPT_SALT_LENGTH / 2) + 2); |
123 |
|
|
$language = $lang_1.$lang_2; |
124 |
|
|
$salt = $salt_1.$salt_2; |
125 |
|
|
$cry = substr(crypt($sifra, $salt), CRYPT_SALT_LENGTH); |
126 |
|
|
if ($cry != $enc) $sifra = ""; |
127 |
dpavlin |
1.1 |
} |
128 |
|
|
function Params($pg = -1, $more = array()) { |
129 |
|
|
global $page; |
130 |
|
|
if ($pg >= 0) $page = $pg; |
131 |
|
|
$tmp = Compose(); |
132 |
|
|
if (is_array($more)) { |
133 |
|
|
while (list($key, $val) = each($more)) { |
134 |
|
|
if ($tmp) $tmp = $tmp."&"; |
135 |
|
|
$tmp = $tmp."$key=$val"; |
136 |
|
|
} |
137 |
|
|
} |
138 |
|
|
if (isset($tmp) && $tmp) $tmp = "?ID=".$tmp; |
139 |
|
|
return $tmp; |
140 |
|
|
} |
141 |
|
|
function nepoznato(&$sto) { |
142 |
|
|
global $language; |
143 |
|
|
if (isset($sto) && $sto == "") { |
144 |
|
|
if ($language == "HR") $sto = "[nepoznato]"; |
145 |
|
|
if ($language == "EN") $sto = "[unknown]"; |
146 |
|
|
$sto = "<I>$sto</I>"; |
147 |
|
|
} |
148 |
|
|
} |
149 |
|
|
function Auth() { |
150 |
|
|
global $sifra; |
151 |
dpavlin |
1.3 |
if ($sifra) return true; |
152 |
|
|
Header("Location: index.php?x="); |
153 |
|
|
return false; |
154 |
dpavlin |
1.1 |
} |
155 |
|
|
Header("Pragma: no-cache"); |
156 |
|
|
if (!isset($language) || !$language) $language = "HR"; |
157 |
|
|
if (!isset($sifra) || !$sifra) $sifra = ""; |
158 |
dpavlin |
1.3 |
if ($ID) Decompose($ID); |
159 |
|
|
unset($ID); |
160 |
|
|
include_once("inc/MySmarty.php"); |
161 |
dpavlin |
1.1 |
?> |