PDA

View Full Version : Online Counter problem!


Quite
26-11-2006, 02:23
Hey peeps.

I added the addon Online Counter to our WoW-guild page the other night. The code looks like this:

<?
# TeamSpeak online counter v 1.0, 2006/02/14 10:11 CET
#
# Copyright (C) 2006 Bastian Schaar (www.teamspeak-einstieg.de)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this program; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307, USA.

######################## CONFIG SECTION ########################

$server_address = "xx.xx.xx.xx"; # your teamspeak servers IP or DNS address
$server_tcpport = "51234"; # your teamspeak servers tcp port (default: 51234)
$server_udpport = "8767"; # your teamspeak servers udp port (default: 8767)

##################### TRANSLATION VARIABLES ####################

$lang_no = "No";
$lang_offline = "Server offline";
$lang_online = "online";
$lang_user = "member";
$lang_users = "members";

######################### SCRIPT START #########################

include("includes/tcpquery.class.php");

$tcpquery = new tcpquery;

if($socket = $tcpquery->connect($server_address, $server_tcpport)) {
$serverinfo = $tcpquery->get_serverinfo($server_udpport);
if($serverinfo) {
if ($serverinfo[server_currentusers] == 1) {
echo "document.write('$serverinfo[server_currentusers] $lang_user $lang_online');";
}
elseif ($serverinfo[server_currentusers] > 0) {
echo "document.write('$serverinfo[server_currentusers] $lang_users $lang_online');";
}
else {
echo "document.write('$lang_no $lang_users $lang_online');";
}
}
}
else {
echo "Server Offline";
}
?>

It works like a charm aslong as the server is online, but once it's offline, it simply wont display on the homepage. It refuses to. I've tried everything, but when the server is offline it just displays nothing. (BTW the script above is edited a bit cause I tried so many different things).

The homepage is here: http://magiknights.liquenox.net/toysoldiers/portal.php

Hope someone can help me to get it to show "offline". I really am puzzled as to why it wont show it....

Quite
26-11-2006, 03:09
Problem sorted.

I fixed this, so if anyone else got this problem, this is how it's solved:

Simply remove the line

socket_set_timeout($this->socket, 2);

In the tcpquery.class.php file in the /includes folder.

(I think tcpquery.class.php was written for a more complex display mod and that could be the problem)....

Bastian
27-11-2006, 08:02
If it displays nothing, an error occurred.

The script should display an error message, but you cannot see it on the page where you added the JavaScript Code as the script returns errors in plain text format instead of JavaScript code. This plain text is than being misinterpreted as code and therefore considered invalid. That's why you get no output on your website.

Accessing the script directly will display the full output including all error messages. In your case, this would be http://magiknights.liquenox.net/toysoldiers/teamspeak/useronline.php.

The error message might enable me to find the problem. But as removing the socket_set_timeout() function solves the problem, it might be caused by your PHP configuration.

ScP
27-11-2006, 09:24
I thnik the main problem is, that you've used one of my outdated PHP classes without asking me for an updated version.

:p

Maybe you should update the script using CyTS or even libacts2.

Bastian
27-11-2006, 10:06
Why don't you simply fix this "problem" yourself then? We are talking about GPL licensed software here.

Do the changes and send them to my mail address.

I have no time to learn how CyTS or libacts2 works.

I have to play WOW. :p

Reedy Boy
27-11-2006, 10:43
I have to play WOW. :p


Who wants to throw the first insult?





*Reedy Boy wonders if this is why TS staff aren't releasing a date for TS3*

:p

Bastian
27-11-2006, 11:19
Should I send my pet over to you to "say hello"? :)

But you will have to wait until I'm back home as I don't play at the office. It's impossible anyway as we have a NPC here called "Proxy - protector of the company network" with level 60. He's using a special spell called "huge wall of fire" which burns all data packets that you shoot at him. ;)

Reedy Boy
27-11-2006, 12:06
Should I send my pet over to you to "say hello"? :)

But you will have to wait until I'm back home as I don't play at the office. It's impossible anyway as we have a NPC here called "Proxy - protector of the company network" with level 60. He's using a special spell called "huge wall of fire" which burns all data packets that you shoot at him. ;)

Lawl

:)

Walls of fire are ace

Quite
27-11-2006, 12:23
Hehe, well, worked fine after I just deleted that line in the query.php file thing stuff.

And yeah, I simply opened useronline.php in the browser, it pointed me to the error and I corrected it :-p

:p