2 /* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
4 * This file is part of e-DoKo.
6 * e-DoKo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * e-DoKo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with e-DoKo. If not, see <http://www.gnu.org/licenses/>.
21 /* make sure that we are not called from outside the scripts,
22 * use a variable defined in config.php to check this
27 /* new user wants to register */
28 if(myisset("Rfullname","Remail","Rtimezone") )
32 /* is this name already in use/ */
34 if(DB_get_userid('name',$_REQUEST['Rfullname']))
36 echo "please chose another name<br />";
39 /* check if email address is already used */
40 if(DB_get_userid('email',$_REQUEST['Remail']))
42 echo "this email address is already used ?!<br />";
45 /* need either openid or password */
46 if(!myisset('Rpassword') && !myisset('Ropenid'))
48 echo "I need either a Password or an Openid url.<br />";
52 /* check against robots */
53 $robots=0; /* at least one anti-robot question needs to be answered */
54 if(myisset('Robotproof0'))
56 if($_REQUEST['Robotproof0']!=42)
61 else if(myisset('Robotproof1'))
63 if($_REQUEST['Robotproof1']!=35)
68 else if(myisset('Robotproof2'))
70 if($_REQUEST['Robotproof2']!=28)
75 else if(myisset('Robotproof3'))
77 if($_REQUEST['Robotproof3']!=21)
82 else if(myisset('Robotproof4'))
84 if($_REQUEST['Robotproof4']!=14)
91 echo "You answered the math question wrong. <br />\n";
94 /* everything ok, go ahead and create user */
97 if(myisset('Rpassword'))
99 $r=DB_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
100 ",".DB_quote_smart($_REQUEST["Remail"]).
101 ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
102 ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)");
104 else if(myisset('Ropenid'))
106 $password = $_REQUEST["Rfullname"].preg_replace('/([ ])/e', 'chr(rand(33,122))', ' ');
107 $r=DB_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
108 ",".DB_quote_smart($_REQUEST["Remail"]).
109 ",".DB_quote_smart(md5($password)).
110 ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)");
113 include_once('openid.php');
114 $myid = DB_get_userid('email',$_REQUEST['Remail']);
115 DB_AttachOpenID($_REQUEST['Ropenid'], $myid);
120 echo 'Error during registration, please contact '.$ADMIN_NAME.' at '.$ADMIN_EMAIL;
124 /* Set session, so that new user doesn't need to log in */
125 $myname = DB_get_name('email',$_REQUEST['Remail']);
126 $_SESSION["name"] = $myname;
128 echo " Welcome to e-DoKo, you are now registered, please visit the".
129 " <a href=\"".$HOST.$INDEX."\">homepage</a> to continue.";
132 echo " something went wrong, couldn't add you to the database, please contact $ADMIN_NAME at $ADMIN_EMAIL.";
136 echo "Couldn't register you. Please <a href=\"index.php?action=register\">try again</a>! </br />\n";
141 /* No information for new user given, ouput a page for registration */
143 /* check for openid information */
147 if(myisset('openid_url'))
148 $openid_url = $_REQUEST['openid_url'];
149 if(myisset('openidname'))
150 $name = $_REQUEST['openidname'];
151 if(myisset('openidemail'))
152 $email = $_REQUEST['openidemail'];
155 echo "<p><br /><strong> IMPORTANT: passwords are going over the net as clear text, so pick an easy password. ".
156 "No need to pick anything complicated here ;)<br />";
157 echo "N.B. Your email address will be exposed to other players whom you play games with. ";
158 echo "<br /><br /></strong></p>";
159 echo ' <form action="index.php?action=register" method="post">';
161 echo ' <legend>Register</legend>';
164 echo ' <td><label for="Rfullname">Full name:</label></td>';
165 echo " <td><input type=\"text\" id=\"Rfullname\" name=\"Rfullname\" size=\"20\" maxlength=\"30\" value=\"$name\" /> </td>";
167 echo ' <td><label for="Remail">Email:</label></td>';
168 echo " <td><input type=\"text\" id=\"Remail\" name=\"Remail\" size=\"20\" maxlength=\"30\" value=\"$email\" /></td>";
172 echo ' <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>';
173 echo ' <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxlength="30" /></td>';
178 echo ' <td><label for="Ropenid">OpenId:</label></td>';
179 echo ' <td><input type="text" id="Ropenid" name="Ropenid" size="20" maxlength="50" value="'.htmlentities($openid_url).'" /></td>';
182 echo ' <td><label for="Rtimezone">Timezone:</label></td>';
185 output_select_timezone("Rtimezone");
191 /* random number to select robotproof question */
192 $rand_number = mt_rand(0,3); /* to get numbers between 0 and 4 */
193 $Robotproof = "Robotproof".$rand_number;
195 <td><label for="Robotproof">Please answer this question: <?php echo output_robotproof($rand_number); ?></label></td>
197 echo "<td><input type=\"text\" id=\"$Robotproof\" name=\"$Robotproof\" size=\"20\" maxlength=\"30\" /></td>\n";
200 <td colspan="2"> <input type="submit" value="register" /></td>