Advertisement
Guest User

Untitled

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