/[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

Annotation of /inc/pgRegistracija.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations)
Sat Oct 27 16:54:50 2001 UTC (17 years, 6 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +2 -9 lines
Rearranged the menu system on plivamed.net. Other fixes/improvements.

1 ravilov 1.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 ravilov 1.4 if (!isset($newsletter)) $newsletter = true;
49     if (!isset($promo)) $promo = true;
50     if (!isset($drzava)) $drzava = "Hrvatska";
51     $drzava = trim($drzava);
52 ravilov 1.1 $tpl->assign("titula", $titula);
53     $tpl->assign("ime", $ime);
54     $tpl->assign("prezime", $prezime);
55     $tpl->assign("email", $email);
56     $tpl->assign("godrod", $godrod);
57     $tpl->assign("zanimanje", $zanimanje);
58     $tpl->assign("ustanova", $ustanova);
59     $tpl->assign("adresa", $adresa);
60     $tpl->assign("mjesto", $mjesto);
61 ravilov 1.4 $tpl->assign("drzava", $drzava);
62 ravilov 1.1 $tpl->assign("sve", !$nesto);
63     $tpl->assign("newsletter", $newsletter);
64     $tpl->assign("promo", $promo);
65     $done = false;
66     $error = 0;
67     if ($salji) {
68     if (!$ime) $error |= 1;
69     if (!$prezime) $error |= 2;
70     if (!$godrod) { $godrodok = true; $error |= 4; }
71     if ($godrod && $godrod."" != intval($godrod)."") { $godrodok = false; $error |= 4; }
72     else if ($godrod) {
73     if ($godrod < 1900) $godrod += 1900;
74     $foo = getdate();
75     if ($godrod < 1900 || $godrod > $foo["year"]) { $godrodok = false; $error |= 4; }
76     }
77     if (!$email) { $emailok = true; $error |= 8; }
78     if ($email && !ereg('^[^\@]+\@[^\.]+\.[^\.]+.*$', $email)) { $emailok = false; $error |= 8; }
79     if (!$zanimanje) $error |= 16;
80     if (!$nesto && !$spec_0) $error |= 32;
81 ravilov 1.5 if (!$username) { $userok = true; $error |= 64; }
82     if ($username) {
83 ravilov 1.6 $sql = "SELECT username FROM users WHERE (username = '$username')";
84 ravilov 1.5 $sth = $dbh->prepare($sql);
85     if (!$sth) error("Cannot prepare query: \"$sql\"");
86     if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
87     $row = $sth->fetchrow_array();
88     $sth->finish();
89     if ($row) $row = array_shift($row);
90     if ($row) { $userok = false; $error |= 64; }
91     }
92     $passerr = 0;
93     if (!$passerr && !$password1) { $error |= 128; $passerr = 1; }
94     if (!$passerr && $password1 != $password2) { $error |= 128; $passerr = 2; }
95     if (!$passerr && strlen($password1) < 5) { $error |= 128; $passerr = 3; }
96 ravilov 1.1 if ($error == 0) {
97 ravilov 1.5 // $username = GenerateUsername($ime, $prezime);
98     // $password = GeneratePassword();
99 ravilov 1.1 $titula = $titula ? my_quote($titula) : "NULL";
100     $ime = $ime ? my_quote($ime) : "NULL";
101     $prezime = $prezime ? my_quote($prezime) : "NULL";
102 ravilov 1.5 $username2 = $username ? my_quote($username) : "NULL";
103 ravilov 1.1 $email2 = $email ? my_quote($email) : "NULL";
104     $ustanova = $ustanova ? my_quote($ustanova) : "NULL";
105     $adresa = $adresa ? my_quote($adresa) : "NULL";
106     $mjesto = $mjesto ? my_quote($mjesto) : "NULL";
107 ravilov 1.4 $drzava = $drzava ? my_quote($drzava) : "NULL";
108 ravilov 1.5 $sql = "INSERT INTO users (titula, ime, prezime, email, zanimanje, godrod, ustanova, adresa, mjesto, drzava, newsletter, promo, username, password) VALUES ($titula, $ime, $prezime, $email2, $zanimanje, $godrod, $ustanova, $adresa, $mjesto, $drzava, ".($newsletter?"true":"false").", ".($promo?"true":"false").", $username2, '".md5($password1)."')";
109 ravilov 1.1 $dbh->dbh_do($sql);
110     for ($i = 0; $i < count($specs); $i++) {
111 ravilov 1.5 if ($specs[0]["checked"]) continue;
112 ravilov 1.1 if (!$specs[$i]["checked"]) continue;
113     if ($specs[$i]["id"] == 0) continue;
114 ravilov 1.6 $sql = "INSERT INTO user_spec (username, spec_id) VALUES ('$username2', ".$specs[$i]["id"].")";
115 ravilov 1.1 $dbh->dbh_do($sql);
116     }
117 ravilov 1.3 $mail = "
118    
119     Dobrodo¹li u PLIVAmed.net zajednicu!
120    
121     Zahvaljujemo Vam ¹to ste ispunili na¹ registracijski obrazac i time ostvarili
122     pravo na pristup struènom i specijaliziranom sadr¾aju PLIVAmed.net portala.
123    
124     Da bi mogli bez ogranièenja pregledavati sve sadr¾aje, prilikom slijedeæeg
125     pristupa trebate unijeti svoje korisnièko ime i lozinku kako je navedeno:
126    
127 ravilov 1.5 Korisnièko ime: $username
128     Lozinka: $password1
129 ravilov 1.3
130 ravilov 1.5 Za nastavak rada na PLIVAmed.net portalu kliknite donji link i unesite
131     gore navedenu lozinku.
132 ravilov 1.3
133 ravilov 1.5 http://www.plivamed.net/?section=prijava&username=".urlencode($username)."
134 ravilov 1.3
135     Predla¾emo Vam da ovu e-mail poruku spremite na sigurno mjesto kako biste u
136     sluèaju da zaboravite Va¹e podatke mogli provjeriti korisnièko ime i lozinku.
137    
138     Sva pitanja i komentare mo¾ete poslati na adresu info@plivamed.net
139    
140     ®elimo Vam ugodan rad na na¹em portalu!
141    
142     PLIVAmed.net
143     ";
144 ravilov 1.2 #echo "[$email] [$mail]<BR>\n";
145 ravilov 1.3 $ret = mail($email, "PLIVAmed.net - Registracija", $mail, "From: registracija@plivamed.net\nContent-Type: text/plain;charset=ISO-8859-2");
146 ravilov 1.1 }
147     $tpl->assign("emailok", $emailok);
148     $tpl->assign("godrodok", $godrodok);
149 ravilov 1.5 $tpl->assign("passerr", $passerr);
150     $tpl->assign("userok", $userok);
151 ravilov 1.1 $tpl->assign("username", $username);
152     if (!$error) $done = true;
153     }
154     $tpl->assign("error", $error);
155     $tpl->assign("done", $done);
156     ?>

  ViewVC Help
Powered by ViewVC 1.1.26