Advertisement
Lonster_Monster

connection.php

Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "cFeu11qJgQ8lNxhO";
  5. $dbname = "users";
  6. $Subscribed = "false";
  7. $steamids = "";
  8. $Botid = "";
  9. $BotName = "";
  10. $BotsID = "";
  11. $BotLink = "";
  12. $BotAvatar = "";
  13. $BotMedAvatar = "";
  14. $BotFullAvatar = "";
  15. $BotOnlineStatus = "";
  16. $Botstatus = "Offline";
  17. $UserID = false;
  18. $AdminID = false;
  19. $Sell_Price = "";
  20. $Keys_Price = "";
  21. $Refs_Price = "";
  22. $f_Bot_Id = "";
  23. $s_Bot_Id = "";
  24. $item_Id = "";
  25. $item_Name = "";
  26. $itemPicture = "";
  27. $market_Value = "";
  28. $bptf_Value = "";
  29. $content = "";
  30. $id = "";
  31. // Create connection
  32. $conn = new mysqli($servername, $username, $password, $dbname);
  33. // Check connection
  34. if ($conn->connect_error) {
  35. die("Connection failed: " . $conn->connect_error);
  36. }
  37.  
  38. if (isset($_POST['sub']))
  39. {
  40. $name = $_POST["name"];
  41. $email = $_POST["mail"];
  42. $sql_table = "newsletter";
  43. $sql = "SELECT * FROM $sql_table WHERE Email = '$email' AND Name = '$name';";
  44. $results = $conn->query($sql);
  45. if ($results) {
  46. $sql = "INSERT INTO $sql_table (Name, Email) VALUES ('$name', '$email');";
  47. $results = $conn->query($sql);
  48. if ($results)
  49. {
  50. $_CONFIG['Subscribe'] = true;
  51. } else {
  52. echo "Error: " . $sql . "<br>" . $conn->error;
  53. }
  54. } else {
  55. echo "Error: " . $sql . "<br>" . $conn->error;
  56. }
  57. }
  58. if(isset($_SESSION['steamid'])){
  59. include ('steamauth/userInfo.php');
  60. $steamid = $steamprofile['steamid'];
  61. $SteamName = $steamprofile['personaname'];
  62. $avatarfull = $steamprofile['avatarfull'];
  63. $avatarmedium = $steamprofile['avatarmedium'];
  64. $avatar = $steamprofile['avatar'];
  65. $search = "none";
  66. $isAdmin = false;
  67. $sql_table = "users";
  68. if($UserID == true){
  69. $sql = "SELECT * FROM $sql_table WHERE steamId = $steamid;";
  70. $results = $conn->query($sql);
  71. if ($results->num_rows > 0) {
  72. // output data of each row
  73. while($row = $results->fetch_assoc())
  74. {
  75.  
  76.  
  77. if ($row["isAdmin"] == "true")
  78. {
  79. $isAdmin = true;
  80. if ($isAdmin == true)
  81. {
  82. $admin =$row["isAdmin"];
  83. $sql = "SELECT * FROM $sql_Admin_table WHERE steamId = $steamid;";
  84. $result = $conn->query($sql);
  85. if ($result->num_rows == 0)
  86. {
  87. $sql = "INSERT INTO $sql_Admin_table (SteamId, SteamName, isAdmin) VALUES ('$steamid', '$SteamName', '$admin');";
  88. if ($conn->query($sql) == TRUE)
  89. {
  90. echo "New record created successfully";
  91. } else {
  92. echo "Error: " . $sql . "<br>" . $conn->error;
  93. }
  94. }
  95. else
  96. {
  97.  
  98. }
  99. }
  100. }
  101. }
  102. }
  103. else
  104. {
  105. $sql = mysqli_query($conn,"INSERT INTO $sql_table (steamId, steam_Name, avatar, avatarmedium, avatarfull) VALUES ('$steamid', '$SteamName', '$avatar', '$avatarmedium', '$avatarfull');");
  106. if ($conn->query($sql) == TRUE)
  107. {
  108.  
  109. echo "New record created successfully";
  110.  
  111.  
  112.  
  113.  
  114. } else {
  115. echo "Error: " . $sql . "<br>" . $conn->error;
  116. }
  117. }
  118. mysqli_close($conn);
  119. }
  120. if($AdminID == "true"){
  121. $sql = "SELECT * FROM $sql_table";
  122. $results = $conn->query($sql);
  123. if ($results->num_rows > 0) {
  124. // output data of each row
  125. while($row = $results->fetch_assoc())
  126. {
  127.  
  128.  
  129. if ($row["isAdmin"] == "true")
  130. {
  131. $isAdmin = true;
  132. if ($isAdmin == true)
  133. {
  134. $sql = "SELECT * FROM $sql_Admin_table WHERE steamId = $A;";
  135. $result = $conn->query($sql);
  136. if ($result->num_rows == 0)
  137. {
  138. $admin =$row["isAdmin"];
  139. $_USER['avatarfull'] =$row['avatarfull'];
  140. }
  141. else
  142. {
  143.  
  144. }
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. if (isset($_POST['submit'])) {
  152. $Sell_Price = $_POST['sell'];
  153. $Keys_Price = $_POST['keys'];
  154. $Refs_Price = $_POST['refs'];
  155. $sql_table = "users";
  156. $sql = "SELECT * FROM $sql_table WHERE steamId=?";
  157.  
  158. /* Prepare statement */
  159. $stmt = $conn->prepare($sql);
  160. if($stmt === false) {
  161. trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->errno . ' ' . $conn->error, E_USER_ERROR);
  162. }
  163.  
  164. $id = $_SESSION['steamid'];
  165.  
  166. /* Bind parameters. Types: s = string, i = integer, d = double, b = blob */
  167. $stmt->bind_param("s", $id);
  168.  
  169. /* Execute statement */
  170. if ($stmt->execute()){
  171.  
  172. /* Fetch result to array */
  173. $res = $stmt->get_result();
  174. while($row = $res->fetch_array(MYSQLI_ASSOC)) {
  175. $f_Bot_Id = $row['Bot_Id'];
  176. }
  177.  
  178. }
  179. $sql_table = "bot_items_db";
  180. $sql = "SELECT * FROM $sql_table WHERE Bot_Id=?";
  181.  
  182. /* Prepare statement */
  183. $stmt = $conn->prepare($sql);
  184. if($stmt === false) {
  185. trigger_error('Wrong SQL: ' . $sql . ' Error: ' . $conn->errno . ' ' . $conn->error, E_USER_ERROR);
  186. }
  187.  
  188. $id = $f_Bot_Id;
  189.  
  190. /* Bind parameters. Types: s = string, i = integer, d = double, b = blob */
  191. $stmt->bind_param("s", $id);
  192.  
  193. /* Execute statement */
  194. if ($stmt->execute()){
  195.  
  196. /* Fetch result to array */
  197. $res = $stmt->get_result();
  198. while($row = $res->fetch_array(MYSQLI_ASSOC)) {
  199. $s_Bot_Id = $row['Bot_Id'];
  200. $item_Id = $row['item_Id'];
  201. $item_Name = $row['item_Name'];
  202. $Sell_Price = $row['Sell_Price'];
  203. $Keys_Price = $row['Keys_Price'];
  204. $Refs_Price = $row['Refined_Price'];
  205. }
  206.  
  207. }
  208. if($s_Bot_Id == $f_Bot_Id ){
  209. if(isset($_POST['sell'])){
  210. $content = $_POST['sell'];
  211. $sql_table = "bot_items_db";
  212. $sql = "UPDATE $sql_table SET Sell_Price=? WHERE Bot_Id=?";
  213. $id = $s_Bot_Id;
  214. $stmt = $conn->prepare($sql);
  215. $stmt->bind_param('ss', $content, $id);
  216. if ($stmt->execute()){
  217. return $stmt->affected_rows;
  218. $stmt->close();
  219. }else {
  220. echo "save not working";
  221. }
  222. }
  223. if(isset($_POST['keys'])){
  224. $content = $_POST['keys'];
  225. $sql_table = "bot_items_db";
  226. $sql = "UPDATE $sql_table SET `Keys_Price` = ? WHERE Bot_Id = ?;";
  227. $id = $s_Bot_Id;
  228. $stmt = $conn->prepare($sql);
  229. $stmt->bind_param('ss', $content, $id);
  230. if ($stmt->execute()){
  231. return $stmt->affected_rows;
  232. $stmt->close();
  233. }else {
  234. echo "save not working";
  235. }
  236. }
  237. if(isset($_POST['refs'])){
  238. $content = $_POST['refs'];
  239. $sql_table = "bot_items_db";
  240. $sql = "UPDATE $sql_table SET Refined_Price=? WHERE Bot_Id=?";
  241. $id = $s_Bot_Id;
  242. $stmt = $conn->prepare($sql);
  243. $stmt->bind_param('ss', $content, $id);
  244. if ($stmt->execute()){
  245. return $stmt->affected_rows;
  246. $stmt->close();
  247. }else {
  248. echo "save not working";
  249. }
  250. }
  251. }
  252. }
  253. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement