/[informatika.old]/html/ko_admin.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

Contents of /html/ko_admin.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations)
Fri Jul 13 07:34:37 2001 UTC (22 years, 8 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
don't nuke password

1 <?
2 include("inc/head.inc");
3 include("inc/prava.inc");
4 include("inc/checkbox.inc");
5 include("inc/bgcolor.inc");
6 include("inc/show_bool.inc");
7
8 if (isset($kontakt_osoba_id)) {
9 $result = pg_Exec ($conn, "select ime,prezime,passwd,prava from kontakt_osobe where aktivna=true and id=$kontakt_osoba_id");
10 $row=pg_fetch_array($result,0);
11 print "<small>Trenutno ste prijavljeni kao $row[ime] $row[prezime], ako je to krivo odaberite <a href=\"$PHP_SELF?what=relogin\">ovaj link</a>.</small>";
12 $curr_md5_passwd=md5($row[passwd]);
13 if ( (!isset($md5_passwd) && $row[passwd] != $passwd) ||
14 (isset($md5_passwd) && $curr_md5_passwd != $md5_passwd) ) {
15 include("inc/auth.inc");
16 $what="auth";
17 echo "<big>Upisana je neispravna loznika!</big>";
18 session_destroy();
19 print '<p><a href="index.php">Povratak na poèetnu stranicu</a>';
20 include("inc/footer.inc");
21 exit;
22 } elseif (($row[prava] & $pr_ko_admin) == 0) {
23 echo "<p><big>Nemate ovla¹tenja za administriranje kontakt osoba!</big>";
24 include("inc/footer.inc");
25 exit;
26 } else {
27 session_register("kontakt_osoba_id");
28 session_register("md5_passwd");
29 $md5_passwd=md5($row[passwd]);
30 # $passwd="";
31 }
32 } else {
33 include("inc/auth.inc");
34 include("inc/footer.inc");
35 exit;
36 }
37
38
39 function vrati_nova_prava () {
40 $result=pg_Exec($GLOBALS["conn"],"select id,opis from status_tip");
41 $foo=0;
42 for ($k = 0; $k < pg_numrows($result); $k++) {
43 $row=pg_fetch_array($result,$k);
44 if ($GLOBALS["pravo_$row[id]"] != "") { $foo+=pow(2,$row[id]); };
45 }
46 return $foo;
47 }
48
49 if ($do_obrisi && isset($id) && $id != "") {
50 $result=pg_Exec($conn,"update kontakt_osobe set prava=0,aktivna=false where id=$id");
51 if ($delete_from_db == "on") {
52 $result=pg_Exec($conn,"delete from kontakt_osobe where id=$id");
53 }
54 }
55
56 if ($do_reset || $do_obrisi ) {
57 $ime="";
58 $prezime="";
59 $e_mail="";
60 $passwd="";
61 $prava="";
62 //$id="";
63 unset ($id);
64 }
65
66 if ($do_promjeni) {
67 $result=pg_Exec($conn,"update kontakt_osobe set ime='$ime',prezime='$prezime',e_mail='$e_mail',passwd='$passwd', prava=".vrati_nova_prava()." where id=$id");
68 }
69
70 if ($do_dodaj) {
71 $result=pg_Exec($conn,"insert into kontakt_osobe (ime,prezime,e_mail,passwd,prava) values ('$ime','$prezime','$e_mail','$passwd',".vrati_nova_prava().")");
72 }
73
74 if ($do_trazi) {
75 $result=pg_Exec($conn,"select id,ime,prezime,e_mail,passwd,prava
76 from kontakt_osobe
77 where upper(ime) like upper('$ime%') and
78 upper(prezime) like upper('$prezime%') and
79 upper(e_mail) like upper('$e_mail%')
80 order by id");
81 if (pg_numrows($result) == 1) {
82 $row=pg_fetch_array($result,$i);
83 $id=$row[id];
84 }
85 }
86
87
88 if (isset($id) && !$do_dodaj) {
89 $result=pg_Exec($conn,"select id,ime,prezime,e_mail,passwd,prava,aktivna from kontakt_osobe where id=$id");
90 $row=pg_fetch_array($result,0);
91 while (list($key,$val) = each($row)) {
92 $GLOBALS["$key"]=$val;
93 }
94 }
95
96 ?>
97
98 <p><a href="#lista">Lista kontakt osoba</a>
99
100 <h1>Podaci o kontakt osobi</h1>
101 <form method="post" action="<? echo $PHP_SELF ?>" name="forma">
102 <table border=0>
103 <tr bgcolor="#f0f0f0">
104 <td>Ime</td>
105 <td colspan="4">
106 <input type="text" name="ime" size="50" value="<? echo $ime ?>">
107 </td>
108 </tr>
109 <tr>
110 <td>Prezime</td>
111 <td colspan="4">
112 <input type="text" name="prezime" size="50" value="<? echo $prezime ?>">
113 </td>
114 </tr>
115 <tr bgcolor="#f0f0f0">
116 <td>e-mail</td>
117 <td colspan="4">
118 <input type="text" name="e_mail" size="50" value="<? echo $e_mail ?>">
119 </td>
120 </tr>
121 <tr>
122 <td>password</td>
123 <td>
124 <input type="text" name="passwd" size="10" value="<? echo $passwd ?>">
125 </td>
126 <td>aktivna: <? echo show_bool($aktivna) ?></td>
127 </tr>
128 <tr bgcolor="#f0f0f0">
129 <td>prava</td>
130 <td>
131 <?
132 $result=pg_Exec($conn,"select id,opis from status_tip");
133 $nova_prava=0;
134 unset($prava_checkbox[]);
135 for ($k = 0; $k < pg_numrows($result); $k++) {
136 $row=pg_fetch_array($result,$k);
137
138 if (isset($prava)) {
139 if ($prava & pow(2,$row[id])) {
140 $GLOBALS["pravo_$row[id]"]="on";
141 } else {
142 unset($GLOBALS["pravo_$row[id]"]);
143 };
144 };
145 print checkbox("pravo_$row[id]",$GLOBALS["pravo_$row[id]"])." $row[opis]<br>";
146 if ($GLOBALS["pravo_$row[id]"] != "") { $nova_prava+=pow(2,$row[id]); };
147 }
148 print "<i>Trenutno: $nova_prava</i>";
149 ?>
150 </td>
151 <td>
152 <? if (! isset($id)): ?>
153 <input type="submit" name="do_trazi" value="Pronaði"><P>
154 <input type="submit" name="do_dodaj" value="Dodaj novog"><P>
155 <? else: ?>
156 <input type="submit" name="do_promjeni" value="Promjeni"><P>
157 <input type="submit" name="do_obrisi" value="Deaktiviraj"> <small><input type=checkbox name=delete_from_db> stvarno obri¹i iz baze</small><P>
158 <? endif; ?>
159 <input type="submit" name="do_reset" value="Odustani"><P>
160 </td>
161 </tr>
162 </table>
163 <input type="hidden" name="id" size="10" value="<? echo $id ?>">
164 </form>
165 <HR>
166
167 <a name="lista">
168
169 <TABLE>
170 <th><TD>id</td><td>ime</TD><TD>prezime</TD><TD>e_mail</TD><TD>prava</TD><td>aktivna</td></TH>
171 <?
172
173
174 $result=pg_Exec($conn,"select id,ime,prezime,e_mail,passwd,prava,aktivna
175 from kontakt_osobe
176 where upper(ime) like upper('$ime%') and upper(prezime) like upper('$prezime%') and
177 upper(e_mail) like upper('$e_mail%')
178 order by id");
179 for ($i=0; $i<pg_numrows($result); $i++) {
180 $row=pg_fetch_array($result,$i);
181 while (list($key,$val) = each($row)) {
182 $GLOBALS["$key"]=$val;
183 }
184 print "<TR".bgcolor()."><td></td><TD><a href=\"$PHP_SELF?id=$id\"> $id</a></TD><TD>$ime</td><td> $prezime</td><td> $e_mail</td><td> $prava</td><td>".show_bool($aktivna)."</td></tr>";
185 }
186
187 ?>
188 </table>
189 <?
190 include("inc/footer.inc")
191
192 ?>

  ViewVC Help
Powered by ViewVC 1.1.26