
<?php $SERVER_IP="TUTAJ MOJE IP"; function get_data($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 5); $data = curl_exec($ch); $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); 'status' => $httpStatus, 'data' => $data ); } $userlistserver = get_data("http://api.iamphoenix.me/list/?server_ip=" . $SERVER_IP . ""); $serverdata = get_data("http://minecraft-api.com/v1/get/?server=" . $SERVER_IP . ""); $data_list = json_decode($userlistserver["data"], true); $data_general = json_decode($serverdata["data"], true); ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> PHP Query 2</title> <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css"> <link href='http://fonts.googleapis.com/css?family=Lato:300,400' rel='stylesheet' type='text/css'> <link href="https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet"> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script type="text/javascript" src="https://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script> <script language="javascript"> jQuery(document).ready(function(){ $("[rel='tooltip']").tooltip(); }); </script> <style> /*Custom CSS Overrides*/ body { font-family: 'Lato', sans-serif !important; } </style> </head> <body> <div class="container"> <h1>MC PHP Query</h1><hr> <div class="row"> <div class="span4"> <h3>General Information</h3> <table class="table table-striped"> <tbody> <tr> <td><b>IP</b></td> </tr> <?php if ($serverdata["status"] == "200" && $data_general['error'] == "") { ?> <tr> <td><b>Version</b></td> </tr> <?php } ?> <?php if ($serverdata["status"] == "200" && $data_general['error'] == "") { ?> <tr> <td><b>Players</b></td> <td><?php echo "".$data_general['players']['online']." / ".$data_general['players']['max']."";?></td> </tr> <?php } ?> <tr> <td><b>Status</b></td> </tr> <?php if ($serverdata["status"] == "200" && $data_general['error'] == "") { ?> <tr> <td><b>Latency</b></td> </tr> <?php } ?> </tbody> </table> </div> <div class="span8"> <h3>Players</h3> <?php if ($userlistserver["status"] == "200" && $data_general['error'] == "") { //Take the username values from the array & grab the avatars from Minotar. foreach($array_list as $key => $value){$users .= "<a data-placement=\"top\" rel=\"tooltip\" style=\"display: inline-block;\" title=\"".$value."\"> <img src=\"https://minotar.net/avatar/".$value."/50\" size=\"40\" width=\"40\" height=\"40\" style=\"width: 40px; height: 40px; margin-bottom: 5px; margin-right: 5px; border-radius: 3px;\"/></a>";} //Display the avatars only when there are players online. if($data_general['players']['online'] > 0) { } //If no avatars can be shown, display an error. else { } }else{ } ?> </div> </div> </div> </body> </html>
Jest to status serwera Minecraft wraz z avatarami graczy online na serwerze. Tylko jest problem. Dokładniej:
<img src=\"https://minotar.net/avatar/".$value."/50\" size=\"40\" width=\"40\" height=\"40\" style=\"width: 40px; height: 40px; margin-bottom: 5px; margin-right: 5px; border-radius: 3px;\"/></a>";
Tam gdzie ma znaleźć się wartość w ogóle jej nie wrzuca. Powinno wyglądać to tak:
https://minotar.net/avatar/NICKGRACZA/50
A wygląda następująco:
https://minotar.net/avatar//50
Przez to wyrzuca niepoprawny obrazek.
Mam nadzieję, że mnie zrozumieliście.
Z góry - wielkie dzięki za pomoc.
