PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/functions/validate.php

https://bitbucket.org/verax/to-ladder
PHP | 203 lines | 190 code | 10 blank | 3 comment | 9 complexity | 4ea246945260af37c858a1ea2de8eb65 MD5 | raw file
  1. <?
  2. function lost_password(){
  3. global $url, $dir, $out;
  4. $ip=$ip=getenv("REMOTE_ADDR");
  5. $tablehead=table_head("show","70%","","center");
  6. $tablefoot=table_foot("show");
  7. $bannerhead=table_head("show","488","80","center");
  8. $bannerfoot=table_foot("show");
  9. $out[body]=$out[body]."
  10. <center>
  11. $bannerhead
  12. $out[banner]
  13. $bannerfoot
  14. </center>
  15. <center>
  16. <br>
  17. $tablehead
  18. <center><strong><font class='catfont'>Recupera tu contrase&nacute;a</font></strong>
  19. <br><br>
  20. <form>
  21. Enter Player ID: <input type='text' name='playerid' value='' maxlength='5'><br><br><br>
  22. <inpit type='hidden' name='ip' value='$ip'>
  23. <input type='hidden' name='action' value='lostpassb'>
  24. <button type='submit' name='' value='Send Password' class='btn btn-mini btn-success'>Recuperar </button>
  25. $tablefoot";
  26. include("$dir[curtheme]");
  27. }
  28. function lost_passwordb($playerid,$ip){
  29. global $url, $dir, $out, $misc;
  30. if(!$playerid){
  31. include("$dir[func]/error.php");
  32. display_error("Player ID es inv&aacute;lido.<br>");
  33. }
  34. //Slightly long-winded method for checking if this ip address made a request already today.
  35. $day=date("z");
  36. $year=date("Y");
  37. $check = mysql_fetch_array(mysql_query("SELECT ipaddress,DATE_FORMAT(requestdate, '%j'),DATE_FORMAT(requestdate, '%Y') FROM passrequests WHERE ipaddress='$ip'"));
  38. if((($check[1]-1) == $day)&&($check[2] == $year)){
  39. include("$dir[func]/error.php");
  40. display_error("You cannot make a lost password request more than once a day.<br>");
  41. }
  42. else if($misc[passrequests] == 'no'){
  43. include("$dir[func]/error.php");
  44. display_error("This feature is currently disabled.<br> Please contact a staff member for further help.<br>");
  45. }else{
  46. $tday=date("Y-m-d H:i:s");
  47. mysql_query("INSERT INTO passrequests VALUES (
  48. '',
  49. '$tday',
  50. '$ip',
  51. '$playerid');");
  52. $resa=mysql_query("SELECT alias,pass,email FROM users WHERE id='$playerid'");
  53. $resb=mysql_fetch_array($resa);
  54. $tablehead=table_head("show","60%","","center");
  55. $tablefoot=table_foot("show");
  56. $bannerhead=table_head("show","488","80","center");
  57. $bannerfoot=table_foot("show");
  58. $out[body]=$out[body]."
  59. <center>
  60. $bannerhead
  61. $out[banner]
  62. $bannerfoot
  63. <br>
  64. $tablehead
  65. <center><strong><font class='catfont'>Password Sent </font></strong>
  66. <br><br>
  67. The password has been sent to $resb[email].<br> Any further enquiries should be submitted to a staff member.
  68. $tablefoot";
  69. include("$dir[curtheme]");
  70. //Email Invited Player
  71. $emailbody="$resb[alias],
  72. You recently requested your password be emailed to you!
  73. Your Password is: $resb[pass]
  74. If you did not make this request, simply ignore this email.
  75. ";
  76. include("$dir[func]/email.php");
  77. send_email($resb[alias], $resb[email], "Requested Password", $emailbody);
  78. }
  79. }
  80. function validate_player($vc){
  81. global $url, $dir, $out;
  82. $tablehead=table_head("show","300","","left");
  83. $tablefoot=table_foot("show");
  84. $bannerhead=table_head("show","488","80","center");
  85. $bannerfoot=table_foot("show");
  86. $out[body]=$out[body]."
  87. <center>
  88. $bannerhead
  89. $out[banner]
  90. $bannerfoot
  91. <br>
  92. $tablehead
  93. &nbsp; &nbsp;<strong><font class='catfont'>Valida tu cuenta</font></strong><br>
  94. <hr class='catfont' size='1'>
  95. <table width='300' border='0' bordercolor='#000000' cellspacing='0' cellpadding='2'>
  96. <form method='post'>
  97. <tr>
  98. <td width='100%' height='100%' valign='top' align='center'>
  99. Codigo de validacion<br>
  100. <input type='text' name='code' value='$vc' maxlength='50' size='30'>
  101. <br><br>
  102. <input type='hidden' name='action' value='validateb'>
  103. <button type='submit' class='btn btn-mini btn-info' name='' value='Validate Me'>Validame</button>
  104. </td>
  105. </tr>
  106. </form>
  107. </table>
  108. $tablefoot
  109. </center>";
  110. include("$dir[curtheme]");
  111. }
  112. function validate_playerb($code){
  113. global $url, $dir, $out, $uinfo, $site;
  114. include("$dir[func]/checkdata.php");
  115. //$code=change_numbersonly($code);
  116. $errormessage=check_validlength($errormessage, $code, "1", "50", "Your Validation Code is Invalid");
  117. error_check($errormessage);
  118. $validatecode=mysql_query("SELECT * FROM validate WHERE vcode='$code'");
  119. $vc=mysql_fetch_array($validatecode);
  120. if(!$vc[alias]){
  121. include("$dir[func]/error.php");
  122. display_error("Unable to find that validation code.<br>");
  123. }
  124. $tday=date("Y-m-d H:i:s");
  125. mysql_query("INSERT INTO users VALUES (NULL,
  126. '$vc[alias]',
  127. '$vc[pass]',
  128. '$vc[email]',
  129. '$vc[icq]',
  130. '$vc[aim]',
  131. '$vc[yahoo]',
  132. '$vc[msn]',
  133. '$vc[website]',
  134. '$vc[logo]',
  135. '$vc[newsletter]',
  136. '$tday',
  137. '$vc[ipaddress]',
  138. '0',
  139. '0',
  140. '0',
  141. '0',
  142. '0',
  143. '0',
  144. '$vc[theme]',
  145. '$vc[country]');");
  146. $getid=mysql_query("SELECT id FROM users WHERE alias='$vc[alias]'");
  147. $newidnfo=mysql_fetch_array($getid);
  148. $playerid=$newidnfo["id"];
  149. mysql_query("INSERT INTO usersinfo VALUES (
  150. '$playerid',
  151. '$vc[firstname]',
  152. '$vc[middlename]',
  153. '$vc[lastname]',
  154. '$vc[address]',
  155. '$vc[city]',
  156. '$vc[state]',
  157. '$vc[zipcode]',
  158. '$vc[phone]',
  159. '$vc[birthday]',
  160. '$vc[occupation]',
  161. '$uinfo[force]');");
  162. clean_validations($code);
  163. $tablehead=table_head("show","100%","","left");
  164. $tablefoot=table_foot("show");
  165. $bannerhead=table_head("show","488","80","center");
  166. $bannerfoot=table_foot("show");
  167. $out[body]=$out[body]."
  168. <center>
  169. $bannerhead
  170. $out[banner]
  171. $bannerfoot
  172. <br>
  173. $tablehead
  174. &nbsp; &nbsp;<strong><font class='catfont'>Welcome $vc[alias]</font></strong>
  175. <hr class='catfont' size='1'>
  176. To get started on $site[shortname] you need to login using your <b>Player ID</b>.<br>
  177. <br>
  178. <strong>Your Player ID is <font color='#FF0000'>$playerid</font></strong><br>
  179. <br>
  180. <br>
  181. <center>
  182. <strong>Have Fun,<br>
  183. $site[longname]<br>
  184. $site[shortname] $site[homeurl]</strong>
  185. </center>
  186. $tablefoot";
  187. include("$dir[curtheme]");
  188. }
  189. function clean_validations($code){
  190. $deletedate=date("Y-m-d H:i:s",time()-60*60*24*1);
  191. mysql_query("DELETE FROM validate WHERE vcode='$code' OR joindate < '$deletedate'");
  192. }
  193. ?>