Resource icon

Automatic Banner 1.0

No permission to download
Joined
Feb 20, 2016
Messages
140
Likes
19
Points
53
Age
24
Location
Netherlands
#21
php-gd installed?
You only have to start ./run start
Still not working



Code:
<?php
set_time_limit(0);
date_default_timezone_set("Europe/Warsaw");
header('Content-Type: image/png');

$config = array (
            'VIP' => '40',
            'S-VIP' => '39',
            'CEO' => '9',
            'ROOT' => '10',
            'SSA' => '13'
        );
//GETTING CACHE
$cache = file_get_contents('cache.ss');
$cache = json_decode($cache, true);

$clients = $cache['clients'];

$serverGroups = $cache['groups'];

$online = $cache['server']['virtualserver_clientsonline'] - $cache['server']['virtualserver_queryclientsonline'];

$channelcounter = $cache['server']['virtualserver_channelsonline'];

$clientconnections = $cache['server']['virtualserver_client_connections'];

$slots = $cache['server']['virtualserver_maxclients'];

$secs = $cache['server']['virtualserver_uptime'];
$now = date_create('now', new DateTimeZone('GMT'));
$here = clone $now;
$here->modify($secs.' seconds');
$diff = $now->diff($here);
$uptime = $diff->format('%a D %h H %i M %s S');

///////ADMINS COUNTER
//CEOs counter
$client = $cache['clients'];
        $CEOs = 0;
        foreach($client as $target) {
        $sgtarget = explode(',', $target['client_servergroups']);
        if(in_array($config['CEO'], $sgtarget)) { $CEOs++; }
        }
//ROOTs counter
$client = $cache['clients'];
        $ROOTs = 0;
        foreach($client as $target) {
        $sgtarget = explode(',', $target['client_servergroups']);
        if(in_array($config['ROOT'], $sgtarget)) { $ROOTs++; }
        }     
//SSAs counter
$client = $cache['clients'];
        $SSAs = 0;
        foreach($client as $target) {
        $sgtarget = explode(',', $target['client_servergroups']);
        if(in_array($config['SSA'], $sgtarget)) { $SSAs++; }
        } 

///////SPECIAL GROUPS COUNTER 
$client = $cache['clients'];
        $VIPs = 0;
        foreach($client as $target) {
        $sgtarget = explode(',', $target['client_servergroups']);
        if(in_array($config['VIP'], $sgtarget)) { $VIPs++; }
        }
$client = $cache['clients'];
        $SVIPs = 0;
        foreach($client as $target) {
        $sgtarget = explode(',', $target['client_servergroups']);
        if(in_array($config['S-VIP'], $sgtarget)) { $SVIPs++; }
        }     
 
//BANNER GENERATING
$time = date("H:i");
$date = date("d.m.y");
$fbebas = 'resources/fonts/bebas.ttf';
$img = imagecreatefrompng("resources/img/bg.png");



$adminscounter = $CEOs + $ROOTs + $SSAs;
$vipscounter = $VIPs + $SVIPs;

$color = array(
            'white' => imagecolorallocate($img, 255, 255, 255),
            'green' => imagecolorallocate($img, 0, 255, 0),
            'red' => imagecolorallocate($img, 255, 0, 0)
        );

        imagettftext($img, 70, 0, 530, 380, $color['white'], $fbebas, $time. ' | ' .$date);     
     
        imagettftext($img, 40, 0, 480, 620, $color['white'], $fbebas, 'Random news about server');
     
        imagettftext($img, 50, 0, 90, 295, $color['white'], $fbebas, $online. '/' .$slots);

        imagettftext($img, 50, 0, 1380, 285, $color['white'], $fbebas, $channelcounter);
     
        imagettftext($img, 45, 0, 430, 870, $color['white'], $fbebas, 'Server uptime:' .$uptime);
     
        if($socket = @fsockopen('localhost', 10011, $errno, $errstr, 2)) {
            imagettftext($img, 50, 0, 80, 690, $color['green'], $fbebas, Online);
        } 
        else {
            imagettftext($img, 50, 0, 80, 690, $color['red'], $fbebas, Offline);
        }
     
        imagettftext($img, 50, 0, 125, 495, $color['white'], $fbebas, $clientconnections);
     
        imagettftext($img, 50, 0, 1400, 495, $color['white'], $fbebas, $adminscounter);
     
        imagettftext($img, 50, 0, 1400, 690, $color['white'], $fbebas, $vipscounter);

imagepng($img, '/var/www/banner.png');
imagedestroy($img);

?>

how can I solve this problem please help me

teamspeak 3: -IP REMOVED-

Edited BY MOD QRAKTZYL
Please do not post your ip here. If you want to invite people for help, join the r4p3 forums.
 
Last edited by a moderator:
Joined
Nov 10, 2015
Messages
40
Likes
25
Points
50
#22
PHP Notice: Use of undefined constant Offline - assumed 'Offline' in /home/banner/banner.php on line 104
Upon manually starting it, no message when doing ./run start
 
Joined
Jan 3, 2016
Messages
4
Likes
0
Points
33
#24
PHP Notice: Use of undefined constant Offline - assumed 'Offline' in /home/banner/banner.php on line 104
Upon manually starting it, no message when doing ./run start
Change the banner.php to the following to remove those errors:
Code:
if ($socket = @fsockopen('YOUR_TS_SERVER_IP_HERE', YOUR_TS_QUERY_PORT_HERE, $errno, $errstr, 2)) {
    imagettftext($img, 50, 0, 80, 690, $color['green'], $fbebas, "Online");
} else {
    imagettftext($img, 50, 0, 80, 690, $color['red'], $fbebas, "Offline");
}
Note the " for Offline and Online.
 

0x0539

Retired Staff
Contributor
Joined
Jan 30, 2016
Messages
1,334
Likes
1,190
Points
214
Location
The Netherlands
#25
Change the banner.php to the following to remove those errors:
Code:
if ($socket = @fsockopen('YOUR_TS_SERVER_IP_HERE', YOUR_TS_QUERY_PORT_HERE, $errno, $errstr, 2)) {
    imagettftext($img, 50, 0, 80, 690, $color['green'], $fbebas, "Online");
} else {
    imagettftext($img, 50, 0, 80, 690, $color['red'], $fbebas, "Offline");
}
Note the " for Offline and Online.
You could just change the words "red" to "green" and "offline" to "online" since it doesn't matter.. at all, if your server is offline the banner won't show up anyway, there's no need for the offline function. (I suppose you use this banner on TS3 & not website).
 
Joined
Jan 3, 2016
Messages
4
Likes
0
Points
33
#26
You could just change the words "red" to "green" and "offline" to "online" since it doesn't matter.. at all, if your server is offline the banner won't show up anyway, there's no need for the offline function. (I suppose you use this banner on TS3 & not website).
This Banner is for a website. Does not make sense to show this in the Teamspeak itself.
 

0x0539

Retired Staff
Contributor
Joined
Jan 30, 2016
Messages
1,334
Likes
1,190
Points
214
Location
The Netherlands
#27
This Banner is for a website. Does not make sense to show this in the Teamspeak itself.
Doesn't need to be for the website, what I meant is that it has a perfect resolution to be used as TS3 banner.
Without the status function it won't be too stupid to use it as TS3 banner
 
Joined
Jan 3, 2016
Messages
4
Likes
0
Points
33
#28
Doesn't need to be for the website, what I meant is that it has a perfect resolution to be used as TS3 banner.
Without the status function it won't be too stupid to use it as TS3 banner
Why would I want to show the current users etc, in Teamspeak itself? They can just take a look at the data listed in teamspeak itself...
I currently use a customized version myself, I show the banner on my website and as host banner I show a smaller banner, with just the news on it.
 

0x0539

Retired Staff
Contributor
Joined
Jan 30, 2016
Messages
1,334
Likes
1,190
Points
214
Location
The Netherlands
#29
Why would I want to show the current users etc, in Teamspeak itself? They can just take a look at the data listed in teamspeak itself...
I currently use a customized version myself, I show the banner on my website and as host banner I show a smaller banner, with just the news on it.
Hmm, that question can be made to anything.. -> "Why would I want to show the current users etc, in Teamspeak itself?"
Why would someone want a Timebot on their TS3 server?
Why would someone want a ClientsOnline on their TS3 server?
Why would someone want a StaffOnline on their TS3 server?
Pretty much every query/bot release...

While all of these information can be seen in the server information.
And about the timebot? Have you heard of your clock in the right bottom corner?
 
Joined
Jan 3, 2016
Messages
4
Likes
0
Points
33
#30
Hmm, that question can be made to anything.. -> "Why would I want to show the current users etc, in Teamspeak itself?"
Why would someone want a Timebot on their TS3 server?
Why would someone want a ClientsOnline on their TS3 server?
Why would someone want a StaffOnline on their TS3 server?

While all of these information can be seen in the server information.
And about the timebot? Have you heard of your clock in the right bottom corner?
xD, Yeah. I never understood why someone would use that.
Does not make sense to me. Eventually the "Staff Online" section on the clock COULD be useful, but the rest is total irrelevant.
 
Joined
Feb 20, 2016
Messages
140
Likes
19
Points
53
Age
24
Location
Netherlands
#31
Hmm, that question can be made to anything.. -> "Why would I want to show the current users etc, in Teamspeak itself?"
Why would someone want a Timebot on their TS3 server?
Why would someone want a ClientsOnline on their TS3 server?
Why would someone want a StaffOnline on their TS3 server?
Pretty much every query/bot release...

While all of these information can be seen in the server information.
And about the timebot? Have you heard of your clock in the right bottom corner?

Whether or not these things apart
My server to the other

This can be a way for me to sell my product and win over simple things like that, I can say that there are few servers that have this system, the customer will find super cool and will take an interest in our new products!
 
Joined
Oct 29, 2015
Messages
23
Likes
24
Points
51
Age
23
#32
If somebody is intrested in graphic so u can do project of banner for me please :) 1600x600
 
Joined
Feb 8, 2016
Messages
23
Likes
5
Points
35
#34
You can also use a cronjob for the updates.
*/1 * * * * cd /home/banner/ ; /usr/bin/php cache.php ; /usr/bin/php banner.php
 
Last edited:
Joined
Dec 1, 2015
Messages
91
Likes
46
Points
63
#35
This error:

You do not have permission to view link Log in or register now.


Code:
if($socket = @fsockopen('XXX.XXX.XXX.XXX', 10011, $errno, $errstr, 2)) {
imagettftext($img, 50, 0, 80, 690, $color['green'], $fbebas, 'Online')
 

0x0539

Retired Staff
Contributor
Joined
Jan 30, 2016
Messages
1,334
Likes
1,190
Points
214
Location
The Netherlands
#36
This error:

You do not have permission to view link Log in or register now.


Code:
if($socket = @fsockopen('XXX.XXX.XXX.XXX', 10011, $errno, $errstr, 2)) {
imagettftext($img, 50, 0, 80, 690, $color['green'], $fbebas, 'Online')
This is just a notification, the script said "assumed 'online'" so it should be working anyway.
 
Joined
Feb 8, 2016
Messages
23
Likes
5
Points
35
#38
This error:

You do not have permission to view link Log in or register now.


Code:
if($socket = @fsockopen('XXX.XXX.XXX.XXX', 10011, $errno, $errstr, 2)) {
imagettftext($img, 50, 0, 80, 690, $color['green'], $fbebas, 'Online')
Change 'online' to "online" and 'offline' to "offline" in the code and the error/notification is gone.
 
Joined
Jan 16, 2016
Messages
24
Likes
1
Points
35
Age
24
#40
PHP Warning: DateTime::modify(): Failed to parse time string ( seconds) at position 0 (s): The timezone could not be found in the database in /home/banner/banner.php on line 32
PHP Warning: Invalid argument supplied for foreach() in /home/banner/banner.php on line 40
PHP Warning: Invalid argument supplied for foreach() in /home/banner/banner.php on line 47
PHP Warning: Invalid argument supplied for foreach() in /home/banner/banner.php on line 54
PHP Warning: Invalid argument supplied for foreach() in /home/banner/banner.php on line 62
PHP Warning: Invalid argument supplied for foreach() in /home/banner/banner.php on line 68
 

Top