English   German
  #1  
Old 19-12-2002, 18:46
IRON_Sniper IRON_Sniper is offline
-= TeamSpeak User =-
 
Join Date: Jun 2002
Location: Madison, WI, USA
Posts: 11
IRON_Sniper is on a distinguished road
Question Question about the ASP script

First, thank you for making the ASP script!

I am trying to just get a simple list of on-line names from a TS server and spit it back out to file.

With the 1.5 TS servers, it was easy, because the server was sending out the user names to the ASP page every 3 minutes. (see an example at the top of http://iron-forums.homeip.net )

Now, in TS 2.0, the TS server does not send out the user names. Instead, we must query the TS server to get that information. To make this query, we need to use the methods provided by W3 Sockets.

Now, Dark-mixer has released ASP code that can do all of things, as long as you have installed W3 Sockets (again, Thanks!!!!!). I was looking through this code, and I understand how it all works. Using portions of this code, I am adapting my old TS 1.5 code to work with 2.0. However, there is one snippet of code that I cannot understand.

In FUNCTION.ASP where you define the GetUserInfo function, you have the following code:
Code:
	Function GetUserInfo(usrData,xID)
	  tmpArray = Split(usrData,vbTab)
	  For I = 0 To UBound(tmpArray) - 1
	   If Len(tmpUsr) > 0 Then tmpUsr = tmpUsr & vbTab
	   tmpUsr = tmpUsr & tmpArray(I)
	  Next
Where is tmpUsr defined? I searched through all of the ASP pages provided, and I did not see it declared anywhere, but on the 4th line of the function, you are looking at the length of tmpUsr.

If tmpUsr should be declared, where should it be declared and what is the default value?



BTW, here is modified code I have right now:

T2WEBPOST.ASP
(note that I just pass the command directly to the GetServerData function, because I am only interested in getting a plain list of current nicknames on the TS server)

Code:
<%@ LANGUAGE = "VBScript" %>
<!--#include file="inc_ts2.asp"-->
<%
Server = Request.ServerVariables("REMOTE_ADDR")
ConnPort = Request.ServerVariables("server_queryport")
Port = Request.ServerVariables("server_port")

UserData = GetServerData(Server,ConnPort,Port,"pl")
UserNames = Split(GetUserInfo(UserData,14),vbCrLf)

DisplayNames = ""

If Ubound(UserNames) > 0 Then
	For Ix = 0 To UBound(UserNames)
		If Ix = UBound(UserName) Then
			DisplayNames = DisplayNames & UserNames(Ix)
		Else
			DisplayNames = DisplayNames & UserNames(Ix) & ", "
		End If
	Next
Else
	DisplayNames = "no players online at this time"
End If

Dim objFSO, objTextFile
Const ForReading = 1, ForWriting = 2, ForAppending = 8
If Request.QueryString <> "" Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\inetpub\wwwroot\ts2\ts2_001.js", ForWriting, True)
	objTextFile.WriteLine "var dynText=''"
	objTextFile.WriteLine "dynText+='Teamspeak users on <b>" & Request.QueryString("server_name") & "</b> (" & Server & ") <br>on " & Now & " CST<br><b>" & DisplayNames & "</b>'"
	objTextFile.WriteLine "document.write(dynText)"
objTextFile.Close
Set objTextFile = Nothing
Set objFSO = Nothing
End If
%>

INC_TS2.ASP

Code:
Function GetServerData(xServer,xConnPort,xPort,xCommand)

	'Open w3 Socket
	set socket = Server.CreateObject("Socket.TCP")
		 
	'Setting up the virtual telnet session.
	socket.DoTelnetEmulation = true
	socket.TelnetEmulation = "vt100"
	socket.Host = xServer & ":" & xConnPort

	'Connection to the server.
	socket.Open()
	socket.WaitFor("[TS]")

	'Send command to server.
	socket.SendText(xCommand & " " & xPort & vbCrLf)
	socket.WaitFor("OK")

	'Storing the data
	GetServerData = socket.Buffer

	'Sending quit command to server.
	socket.SendText("quit" & vbCrLf)
	socket.WaitForDisconnect
	socket.Close()
	set socket = Nothing

End Function
	
	
	
Function GetUserInfo(usrData,xID)
	tmpArray = Split(usrData,vbTab)
	For I = 0 To UBound(tmpArray) - 1
		If Len(tmpUsr) > 0 Then tmpUsr = tmpUsr & vbTab
			tmpUsr = tmpUsr & tmpArray(I)
	Next

	xUsr = Split(tmpUsr,vbTab)
		If UBound(xUsr) >= 15 Then
			For I = 0 To UBound(xUsr) step 16
				If Len(xOutUsr) > 0 Then xOutUsr = xOutUsr & vbCrLf
					xOutUsr = xOutUsr & xUsr(I + int(xID))
			Next
				Else
					xOutUsr = ""
		End If
	GetUserInfo = xOutUsr
End Function


Comments, suggestions, improvements??? Please let me know, and Thanks in advance!

Last edited by IRON_Sniper; 20-12-2002 at 17:17.
Reply With Quote
  #2  
Old 23-12-2002, 20:42
Dark-mixer's Avatar
Dark-mixer Dark-mixer is offline
-= TeamSpeak Lover =-
 
Join Date: Oct 2002
Location: Denmark
Posts: 31
Dark-mixer is on a distinguished road
Send a message via ICQ to Dark-mixer Send a message via MSN to Dark-mixer
Hello Iron
First of all thx for you comment

Second
The function are pretty simple.
if tmpUsr isn't defined it will by default have a zero length.
The variable are for the first time defined in the line :
tmpUsr = tmpUsr & tmpArray(I)

If you would like to have your script reviewed just mail a copy to me, and i'll go through it

/Dark-MiXer
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:33.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Add to Bookmarks   |   Printview   |   Contact Us   |   Legal Notices