Shubbler

Untitled

May 5th, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 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.  
  19. /*Connection to database
  20. This allows the script to connect to the database */
  21. $conn = new mysqli($servername, $username, $password, $dbname);
  22. /* Checks if the connection is working, if not closes it down */
  23. if ($conn->connect_error) {
  24. die("Connection failed" . $conn->connect_error);
  25. }
  26. /*Gets last 5 donations for the database */
  27. $sql = "SELECT * FROM gmd_donations ORDER BY ID DESC LIMIT 5";
  28. $result = $conn->query($sql);
  29. /*Check if data was actually pulled from database */
  30. if (!$result) {
  31. echo "Failed to get data from database";
  32. }
  33. /* Creating HTML table */
  34. echo "<table><tr><th></th><th align='center'></th><th align='center' width='60px'></th></tr>";
  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. */
  49. /* Getting SteamID */
  50. $array=preg_split('#:#',$row['SteamID']);
  51. $id = convert_id($array[2],$array[1]);
  52. $link = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=key&steamids='$id'%20&format=json");
  53. $myarray = json_decode($link, true);
  54. $steamName = $myarray['response']['players'][0]['personaname'];
  55. $steamLink = $myarray['response']['players'][0]['profileurl'];
  56. $steamPicture = $myarray['response']['players'][0]['avatar'];
  57. /*Put it all in the table */
  58. echo "<tr><td><a href=".$steamLink."><img src='".$steamPicture." width='32px' height = '32px'></a></td> <td align='center'><a href=".$steamLink.">".$steamName."</a></td><td align='left' width='60px'><b>&pound;".$row["Amount"]."</b></td></tr>";
  59. }
  60. echo "</table>";
  61. $conn->close();
  62. }
  63. }
  64. ?>
Add Comment
Please, Sign In to add comment