Guest User

Untitled

a guest
Oct 13th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. <?PHP
  2.  
  3.  
  4.  
  5.  
  6. function genRandomString() {
  7. $length = 5;
  8. $characters = "0123456789abcdefghijklmnopqrstuvwxyz";
  9. $string = "";
  10. $p = 0;
  11. for ($p = 0; $p < $length; $p++) {
  12. $string .= $characters[mt_rand(0, strlen($characters))];
  13. }
  14. return $string;
  15. }
  16. $string = genRandomString()."-".genRandomString()."-".genRandomString()."-".genRandomString()."-".genRandomString();
  17. $string = strtoupper($string);
  18.  
  19. require_once("include/config.php");
  20. require('libs/Smarty.class.php');
  21. $smarty = new Smarty;
  22. $smarty->template_dir = 'templates';
  23. $smarty->compile_dir = 'temp';
  24. $time = Time();
  25. if(isset($_POST['username']) and ($_POST['password']) and ($_POST['key'])){
  26. $username = $_POST['username'];
  27. $password = md5($_POST['password']);
  28.  
  29. $key = $_POST['key'];
  30. $query = mysql_query("SELECT * FROM `keys` WHERE `key`='{$key}'");
  31. if (mysql_num_rows($query) == 1) {
  32. while($row = mysql_fetch_array($query)){
  33. $key1 = $row[0];
  34. $months = $row[1];
  35. $max = $row[2];
  36. $type = $row[3];
  37. $reseller = $row[4];
  38. $trial1 = $row[5];
  39. $attacks = $row[6];
  40. }
  41. if($months=="lifetime"){
  42. $months = "lifetime";
  43. }elseif($months=="trial"){
  44. $months = $time + 86400 * $months;
  45. }else{
  46. $months = $time + 86400 * $months;
  47. }
  48.  
  49.  
  50. $key = mysql_real_escape_string($key);
  51. $query = mysql_query("INSERT INTO `users` (`login`, `passwd`, `max`, `trial`, `attacks`, `reseller`, `expiry`, `type`, `key`) VALUES ('".$username."', '".$password."', '".$max."', '".$trial1."', '$attacks', '".$reseller."', '".$months."', '".$type."', '{$key}');");
  52. $query = mysql_query("delete from `keys` where `key`='{$key}'");
  53.  
  54.  
  55.  
  56. echo mysql_error();
  57. $smarty->assign("done", "Your account has been added, you can now Login!");
  58. }else{
  59. die("Your key isn't valid, please contact support.");
  60. }
  61. }else{
  62. $smarty->assign("done", "");
  63. }
  64.  
  65. $smarty->display("class.register.tpl");
  66. ?>
Add Comment
Please, Sign In to add comment