/[health_html]/inc/pgRegistracija.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 /inc/pgRegistracija.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Wed Sep 26 13:04:28 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Changes since 1.1: +5 -37 lines
Added some missing files, and some missing features...

1 <?php
2 function mycmp1($a, $b) { return MyCompare($a["caption"], $b["caption"]); }
3 function my_quote($str, $czs = false, $q = true) {
4 if ($czs) $str = strtr($str, "¹šðè澞©ŠÐÈÆ®Ž ", "ssdcczzSSDCCZZ_");
5 else $str = strtr($str, "šðè枊ÐÈƎ", "¹ðè澩ÐÈÆ®");
6 if ($q) {
7 global $dbh;
8 $str = $dbh->quote($str);
9 }
10 return $str;
11 }
12 include("inc/conn.php");
13 $sql = "SELECT zan_id, naziv FROM zanimanja";
14 $sth = $dbh->prepare($sql);
15 if (!$sth) error("Cannot prepare query: \"$sql\"");
16 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
17 $zanimanja = array();
18 while ($row = $sth->fetchrow_array())
19 array_push($zanimanja, array("id" => $row[0], "caption" => MyEscape($row[1])));
20 $sth->finish();
21 $tpl->assign("zanimanja", $zanimanja);
22 $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (spec_id != 0) AND (NOT link)";
23 $sth = $dbh->prepare($sql);
24 if (!$sth) error("Cannot prepare query: \"$sql\"");
25 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
26 $specs = array();
27 $nesto = false;
28 while ($row = $sth->fetchrow_array()) {
29 $checked = ${"spec_".$row[0]} ? true : false;
30 if ($checked) $nesto = true;
31 array_push($specs, array("id" => $row[0], "caption" => MyEscape($row[1]), "checked" => $checked));
32 }
33 $sth->finish();
34 usort($specs, "mycmp1");
35 if ($godrod) {
36 $pos = strpos($godrod, ".");
37 if ($pos && $pos == strlen($godrod) - 1) $godrod = substr($godrod, 0, -1);
38 }
39 $tpl->assign("specs", $specs);
40 $titula = trim($titula);
41 $ime = trim($ime);
42 $prezime = trim($prezime);
43 $email = trim($email);
44 $godrod = trim($godrod);
45 $ustanova = trim($ustanova);
46 $adresa = trim($adresa);
47 $mjesto = trim($mjesto);
48 $tpl->assign("titula", $titula);
49 $tpl->assign("ime", $ime);
50 $tpl->assign("prezime", $prezime);
51 $tpl->assign("email", $email);
52 $tpl->assign("godrod", $godrod);
53 $tpl->assign("zanimanje", $zanimanje);
54 $tpl->assign("ustanova", $ustanova);
55 $tpl->assign("adresa", $adresa);
56 $tpl->assign("mjesto", $mjesto);
57 $tpl->assign("sve", !$nesto);
58 if (!isset($newsletter)) $newsletter = true;
59 if (!isset($promo)) $promo = true;
60 $tpl->assign("newsletter", $newsletter);
61 $tpl->assign("promo", $promo);
62 $done = false;
63 $error = 0;
64 if ($salji) {
65 if (!$ime) $error |= 1;
66 if (!$prezime) $error |= 2;
67 if (!$godrod) { $godrodok = true; $error |= 4; }
68 if ($godrod && $godrod."" != intval($godrod)."") { $godrodok = false; $error |= 4; }
69 else if ($godrod) {
70 if ($godrod < 1900) $godrod += 1900;
71 $foo = getdate();
72 if ($godrod < 1900 || $godrod > $foo["year"]) { $godrodok = false; $error |= 4; }
73 }
74 if (!$email) { $emailok = true; $error |= 8; }
75 if ($email && !ereg('^[^\@]+\@[^\.]+\.[^\.]+.*$', $email)) { $emailok = false; $error |= 8; }
76 if (!$zanimanje) $error |= 16;
77 if (!$nesto && !$spec_0) $error |= 32;
78 if ($error == 0) {
79 $username = GenerateUsername($ime, $prezime);
80 $password = GeneratePassword();
81 $titula = $titula ? my_quote($titula) : "NULL";
82 $ime = $ime ? my_quote($ime) : "NULL";
83 $prezime = $prezime ? my_quote($prezime) : "NULL";
84 $email2 = $email ? my_quote($email) : "NULL";
85 $ustanova = $ustanova ? my_quote($ustanova) : "NULL";
86 $adresa = $adresa ? my_quote($adresa) : "NULL";
87 $mjesto = $mjesto ? my_quote($mjesto) : "NULL";
88 $sql = "INSERT INTO users (titula, ime, prezime, email, zanimanje, godrod, ustanova, adresa, mjesto, newsletter, promo, username, password) VALUES ($titula, $ime, $prezime, $email2, $zanimanje, $godrod, $ustanova, $adresa, $mjesto, ".($newsletter?"true":"false").", ".($promo?"true":"false").", '$username', '".md5($password)."')";
89 $dbh->dbh_do($sql);
90 $sql = "SELECT currval('users_user_id_seq')::text";
91 $sth = $dbh->prepare($sql);
92 if (!$sth) error("Cannot prepare query: \"$sql\"");
93 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
94 $row = $sth->fetchrow_array();
95 $sth->finish();
96 $row = array_shift($row);
97 for ($i = 0; $i < count($specs); $i++) {
98 if (!$specs[$i]["checked"]) continue;
99 if ($specs[$i]["id"] == 0) continue;
100 $sql = "INSERT INTO user_spec (user_id, spec_id) VALUES ($row, ".$specs[$i]["id"].")";
101 $dbh->dbh_do($sql);
102 }
103 $mail = "\nKorisnièko ime: $username\nLozinka: $password\n\nhttp://dpavlinusic1.pliva.hr/ph/thefilez/med/?section=prijava&username=$username\n";
104 #echo "[$email] [$mail]<BR>\n";
105 $ret = mail($email, "PLIVAmed.net - Registracija", $mail, "From: registracija@plivamed.net");
106 }
107 $tpl->assign("emailok", $emailok);
108 $tpl->assign("godrodok", $godrodok);
109 $tpl->assign("username", $username);
110 if (!$error) $done = true;
111 }
112 $tpl->assign("error", $error);
113 $tpl->assign("done", $done);
114 ?>

  ViewVC Help
Powered by ViewVC 1.1.26