Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("config.php");
- if(!file_exists($installationFile))
- {
- redirect("install", 0);
- }
- echo "<center>";
- echo
- "<form action='index' method='POST'>
- <input type='hidden' name='register' value='1'>
- <input type='submit' value='' class='register'>
- </form>
- <form action='index' method='POST'>
- <input type='hidden' name='login' value='1'>
- <input type='submit' value='' class='login'>
- </form>";
- echo "<br><br><br><br>";
- if($_POST['register'])
- {
- echo
- "<form action='index' method='POST'>
- <input type='text' name='username' placeholder='* Username' maxlength='60' size='30'/><br>
- <input type='password' name='password' placeholder='* Password' size='30'/><br>
- <input type='email' name='email' placeholder='* Email' maxlength='60' size='30'/><br>
- <input type='text' name='nickname' placeholder='* Nickname' maxlength='60' size='30'/><br><br>
- <font class='outline' face='arial' color='red'><b>Fields marked with a * are required.</b></font><br><br>
- <input type='hidden' name='doregister' value='1'>
- <input type='submit' value='' class='continue'>
- </form>";
- }
- else if($_POST['login'])
- {
- echo
- "<form action='index' method='POST'>
- <input type='text' name='username' placeholder='Username' maxlength='60' size='30'/><br>
- <input type='password' name='password' placeholder='Password' size='30'/><br><br>
- <input type='hidden' name='dologin' value='1'>
- <input type='submit' value='' class='continue'>
- </form>";
- }
- else if($_POST['doregister'])
- {
- $username = $_POST['username'];
- $password = hash('whirlpool', $_POST['password']);
- $email = $_POST['email'];
- $nickname = $_POST['nickname'];
- if($username && $password && email)
- {
- $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `username` = '$username'");
- if(!mysql_num_rows($query))
- {
- if(strpos($email, "@") !== false && strpos($email, ".") !== false)
- {
- $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `email` = '$email'");
- if(!mysql_num_rows($query))
- {
- $validateNumber1 = rand(1000000000, 2147483646);
- $validateNumber2 = rand(1000000000, 2147483646);
- $validateNumber3 = rand(1000000000, 2147483646);
- $validateNumber4 = rand(1000000000, 2147483646);
- $validateNumber5 = rand(1000000000, 2147483646);
- $validateKey = "$validateNumber1$validateNumber2$validateNumber3$validateNumber4$validateNumber5";
- $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `validatekey` = '$validateKey'");
- while(mysql_num_rows())
- {
- $validateNumber1 = rand(1000000000, 2147483646);
- $validateNumber2 = rand(1000000000, 2147483646);
- $validateNumber3 = rand(1000000000, 2147483646);
- $validateNumber4 = rand(1000000000, 2147483646);
- $validateNumber5 = rand(1000000000, 2147483646);
- $validateKey = "$validateNumber1$validateNumber2$validateNumber3$validateNumber4$validateNumber5";
- $query = mysql_query("SELECT `id` FROM `shop_accounts` WHERE `validatekey` = '$validateKey'");
- }
- mysql_query("INSERT INTO `shop_accounts` (`username`, `password`, `email`, `validatekey`, `requirevalidate`, `nickname`) VALUES ('$username', '$password', '$email', '$validateKey', '1', '$nickname')");
- $_SESSION['accountid'] = mysql_insert_id();
- redirect("register", 0);
- }
- else echo "<font class='outline' face='arial' color='red'><b>That email address is already in use!</b></font>";
- }
- else echo "<font class='outline' face='arial' color='red'><b>You have entered an invalid email address!</b></font>";
- }
- else echo "<font class='outline' face='arial' color='red'><b>That account already exists!</b></font>";
- }
- else echo "<font class='outline' face='arial' color='red'><b>You must fill all of the fields!</b></font>";
- }
- else if($_POST['dologin'])
- {
- $username = $_POST['username'];
- $password = hash('whirlpool', $_POST['password']);
- $query = mysql_query("SELECT `id`, `password` FROM `shop_accounts` WHERE `username` = '$username'");
- if(mysql_num_rows($query))
- {
- $row = mysql_fetch_assoc($query);
- $accountID = $row['id'];
- $accountPassword = $row['password'];
- if($password == $accountPassword)
- {
- $_SESSION['accountid'] = $accountID;
- $_SESSION['loggedin'] = true;
- redirect("main", 0);
- }
- else echo "<font class='outline' face='arial' color='red'><b>The password you have entered is incorrect!</b></font>";
- }
- else echo "<font class='outline' face='arial' color='red'><b>That account does not exist!</b></font>";
- }
- echo "</center>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement