<?php
	if($_GET['ip']){
		$url = "https://list.fansmc.com/api/" . $_GET['ip'];
		$q = json_decode(file_get_contents($url));
	}
	$u = "https://list.fansmc.com/api";
	$p = json_decode(file_get_contents($u));
?>
<!DOCTYPE html>
<html>
	<head>
		<base href="https://list.fansmc.com/">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>我的世界服务器查询</title>
		<link href="https://list.fansmc.com/list.css" rel="stylesheet" type="text/css">
		<link href="static/css/styles.css" rel="stylesheet">
	</head>
	<body>
        <!-- 这里是预加载器代码 -->
    <div class="spinner-wrapper">
        <div class="spinner">
            <div class="bounce1"></div>
            <div class="bounce2"></div>
            <div class="bounce3"></div>
        </div>
    </div>
    <!-- 结束预加载器代码 -->
		<div class="container">
			<h1><a href="/">我的世界服务器查询</a></h1>
			<div class="x">
				Minecraft是一款沙盒游戏，整个游戏没有剧情，玩家在游戏中自由建设和破坏，透过像积木一样来对元素进行组合与拼凑，轻而易举的就能制作出小木屋、城堡甚至城市，玩家可以通过自己创造的作品来体验上帝一般的感觉。在这款游戏里，不仅可以单人娱乐，还可以多人联机，玩家也可以安装一些模组来增加游戏趣味性。
			</div>	
			<div class="x"> 
				我的世界服务器查询，服务器状态查询，查询服务器滚动显示。
			</div>
			<div class="x">
				<form action="" method="get">
					<input type="text" class="form-control" name="ip" autocomplete="off" value="<?php echo $_GET['ip']; ?>" placeholder="IP地址">	
					<button type="submit" id="btn" class="btn btn-success">查询</button>
				</form>
			</div>
			<?php if($_GET['ip']){ ?>
			<div class="table-container">
				<table align="center">
					<thead>
						<tr>
							<th>图标</th>
							<th>MOTD</th>
							<th>模组</th>
							<th>在线人数</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td><img width="60px" src="<?php echo $q->logo; ?>"/></td>	
							<td><?php echo $q->motd; ?></td>
							<td><?php echo $q->mod; ?></td>
							<td><span class="badge"><?php echo $q->p . ' / ' . $q->mp; ?></span></td>
						</tr>
					</tbody>
				</table>
			</div>
			<?php } ?>
			<div class="table-container">
				<table align="center">
					<thead>
						<tr>
							<th>图标</th>
							<th>服务器IP地址</th>
							<th>MOTD</th>
							<th>在线人数</th>
						</tr>
					</thead>
					<tbody>
						<?php foreach($p as $k => $v){ ?>
						<tr>
							<td><img width="60px" src="<?php echo $v->logo; ?>"/></td>
							<td><?php echo $v->ip; ?></td>	
							<td><?php echo $v->motd; ?></td>
							<td><span class="badge"><?php echo $v->p; ?></span></td>
						</tr>
						<?php } ?>
					</tbody>
				</table>
			</div>
			<div class="x">
				<div class="bg">
				</div>
			</div>				
		</div>
	</body>
</html>