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