/[pliva-si]/inc/common.inc
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/common.inc

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

revision 1.1.1.1 by ravilov, Mon Jun 25 09:57:25 2001 UTC revision 1.13 by dpavlin, Tue May 14 12:54:54 2002 UTC
# Line 1  Line 1 
1  <?  <?
2    
3  global $smarty,$dbh;  global $smarty,$dbh,$user_authed;
4    
5  // fetch menu  // fetch menu
6    
7  $sth = $dbh->prepare("select item,url,file from menu where section='$section' order by num");  if (!isset($m)) {
8            $m=$section;
9    } else {
10            $smarty->assign("m_session","m=$m&");
11            $smarty->assign("m_session_urlend","&m=$m");
12            $smarty->assign("m_form_session","<input type=\"hidden\" name=\"m\" value=\"$m\">");
13    }
14    
15    $sth = $dbh->prepare("select item,url,file,w,h from menu where section='$m' and $visible_is_true order by num");
16  $sth->execute();  $sth->execute();
17  while ($row=$sth->fetchrow_hash()) {  while ($row=$sth->fetchrow_hash()) {
18          $menu[]=$row;          $menu[]=$row;
# Line 12  while ($row=$sth->fetchrow_hash()) { Line 20  while ($row=$sth->fetchrow_hash()) {
20    
21  $smarty->assign("menu",$menu);  $smarty->assign("menu",$menu);
22    
23    
24    // link na otroke sa slatkorne stran
25    if ($m == "sladkorna") $smarty->assign("link_otroci",1);
26    
27    
28    $sql_where=" and substr(type,3,1)<>'x'" ; // don't show locked records
29    
30    
31    // auth... based on m
32    
33    $cookie_data=md5(strftime("%w%Y").$PHP_AUTH_USER.$PHP_AUTH_PW);
34    
35    if ($m == "za_zdravnike") {
36    
37    
38            if ($cookie_data != $pliva_si_user) {
39    
40                    $sth = $dbh->prepare("select login as user,geslo as pw from people where login = '$PHP_AUTH_USER'");
41                    $sth->execute();
42                    if (! $row=$sth->fetchrow_hash() || $PHP_AUTH_PW != $row[pw]) {
43                            header("WWW-authenticate: basic realm=\"$HTTP_HOST\"") ;
44                            header("HTTP/1.0 401 Unauthorized") ;
45                            print "<html>Unauthorized</html>";
46                            exit;
47                    } else {
48                            setcookie("pliva_si_user",$cookie_data);
49                    }
50            }
51    
52            $user_authed++;
53            $sql_where="";  // don't limit output to authed users
54    } else {
55            if ($cookie_data == $pliva_si_user) {
56                    $user_authed++;
57                    $sql_where="";  // don't limit output to authed users
58            }
59    }
60    $smarty->assign("user_authed",$user_authed);
61    
62    
63  // fetch news  // fetch news
64    
65  $sth = $dbh->prepare("select id,title from news where type<>'e' and type<>'p' and visible order by date desc limit 5");  $sth = $dbh->prepare("select id,title from news where substr(type,1,1)='n' $sql_where and $visible_is_true order by date desc limit 5");
66  $sth->execute();  $sth->execute();
67  while ($row=$sth->fetchrow_hash()) {  while ($row=$sth->fetchrow_hash()) {
68          $news[]=$row;          $news[]=$row;
69  }  }
70  $smarty->assign("news",$news);  $smarty->assign("news",$news);
71    
72  $sth = $dbh->prepare("select id,title from news where type='e' and visible order by priority desc,date desc limit 5");  $sth = $dbh->prepare("select id,title from news where substr(type,1,1)='e' $sql_where and $visible_is_true order by priority desc,date desc limit 5");
73  $sth->execute();  $sth->execute();
74  while ($row=$sth->fetchrow_hash()) {  while ($row=$sth->fetchrow_hash()) {
75          $events[]=$row;          $events[]=$row;
76  }  }
77  $smarty->assign("events",$events);  $smarty->assign("events",$events);
78    
79  #include("debug.inc");  $smarty->assign("self",$PHP_SELF);
80    
81  if ($multi_page) {  #include("debug.inc");
         $max=count($multi_page);  
         $next=$multi_page[$current+1];  
         $show=0;  
   
         $uri=basename($GLOBALS[REQUEST_URI]);  
   
         for ($i=0; $i<=$max; $i++) {  
                 if ($multi_page[$i]==substr($uri,0,strlen($uri))) {  
                         $current=$i;  
                         $show=1;  
                 }  
         }  
   
         if ($current && $current!=0) {  
                 $prev=$multi_page[$current-1];  
         }  
         if ($current && $current!=$max) {  
                 $next=$multi_page[$current+1];  
         }  
         if ($show) {  
                 $smarty->assign(array(  
                 "multi_page_show" => 1,  
                 "multi_page"=>$multi_page,  
                 "multi_page_current"=>($current+1),  
                 "multi_page_max"=>$max,  
                 "multi_page_prev"=>$prev,  
                 "multi_page_next"=>$next  
                 ));  
         }  
   
 }  
   
 function check_required() {  
         global $inputs_required;  
         global $inputs_required_type;  
         $ok=1;  
         if (isset($inputs_required)) {  
                 foreach ($inputs_required as $i) {  
                         if (! isset($GLOBALS[$i]) || $GLOBALS[$i] == "") $ok=0;  
                         switch (strtolower($inputs_required_type[$i])) {  
                                 case 'email':  
                                         if (!strstr($GLOBALS[$i],'@')) $ok=0;  
                         }  
 //                      print "$i: $GLOBALS[$i] type: $inputs_required_type[$i] $ok -- ";  
   
                 }  
         } else {  
                 print "<!-- no inputs required -->";  
         }  
         return $ok;  
 }  
82    
83  ?>  ?>

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.26