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