/
fonline.png
47 lines (35 loc) · 1.74 KB
/
fonline.png
File metadata and controls
47 lines (35 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
include( 'lib/fowww/FOnlineFont.php' );
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Cache-Control: post-check=0, pre-check=0", false );
header( "Pragma: no-cache" );
header( "Connection: close" );
$img = NULL;
$status = NULL;
if( file_exists( 'data/status.json' ) && is_readable( 'data/status.json' ))
$status = json_decode( file_get_contents( 'data/status.json' ), true );
if( $status != NULL && isset($status['fonline']['status']['servers']) && $status['fonline']['status']['servers'] > 0 )
{
$img = imagecreatefrompng( 'gfx/online.png' );
$font_big = new FOnlineFont( 'fonts/Big.fofnt' );
$font_default = new FOnlineFont( 'fonts/Default.fofnt' );
$img_fonline = $font_big->TextToImage( 'FOnline', 2, 238, 0 );
$img_servers = $font_default->TextToImage( 'Servers: '.$status['fonline']['status']['servers'], 2, 238, 0 );
$img_players = $font_default->TextToImage( 'Players: '.$status['fonline']['status']['players'], 2, 238, 0 );
imagecopy( $img, $img_fonline, 30, 14, 0, 0, imagesx($img_fonline), imagesy($img_fonline) );
imagecopy( $img, $img_servers, 141, 16, 0, 0, imagesx($img_servers), imagesy($img_servers) );
imagecopy( $img, $img_players, 141, 26, 0, 0, imagesx($img_players), imagesy($img_players) );
}
else
{
$img = imagecreatefrompng( 'gfx/offline.png' );
$font_big = new FOnlineFont( 'fonts/Big.fofnt' );
$img_fonline = $font_big->TextToImage( 'FOnline', 180, 0, 0 );
imagecopy( $img, $img_fonline, (imagesx($img)/2)-(imagesx($img_fonline)/2), 14, 0, 0, imagesx($img_fonline), imagesy($img_fonline) );
}
header( "Content-Type: image/png" );
imagepng($img);
imagedestroy($img);
?>