TinyPortal

Development => Support => Topic started by: IchBin on March 31, 2005, 08:29:44 AM

Title: layout php problem
Post by: IchBin on March 31, 2005, 08:29:44 AM
I have a script at my http://ichbin.is-a-geek.com site. On the left you should see a TeamSpeak block. In IE it does not display right. Can anyone tell me why? I'll post the code below if anyone dares to take a look. :) Sorry for the jumpled mess, but that's the way the coder did it. If I new how to format it without screwing it up I would. :)

<?php class ts_viewer
{var $g_AbsPath;
var
$g_serverAddress;
var
$g_serverQueryPort;
var
$g_serverUDPPort;
var
$g_serverPasswort;
var
$g_Default=1;
var
$g_tabellenbreite=170;
var
$g_sitetitle="";
var
$g_sitelink="";
var
$g_userName;
var
$g_playerList=array();
var
$g_channelList=array();
var
$g_channels=array();
function
ts_viewer ($_D="images/"){$this->g_AbsPath=$_D;} function _1(){unset($this->g_channels);
unset(
$this->$_F); unset($this->$_10); $this->g_sitetitle="";$this->g_sitelink=""; $this->g_tabellenbreite=400;
$this->g_Default=0;}
function
set_Viewer($_11="", $_12="", $_13=400, $_14=0){$this->g_sitetitle=$this->_9($_11,false); $this->g_sitelink=$_12; $this->g_tabellenbreite=$_13; $this->g_Default= $_14;} function set_Channels($_15=""){if ($_15 != "")$this->g_channels=explode (":", $_15); else unset($this->g_channels);} function show_ts_viewer($_16, $_17=8767, $_18=51234, $_19=""){$this->g_serverAddress=$_16; $this->g_serverQueryPort=$_18; $this->g_serverUDPPort=$_17; $this->g_serverPasswort=$_19; $this->_8(); $this->g_userName="Guest"; echo "<table border=\"0\" width=\"0".$this->g_tabellenbreite."\" cellpadding=\"0\" cellspacing=\"0\" class=\"tsviewer\">\n"; echo "<tr class=\"tsviewer\">\n"; echo "<td class=\"tsviewer\">\n"; echo "</td>\n"; echo "</tr>\n"; echo "<tr class=\"tsviewer\">\n"; echo "<td class=\"tsviewer\">\n"; echo "<table border=\"0\" width=\"".$this->g_tabellenbreite."\" cellpadding=\"0\" cellspacing=\"0\" class=\"tsviewer\">\n"; echo "<tr class=\"tsviewer\">\n"; if ($this->g_sitelink=="" || $this->g_sitelink=="http://") $_1A="<strong>&nbsp;".$this->g_sitetitle."</strong>"; else $_1A="<a href=\"".$this->g_sitelink."\" target=\"_blank\" class=\"tsviewer\"><strong>&nbsp;".$this->g_sitetitle."</strong></a>"; if ($this->g_sitelink=="") $this->g_sitelink="TeamSpeak"; echo "<td width=\"16\" class=\"tsviewer\"><img src=\"".$this->g_AbsPath."/TS/TeamSpeak/teamspeak.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td><td class=\"tsviewer\">$_1A</td>\n"; echo "</tr>\n"; echo "</table>\n"; $_1B=""; $_1C=count($this->g_channels); if ($_1C==0) {$_1B=@$this->_13();} else {for ($_1D=0;$_1D<count($this->g_channels);$_1D++) $_1B .= @$this->_14($this->g_channels[$_1D]);} if ($_1B != "") {echo $_1B;} else {echo ("<tr class=\"tsviewer\">\n");echo ("<td class=\"tsviewer\">\n"); echo ("<table border=\"0\" width=\"".$this->g_tabellenbreite."\" cellpadding=\"0\" cellspacing=\"0\" class=\"tsviewer\">\n"); echo ("<tr class=\"tsviewer\"><td class=\"tsviewer\" width=\"110\"align=\"center\" colspan=\"2\"><b>Offline</b></td></tr>\n"); echo ("</table>\n"); echo ("</td>\n"); echo ("</tr>\n");} echo ("<tr class=\"tsviewer\" title=\"www.the-targets.de\">\n"); echo ("<td class=\"tsviewer\">\n<br>\n"); echo ("<small><small>&nbsp;&nbsp;<a href=\"http://www.the-targets.de/\" target=\"_blank\" class=\"tsviewer\">Designed & created by Mike ÃÆ'ââ,¬Å¡Ãƒâ€šÃ,© 2004</a></small></small>"); echo ("</td>\n"); echo ("</tr>\n"); echo ("</table>\n");} function _5($_1E){$this->g_AbsPath=$_1E;} function _6($_1F) {if(strpos($_1F, '"')==0) $_1F=substr($_1F, 1, strlen($_1F) - 1); if(strrpos($_1F, '"')==strlen($_1F) - 1) $_1F=substr($_1F, 0, strlen($_1F) - 1); return $_1F;} function _7($_20) {if($_20==0) {$_20="CELP 5.1 Kbit"; } elseif($_20==1) {$_20="CELP 6.3 Kbit"; } elseif($_20==2) {$_20="GSM 14.8 Kbit";} elseif($_20==3) {$_20="GSM 16.4 Kbit";} elseif($_20==4) {$_20="CELP Windows 5.2 Kbit";} elseif($_20==5) {$_20="Speex 3.4 Kbit";} elseif($_20==6) {$_20="Speex 5.2 Kbit";} elseif($_20==7) {$_20="Speex 7.2 Kbit";} elseif($_20==8) {$_20="Speex 9.3 Kbit";} elseif($_20==9) {$_20="Speex 12.3 Kbit";} elseif($_20==10) {$_20="Speex 16.3 Kbit";} elseif($_20==11) {$_20="Speex 19.5 Kbit";} elseif($_20==12) {$_20="Speex 25.9 Kbit";} else {$_20="unknown (".$_20.")";} return $_20;} function _8() {$this->g_playerList=$this->_C($this->g_serverAddress, $this->g_serverQueryPort, $this->g_serverUDPPort);$this->g_channelList=$this->_A($this->g_serverAddress, $this->g_serverQueryPort, $this->g_serverUDPPort);} function _9($_21,$_22=true) {$_21=str_replace('\"','"',$_21);$_21=str_replace("\'","'",$_21); if ($_22) {if (substr($_21,0,1)=='"') $_21=substr($_21,1);if (substr($_21,-1)=='"') $_21=substr($_21,0,-1);} $_21=htmlentities("$_21"); return $_21;} function _A($_23, $_24, $_25) {$_10=array(); $_26="cl $_25\nquit\n"; $_27=@fsockopen ("$_23", $_24, &$_28, &$_29, 1); if (!$_27) {} else {$_2A=fputs($_27,$_26, strlen($_26)); if (!$_2A) {echo "Cannot read Data!<br>";} else {while($_2B=fgets($_27, 4096)) {$_2B=explode(" ", $_2B); $_2C=trim($_2B[0]); $_2D=trim($_2B[1]); $_2E=trim($_2B[2]); $_2F=trim($_2B[3]); $_30=trim($_2B[4]); $_31=trim("$_2B[5]"); $_31=$this->_9($_31); $_32=trim($_2B[6]); $_33=trim($_2B[7]); $_34=trim("$_2B[8]"); $_34=$this->_9($_34); $_35=$_2C; if ($_35 > 0) {$_10[$_35]=array("channelid" => $_35,"codec" => $_2D,"parent" => $_2E,"order" => $_2F,"maxplayers" => $_30,"channelname" => $_31,"attribute" => $this->_F($_32),"isdefault" => 0,"topic" => $_34);}}} fclose($_27);} usort($_10, array ($this, _B)); return $_10;} function _B ($_36, $_37) {if ($_36["order"]==$_37["order"]) {return (strcasecmp($_36["channelname"], $_37["channelname"]));}return ($_36["order"] < $_37["order"]) ? -1 : 1;} function _C($_23, $_24, $_25) {$_F=array(); $_26="pl $_25\nquit\n"; $_27=@fsockopen ("$_23", $_24, &$_28, &$_29, 1); if (!$_27) {} else {fputs($_27,$_26, strlen($_26)); while($_38=fgets($_27, 4096)) {$_38=explode(" ", $_38); $_39=trim($_38[0]); $_3A=trim($_38[1]); $_3B=trim($_38[2]); $_3C=trim($_38[3]); $_3D=trim($_38[4]); $_3E=trim($_38[5]); $_3F=trim($_38[6]); $_40=trim($_38[7]); $_41=trim($_38[8]); $_42=trim($_38[9]); $_43=trim($_38[10]); $_44=trim($_38[11]); $_45=trim($_38[12]); $_46=trim($_38[13]); $_47=trim("$_38[14]"); $_47=$this->_9($_47); $_48=trim("$_38[15]"); $_48=$this->_9($_48); $_49=$_39; $_F[$_49]=array("playerid" => $_49,"channelid" => $_3A,"receivedpackets" => $_3D,"receivedbytes" => $_3E,"sentpackets" => $_3B,"sentbytes" => $_3C,"paketlost" => $_3F / 100,"pingtime" => $_40,"totaltime" => $this->_11($_41),"idletime" => $this->_11($_42),"privileg" => $_43,"userstatus" => $_44,"attribute" => $this->_10($_45),"attribute_2" => $_45,"flags" => $this->_E($_44,$_43),"s" => $_46,"playername" => $_47);} fclose($_27);} usort($_F, array ($this, _D)); return $_F;} function _D ($_36, $_37) {return (strcasecmp(str_replace(htmlentities(" "),"",$_36["playername"]), str_replace(htmlentities(" "),"",$_37["playername"])));} function _E($_4A,$_4B) {if ($_4A=='13') {$_4C="(R <b>SA</b>";} else if ($_4A=='5') {$_4C="(R SA";} else if ($_4A=='4') {$_4C="(R";} else if ($_4A < '4') {$_4C="(U";} if ($_4B=='1') {$_4D=" CA)";} else {$_4D=")";} return $_4C.$_4D;} function _F($_4E) {if ($_4E=='30') {$_4F="(RMPSD)";} else if ($_4E=='28') {$_4F="(RPSD)";} else if ($_4E=='26') {$_4F="(RMSD)";} else if ($_4E=='24') {$_4F="(RSD)";} else if ($_4E=='22') {$_4F="(RMPD)";} else if ($_4E=='20') {$_4F="(RPD)";} else if ($_4E=='18') {$_4F="(RMD)";} else if ($_4E=='16') {$_4F="(RD)";} else if ($_4E=='15') {$_4F="(UMPS)";} else if ($_4E=='14') {$_4F="(RMPS)";} else if ($_4E=='13') {$_4F="(UPS)";} else if ($_4E=='12') {$_4F="(RPS)";} else if ($_50[9]=='11') {$_4F="(UMS)";} else if ($_4E=='10') {$_4F="(RMS)";} else if ($_4E=='9') {$_4F="(US)";} else if ($_4E=='8') {$_4F="(RS)";} else if ($_4E=='7') {$_4F="(UMP)";} else if ($_4E=='6') {$_4F="(RMP)";} else if ($_4E=='5') {$_4F="(UP)";} else if ($_4E=='4') {$_4F="(RP)";} else if ($_4E=='3') {$_4F="(UM)";} else if ($_4E=='2') {$_4F="(RM)";} else if ($_4E=='1') {$_4F="(U)";} else if ($_4E=='0') {$_4F="(R)";} else {$_4F="";} return $_4F;} function _10($_51) {$_52="player.gif"; if ($_51=="0") $_52="player.gif"; if (($_51=="8") or ($_51=="9") or ($_51=="12") or ($_51=="13") or ($_51=="24") or ($_51=="25") or ($_51=="28") or ($_51=="29") or ($_51=="40") or ($_51=="41") or ($_51=="44") or ($_51=="45") or ($_51=="56") or ($_51=="57")) $_52="away.gif"; if (($_51=="16") or ($_51=="17") or ($_51=="20") or ($_51=="21")) $_52="mutemicro.gif"; if (($_51=="32") or ($_51=="33") or ($_51=="36") or ($_51=="37") or ($_51=="48") or ($_51=="49") or ($_51=="52") or ($_51=="53")) $_52="mutespeakers.gif"; if ($_51 >= "64") $_52="record.gif"; if ($_51=="4") $_52="player.gif"; if (($_51=="1") or ($_51=="5")) $_52="channelcommander.gif"; return $_52;} function _11($_53) {$_54="0 seconds"; if ($_53 < 60 ) {$_54=strftime("%S seconds", $_53);} else {if ($_53 >= 3600 ) {$_54=strftime("%H:%M:%S hours", $_53 - 3600);} else {$_54=strftime("%M:%S minutes", $_53);}} return htmlentities("$_54");} function _12($_55, $_56, $_57) {$_58=""; foreach($this->g_playerList as $_59) {if ($_59[channelid]==$_56) {$_58 .= ("<tr class=\"tsviewer\">\n"); $_58 .= ("<td class=\"tsviewer\">\n"); $_58 .= (" <table border=\"0\" width=\"180\" cellpadding=\"0\" cellspacing=\"0\" class=\"tsviewer\">\n"); $_5A=32; $_5B=""; for ($_1D=0;$_1D<=$_57;$_1D++) {$_5A+=16; $_5B .= "<img src=\"".$this->g_AbsPath."/TS/TeamSpeak/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\">";} $_58 .= ("   <tr class=\"tsviewer\"><td width=\"$_5A\" class=\"tsviewer\">$_5B<img src=\"".$this->g_AbsPath."/TS/TeamSpeak/gitter2.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"><img src=\"".$this->g_AbsPath."/TS/TeamSpeak/".$_59[attribute]."\" width=\"16\"height=\"16\" border=\"0\" alt=\"Time [online: ".$_59[totaltime]." | idle: ".$_59[idletime]."] Ping:".$_59[pingtime]."ms\"></td><td class=\"tsviewer\" title=\"Time [online: ".$_59[totaltime]." | idle:".$_59[idletime]."] Ping:".$_59[pingtime]."ms\"><small>&nbsp;".$_59[playername]." ".$_59[flags]."</small></td></tr>\n"); $_58 .= (" </table>\n"); $_58 .= ("</td>\n"); $_58 .= ("</tr>\n");}} return $_58;} function _13($_55=-1,$_57=0) {$_5C=""; if ($_55==-1) $_57=0; else $_57++; foreach($this->g_channelList as $_5D) {$_5E=$_5D[channelname]; $_20=$this->_7($_5D[codec]); if ($_5D[parent]==$_55) {$_5C .= ("<tr class=\"tsviewer\">\n"); $_5C .= ("<td class=\"tsviewer\">\n"); $_5C .= (" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"tsviewer\">\n"); $_5C .= ("   <tr class=\"tsviewer\" title=\"".$_5E." \nID: ".$_5D[channelid]."\">\n"); $_5A=32; $_5B=""; for ($_1D=1;$_1D<=$_57;$_1D++) {$_5A+=16; $_5B .= "<img src=\"".$this->g_AbsPath."/TS/TeamSpeak/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\">";} $_5C .= ("    <td width=\"$_5A\" class=\"tsviewer\">$_5B<img width=\"16\"height=\"16\" src=\"".$this->g_AbsPath."/TS/TeamSpeak/gitter2.gif\" border=\"0\" alt=\"\"><img src=\"".$this->g_AbsPath."/TS/TeamSpeak/channel.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td>"); if ($this->g_Default==0 || strpos($_5D[attribute],"D") > 0) {$_5C .= ("<td class=\"tsviewer\">&nbsp;<a href=\"teamspeak://".$this->g_serverAddress.":".$this->g_serverUDPPort."/?channel=".$_5E."?password=".$this->g_serverPasswort."\" title=\"".$_5D[topic]."\" class=\"tsviewer\"><strong>".$_5E."</strong></a></td>\n");} else {$_5C .= ("<td class=\"tsviewer\"><strong>&nbsp;".$_5E."</strong></td>\n");} if ($_57==0) $_5C .= ("<td class=\"tsviewer\"><small>&nbsp;".$_5D[attribute]."</small></td>\n"); $_5C .= ("  </tr>\n"); $_5C .= (" </table>\n"); $_5C .= ("</td>\n"); $_5C .= ("</tr>\n"); if ($_5C!="") $_5C .= $this->_13($_5D[channelid],$_57); $_5C .= $this->_12($_5D[channelid],$_5D[channelid],$_57);}} return $_5C;} function _14($_5F,$_55=-1,$_57=0) {$_5C=""; if ($_55==-1) $_57=0; else $_57++; foreach($this->g_channelList as $_5D) {$_5E=$_5D[channelname]; $_20=$this->_7($_5D[codec]); if (($_5D[parent]==$_55) && ($_5F==$_5D[parent] || $_5F==$_5D[channelid])) {$_5C .= ("<tr class=\"tsviewer\">\n"); $_5C .= ("<td class=\"tsviewer\">\n"); $_5C .= (" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"tsviewer\">\n"); $_5C .= ("<tr class=\"tsviewer\" title=\"".$_5E." \nID: ".$_5D[channelid]."\">\n"); $_5A=32; $_5B=""; for ($_1D=1;$_1D<=$_57;$_1D++) {$_5A+=16; $_5B .= "<img src=\"".$this->g_AbsPath."/TS/TeamSpeak/gitter.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\">";} $_5C .= ("<td width=\"$_5A\" class=\"tsviewer\">$_5B<img width=\"16\"height=\"16\" src=\"".$this->g_AbsPath."/TS/TeamSpeak/gitter2.gif\" border=\"0\" alt=\"\"><img src=\"".$this->g_AbsPath."/TS/TeamSpeak/channel.gif\" width=\"16\"height=\"16\" border=\"0\" alt=\"\"></td>"); if ($this->g_Default==0 || strpos($_5D[attribute],"D") > 0) {$_5C .= ("    <td class=\"tsviewer\">&nbsp;<a href=\"teamspeak://".$this->g_serverAddress.":".$this->g_serverUDPPort."/?channel=".$_5E."?password=".$this->g_serverPasswort."\" title=\"".$_5D[topic]."\" class=\"tsviewer\"><strong>".$_5E."</strong></a></td>\n");} else {$_5C .= ("    <td class=\"tsviewer\"><strong>&nbsp;".$_5E."</strong></td>\n");} if ($_57==0) $_5C .= ("<td class=\"tsviewer\">&nbsp;".$_5D[attribute]."</td>\n"); $_5C .= ("</tr>\n"); $_5C .= ("</table>\n"); $_5C .= ("</td>\n"); $_5C .= ("</tr>\n"); if ($_5C!="") $_5C .= $this->_14($_5F,$_5D[channelid],$_57); $_5C .= $this->_12($_5D[channelid],$_5D[channelid],$_57);}}return $_5C;}} ?>

Title: Re: layout php problem
Post by: Bjørn on March 31, 2005, 12:06:49 PM
Its a div problem in IE.

How do you call it?
Because if you enclose its output in a <div style="overflow: auto;">....</div> it will at least not push it to the right.

Or you could just make the left bar a little wider - to see if it helps. 
Title: Re: layout php problem
Post by: IchBin on March 31, 2005, 09:11:02 PM
I call it by include. I include a file called ts_view.php which inside that file includes the config.php file that I posted above. I'll enclose it all in a div and post back when I get a chance.
Title: Re: layout php problem
Post by: IchBin on April 01, 2005, 07:19:41 AM
The code you provided caused it to have scroll bars. I don't want scroll bars if possible. Also, the width of the left bar doesn't seem to matter. If I set it to 200 or 150 it still has that extended right side of the block.
Title: Re: layout php problem
Post by: JustClem on April 01, 2005, 07:26:46 AM
IchBin, it looks OK to me in FireFox. 

Is that TeamSpeak section included with TinyPortal?  It is pretty cool.
Title: Re: layout php problem
Post by: IchBin on April 01, 2005, 07:28:43 AM
Got it! Changed overflow to hidden which cuts it off and doesn't display whatever is on the end. Which in my case, was just blank space.

JustClem, all I did was create a phpbox block in Tinyportal and include the script I found at the goteamspeak.com website. I like being able to see who's online. :)
Title: Re: layout php problem
Post by: JustClem on April 01, 2005, 07:30:42 AM
Cool, thank IchBin.

I am working on trying to get my clan to swicth from phpBB to SMF, and eventually having a portal with our TeamSpeak server showing would rock.
Title: Re: layout php problem
Post by: Bjørn on April 01, 2005, 08:37:23 AM
Glad it worked out.:)
Title: Re: layout php problem
Post by: IchBin on April 02, 2005, 12:03:12 AM
You need any information or the Teamspeak script JustClem feel free to contact me.
Oh and thanks for the code Bloc.
Title: Re: layout php problem
Post by: JustClem on April 02, 2005, 02:47:47 AM
Thanks, Bloc and IchBin.   :)

And Bloc, your portal is excellent!  I hope to have some time this weekend to play with it and provide you some feedback.