tables in php
Posted: Thu Jun 29, 2006 5:26 am
is there anyway to make a html table an image in php?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Using fopen, fgets and the gd library, this should be possible.jeeep wrote:is there anyway to make a html table an image in php?
I'd say the automatic *transfer* of data from server 1 to server 2...Jenk wrote:But very 'long'
May we ask for what purpose you desire this functionality?
You know. What we need to is to enforce a new forum rule that says "all posters should provide information on what they are trying to achieve functionality-wise rather than just the specifics of a problem". I read so many posts and very often I can't help but say, out loud, "why do you want to do that?" and they always have some funny reason for it.May we ask for what purpose you desire this functionality?
Code: Select all
<?php
require("cyts.class.php");
$cyts = new cyts;
$cyts->connect("xxx.xx.xxx.xx", 51234, xxxx) or print "Cannot connect to server.";
$cyts->login("adminuser", "password");
$list = $cyts->info_channelList();
$users = $cyts->admin_dbUserList();
$tsusers = $cyts->info_playerList();
$tsserv = $cyts->info_serverInfo();
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class=\"team\">";
$server=false;
if ($tsserv[server_name] == NULL) $server=true;
if ($server == true) { echo "<tr><td>The server is Offline</td></tr>"; } else { echo "
<tr>
<td colspan=\"3\" align=\"left\" nowrap=\"nowrap\">
<img src=\"images/teamspeak_online.png\" alt=\"TS server\" width=\"16\" height=\"16\" />
$tsserv[server_name]
</td>
</tr>";}
foreach ($list as $channel) {
echo "
<tr>
<td nowrap=\"nowrap\" align=\"left\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/channel.png\" alt=\"TS channel\" width=\"16\" height=\"16\" />
$channel[name]:
</td>
</tr>";
$chanUsers = $cyts->info_channelUser($channel["id"]);
foreach ($chanUsers as $user) {
echo "
<tr>
<td nowrap=\"nowrap\" align=\"left\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/treeimage3.png\" alt=\"tree\" width=\"16\" height=\"16\" />
<img src=\"images/online.gif\" alt=\"online\" width=\"16\" height=\"16\" />
$user[nick]
</td>
</tr> ";
}
}
echo "
<tr>
<td height=\"12\">
<br />
<p>
<img src=\"images/black.gif\" width=100 height=1 vspace=1 alt=\"line\">
<br /> Members Offline:<br />
<img src=\"images/black.gif\" width=100 height=1 vspace=1 alt=\"line\">
</p>
</td>
</tr>";
foreach ($users as $offline) {
//Go through the memberlist
$online = false;
//At first we believe he/she is offline
foreach ($tsusers as $tsuser)
{
//Go through the list of users which are online in TS
if ($tsuser["loginname"] == $offline[5]) $online = true;
//If someone who is online in TS is logged in with the member's loginname change the status to true
}
//If he is online print nothing else print offline
if ($online ==false) echo "
<tr>
<td title=\"last login $offline[4]\" align=\"left\" valign=\"middle\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/offline.gif\" alt=\"offline\" width=\"16\" height=\"16\" />
$offline[5]
</td>
</tr>
";
} echo"</table>
<br />";
?>Even though flash can load external images, I would stick to loadVars and create the chart in flash or use a dynamic textfield.jeeep wrote:I have this code here for showing stats about my teamspeak server and I'm trying to make it where the stats can be called from flash to load. There are several ways of doing this but I am having problems with the other method. Here is the script:
For example when I use createimagefrompng and put the strings down, only the ones with one figure work, arrays and what not show nothing. So I was hoping that if I could somehow just turn this whole thing into an image it would be easier!
Code: Select all
echo "text".$tsserv['server_name']."more text";I generally make sure to include my purpose when I post a question for this very reason. Often I ask a question and people are like... uhh, there is a WAY easier way to do that. Anyway... carry on.ole wrote:You know. What we need to is to enforce a new forum rule that says "all posters should provide information on what they are trying to achieve functionality-wise rather than just the specifics of a problem". I read so many posts and very often I can't help but say, out loud, "why do you want to do that?" and they always have some funny reason for it.May we ask for what purpose you desire this functionality?
Code: Select all
<?php
require("cyts.class.php");
$cyts = new cyts;
//Parameters are: IP-Address, TCP-Queryport, UDP-Port
$cyts->connect("xxx.xxx.xxx.xx", 51234, xxxx) or die ("Unable to connect to TeamSpeak-server");
$cyts->login("admin", "password");
header("Content-type: image/png");
$bg = "teamspeakimg.png";
$im = @ImageCreateFromPNG($bg);
$width =1;
$font = 2;
$fonta = 3;
$black = imagecolorallocate($im, 255, 255, 255);
$users = $cyts->admin_dbUserList();
$srvinfo = $cyts->info_serverInfo();
$playerlist = $cyts->info_playerNameList( );
$tsusers = $cyts->info_playerList();
imagestring($im, $font, 5, 5,$srvinfo["server_currentusers"] , $black);
imagestring($im, $font, 20, 5,"users online", $black);
imagestring($im, $font, 5, 20,$srvinfo["server_name"] , $black);
imagestring($im, $font, 5, 30,$srvinfo["server_uptime"] , $black);
imagePNG($im);
ImageDestroy;
?>Code: Select all
imagestring($im, $font, 5, 40,$tsusers["nick"] , $black);Code: Select all
method info_playerList [line 311]
array info_playerList( )
info_playerList: Returns a list of players that are connected to the server
array:
[0], [unparsed] => Unparsed playerstring
[1], [p_id] => PlayerID
[2], [c_id] => ChannelID
[3], [ps] => Packets sent by server
[4], [bs] => Bytes sent by server
[5], [pr] => Packets received by server
[6], [br] => Bytes received by server
[7], [pl] => Packet Loss
[8], [ping] => Ping
[9], [logintime] => Seconds since Login
[10], [idletime] => Idletime in seconds
[11], [cprivs] => Channelflags (1 - CA, 2 - O, 4 - V, 8 - AO, 16 - AV)
[12], [pprivs] => Serverflags (1 - SA, 2 - Allowed To Register(AR), 4 - R, 8 - ???, 16 - Sticky)
[13], [pflags] => Playerflags (1 - Channel Commander(CC), 2 - Voice Request(VR), 4 - No Whisper(NW), 8 - Away(AW), 16 - Mic Muted(MM), 32 - Snd Muted(SM), 64 - Rec(RC))
[14], [ip] => IP-Adress (Note: This will be 0.0.0.0 for all players if you are not logged in as a server admin)
[15], [nick] => Nickname
[16], [loginname] => Loginname (empty if user is not registered)
Tags:
return: multi-dimensional array with player data
access: public
see: cyts::info_translateFlag(), for converting flags to arrays
version: 2.0
author: Steven BarthCode: Select all
info_playerList( );Code: Select all
foreach ($list as $channel) {
echo "
<tr>
<td nowrap=\"nowrap\" align=\"left\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/channel.png\" alt=\"TS channel\" width=\"16\" height=\"16\" />
$channel[name]:
</td>
</tr>";
$chanUsers = $cyts->info_channelUser($channel["id"]);
foreach ($chanUsers as $user) {
echo "
<tr>
<td nowrap=\"nowrap\" align=\"left\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/treeimage3.png\" alt=\"tree\" width=\"16\" height=\"16\" />
<img src=\"images/online.gif\" alt=\"online\" width=\"16\" height=\"16\" />
$user[nick]
</td>
</tr> ";
}
}Code: Select all
imagestring($im, $font, 5, 45,$user["nick"] , $black);Code: Select all
method info_channelList [line 377]
array info_channelList( )
info_channelList: Returns a list of channels that are available on the server
array:
[0], [unparsed] => Unparsed channelstring
[1], [id] => ChannelID
[2], [codec] => Codec (from 0 to 13):
[3], [parent] => Parent ChannelID (-1 if no Subchannel)
[4], [order] => Channel Order
[5], [maxusers] => Max Users
[6], [name] => Name
[7], [flags] => Flags (1 - Unregistered(U), 2 - Moderated(M), 4 - Private(P), 8 - Subchannels(S), 16 - Default(D))
[8], [password] => Passworded (1 - True, 0 - False)
[9], [topic] => Topic
Tags:
return: multi-dimensional array with channel data
see: cyts::info_getCodec(), for getting a codecs name by its id
see: cyts::info_translateFlag(), for converting flags to arrays
access: public
version: 2.0
author: Steven Barth
[ Top ]Code: Select all
method info_channelUser [line 709]
array info_channelUser( integer $cID)
info_channelUser: Returns all users in the target channel in an array
Tags:
return: user list, false at failure
see: getPlayers(), for an array description
see: getChannelByName(), for converting a channel name to an ID
access: public
version: 2.0
author: Steven Barth
Parameters:
integer $cID The Channel IDCode: Select all
<?php
require("cyts.class.php");
$cyts = new cyts;
//Parameters are: IP-Address, TCP-Queryport, UDP-Port
$cyts->connect("xxxxxxxxxx", 51234, xxxx) or die ("Unable to connect to TeamSpeak-server");
$cyts->login("admin", "pass");
header("Content-type: image/png");
$bg = "teamspeakimg.png";
$im = @ImageCreateFromPNG($bg);
$width =1;
$font = 2;
$fonta = 3;
$black = imagecolorallocate($im, 255, 255, 255);
$users = $cyts->admin_dbUserList();
$srvinfo = $cyts->info_serverInfo();
$playerlist = $cyts->info_playerNameList( );
$tsusers = $cyts->info_playerList();
imagestring($im, $font, 5, 5,$srvinfo["server_currentusers"] , $black);
imagestring($im, $font, 20, 5,"users online", $black);
imagestring($im, $font, 5, 20,$srvinfo["server_name"] , $black);
imagestring($im, $font, 5, 30,$srvinfo["server_uptime"] , $black);
imagestring($im, $font, 5, 45,$tsusers["nick"] , $black);
imagePNG($im);
ImageDestroy;
?>Code: Select all
<?php
require("cyts.class.php");
$cyts = new cyts;
$cyts->connect("xxxxxxxxxx", 51234, xxxx) or print "Cannot connect to server.";
$cyts->login("admin", "pass");
$list = $cyts->info_channelList();
$users = $cyts->admin_dbUserList();
$tsusers = $cyts->info_playerList();
$tsserv = $cyts->info_serverInfo();
echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" class=\"team\">";
$server=false;
if ($tsserv[server_name] == NULL) $server=true;
if ($server == true) { echo "<tr><td>The server is Offline</td></tr>"; } else { echo "
<tr>
<td colspan=\"3\" align=\"left\" nowrap=\"nowrap\">
<img src=\"images/teamspeak_online.png\" alt=\"TS server\" width=\"16\" height=\"16\" />
$tsserv[server_name]
</td>
</tr>";}
foreach ($list as $channel) {
echo "
<tr>
<td nowrap=\"nowrap\" align=\"left\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/channel.png\" alt=\"TS channel\" width=\"16\" height=\"16\" />
$channel[name]:
</td>
</tr>";
$chanUsers = $cyts->info_channelUser($channel["id"]);
if (!empty($chanUsers) && is_array($user))
{
foreach ($chanUsers as $user) {
echo "
<tr>
<td nowrap=\"nowrap\" align=\"left\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/treeimage3.png\" alt=\"tree\" width=\"16\" height=\"16\" />
<img src=\"images/online.gif\" alt=\"online\" width=\"16\" height=\"16\" />
$user[nick]
</td>
</tr> ";
}}
}
echo "
<tr>
<td height=\"12\">
<br />
<p>
<img src=\"images/black.gif\" width=100 height=1 vspace=1 alt=\"line\">
<br /> Members Offline:<br />
<img src=\"images/black.gif\" width=100 height=1 vspace=1 alt=\"line\">
</p>
</td>
</tr>";
foreach ($users as $offline) {
//Go through the memberlist
$online = false;
//At first we believe he/she is offline
foreach ($tsusers as $tsuser)
{
//Go through the list of users which are online in TS
if ($tsuser["loginname"] == $offline[5]) $online = true;
//If someone who is online in TS is logged in with the member's loginname change the status to true
}
//If he is online print nothing else print offline
if ($online ==false) echo "
<tr>
<td title=\"last login $offline[4]\" align=\"left\" valign=\"middle\">
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/treeimage4.png\" alt=\"blank\" width=\"16\" height=\"16\" />
<img src=\"images/offline.gif\" alt=\"offline\" width=\"16\" height=\"16\" />
$offline[5]
</td>
</tr>
";
} echo"</table>
<br />";
?>Code: Select all
$list = $cyts->info_channelList();
$chanUsers = $cyts->info_channelUser($channel["id"]);
print_r($list);
print_r($chanUsers);