1. When making a thread, please tag your thread accordingly using the menu to the left of the textfield where you name your thread where applicable. Server Advertisements and Mod Releases should be contained to their respective subforums.

Server Help Tools for server administration

Discussion in 'Multiplayer' started by Meuhmeuh, Dec 12, 2013.

  1. Ripe

    Ripe Space Hobo

    Yes I know you can but short tags were only enabled by default in PHP5, it's just safer to use echo.
     
    danks_ likes this.
  2. wolvern

    wolvern Orbital Explorer

    can anyone tell me how to get the "Info: <username> " to come up in a
    return preg_match('/ /', $line);?
     
  3. danks_

    danks_ Existential Complex

    damn me, I know I haven't used php for about 2 years now, I'll need to try that.

    Thanks to you and Plnda :)
     
  4. Plnda

    Plnda Industrial Terraformer

    whate are you trying to accomplish? getting the chats ?
     
  5. nithon

    nithon Seal Broken

    hey, thanks everyone for the fixes provided to the script.

    ill added ripe's fixes for regexp & htmlentities :)

    https://gist.github.com/dkesberg/7926899

    @shidib
    allow_url_fopen must be set to read remote file with file_get_contents, but i havent tested any remote yet so it may be something different

    /edit ok i just uploaded mylog to a pastebin and could read it so should be allow_url_fopen.
    you can also et display errors to true in line 8 to "hopefully" get an idea why it isnt working
     
    Last edited: Dec 15, 2013
  6. Shirou

    Shirou Aquatic Astronaut

  7. wolvern

    wolvern Orbital Explorer

    I want to get the chats so i can add it into a website and then possibly find a way to implement a chat interface to allow people on site to communicate with people in game...
     
  8. Plnda

    Plnda Industrial Terraformer

    use the following regexp
    PHP:
    !Info\:\s*<([^>]{2,})>\s?(.*)!i
    trying to get to chat ingame is going to be hard unless you know how there tcp protocol works
     
  9. wolvern

    wolvern Orbital Explorer

    took me hours to find... i'm new to PHP coding... but damn i persisted...

    <?php echo htmlspecialchars($Chats); ?>

    i didn't know that <> would be taken out of the chat... i looked around for hours to get it working.... hehe... go the persistent kitty!!

    http://pastebin.com/aNvCaW2i
     
  10. nithon

    nithon Seal Broken

    moiph likes this.
  11. shibdib

    shibdib Starship Captain

    I'm stumped on how to get these to work remotely. Hosting the log and downloading it via python isn't working for numerous reasons. (Log doesn't update being the main)
     
  12. nithon

    nithon Seal Broken

    @shibdib
    you may be able to symlink the log file if you have a web server on your starbound server running
     
  13. shibdib

    shibdib Starship Captain

    I moved my site off that box so I didn't need to waste resources on a webserver :p

    I'll probably just find a lightweight one and host that page and iframe it onto my site. Probably the easiest route to take
     
  14. moiph

    moiph Void-Bound Voyager

    I happen to be running Starbound on a Windows server, so I've already got IIS and .net available. Rather than installing php/python etc I took nithon's existing script (https://gist.github.com/dkesberg/7926899) and ported it over to asp.net:

    https://gist.github.com/moiph/7977253

    nithon let me know if you have any issues with that -- I did call out yours directly from comments in mine. The UI is exactly the same, it's just c# instead of php :) Only thing I didn't port over was the server online status, but I can update it later to include more.
     
    Last edited: Dec 15, 2013
    nithon likes this.
  15. nithon

    nithon Seal Broken

    no issues have fun forking :)
     
  16. unleashurgeek

    unleashurgeek Space Spelunker

  17. Seriallos

    Seriallos Space Penguin Leader

  18. wolvern

    wolvern Orbital Explorer

    Last edited: Dec 16, 2013
  19. nithon

    nithon Seal Broken

  20. Clinton

    Clinton Zero Gravity Genie

    Here's a python script I made. Name it anything you want .py

    It's simple to run, just enter in your logfile location and run it with: python stat.py

    It's similar to the already released who.py, but this works with the latest version of Starbound.

    Code:
    import re
    
    
    ### Enter your log file location. This can be relative or absolute.
    log_dir = '/home/clinton/starbound:21025/starbound_server.log'
    
    def main():
        clients = {}
        line_num = 0
        log = open(log_dir, 'r')
        for line in log:
            line_num += 1
            match = re.search('^Info: (.*)$', line)
            try:
                line = match.group()
                stat = ''
                status = line.split('<User: ')
                if status[0].find('Loading ship') != -1:
                    stat = 'connected'
                if status[0].find('disconnected') != -1:
                    stat = 'disconnected'
                    s = status[0].split("'")
                    user = s[1]
                    clients[user] = stat
                if len(status) > 1:
                    user = status[1].replace(">", "")
                    clients[user] = stat
            except AttributeError:
                pass
    
        total = len(clients.keys())
        for player, stat in clients.items():
            if stat == 'disconnected':
                del clients[player]
    
        print "Total Unique Players: %s" % total
        print "Total Connected Players: %s" % len(clients.keys())
        for player, stat in clients.iteritems():
            print "[Client %s = %s]" % (player, stat)
    
    main()
     

Share This Page