2 /* make sure that we are not called from outside the scripts,
3 * use a variable defined in config.php to check this
8 /* new user wants to register */
9 if(myisset("Rfullname","Remail","Rtimezone") )
13 /* is this name already in use/ */
15 if(DB_get_userid('name',$_REQUEST['Rfullname']))
17 echo "please chose another name<br />";
20 /* check if email address is already used */
21 if(DB_get_userid('email',$_REQUEST['Remail']))
23 echo "this email address is already used ?!<br />";
26 /* need either openid or password */
27 if(!myisset('Rpassword') && !myisset('Ropenid'))
29 echo "I need either a Password or an Openid url.<br />";
33 /* check against robots */
34 $robots=0; /* at least one anti-robot question needs to be answered */
35 if(myisset('Robotproof0'))
37 if($_REQUEST['Robotproof0']!=42)
42 else if(myisset('Robotproof1'))
44 if($_REQUEST['Robotproof1']!=35)
49 else if(myisset('Robotproof2'))
51 if($_REQUEST['Robotproof2']!=28)
56 else if(myisset('Robotproof3'))
58 if($_REQUEST['Robotproof3']!=21)
63 else if(myisset('Robotproof4'))
65 if($_REQUEST['Robotproof4']!=14)
72 echo "You answered the math question wrong. <br />\n";
75 /* everything ok, go ahead and create user */
78 if(myisset('Rpassword'))
80 $r=DB_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
81 ",".DB_quote_smart($_REQUEST["Remail"]).
82 ",".DB_quote_smart(md5($_REQUEST["Rpassword"])).
83 ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)");
85 else if(myisset('Ropenid'))
87 $password = $_REQUEST["Rfullname"].preg_replace('/([ ])/e', 'chr(rand(33,122))', ' ');
88 $r=DB_query("INSERT INTO User VALUES(NULL,".DB_quote_smart($_REQUEST["Rfullname"]).
89 ",".DB_quote_smart($_REQUEST["Remail"]).
90 ",".DB_quote_smart(md5($password)).
91 ",".DB_quote_smart($_REQUEST["Rtimezone"]).",NULL,NULL)");
94 include_once('openid.php');
95 $myid = DB_get_userid('email',$_REQUEST['Remail']);
96 DB_AttachOpenID($_REQUEST['Ropenid'], $myid);
101 echo 'Error during registration, please contact '.$ADMIN_NAME.' at '.$ADMIN_EMAIL;
105 /* Set session, so that new user doesn't need to log in */
106 $myname = DB_get_name('email',$_REQUEST['Remail']);
107 $_SESSION["name"] = $myname;
109 echo " Welcome to e-DoKo, you are now registered, please visit the".
110 " <a href=\"".$HOST.$INDEX."\">homepage</a> to continue.";
113 echo " something went wrong, couldn't add you to the database, please contact $ADMIN_NAME at $ADMIN_EMAIL.";
117 echo "Couldn't register you. Please <a href=\"index.php?action=register\">try again</a>! </br />\n";
122 /* No information for new user given, ouput a page for registration */
124 /* check for openid information */
128 if(myisset('openid_url'))
129 $openid_url = $_REQUEST['openid_url'];
130 if(myisset('openidname'))
131 $name = $_REQUEST['openidname'];
132 if(myisset('openidemail'))
133 $email = $_REQUEST['openidemail'];
136 echo "<p><br /><strong> IMPORTANT: passwords are going over the net as clear text, so pick an easy password. ".
137 "No need to pick anything complicated here ;)<br />";
138 echo "N.B. Your email address will be exposed to other players whom you play games with. ";
139 echo "<br /><br /></strong></p>";
140 echo ' <form action="index.php?action=register" method="post">';
142 echo ' <legend>Register</legend>';
145 echo ' <td><label for="Rfullname">Full name:</label></td>';
146 echo " <td><input type=\"text\" id=\"Rfullname\" name=\"Rfullname\" size=\"20\" maxlength=\"30\" value=\"$name\" /> </td>";
148 echo ' <td><label for="Remail">Email:</label></td>';
149 echo " <td><input type=\"text\" id=\"Remail\" name=\"Remail\" size=\"20\" maxlength=\"30\" value=\"$email\" /></td>";
153 echo ' <td><label for="Rpassword">Password(will be displayed in cleartext on the next page):</label></td>';
154 echo ' <td><input type="password" id="Rpassword" name="Rpassword" size="20" maxlength="30" /></td>';
159 echo ' <td><label for="Ropenid">OpenId:</label></td>';
160 echo ' <td><input type="text" id="Ropenid" name="Ropenid" size="20" maxlength="50" value="'.htmlentities($openid_url).'" /></td>';
163 echo ' <td><label for="Rtimezone">Timezone:</label></td>';
166 output_select_timezone("Rtimezone");
172 /* random number to select robotproof question */
173 $rand_number = mt_rand(0,3); /* to get numbers between 0 and 4 */
174 $Robotproof = "Robotproof".$rand_number;
176 <td><label for="Robotproof">Please answer this question: <?php echo output_robotproof($rand_number); ?></label></td>
178 echo "<td><input type=\"text\" id=\"$Robotproof\" name=\"$Robotproof\" size=\"20\" maxlength=\"30\" /></td>\n";
181 <td colspan="2"> <input type="submit" value="register" /></td>