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. Shirou

    Shirou Aquatic Astronaut

    Yip

     
  2. wolvern

    wolvern Orbital Explorer

    http://pastebin.com/YHpNLZGx

    I fixed up daniel's status / online person script for php.... yes... i don't know much php... so i went by errors and fixed it that way.... it's a quick patch that made it work

    line 119 - <td><?php echo 'www.colony-nyan.com'; ?></td>

    It wasn't working for me... so i fixed it this way
     
  3. Plnda

    Plnda Industrial Terraformer

    i haven't made a single change to my script. everything is still working

    Detect Chats Rexex :
    PHP:
    !Info\:\s*<([^>]{2,})>\s?(.*)!i
    Detect Client Rexex :
    PHP:
    !%Info: (.*) Client <([0-9]*)> <User: ([0-9a-zA-Z\s]*)>%i
     
  4. Shirou

    Shirou Aquatic Astronaut

    Still waiting for yours to be released :D
     
  5. Ripe

    Ripe Space Hobo

    I wasn't able to get your snipplet working but if you use the same regex as I used in the other script it works with some other minor adjustments:

    PHP:
        /**
        * little parser for the logs file
        *
        * use a preg_match to check a connected ora disconnected user
        */
        
    private function parseClient(){
            
    $file fopen($this->path,"r");

            if(
    $file){
                while((
    $line fgets($file))){
                    if(
    preg_match("%Info: Client \\'(.*)\\'.*?\(.*?\)(.*)%i"$line$val)){
                        
    $status trim($val[2]);
                        if(
    $status =="connected"){
                            
    $this->players[$val[1]] = 1;
                        } else {
                            
    $this->players[$val[1]] = 0;
                        }
                    }else if(
    preg_match("%Info: Server version '([0-9a-zA-Z\.\s]*)' '([0-9]*)' '([0-9]*)'%i"$line$val)){
                        
    //Info: Server version 'Beta v. Indignant Koala' '622' '424'
                        
    if(isset($val) && count($val)>1){
                            
    $this->version "";
                            for(
    $i=1$i<count($val);$i++){
                                
    $this->version .= $val[$i]." ";
                            }
                        }
                    }else{
                        
    //nothing to do
                        //adding some parsing line
                    
    }
                }
                
    fclose($file);
            }
        }
     
    Last edited: Dec 15, 2013
    danks_ likes this.
  6. danks_

    danks_ Existential Complex

    Thanks a lot!! :DDD
     
  7. Clinton

    Clinton Zero Gravity Genie

    I have a python script that parses unique users, current connected users, and all the chat messages on the server if anyone is interested. It's pretty similar to who.py, except has chat messages and total unique players added.
     
  8. shibdib

    shibdib Starship Captain

    Using wolverns updated script im trying to get it to read a webhosted log file but it doesn't seem to work. Trying to use

    PHP:
    $config = array(
        
    'server'    => array(
            
    'hostname'  => '66.187.75.150',
            
    'port'      => 21025
        
    ),
        
    'paths'    => array(
            
    'log' => file_get_contents('http://66.187.75.150:8080/starbound_server.log')
        )
    );
    I just moved my webserver to a seperate box, and I'm using mongoose (doesn't support php) as a lightweight web server on the game box.
     
  9. Ripe

    Ripe Space Hobo

    Just remove the file_get_contents around the value. So it becomes:

    PHP:
    $config = array(
        
    'server'    => array(
            
    'hostname'  => '66.187.75.150',
            
    'port'      => 21025
        
    ),
        
    'paths'    => array(
            
    'log' => 'http://66.187.75.150:8080/starbound_server.log'
        
    )
    );
    Not sure I would recommend doing it this way since that file is going to become massive and the status page will take longer to load.
     
  10. shibdib

    shibdib Starship Captain

    I've tried it that way and it doesn't seem to work. Currently trying to get it to create a local version using

    PHP:
    $sblog 'sblog.log';
    $updatelog file_get_contents('http://66.187.75.150:8080/starbound_server.log');
    file_put_contents('$sblog, $current') ;
    at the top and then pointing to " /var/www/sblog.log" as the log file.
     
  11. Ripe

    Ripe Space Hobo

    Change
    PHP:
    file_put_contents('$sblog, $current') ;
    to just
    PHP:
    file_put_contents($sblog$updatelog);
    Quotes aren't needed.
     
  12. shibdib

    shibdib Starship Captain

    Hmm tried without quotes and it's not creating a sblog.log file.
     
  13. wolvern

    wolvern Orbital Explorer

    if you don't want it getting huge... make the script cut it into pages of text and dump off the useless lines.... that way you get limited info at a time

    edit:

    and yes i'm storing my server with the php pages on the same machine... it works well....
     
  14. shibdib

    shibdib Starship Captain

    I had just put this at the top of your php script, would i be better off making a seperate one and having yours call it? Not sure why it would change anything tho as it still isn't creating the file.
     
  15. danks_

    danks_ Existential Complex

    Ripe, I've been having some trouble, I'm retesting this (like always) on Windows before moving it to the linux server and it shows nothing at all. I know the path is right because if I do a fopen, fread and echo I get all my text back. In fact, I can do $r->AddAcount(x, y); $r->writeData(); and have it work, he creates the account no problem, but anything that has to do with the log, like $l->countPlayers, returns nothing.
    I get absolutely nothing back. No error, but I also don't get any false information, it's just blank.

    I'm just scared of updating it to the linux version to have the same error, I'm just worried it's the parser that's not working.

    I'm using this path
    PHP:
    private $path "C:\\Steam\\SteamApps\\common\\Starbound\\starbound_server.log";
    this is how the functions look in the index.php
    PHP:
    <?php
    include('inc/log.class.php');
    $call = new Logs();
    include(
    'inc/register.class.php');
    $r = new Register(); ?>
    (I've tried include, require and require_once, just to be sure, register works fine with all those, logs doesn't)

    This is my current parser

    PHP:
    /**
        * little parser for the logs file
        *
        * use a preg_match to check a connected ora disconnected user
        */
        
    private function parseClient(){
            
    $file fopen($this->path,"r");

            if(
    $file){
                while((
    $line fgets($file))){
                    if(
    preg_match("%Info: Client \\'(.*)\\'.*?\(.*?\)(.*)%i"$line$val)){
                        
    $status trim($val[2]);
                        if(
    $status =="connected"){
                            
    $this->players[$val[1]] = 1;
                        } else {
                            
    $this->players[$val[1]] = 0;
                        }
                    }else if(
    preg_match("%Info: Server version '([0-9a-zA-Z\.\s]*)' '([0-9]*)' '([0-9]*)'%i"$line$val)){
                        
    //Info: Server version 'Beta v. Indignant Koala' '622' '424'
                        
    if(isset($val) && count($val)>1){
                            
    $this->version "";
                            for(
    $i=1$i<count($val);$i++){
                                
    $this->version .= $val[$i]." ";
                            }
                        }
                    }else{
                        
    //nothing to do
                        //adding some parsing line
                    
    }
                }
                
    fclose($file);
            }
        }
    ]

    I know you told me you didn't get it working, but, when you said minor changes, did you also mean minor changes to other parts of the file? I think this code is a lot easier to implement in a bigger site.
    Also, if there's no easy way for you to answer, please let me know and I'll just see if I can turn the other one into a function based file, I guess, I don't want to disturb you from anything for something that can be replaced.

    EDIT: Nvm, I'll use yours, thanks for the awesome release :)
     
    Last edited: Dec 15, 2013
  16. Plnda

    Plnda Industrial Terraformer

  17. Ripe

    Ripe Space Hobo

    When you say $l->countPlayers() doesn't work, have you tried $call->countPlayers() because that's what you initialised the class as. If that was just a typo, maybe PM me your code pasted on pastebin.com and I'll take a look
     
  18. danks_

    danks_ Existential Complex

    It was just a typo, what I used on the website was
    PHP:
    ...
                    <?php $call->getServerVersion(); ?>
    ...
                    <?php $call->countPlayers(); ?>
    ...
    but like I said, I'll give yours a try, if It doesn't work I'll send you a PM, thanks a lot
     
  19. Ripe

    Ripe Space Hobo

    Oh right, you need to do

    PHP:
    echo $call->getServerVersion();
    echo 
    $call->countPlayers();
    Those functions only return values, they don't echo.
     
    danks_ likes this.
  20. Plnda

    Plnda Industrial Terraformer

    you know you can do this right

    PHP:
    <?=$call->getServerVersion()?>
    same as

    PHP:
    echo $call->getServerVersion();
     
    danks_ likes this.

Share This Page