/[hr-web]/inc/global.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

Diff of /inc/global.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Wed Apr 25 13:18:50 2001 UTC revision 1.7 by ravilov, Thu Sep 5 09:09:03 2002 UTC
# Line 1  Line 1 
1  <?php  <?php
2          include("inc/stuff.php");          include("inc/stuff.php");
3          mt_srand(time());          mt_srand(time());
4            $PG_HOME = 0;
5            $PG_OVERVIEW = 16;
6          $pages = array(          $pages = array(
7                  0 => "main.php",                  $PG_HOME => "main.php",
8                  1 => "OpciPodaci.php",                  1 => "OpciPodaci.php",
9                  2 => "UPlivi.php",                  2 => "UPlivi.php",
10                  3 => "IzvanPlive.php",                  3 => "IzvanPlive.php",
# Line 14  Line 16 
16                  9 => "StraniJezici.php",                  9 => "StraniJezici.php",
17                  10 => "RadSRacunalom.php",                  10 => "RadSRacunalom.php",
18                  11 => "Nagrade.php",                  11 => "Nagrade.php",
19                  12 => "Radovi.php",                  12 => "Patenti.php",
20                  13 => "StrucniSkupovi.php",                  13 => "Radovi.php",
21                  14 => "OMeni.php",                  14 => "StrucniSkupovi.php",
22                  15 => "Overview.php",                  15 => "OMeni.php",
23                    $PG_OVERVIEW => "Overview.php",
24                  100 => "NovaAplikacija.php",                  100 => "NovaAplikacija.php",
25                  200 => "NovaUstanova.php",                  200 => "NovaUstanova.php",
26                  300 => "NoviTecaj.php"                  300 => "NoviTecaj.php"
# Line 39  Line 42 
42                          if ($val == $script) $pg = $var;                          if ($val == $script) $pg = $var;
43                  return $pg;                  return $pg;
44          }          }
45          function HTML_escape($str) {          function HTML_Escape($str) {
46                  $oldstr = $str;                                         # KLUDGY!!!                  $oldstr = $str;                                         # KLUDGY!!!
47                  $str = eregi_replace("\<BR\>", "\n", $str);             # KLUDGY!!!                  $str = eregi_replace("\<BR\>", "\n", $str);             # KLUDGY!!!
48                  $foo = ($str != $oldstr);                               # KLUDGY!!!                  $foo = ($str != $oldstr);                               # KLUDGY!!!
# Line 89  Line 92 
92                  list($d, $m, $y) = $dt;                  list($d, $m, $y) = $dt;
93                  return sprintf("%04d-%02d-%02d", $y, $m, $d);                  return sprintf("%04d-%02d-%02d", $y, $m, $d);
94          }          }
95            $_composed = "";
96          function Compose() {          function Compose() {
97                  global $_composed;                  global $_composed;
98                  if (!$_composed) {                  if (!$_composed) {
99                          global $sifra, $language;                          global $sifra, $language, $REMOTE_ADDR;
100                          $chars = preg_split("//", "ABCDEFGHIJKLMNOPQRSTUVW".                          $crc = md5($sifra."@".$REMOTE_ADDR);
                                 "XYZabcdefghijklmnopqrstuvwxyz0123456789",  
                                 0, PREG_SPLIT_NO_EMPTY);  
                         $salt = "";  
                         for ($i = 0; $i < CRYPT_SALT_LENGTH; $i++)  
                                 $salt .= $chars[mt_rand(0, count($chars) - 1)];  
                         $enc = substr(crypt($sifra, $salt), CRYPT_SALT_LENGTH);  
                         $lang_1 = $language[0];  
                         $lang_2 = $language[1];  
                         $salt_1 = substr($salt, 0, CRYPT_SALT_LENGTH / 2);  
                         $salt_2 = substr($salt, CRYPT_SALT_LENGTH / 2);  
101                          $_composed = implode("|", array($sifra,                          $_composed = implode("|", array($sifra,
102                                  $enc.$lang_1.$salt_1.$lang_2.$salt_2));                                  $language[1].$crc.$language[0]));
                         $_composed = str_replace("/", "!", $_composed);  
103                  }                  }
104                  return $_composed;                  return $_composed;
105          }          }
106          function Decompose($str) {          function Decompose($str) {
107                  global $sifra, $language;                  global $sifra, $language, $REMOTE_ADDR;
108                  $str = str_replace("!", "/", $str);                  list($sifra, $crc) = explode("|", $str);
109                  list($sifra, $lang) = explode("|", $str);                  $language = $crc[strlen($crc) - 1].$crc[0];
110                  $enc = substr($lang, 0, -(CRYPT_SALT_LENGTH + 2));                  if (md5($sifra."@".$REMOTE_ADDR) != substr($crc, 1, -1))
111                  $lang = substr($lang, strlen($enc));                          $sifra = "";
                 $lang_1 = $lang[0];  
                 $salt_1 = substr($lang, 1, CRYPT_SALT_LENGTH / 2);  
                 $lang_2 = $lang[(CRYPT_SALT_LENGTH / 2) + 1];  
                 $salt_2 = substr($lang, (CRYPT_SALT_LENGTH / 2) + 2);  
                 $language = $lang_1.$lang_2;  
                 $salt = $salt_1.$salt_2;  
                 $cry = substr(crypt($sifra, $salt), CRYPT_SALT_LENGTH);  
                 if ($cry != $enc) $sifra = "";  
112          }          }
113          function Params($pg = -1, $more = array()) {          function Params($pg = -1, $more = array()) {
114                  global $page;                  global $page;
115                  if ($pg >= 0) $page = $pg;                  if ($pg >= 0) $page = $pg;
116                  $tmp = Compose();                  $tmp = Compose();
117                  if (is_array($more)) {                  if (is_array($more)) {
118                          while (list($key, $val) = each($more)) {                          $foo = array();
119                                  if ($tmp) $tmp = $tmp."&";                          while (list($key, $val) = each($more))
120                                  $tmp = $tmp."$key=$val";                                  array_push($foo, "$key=$val");
121                          }                          $foo = implode("&", $foo);
122                            if ($foo) $tmp .= "&$foo";
123                  }                  }
124                  if (isset($tmp) && $tmp) $tmp = "?ID=".$tmp;                  if (isset($tmp) && $tmp) $tmp = "?ID=".$tmp;
125                  return $tmp;                  return $tmp;
126          }          }
127          function nepoznato(&$sto) {          function nepoznato(&$sto) {
128                  global $language;                  global $language;
129                  if (isset($sto) && $sto == "") {                  if ($sto) return;
130                          if ($language == "HR") $sto = "[nepoznato]";                  $sto = "-";
131                          if ($language == "EN") $sto = "[unknown]";  /* STARO!!!
132                          $sto = "<I>$sto</I>";                  switch ($language) {
133                            case "HR": $sto = "[nepoznato]"; break;
134                            case "EN": $sto = "[unknown]"; break;
135                  }                  }
136                    $sto = "<I>$sto</I>";
137    */
138          }          }
139          function Auth() {          function Auth() {
140                  global $sifra;                  global $sifra, $PHP_SELF;
141                  if ($sifra) return true;                  if ($sifra) return true;
142                  Header("Location: index.php?x=");                  Header("Location: index.php?x=");
143                  return false;                  return false;
144          }          }
145          Header("Pragma: no-cache");          Header("Pragma: no-cache");
146            if ($ID) Decompose($ID);
147          if (!isset($language) || !$language) $language = "HR";          if (!isset($language) || !$language) $language = "HR";
148          if (!isset($sifra) || !$sifra) $sifra = "";          if (!isset($sifra) || !$sifra) $sifra = "";
         if ($ID) Decompose($ID);  
         unset($ID);  
149          include_once("inc/MySmarty.php");          include_once("inc/MySmarty.php");
150  ?>  ?>

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26