Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*the function that converts the Steam Id */
- function convert_id($id,$s){
- return (string)bcadd((string)(intval($id)*2+intval($s)),"76561197960265728");
- }
- /* © Rarufu */
- /*Database connection login*/
- $servername = "server.sc3network.com";
- $username = "donationwidget";
- $password = "YH6arXNezMzcq3Jw";
- $dbname = "donations";
- /*Connection to database
- This allows the script to connect to the database */
- $conn = new mysqli($servername, $username, $password, $dbname);
- /* Checks if the connection is working, if not closes it down */
- if ($conn->connect_error) {
- die("Connection failed" . $conn->connect_error);
- }
- /*Gets last 5 donations for the database */
- $sql = "SELECT * FROM gmd_donations ORDER BY ID DESC LIMIT 5";
- $result = $conn->query($sql);
- /*Check if data was actually pulled from database */
- if (!$result) {
- echo "Failed to get data from database";
- }
- /* Creating HTML table */
- echo "<table><tr><th>Date</ht><th>Profile Link</th><th>Amount</th></tr>";
- /* Putting data in table */
- while($row = $result->fetch_assoc())
- {
- /* Getting Date */
- $d=strtotime("now");
- $date = $row['Date'];
- if($d - $date < 7)
- {
- $dateEcho = date('D',$date);
- }
- else{
- $dateEcho = date('m-d',$date);
- }
- /* Getting SteamID */
- $array=preg_split('#:#',$row['SteamID']);
- $id = convert_id($array[2],$array[1]);
- $link = file_get_contents("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=26048C791458D716AB82172267F6BD13&steamids='$id'%20&format=json");
- $myarray = json_decode($link, true);
- $steamName = $myarray['response']['players'][0]['personaname'];
- $steamLink = $myarray['response']['players'][0]['profileurl'];
- /*Put it all in the table */
- echo "<tr><td>".$dateEcho."</td><td><a href="$steamLink">".$steamName.""/a>"</td><td>""£"".$row["Amount"]."</td></tr>";
- }
- echo "</table>";
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement