the ajax chat registration script

| about 1 month ago |
34
|
| View Raw
  1. 1
    <?php
  2. 2
    error_reporting(0);
  3. 3
     
  4. 4
    if (isset($_GET['ajax'])) {
  5. 5
    switch (strtolower($_GET['ajax'])) {
  6. 6
    case 'createaccount':
  7. 7
    if (!strlen(trim($_POST['username']) && ($_POST['password']))) {
  8. 8
    header('Location: ?errormessage=Username%20or%20Password%20were%20not%20entered.');
  9. 9
    } else {
  10. 10
    include('./lib/data/users.php');
  11. 11
    $encryptedpass = md5($_POST['password']);
  12. 12
    if ($_POST['username']) {}
  13. 13
    $user_amount = count($users);
  14. 14
    for ($i=0; $i <=$user_amount;$i++);
  15. 15
    {
  16. 16
    if (strtolower($_POST['username']) == strtolower($users[$i]['userName']))
  17. 17
    $username_used = 1;
  18. 18
    }
  19. 19
    if (!$_POST['password'])
  20. 20
    $password_error = 1;
  21. 21
    if (!$username_used and !$password_error) {
  22. 22
    $next_user = $user_amount++;
  23. 23
    $new_user_information = '
  24. 24
     
  25. 25
    // Created via IP '.$_SERVER["REMOTE_ADDR"].'
  26. 26
    $users['.$next_user.'] = array();
  27. 27
    $users['.$next_user.'][\'userRole\'] = AJAX_CHAT_USER;
  28. 28
    $users['.$next_user.'][\'userName\'] = \''.$_POST['username'].'\';
  29. 29
    $users['.$next_user.'][\'password\'] = \''.$encryptedpass.'\';
  30. 30
    $users['.$next_user.'][\'channels\'] = array(0,1);
  31. 31
    // Email Address: '.$_POST['email'].'
  32. 32
    ?>';
  33. 33
    $file_edit = fopen('./lib/data/users.php', 'r+');
  34. 34
    fseek($file_edit, -3,SEEK_END);
  35. 35
    fwrite($file_edit, $new_user_information);
  36. 36
    fclose($file_edit);
  37. 37
    }
  38. 38
    header('Location: index.php');
  39. 39
    }
  40. 40
    break;
  41. 41
    }
  42. 42
    }
  43. 43
    ?>
  44. 44
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  45. 45
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="[LANG_CODE/]" lang="[LANG_CODE/]" dir="[BASE_DIRECTION/]">
  46. 46
    <head>
  47. 47
    <title>Flashii Chat :: Registration</title>
  48. 48
    <style type="text/css">
  49. 49
    body {
  50. 50
    padding:0;
  51. 51
    margin:0;
  52. 52
    }
  53. 53
    </style>
  54. 54
    <link rel="stylesheet" type="text/css" href="css/legacy.css">
  55. 55
    <!--[if lt IE 7]>
  56. 56
    <link rel="stylesheet" type="text/css" href="css/ie5-6.css"/>
  57. 57
    <![endif]-->
  58. 58
    </head>
  59. 59
    <body>
  60. 60
    <div id="loginContent">
  61. 61
    <div id="loginHeadlineContainer">
  62. 62
    <h1>Flashii Chat :: Registration</h1>
  63. 63
    <h4>Reregistering <u>might</u> be required in a few days</h4>
  64. 64
    </div>
  65. 65
    <form id="loginForm" action="?ajax=createaccount" method="post" enctype="application/x-www-form-urlencoded">
  66. 66
    <div id="loginFormContainer">
  67. 67
    <div><label for="userNameField">Username:</label><br />
  68. 68
    <input type="text" name="username" id="userNameField" maxlength="20"/></div>
  69. 69
    <div><label for="passwordField">Password:</label><br />
  70. 70
    <input type="password" name="password" id="passwordField"/></div>
  71. 71
    <div><label for="passwordField">E-Mail Address:</label><br />
  72. 72
    <input type="text" name="email" id="userNameField"/></div>
  73. 73
    <div><input type="submit" name="submit" id="loginButton" value="Create account"/></div>
  74. 74
    </div>
  75. 75
    </form>
  76. 76
    <div id="errorContainer">
  77. 77
    <?php
  78. 78
    if (isset($_GET['errormessage'])) {
  79. 79
    echo $_GET['errormessage'];
  80. 80
    } else {
  81. 81
    echo "";
  82. 82
    }
  83. 83
    ?>
  84. 84
    </div>
  85. 85
    <div id="copyright"><a href="./">Login</a> - <b><a href="register.php">Register</a></b> - <a href="rules.php">Rules</a></div><div id="copyright"><a href="https://blueimp.net/ajax/">AJAX Chat</a> &copy; <a href="https://blueimp.net">blueimp.net</a></div>
  86. 86
    </div>
  87. 87
    </body>
  88. 88
     
  89. 89
    </html>