-
Notifications
You must be signed in to change notification settings - Fork 0
/
signstats.php
44 lines (38 loc) · 2.03 KB
/
signstats.php
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
<?php
/**
* Created by @TrK for http://post4vps.com
* Source is available on http://github.com/DarkPowerInvador/MyBBstatssign
* See http://php.net/manual/en/function.imagettftext.php to know about text on images using TTF/OTF Fonts.
*/
if (!isset($_SERVER['HTTP_REFERER']))die('Direct access to file is not allowed'); //disallow users to not open the file by typing URL
//-----------Start MyBB integration----------------
define('IN_MYBB',1); //required don't change
define('NO_ONLINE',1); //required don't change
require_once './global.php'; //main file to read statstics
$lang->load('stats'); //function to load stats variables
$stats=$cache->read('stats'); //cache the stats values
//------------End MyBB integration-----------------
//----------Start Header section-------------------
header('Pragma: public');
header('Cache-Control: max-age=240');
header('Expires: '. gmdate('D, d M Y H:i:s \G\M\T', time() + 240));
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])){
header('Last-Modified: '.$_SERVER['HTTP_IF_MODIFIED_SINCE'],true,304);
exit;
}
header("Content-Type: image/png");
//----------End Header section--------------------
$bg = 'stats.png'; //background file
$font = 'roung.otf'; //font file
$forum = 'Post4VPS.com Free VPS Forum'; //forum name or description
//------------------------------------------------------------------
//PHP function to write text on image using font
$img = imagecreatefrompng($bg);
$fontcol = imagecolorallocate($img, 255, 255, 0);
imagettftext($img,11,0,20,30,$fontcol,$font,utf8_decode($lang->members).' '.number_format($stats['numusers']));
imagettftext($img,11,0,144,30,$fontcol,$font,utf8_decode($lang->posts).' '.number_format($stats['numposts']));
imagettftext($img,11,0,271,30,$fontcol,$font,utf8_decode($lang->threads).' '.number_format($stats['numthreads']));
imagettftext($img,11,0,98,60,$fontcol,$font,$forum);
imagepng($img);
imagedestroy($img);
?>