Game server HTMLs display in hub
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Game server HTMLs display in hub

Started by achiever, 20 June, 2007, 08:45:33

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

achiever

hi,

i have software (aGsm) which gets me the information of our local game servers and save the information as html files.
i need a script to show this files in my hub in an arranged manner with details from the files.

can some plzz script it for me.

thanks,
achiever.
the files shows information like

extended infromation for HalfLife-TFC-CS server lol?!?!?

Address: 172.19.25.184:27015
Players: 16 / 32
Game : HalfLife-TFC-CS
Map : fy_iceworld_cz
Ping : 16

the in formation in bolds are constants and the values keep on changing from server to server.

i need this to be shown as
Game: Condition Zero  Server: 172.19.25.184:27015  Map: fy_iceworld_cz  Hostname: lol?!?!?  Ping: 16  Players: 16/32   [Bill(3)  TYrone!!!!!!!!(2)  Dustin(1)  Toby(0)  Opie(0)  Josh(0)  Pat(0)  Calvin(0) Clarence(0)  Frank(0)  Alfred(0) Fred(0)  Ulric(0)  Perry(0)  Will(0)  Frasier(0)  -- which is in order of player-name(frags)]

and this information shown for all the servers listed.

plzz c the attached file,
i hope i was able to explain it properly.

thnks for help,
achiever.
thks,
achiever.

bastya_elvtars

#1
  List of servers on our LAN    List of servers, our LAN 

June 18, 2007 at 13:01:14  

	#	Name	Address	Players	State	Game	Launch! 

 	1 	Counter-Strike: Condition Zero 	172.19.19.90:27015 	13/13 	running 	HalfLife-TFC-CS 	GO 

 	2 	lol?!?!? 	172.19.25.184:27015 	16/32 	running 	HalfLife-TFC-CS 	GO 

 	3 	Condition Zero 	172.19.3.20:27015 	18/20 	running 	HalfLife-TFC-CS 	GO 


Do you like this?
Everything could have been anything else and it would have just as much meaning.

achiever

can it be
#   Game   Host-Name   Address   Map   Ping      Players

game mentioned should be 1st, then the name which is really the host name and also ping and map info from the linked files
the state and launch will not be needed in hub

thanks,
achiever.
thks,
achiever.

bastya_elvtars

Quote from: achiever on 20 June, 2007, 15:33:50
can it be
#   Game   Host-Name   Address   Map   Ping      Players

game mentioned should be 1st, then the name which is really the host name and also ping and map info from the linked files
the state and launch will not be needed in hub

thanks,
achiever.

I'm afraid it is not easy to do since I am just parsing the HTML files. Can't you change the way your program fetches the info?
Everything could have been anything else and it would have just as much meaning.

achiever

#4
hmm i'll try to work it out :-(, but i m sure i'll not be able add nething to main file. still have go can u please think of some way to do this?
i have done changes to the sub files which now shows all the info in order.

so now can we take it directly from the subfiles only?

i m attaching the changed files
thks,
achiever.

bastya_elvtars

  List of servers on our LAN    List of our LAN servers 

June 20, 2007 at 20:16:04  

	#	Name	Address	Players	State	Game	Launch! 

 	1 	:D:D 	172.19.1.103:27015 	6/32 	running 	HalfLife-TFC-CS 	GO 

 	2 	Counter-Strike: Condition Zero 	172.19.19.90:27015 	13/13 	running 	HalfLife-TFC-CS 	GO 

 	3 	*)((_.NeelZ._))(* 	172.19.33.66:27015 	13/32 	running 	HalfLife-TFC-CS 	GO 

 	4 	pass-->hAha 	172.19.30.40:27015 	16/22 	running 	HalfLife-TFC-CS 	GO   


The sdf files contain way too few info.
Everything could have been anything else and it would have just as much meaning.

achiever

ok i think i get it now, we can not pick only the information we want from html files as we can from text files to be displayed, correct?

so u posted the 1st file info only.

i have removed all the other info from the sub files except the required once can it be done now.
plzz have a look.

if not yet, cant we convert it to text files first then go do it?

thanks for being patient,
achiever.
thks,
achiever.

bastya_elvtars

I cannot fetch them from the text version either, if I only have the HTML, because I do not know which table header belongs to which column in the table. :(
Everything could have been anything else and it would have just as much meaning.

achiever

i did not understand u difficulty?

do u need the info in a table manner?

or is it a dead end with no solution  :'(
i have made it in table form.
plzz plzz try now  :-\
attached files,
thanks
achiever.
thks,
achiever.

bastya_elvtars

Wouldn't that be easier to serve the HTML files with the PtokaX webserver and announce links in mainchat?
Everything could have been anything else and it would have just as much meaning.

achiever

i run a lan hub and have no webserver. :(
but u were getting the display alright for main file?
then y not for the others, actually now the main lan file is not required all the the data needed is there in sub files.
thks,
achiever.

bastya_elvtars

Quote from: achiever on 20 June, 2007, 19:25:27
i run a lan hub and have no webserver. :(

So what? If the users are from the LAN anyway, you just make your program put the HTML files into the webroot of the builtin PtokaX webserver, create a script that checks the list periodically, then the script will post the links to the files (eg. http://192.168.77.88:1234/fpsserv1.html)
Everything could have been anything else and it would have just as much meaning.

achiever

for the eg. page i m getting The page cannot be displayed

but u were making the display earlier,
Quote from: bastya_elvtars on 20 June, 2007, 13:19:38
  List of servers on our LAN    List of servers, our LAN 

June 18, 2007 at 13:01:14  

	#	Name	Address	Players	State	Game	Launch! 

 	1 	Counter-Strike: Condition Zero 	172.19.19.90:27015 	13/13 	running 	HalfLife-TFC-CS 	GO 

 	2 	lol?!?!? 	172.19.25.184:27015 	16/32 	running 	HalfLife-TFC-CS 	GO 

 	3 	Condition Zero 	172.19.3.20:27015 	18/20 	running 	HalfLife-TFC-CS 	GO 


Do you like this?
cant it be done now?

sorry for being persistant, i have just tried too hard for this 1.
achiever
thks,
achiever.

bastya_elvtars

Ah, it is a bit hard to make you understand. :-)
I'll make you an example.
Everything could have been anything else and it would have just as much meaning.

achiever

i really m confused now :P that all the files are almost the same.

i think ur example will make it clear to me :)
bastya  ;D ;D ;D

i have finally got all the detals to come in 1 file the main lan file :D :D :D

now plzz can u make the script or its making it being the difficult part? ::)

thanks,
achiever
thks,
achiever.

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

achiever

oh! wow!

plzz explain how, or can u give me the link where i can find how to do it?

and did u c my last post???

thanks neways,
achiever.
thks,
achiever.

bastya_elvtars

Just create directories in the PtokaX root folder:
html
html\webstats

and put the html files into html\webstats directory.
Of course you can use an external webserver, like shttpd for this as well, since the PtokaX webserver is broken as hell.
Now you will need a script that announces these files. OR you can create an index.html linking to all files there.
Everything could have been anything else and it would have just as much meaning.

achiever

ok thanks,
i think i'll try this tomorrow now.
neways i would still be much happier with a script if a could show the file as its in hub.

thanks a lot bastya for ur help :)
achiever.
thks,
achiever.

bastya_elvtars

I'll prepare that script for you but have some questions:
- Is there only one file to be displayed?
- Is there anything else to be added to the displayed message, like links or other stuff?
Everything could have been anything else and it would have just as much meaning.

achiever

u kno what i can dance on hereing that.

-yes just the main lan.html only like u asked earlier would be too good, as i have managed to get all info to it
-no just show it in hub on cammands +servers

u made my day after all :)
thanks,
achiever.
thks,
achiever.

bastya_elvtars

#21
Code: lua
--[[
This is a sample script base dupon my HTML parser
It grabs the content of a specified HTML file
and displays it in given intervals or on-demand.
Requested by achiever.

Distributed under a modified BSD license, see at the end of the file]]

-- Settings.

Timer = 0 -- Set to 0 to disable, otherwise specify the interval in minutes.

Command = "servers" -- The command for getting the serverinfo. NO prefix!

Filename = "Y:/Servers/lan.html"

-- End of settings, only edit below if you know what you are doing.

function Main()
  if Timer ~= 0 then
    SetTimer (Timer*60000)
    StartTimer()
  end
end

function ChatArrival (user, data)
  local cmd = string.match (data, "^%b<>%s+[%+%!%-%?%§](%S+)%|$")
  if cmd == Command then
    user:SendData(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
    return 1
  end
end

function OnTimer()
  SendToAll(frmHub:GetHubBotName(),"\r\n"..HTML_ToText (Filename))
end

function HTML_ToText (file)
  -- Declare variables, load the file. Make tags lowercase.
  local nl = "\r\n"
  local text
  local f,err=io.open (file)
  if f then
    text = f:read ("*a")
    f:close()
  else
    SendToOps ("*** "..err)
    return
  end
  text = string.gsub (text,"(%b<>)",
  function (tag)
    return tag:lower()
  end)
  --[[ 
  First we kill the developer formatting (tabs, CR, LF)
  and produce a long string with no newlines and tabs.
  We also kill repeated spaces as browsers ignore them anyway.
  ]]
  local devkill=
    {
      ["("..string.char(10)..")"] = " ",
      ["("..string.char(13)..")"] = " ",
      ["("..string.char(15)..")"] = "",
      ["(%s%s+)"]=" ",
    }
  for pat, res in pairs (devkill) do
    text = string.gsub (text, pat, res)
  end
  -- Then we remove the header. We do this by stripping it first.
  text = string.gsub (text, "(<%s*head[^>]*>)", "<head>")
  text = string.gsub (text, "(<%s*%/%s*head%s*>)", "</head>")
  text = string.gsub (text, "(<head>,*<%/head>)", "")
  -- Kill all scripts. First we nuke their attribs.
  text = string.gsub (text, "(<%s*script[^>]*>)", "<script>")
  text = string.gsub (text, "(<%s*%/%s*script%s*>)", "</script>")
  text = string.gsub (text, "(<script>,*<%/script>)", "")
  -- Ok, same for styles.
  text = string.gsub (text, "(<%s*style[^>]*>)", "<style>")
  text = string.gsub (text, "(<%s*%/%s*style%s*>)", "</style>")
  text = string.gsub (text, "(<style>.*<%/style>)", "")
  
  -- Replace <td> and <th> with tabulators.
  text = string.gsub (text, "(<%s*td[^>]*>)","\t")
  text = string.gsub (text, "(<%s*th[^>]*>)","\t")
  
  -- Replace <br> with linebreaks.
  text = string.gsub (text, "(<%s*br%s*%/%s*>)",nl)
  
  -- Replace <li> with an asterisk surrounded by spaces.
  -- Replace </li> with a newline.
  text = string.gsub (text, "(<%s*li%s*%s*>)"," *  ")
  text = string.gsub (text, "(<%s*/%s*li%s*%s*>)",nl)
  
  -- <p>, <div>, <tr>, <ul> will be replaced to a double newline.
  text = string.gsub (text, "(<%s*div[^>]*>)", nl..nl)
  text = string.gsub (text, "(<%s*p[^>]*>)", nl..nl)
  text = string.gsub (text, "(<%s*tr[^>]*>)", nl..nl)
  text = string.gsub (text, "(<%s*%/*%s*ul[^>]*>)", nl..nl)
    
  -- Some petting with the <a> tags. :-P
--[[   local addresses = {}
  local c = 0
  for url,name in string.gfind (text, "<%s*a%s*href=[\'\"](%S-)[\'\"][^>]*>(.+)<%s*%/a%s*>") do
    c = c + 1
    string.gsub (name, "<%s*a%s*href=[^>]+>(.+)<%s*%/a[^>]*>",
    function (nm)
      nm = string.gsub (nm, "(%b<>)","")
      nm = nm.."["..c.."]"
      return nm
    end)
    table.insert (addresses, {url, name})
    print(url, nm)
  end ]]
  
  -- Nuke all other tags now.
  text = string.gsub (text, "(%b<>)","")
  
  -- Replace entities to their correspondant stuff where applicable.
  -- C# is owned badly here by using a table. :-P
  -- A metatable secures entities, so you can add them natively as keys.
  -- Enclosing brackets also get added automatically (capture!)
  local entities = {}
  setmetatable (entities,
  {
    __newindex = function (tbl, key, value)
      key = string.gsub (key, "(%#)" , "%%#")
      key = string.gsub (key, "(%&)" , "%%&")
      key = string.gsub (key, "(%;)" , "%%;")
      key = string.gsub (key, "(.+)" , "("..key..")")
      rawset (tbl, key, value)
    end
  })
  entities = 
  {
    ["&nbsp;"] = " ",
    ["&bull;"] = " *  ",
    ["&lsaquo;"] = "<",
    ["&rsaquo;"] = ">",
    ["&trade;"] = "(tm)",
    ["&frasl;"] = "/",
    ["&lt;"] = "<",
    ["&gt;"] = ">",
    ["&copy;"] = "(c)",
    ["&reg;"] = "(r)",
    -- Then kill all others.
    -- You can customize this table if you would like to, 
    -- I just got bored of copypasting. :-)
    -- http://hotwired.lycos.com/webmonkey/reference/special_characters/
    ["%&.+%;"] = "",
  }
  for entity, repl in pairs (entities) do
    text = string.gsub (text, entity, repl)
  end
--   text = text..nl..nl..("-"):rep(27)..nl..nl
--   
--   for k,v in ipairs (addresses) do
--     text = text.."["..k.."] "..v[1]..nl
--   end
  
  return text
  
end


--[[
Copyright (c) 2007, bastya_elvtars

All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this
      list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of the author nor the names of contributors may be used
      to endorse or promote products derived from this code without specific
      prior written permission.

THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
Everything could have been anything else and it would have just as much meaning.

achiever

[02:31] Syntax ...s\My Hub\scripts\new.lua:47: bad argument #1 to 'gsub' (string expected, got nil)
thks,
achiever.

bastya_elvtars

Everything could have been anything else and it would have just as much meaning.

achiever

thks,
achiever.

SMF spam blocked by CleanTalk