Advertisement
Guest User

Untitled

a guest
Jun 28th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. <?php
  2. if($_SERVER['REQUEST_METHOD'] === "POST") {
  3. $viewer = (int)$_POST['v'];
  4. $chatviewer = (int)$_POST['c'];
  5. $channelname = htmlspecialchars($_POST['cn']);
  6. $time = (int)$_POST['t'];
  7. $key = htmlspecialchars($_POST['k']);
  8. $error = false;
  9. $error_message = "User input is invalid";
  10.  
  11. function showError($_string)
  12. {
  13. $error = true;
  14. echo '<div class="info">
  15. <h2>Error</h2>
  16. <p>' . $_string . '</p>
  17. </div>';
  18. };
  19.  
  20. function showInfo($_string)
  21. {
  22. $error = true;
  23. echo '<div class="infosuccess">
  24. <h2>Success!</h2>
  25. <p>' . $_string . '</p>
  26. </div>';
  27. };
  28.  
  29. function getHttpCode($http_response_header)
  30. {
  31. if(is_array($http_response_header))
  32. {
  33. $parts=explode(' ',$http_response_header[0]);
  34. if(count($parts)>1) //HTTP/1.0 <code> <text>
  35. return intval($parts[1]); //Get code
  36. }
  37. return 0;
  38. }
  39.  
  40. ///
  41. if(strpos($_POST['cn'], " ") === true) {
  42. showError("The channelname can not contain white spaces.");
  43. } else {
  44.  
  45. if (strlen($key) > 27 && strlen($key) < 30 && $error === false && strlen($channelname) > 3 && strlen($channelname) < 32) {
  46. if ((($viewer === 0 || $chatviewer === 0 || $time === 0) && $error === false) ) {
  47. showError("Invalid user input");
  48. } else {
  49. ////
  50. // mysql
  51. ///
  52. $servername = "localhost";
  53. $username = "streamhu_streamh";
  54. $password = "N2vpf6Uf";
  55.  
  56. // Create connection
  57. $conn = mysqli_connect($servername, $username, $password, "streamhu_liveviewers");
  58. // Check connection
  59. if (!$conn) {
  60. die("Connection failed: " . mysqli_connect_error());
  61. }
  62.  
  63. $sql = "SELECT * FROM liveviewers WHERE serial LIKE '%".$key."%'";
  64. $result = $conn->query($sql);
  65. if ($result->num_rows > 0) {
  66. while($row = $result->fetch_assoc()) {
  67. if(($row['product'] == 0) && ($viewer > 100 || $chatviewer > 100)) {
  68. showError("You can only select up to 100 viewers with this package.");
  69. } else {
  70. if(true) {
  71. if($row['subscription'] == 0) {
  72. if($row['used'] == 0) {
  73. // einmalig
  74. $sqll = "UPDATE liveviewers SET used=1, channelname='".$channelname."' WHERE serial LIKE '%" . $key . "%'";
  75. if ($conn->query($sqll) === TRUE) {
  76. showInfo("Your views have been sent! If you encounter any problems, contact us via livechat or in our Discord.");
  77. file_get_contents("http://xxxx/liveViewers/".$channelname."/".$key."/".$viewer."/".$chatviewer."/".$time);
  78. $code = getHttpCode($http_response_header);
  79. } else {
  80. showError("An error occured, contact support. Error: 2");
  81. }
  82. } else {
  83. showError("This serial has already been used! Contact support if you think this is wrong.");
  84. }
  85. } else {
  86. if(true) {
  87. $sql = "UPDATE liveviewers SET used=1, channelname='".$channelname."' WHERE serial LIKE '%".$key."%'";
  88. if ($conn->query($sql) === TRUE) {
  89. showInfo("Your views have been sent! If you encounter any problems, contact us via livechat or in our Discord.");
  90. file_get_contents("http://xxxx/liveViewers/".$channelname."/".$key."/".$viewer."/".$chatviewer."/".$time);
  91. $code = getHttpCode($http_response_header);
  92.  
  93. if($row['subscription'] == 1) {
  94. $sql2 = "UPDATE liveviewers SET subscription=".time()." WHERE serial LIKE '%".$key."%'";
  95. $conn->query($sql2);
  96. }
  97.  
  98. } else {
  99. showError("An error occured, contact support. Error: 2");
  100. }
  101. } else {
  102.  
  103. /// wöchentlich
  104. showError("An error occured, contact support. Error: 3 " . $use_date);
  105. }
  106. }
  107. } else {
  108. showError("An error occured. Contact support.");
  109. }
  110. }
  111. }
  112. } else {
  113. showError("Invalid purchase key. Contact support if you think this might be wrong.");
  114. }
  115.  
  116. mysqli_close($conn);
  117. }
  118. } else {
  119. showError("Invalid purchase key. Contact support if you think this might be wrong.");
  120. }
  121.  
  122. }
  123. ///
  124. }
  125. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement