Added rudimentary transport support to get_threaded_children
[mirrors/Kyberia-bloodline.git] / wwwroot / inc / eventz / register.inc
1 <?php
2 function register() {
3 global $db, $error;
4
5 $content = mysql_real_escape_string(strip_tags(trim($_POST['reg_content'])));
6 $email = mysql_real_escape_string(strip_tags(trim($_POST['reg_email'])));
7 $login = mysql_real_escape_string(strip_tags(trim($_POST['reg_login'])));
8 $pass = mysql_real_escape_string($_POST['reg_pass']);
9 $pass2 = mysql_real_escape_string($_POST['reg_pass2']);
10
11 if (empty($login)) {
12 $error = 'please enter your nick name';
13 return false;
14 }
15 elseif (empty($email)) {
16 $error = 'please enter your email address';
17 return false;
18 }
19 elseif (preg_match('/^(.+?)@(.+?)\.([a-z]{2,4})$/', $email) == false) {
20 $error = 'please enter correct mail';
21 return false;
22 }
23 elseif (empty($content)) {
24 $error = 'please write something about you';
25 return false;
26 }
27 elseif (strlen($pass) < 5) {
28 $error = 'password toooooooo short, (<5)';
29 return false;
30 }
31 elseif ($pass != $pass2) {
32 $error = 'passwords do not match';
33 return false;
34 }
35
36 $set = $db->query(sprintf('select login from users where
37 login = "%s" or email = "%s"', $login, $email));
38 if ($set->getNumRows() > 0) {
39 $error = sprintf('No-no, user with this email is already registered');
40 return false;
41 }
42
43 // registration clause // XXX hard coded, registration text
44 $qr_rc = $db->query('select node_content from nodes where node_id = '.REGISTRATION_TEXT_NODE);
45 $qr_rc->next();
46
47 $params['node_content'] = sprintf('<i>%s</i><br />%s<br />
48 E-mail address:: %s',
49 $qr_rc->getString('node_content'),
50 $content,
51 $email);
52 // XXX hard-coded
53 $params['node_parent'] = UNVERIFIED_REGISTRATIONS_NODE; // registrations_noverified forum
54 $params['node_name'] = 'request for access';
55 $params['flag'] = 'registration';
56 $user_id = nodes::addNode($params);
57 $q = sprintf('update nodes set node_system_access = "private" where node_id = %d', $user_id);
58 $db->update($q);
59
60 $pass = md5($pass);
61 $vercode = substr( md5( uniqid( rand() ) ), rand(0, 7), 23);
62 $q = sprintf('insert into users set password = "%s", user_id = %d,
63 header_id = 2091520, login = "%s", email = "%s",
64 hash = "%s"',
65 $pass, $user_id, $login, $email, $vercode);
66 $db->query($q); // XXX rewrite
67 $emailtext = sprintf(
68 'Vitaj %s! Prave som sa s radostou dozvedel, ze si vyplnil(a)
69 registracny formular na stranke '.SYSTEM_URL.' a chces sa stat
70 clenom tejto komunity.
71 Budem sa snazit urobit tento pokec trosku dlhsi,
72 lebo v povodnej kratkej forme ho pohlcuju spamfiltre, takze
73 ospravedln nasledujuce blabla a moj typicky atypicky zmysel
74 pre cierny humor, kedze sluzi ku dobrej veci :)
75 Pri registracii ti bol prideleny verifikacny kod.
76 Ten kod znie "%s" [bez uvodzoviek].
77 Ten musis zadat na adresu '.SYSTEM_URL.'/id/1976899/, kde
78 vyplnis formular s tvojim nickom a verifkacnym kodom.
79 Od tej chvile bude tvoja ziadost volne pristupna
80 uz zaregistrovanym clenom, ktori o nej budu hlasovat.
81 Pocet hlasov aby sa ziadosti vyhovelo je x.
82 Deadline na nazbieranie je 1 tyzden.
83 Takze fakticky dufam ze si o sebe napisal(a) nieco inteligentne :)
84
85 Prajem pekny zvysok dna',
86 $login, $vercode);
87 // edit by br
88 $headers = 'From: kyberia@'. SYSTEM_URL . "\r\n" . 'X-Mailer: PHP';
89 mail($email, SYSTEM_URL.' verification code', $emailtext, $headers);
90 $error = '<h2>Request saved, verification code sent, please check your e-mail.<h2>';
91
92 return false;
93 }
94 ?>
This page took 1.203794 seconds and 4 git commands to generate.