├── .env.example ├── .gitignore ├── README.md ├── composer.json ├── composer.lock ├── public ├── assets │ ├── background.jpg │ ├── minecraft-logo.svg │ └── style.css └── index.php ├── screenshot.png └── templates ├── base.php ├── offline.php └── online.php /.env.example: -------------------------------------------------------------------------------- 1 | # Minecraft server host, optionally include a port. Defaults to 25565 when not specified. 2 | SERVER_HOST=minecraft.example.com:25565 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | composer.phar 3 | /vendor/ 4 | 5 | /.idea/ 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Minecraft server status page 2 | A simple page to see if your minecraft server is online with some basic stats like the version and amount of players online. 3 | 4 | ## Requirements 5 | - A webserver with php >= 7 6 | - [Composer](https://getcomposer.org/) 7 | 8 | ## Setup 9 | 1. Clone this repository on your webserver. 10 | 2. Duplicate the `.env.example` file to `.env` and update this file with the settings that apply to you. 11 | 3. From within the project directory run `composer install` to download and install the dependencies. 12 | 4. Point your webserver to the `public` dir of this project and the Minecraft server status page is up and running. 13 | 14 | ## Screenshot 15 | ![dummy screenshot](https://raw.githubusercontent.com/styxit/MinecraftStatusPage/master/screenshot.png) 16 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "styxit/mc-status", 3 | "description": "Minecraft server status page", 4 | "keywords": ["minecraft", "server", "status", "online", "check"], 5 | "type": "project", 6 | "require": { 7 | "xpaw/php-minecraft-query": "^2.0", 8 | "league/plates": "^3.3", 9 | "josegonzalez/dotenv": "^3.2" 10 | }, 11 | "authors": [ 12 | { 13 | "name": "Styxit", 14 | "email": "info@styxit.com", 15 | "role": "Author", 16 | "homepage": "https://styxit.com" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "926c5673359f3df39dfd2b84c7251d2c", 8 | "packages": [ 9 | { 10 | "name": "josegonzalez/dotenv", 11 | "version": "3.2.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/josegonzalez/php-dotenv.git", 15 | "reference": "f19174d9d7213a6c20e8e5e268aa7dd042d821ca" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/josegonzalez/php-dotenv/zipball/f19174d9d7213a6c20e8e5e268aa7dd042d821ca", 20 | "reference": "f19174d9d7213a6c20e8e5e268aa7dd042d821ca", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "m1/env": "2.*", 25 | "php": ">=5.5.0" 26 | }, 27 | "require-dev": { 28 | "php-mock/php-mock-phpunit": "^1.1", 29 | "satooshi/php-coveralls": "1.*", 30 | "squizlabs/php_codesniffer": "2.*" 31 | }, 32 | "type": "library", 33 | "autoload": { 34 | "psr-0": { 35 | "josegonzalez\\Dotenv": [ 36 | "src", 37 | "tests" 38 | ] 39 | } 40 | }, 41 | "notification-url": "https://packagist.org/downloads/", 42 | "license": [ 43 | "MIT" 44 | ], 45 | "authors": [ 46 | { 47 | "name": "Jose Diaz-Gonzalez", 48 | "email": "dotenv@josegonzalez.com", 49 | "homepage": "http://josediazgonzalez.com", 50 | "role": "Maintainer" 51 | } 52 | ], 53 | "description": "dotenv file parsing for PHP", 54 | "homepage": "https://github.com/josegonzalez/php-dotenv", 55 | "keywords": [ 56 | "configuration", 57 | "dotenv", 58 | "php" 59 | ], 60 | "time": "2017-09-19T15:49:58+00:00" 61 | }, 62 | { 63 | "name": "league/plates", 64 | "version": "3.3.0", 65 | "source": { 66 | "type": "git", 67 | "url": "https://github.com/thephpleague/plates.git", 68 | "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af" 69 | }, 70 | "dist": { 71 | "type": "zip", 72 | "url": "https://api.github.com/repos/thephpleague/plates/zipball/b1684b6f127714497a0ef927ce42c0b44b45a8af", 73 | "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af", 74 | "shasum": "" 75 | }, 76 | "require": { 77 | "php": "^5.3 | ^7.0" 78 | }, 79 | "require-dev": { 80 | "mikey179/vfsstream": "^1.4", 81 | "phpunit/phpunit": "~4.0", 82 | "squizlabs/php_codesniffer": "~1.5" 83 | }, 84 | "type": "library", 85 | "extra": { 86 | "branch-alias": { 87 | "dev-master": "3.0-dev" 88 | } 89 | }, 90 | "autoload": { 91 | "psr-4": { 92 | "League\\Plates\\": "src" 93 | } 94 | }, 95 | "notification-url": "https://packagist.org/downloads/", 96 | "license": [ 97 | "MIT" 98 | ], 99 | "authors": [ 100 | { 101 | "name": "Jonathan Reinink", 102 | "email": "jonathan@reinink.ca", 103 | "role": "Developer" 104 | } 105 | ], 106 | "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", 107 | "homepage": "http://platesphp.com", 108 | "keywords": [ 109 | "league", 110 | "package", 111 | "templates", 112 | "templating", 113 | "views" 114 | ], 115 | "time": "2016-12-28T00:14:17+00:00" 116 | }, 117 | { 118 | "name": "m1/env", 119 | "version": "2.1.0", 120 | "source": { 121 | "type": "git", 122 | "url": "https://github.com/m1/Env.git", 123 | "reference": "d87eddd031f2aa5450fa04bb1325de8a489b3cd0" 124 | }, 125 | "dist": { 126 | "type": "zip", 127 | "url": "https://api.github.com/repos/m1/Env/zipball/d87eddd031f2aa5450fa04bb1325de8a489b3cd0", 128 | "reference": "d87eddd031f2aa5450fa04bb1325de8a489b3cd0", 129 | "shasum": "" 130 | }, 131 | "require": { 132 | "php": ">=5.3.0" 133 | }, 134 | "require-dev": { 135 | "phpunit/phpunit": "4.*", 136 | "scrutinizer/ocular": "~1.1", 137 | "squizlabs/php_codesniffer": "^2.3" 138 | }, 139 | "suggest": { 140 | "josegonzalez/dotenv": "For loading of .env", 141 | "m1/vars": "For loading of configs" 142 | }, 143 | "type": "library", 144 | "autoload": { 145 | "psr-4": { 146 | "M1\\Env\\": "src" 147 | } 148 | }, 149 | "notification-url": "https://packagist.org/downloads/", 150 | "license": [ 151 | "MIT" 152 | ], 153 | "authors": [ 154 | { 155 | "name": "Miles Croxford", 156 | "email": "hello@milescroxford.com", 157 | "homepage": "http://milescroxford.com", 158 | "role": "Developer" 159 | } 160 | ], 161 | "description": "Env is a lightweight library bringing .env file parser compatibility to PHP. In short - it enables you to read .env files with PHP.", 162 | "homepage": "https://github.com/m1/Env", 163 | "keywords": [ 164 | ".env", 165 | "config", 166 | "dotenv", 167 | "env", 168 | "loader", 169 | "m1", 170 | "parser", 171 | "support" 172 | ], 173 | "time": "2016-10-06T19:31:28+00:00" 174 | }, 175 | { 176 | "name": "xpaw/php-minecraft-query", 177 | "version": "2.0.0", 178 | "source": { 179 | "type": "git", 180 | "url": "https://github.com/xPaw/PHP-Minecraft-Query.git", 181 | "reference": "d7184150af24c82341cfe3c34fc8d2c788ef2815" 182 | }, 183 | "dist": { 184 | "type": "zip", 185 | "url": "https://api.github.com/repos/xPaw/PHP-Minecraft-Query/zipball/d7184150af24c82341cfe3c34fc8d2c788ef2815", 186 | "reference": "d7184150af24c82341cfe3c34fc8d2c788ef2815", 187 | "shasum": "" 188 | }, 189 | "require": { 190 | "php": ">=5.4" 191 | }, 192 | "type": "library", 193 | "autoload": { 194 | "psr-4": { 195 | "xPaw\\": "src" 196 | } 197 | }, 198 | "notification-url": "https://packagist.org/downloads/", 199 | "license": [ 200 | "MIT" 201 | ], 202 | "description": "PHP library to query Minecraft servers", 203 | "keywords": [ 204 | "minecraft" 205 | ], 206 | "time": "2016-11-06T08:23:55+00:00" 207 | } 208 | ], 209 | "packages-dev": [], 210 | "aliases": [], 211 | "minimum-stability": "stable", 212 | "stability-flags": [], 213 | "prefer-stable": false, 214 | "prefer-lowest": false, 215 | "platform": [], 216 | "platform-dev": [] 217 | } 218 | -------------------------------------------------------------------------------- /public/assets/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/styxit/MinecraftStatusPage/0c69956650b99306d8f58f29540c4180f5cc9306/public/assets/background.jpg -------------------------------------------------------------------------------- /public/assets/minecraft-logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/assets/style.css: -------------------------------------------------------------------------------- 1 | html { 2 | -webkit-font-smoothing: antialiased; 3 | min-width: 300px; 4 | text-rendering: optimizeLegibility; 5 | } 6 | 7 | body { 8 | background: url(background.jpg) no-repeat center center fixed; 9 | -webkit-background-size: cover; 10 | -moz-background-size: cover; 11 | -o-background-size: cover; 12 | background-size: cover; 13 | padding: 0px 40px 40px 40px; 14 | font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; 15 | } 16 | 17 | a { 18 | font-size: 100%; 19 | background: 0 0; 20 | color: #663300; 21 | text-decoration: none; 22 | -webkit-transition: none 86ms ease-out; 23 | transition: none 86ms ease-out; 24 | } 25 | a:hover { 26 | text-decoration: underline; 27 | } 28 | 29 | .container { 30 | margin: auto; 31 | padding-top: 50px; 32 | max-width: 968px; 33 | } 34 | .section { 35 | padding: 20px; 36 | margin-top: 40px; 37 | border: 1px solid #efefef; 38 | border-radius: 5px; 39 | background-color: #fff; 40 | } 41 | 42 | .status-header { 43 | padding: 30px ; 44 | color: #222324; 45 | font-size: 28px; 46 | line-height: 1; 47 | font-weight: 300; 48 | } 49 | .status-header .subtitle { 50 | margin-left: auto; 51 | color: #69707a; 52 | font-size: 18px; 53 | line-height: 1.125; 54 | } 55 | 56 | .status-header .indicator { 57 | position: relative; 58 | left: -5px; 59 | } 60 | 61 | .status-header i { 62 | font-size: 0.7em; 63 | } 64 | i.online { 65 | color: #17d766; 66 | } 67 | i.offline { 68 | color: orangered; 69 | } 70 | 71 | .status-list { 72 | padding: 10px 30px; 73 | } 74 | 75 | .status-hero { 76 | padding: 10px 30px; 77 | font-size: 2em; 78 | } 79 | 80 | .status-list .label { 81 | font-size: 1.3em; 82 | 83 | margin-bottom: 5px; 84 | } 85 | 86 | .table { 87 | margin-bottom: 20px; 88 | width: 100%; 89 | } 90 | .table td { 91 | font-size: 14px; 92 | border: 1px solid #d3d6db; 93 | border-width: 0 0 1px; 94 | padding: 8px 10px; 95 | } 96 | 97 | .progress{ 98 | border:none; 99 | border-radius:290486px; 100 | display:block; 101 | height:12px; 102 | overflow:hidden; 103 | padding:0; 104 | width:100% 105 | } 106 | .progress::-webkit-progress-bar { 107 | background-color:#d3d6db; 108 | } 109 | .progress::-webkit-progress-value { 110 | background-color:#72AD48; 111 | }.progress::-moz-progress-bar { 112 | background-color:#72AD48; 113 | } 114 | 115 | .status-list .amount { 116 | font-size: 16px; 117 | font-weight: bold; 118 | color: #bbb; 119 | text-align: center; 120 | } 121 | 122 | .logo { 123 | text-align: center; 124 | } 125 | .logo img { 126 | width: auto; 127 | max-height: 100px; 128 | max-width: 100%; 129 | } 130 | 131 | .status-footer a { 132 | padding: 0 10px; 133 | } 134 | .status-footer a i { 135 | color: #72AD48; 136 | } 137 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 | parse() 13 | ->expect('SERVER_HOST') 14 | ->putenv(true); 15 | 16 | // Try to query the Minecraft server. 17 | try { 18 | $Query = new MinecraftPing(getenv('SERVER_HOST'), 25565, 1); 19 | $response = $Query->Query(); 20 | $Query->Close(); 21 | } catch (MinecraftPingException $e) { 22 | // If no (valid) response, use empty array as response. 23 | $response = []; 24 | } 25 | 26 | // Set online state. 27 | $response['online'] = (boolean) !empty($response); 28 | // Add host. 29 | $response['host'] = getenv('SERVER_HOST'); 30 | 31 | // Create new Plates template instance. 32 | $templates = new TemplateEngine('../templates'); 33 | 34 | // Render online or offline template. 35 | if ($response['online'] === true) { 36 | // Add online player percentage. 37 | $response['players']['percentage'] = floor(($response['players']['online'] / $response['players']['max']) * 100); 38 | // Render online template. 39 | echo $templates->render('online', $response); 40 | } else { 41 | // Render offline template. 42 | echo $templates->render('offline', $response); 43 | } 44 | -------------------------------------------------------------------------------- /screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/styxit/MinecraftStatusPage/0c69956650b99306d8f58f29540c4180f5cc9306/screenshot.png -------------------------------------------------------------------------------- /templates/base.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | <?= $this->e($title) ?> 8 | 9 | 10 | 11 | 12 | 13 |
14 | 17 |
18 | section('content') ?> 19 |
20 |
21 | 27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /templates/offline.php: -------------------------------------------------------------------------------- 1 | layout('base', ['title' => $host.' is offline']) ?> 2 | 3 |
4 |

e($host) ?>

5 |

Unreachable

6 |
7 | 8 |
9 |

e($host) ?> seems offline.

10 |
11 | -------------------------------------------------------------------------------- /templates/online.php: -------------------------------------------------------------------------------- 1 | layout('base', ['title' => $host.' is online']) ?> 2 | 3 |
4 |

e($host) ?>

5 |

e($description['text']) ?>

6 |
7 | 8 |
9 |
Server stats
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
Versione($version['name']) ?>
Protocole($version['protocol']) ?>
22 |
23 |
24 |
25 |
Players online
26 |
27 | e($players['percentage']) ?>% 28 |
29 |
e($players['online']) ?>/e($players['max']) ?>
30 |
31 |
32 | --------------------------------------------------------------------------------