Advertisement
Guest User

Untitled

a guest
Apr 12th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "mysql.hostinger.co.uk";
  4. $username = "u514786551_liam";
  5. $password = "Jinx09";
  6. $dbname = "u514786551_newdb";
  7.  
  8. function GetTimeDifference($time, $time2, $date, $date2)
  9. {
  10. $Start = '' . $date . ' ' . $time . '.000';
  11. $End = '' . $date2 . ' ' . $time2 . '.000';
  12. $StartDate = new DateTime($Start);
  13. $EndDate = new DateTime($End);
  14. $Differnce = $StartDate->diff($EndDate);
  15. $minutes = $Differnce->days * 24 * 60;
  16. $minutes += $Differnce->h * 60;
  17. $minutes += $Differnce->i;
  18. return $minutes;
  19. }
  20.  
  21. $mysqli = new mysqli($servername, $username, $password, $dbname);
  22.  
  23. if ($mysqli->connect_error)
  24. {
  25. die("Connection failed: " . $mysqli->connect_error);
  26. }
  27. else
  28. {
  29. if (isset($_GET["key"]))
  30. {
  31. $Key = (string)$_GET["key"];
  32. if (preg_match("/([A-Za-z0-9]+)/", $Key))
  33. {
  34. if (preg_match('/<script>/', $Key))
  35. {
  36. echo "Keys are numbers and letters only.";
  37. }
  38. else if (preg_match('/%3Cscript%3E/', $Key))
  39. {
  40. echo "Keys are numbers and letters only.";
  41. }
  42. else
  43. {
  44. if (strlen($Key) < 32)
  45. {
  46. echo "Your key is too short.";
  47. }
  48. else if (strlen($Key) > 32)
  49. {
  50. echo "Your key is too long.";
  51. }
  52. else
  53. {
  54. $result = $mysqli->query("SELECT * FROM `Keys`");
  55. while($row = $result->fetch_assoc())
  56. {
  57. if($Key == $row['Key'])
  58. {
  59. date_default_timezone_set('Europe/London');
  60. if($row['Activated'] == 1)
  61. {
  62. if(GetTimeDifference($row['Timestamp'], date("H:i:s"), $row['DATE'], date("Y-m-d")) > 1440) // 1440 is 24 hours (Meaning the key will reset every 24 hours)
  63. {
  64. $ID = intval($row['ID']);
  65. $IP = $_SERVER['REMOTE_ADDR'];
  66. $mysqli->query("UPDATE `$dbname`.`Keys` SET `Timestamp` = NOW(), `IP` = '$IP', `DATE` = NOW() WHERE `Keys`.`ID` = $ID;");
  67. $mysqli->close();
  68. die("Key is valid.");
  69. }
  70. else
  71. {
  72. $IP = (string)$_SERVER['REMOTE_ADDR'];
  73. if($IP == $row['IP'])
  74. {
  75. $ID = intval($row['ID']);
  76. $IP = $_SERVER['REMOTE_ADDR'];
  77. $mysqli->query("UPDATE `$dbname`.`Keys` SET `Timestamp` = NOW(), `IP` = '$IP', `DATE` = NOW() WHERE `Keys`.`ID` = $ID;");
  78. $mysqli->close();
  79. die("Key is valid.");
  80. }
  81. else
  82. {
  83. die("Key is being used.");
  84. }
  85. }
  86. }
  87. }
  88. }
  89. $mysqli->close();
  90. echo "Key is not valid.";
  91. }
  92. }
  93. }
  94. else
  95. {
  96. echo "Keys are numbers and letters only.";
  97. }
  98. }
  99. else
  100. {
  101. echo "Please enter your license key.";
  102. }
  103. }
  104.  
  105. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement