Guest User

Untitled

a guest
May 4th, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <?php
  2. /*the function that converts the Steam Id*/
  3. function convert_id($id,$s){
  4. return (string)bcadd((string)(intval($id)*2+intval($s)),"76561197960265728");
  5. }
  6. /* © Rarufu */
  7. /*Database connection login*/
  8. $servername = "server.sc3network.com";
  9. $username = "donationwidget";
  10. $password = "YH6arXNezMzcq3Jw";
  11. $dbname = "donations";
  12.  
  13. /*Connection to database
  14. This allows the script to connect to the database */
  15. $conn = new mysqli($servername, $username, $password, $dbname);
  16. /* Checks if the connection is working, if not closes it down */
  17. if ($conn->connect_error) {
  18. die("Connection failed" . $conn->connect_error);
  19. }
  20. /*Gets last 5 donations for the database */
  21. $sql = "SELECT * FROM gmd_donations ORDER BY ID DESC LIMIT 5";
  22. $result = $conn->query($sql);
  23. /*Check if data was actually pulled from database */
  24. if (!$result) {
  25. echo "Failed to get data from database";
  26. }
  27. /* Creating HTML table */
  28. echo "<table><tr><th>Date</ht><th>Profile Link</th><th>Amount</th></tr>";
  29.  
  30. /* Putting data in table */
  31. while($row = $result->fetch_assoc())
  32. {
  33. /* Getting Date */
  34. $d=strtotime("now");
  35. $date = $row['Date'];
  36. if($d - $date < 7)
  37. {
  38. $dateEcho = date('D',$date);
  39. }
  40. else{
  41. $dateEcho = date('m-d',$date);
  42. }
  43. /* Getting SteamID */
  44. $array=preg_split('#:#',$row['SteamID']);
  45. $id = convert_id($array[2],$array[1]);
  46. $link = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=26048C791458D716AB82172267F6BD13&steamids='$id'%20&format=json");
  47. $myarray = json_decode($link, true);
  48. $steamName = $myarray['response']['players'][0]['personaname'];
  49.  
  50. /*Put it all in the table */
  51. echo "<tr><td>".$dateEcho."</td><td>".$steamName."</td><td>£".$row["Amount"]."</td></tr>";
  52. }
  53. echo "</table>";
  54. $conn->close();
  55. ?>
Add Comment
Please, Sign In to add comment