Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Co tutaj nie działa?
Forum PHP.pl > Forum > Przedszkole
CamerDisco
Hej, mam takie coś:
  1. <div class=\"playerAvatar ".getPlayerState(GetCommunityID($auth))."\"><a href=\"http://steamcommunity.com/profiles/".GetCommunityID($auth)."\"><img src=\"".getAvatar(GetCommunityID($auth))."\" height=\"184\" width=\"184\"/></a>";

Ma to pobierać avatar ze steama i pokazywać, jednak nie działa i nie pokazuje żadnego screena, co jest tutaj źle napisane?
markuz
Pokaż cały plik
CamerDisco
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5.  
  6. <?php
  7. require_once 'includes/config.inc.php';
  8. require_once 'includes/utils.inc.php';
  9. echo "<title>$page_title</title>";
  10. $time = microtime();
  11. $time = explode(' ', $time);
  12. $time = $time[1] + $time[0];
  13. $start = $time;
  14. ?>
  15.  
  16. <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico">
  17. <link href="css/style.css" rel="stylesheet" type="text/css" media="all">
  18. </head>
  19. <body>
  20. <div class="container">
  21. <div class="everything">
  22.  
  23. <?php
  24. if (!isset($_GET['id']) && empty($_GET['id']) || $_GET['id']==''){
  25. echo "<h3>$page_title</h3>";
  26. echo "<div class=\"searchnoinfo\">";
  27. } else{
  28. echo "<div class=\"search\">";
  29. }
  30. ?>
  31.  
  32. <form action="search.php" method="GET">
  33. <h6>Search player stats:</h6><input type="text" name="searchquery">
  34. <input type="submit" value="Submit">
  35. </form>
  36. </div>
  37.  
  38. <?php
  39. if (!isset($_GET['id']) && empty($_GET['id']) || $_GET['id']==''){
  40. echo "<div class=\"topPlayers\"><h1>Top 15 Players</h1>";
  41. include 'includes/generatetopplayers.php';
  42. echo "</div>";
  43. }
  44.  
  45. if (isset($_GET['id']) && !empty($_GET['id'])){
  46.  
  47. $server_limit = 'AND serverID=0';
  48. $server_id = '0';
  49. if (isset($_GET['serverid'])) {
  50. $server_id = (int)$_GET['serverid'];
  51. $server_limit = 'AND serverID='.(int)$_GET['serverid'];
  52. }
  53. // TODO: Fix serverid. Combine user's stats if the serverid is not set.
  54.  
  55. $totalplayers = mysqli_num_rows(mysqli_query($connect, "SELECT * FROM $mysql_table WHERE serverID=$server_id"));
  56. $run_query = "SELECT s1.*, (SELECT COUNT(*) FROM $mysql_table AS s2 WHERE s2.rating > s1.rating $server_limit)+1 AS rank FROM $mysql_table AS s1 WHERE accountID=".(int)$_GET['id']." $server_limit";
  57. $query = mysqli_query($connect, $run_query);
  58.  
  59. if (mysqli_num_rows($query) > 0){
  60. if ($query){
  61. while ($row = mysqli_fetch_assoc($query)){
  62. $accountID = $row['accountID'];
  63. $auth = $row['auth'];
  64. $rank = $row['rank'];
  65. $name = htmlentities($row['name']);
  66. $wins = $row['wins'];
  67. $losses = $row['losses'];
  68. $rating = $row['rating'];
  69. $lastTime = $row['lastTime'];
  70.  
  71. if ($losses == 0) {
  72. $WL = $wins;
  73. } else{
  74. $WL = round($wins/$losses, 2);
  75. }
  76.  
  77. echo "<h3>Stats for player: <a href=\"http://steamcommunity.com/profiles/".GetCommunityID($auth)."\">$name</a></h3>
  78. <div class=\"stats\">
  79. <h4>Rank: $rank of $totalplayers</h4><br>
  80. <h4>Wins: $wins</h4><br>
  81. <h4>Losses: $losses</h4><br>
  82. <h4>W/L Ratio: $WL</h4><br>
  83. <h4>ELO Rating: $rating</h4><br>
  84. <div class=\"playerAvatar ".getPlayerState(GetCommunityID($auth))."\"><a href=\"http://steamcommunity.com/profiles/".GetCommunityID($auth)."\"><img src=\"".getAvatar(GetCommunityID($auth))."\" height=\"184\" width=\"184\"/></a>";
  85. if (isPlayerActive($lastTime) == true){
  86. echo "<div class=\"activity inactive\">INACTIVE</div></div>";
  87. } else{
  88. echo "<div class=\"activity\">ACTIVE</div></div>";
  89. }
  90. }
  91. }
  92. } else{
  93. die("<h1>User not found.</h1>");
  94. }
  95. }
  96. ?>
  97.  
  98. </div>
  99.  
  100. <?php
  101. if (isset($_GET['id']) && !empty($_GET['id'])){
  102. $time = microtime();
  103. $time = explode(' ', $time);
  104. $time = $time[1] + $time[0];
  105. $finish = $time;
  106. $total_time = round(($finish - $start), 4);
  107. echo '<center>Page generated in '.$total_time.' seconds.</center>';
  108. }
  109. ?>
  110. </div>
  111. </div>
  112. </body>
  113. </html>
Johnas
Spróbuj tego smile.gif

  1. $html = file_get_contents("http://steamcommunity.com/profiles/76561197991341238");
  2. preg_match('/<div class="avatarFull"><img src="(.*)" \/><\/div>/i', $html, $profile_picture); // $profile_picture[1]; is the url itself


zmienna $profile_picture[1]; da Tobie link do avataru smile.gif Kod nie jest mój smile.gif

@edit:
Powyższy kod nie działa, ale napisałem na szybko z ciekawości, ponieważ może taką opcję w przyszłości dodam do siebie na forum smile.gif smile.gif
  1. <?php
  2. $url = "http://steamcommunity.com/id/God-Of-People";
  3. $html = file_get_contents($url);
  4. preg_match('/<div class="playerAvatarAutoSizeInner"><img src="(.*)"><\/div>/i', $html, $profile_picture);
  5. echo '$profile_picture[0] wyświetli:<br>'.$profile_picture[0];
  6. echo '$profile_picture[1] wyświetli:<br>'.$profile_picture[1];
  7. ?>


Działanie masz tutaj:
Pobieranie avataru ze stram - Demo

@Edit
Za późno... Przez Ciebie wprowadziłem możliwość zmiany avataru przez (profil steam, Gravatar lub wgrania avataru z dysku) u mnie na forum smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.