Activity/Online In database

Results 1 to 10 of 10
  1. #1
    Member doemondo is offline
    MemberRank
    Oct 2004 Join Date
    94Posts

    Activity/Online In database

    Right now im trying to get a script going that tells who is online and if the server is up (I got it with some registration ASP I got here)

    Anyways what it does to see if the server is online, it checks if there is 0 users online (which doesnt mean the server is off, and sometimes the server crashes while the database is still up so the database is on but the server isnt)

    OK to check if a user is online it checks the amount of times a user has logged in vs logged out (but again if the server crashes this doesnt count as a logout and screws everything up)

    Now is there a way (spot in the database) where it is kept to see if the user is actually active, what im trying to do is get an accurate list of who all is online. AlsoI would like to have a way to check if server is up or down also (So I could have a webpage saying the status, like if something tests the port or I dont know the process)

    Any ideas lemme know


  2. #2
    Sorcerer Supreme rstrst is offline
    Member +Rank
    Oct 2004 Join Date
    Russia, MoscowLocation
    320Posts
    You can check if server ports accepts connections

  3. #3
    Member doemondo is offline
    MemberRank
    Oct 2004 Join Date
    94Posts
    ooh very nice idea, umm, hehe i wish i knew asp better, but i catch on quick, il work on it

  4. #4
    Member doemondo is offline
    MemberRank
    Oct 2004 Join Date
    94Posts
    Ok man good idea on the online/offline thing, anyone know a good way I can make a script to see if the l2 server port is accepting connections? (in php or asp, whatever)

  5. #5
    Elite Member ~Nyx~ is offline
    Member +Rank
    Sep 2004 Join Date
    CANADALocation
    140Posts
    YEa we had that it just scans port.. 10 people on my server were using this, lol its annoying because you can see it pop up on the auth serv window (at first I thought people were trying to hack me rofl)

    Code:
    <?PHP
    function scanport($host, $port) {
        $sock = fsockopen($host, $port, &$num, &$error, 2);
        if ($sock) {
            if (getservbyport($port,"tcp")!=null) {
                $serv = getservbyport($port,"tcp");
            ** else {
                $serv = "Unknown";
            **
            echo "<font face=\"fixedsys\">Port: $port/tcp open. Service: $serv<br>\n";
            fclose($sock);
            unset($sock);
        **else{
            echo "<font face=\"fixedsys\">Port: $port/tcp CLOSED. Service: $serv<br>\n";
            unset($sock);
        **
    **
    
    /* Voorbeelden: */
    scanport("server1.pwn.be", 21);
    scanport("server1.pwn.be", 22);
    scanport("server1.pwn.be", 25);
    scanport("server1.pwn.be", 53);
    scanport("server1.pwn.be", 80);
    ?>
    The function scanport() will scan the server for an open port. This way you can make a "Server Status" page.

    Syntax:
    scanport(HOSTNAME, PORT);

    Examples:
    scanport("localhost", 21);
    scanport("server1.pwn.be", 25);
    scanport("www.phpfreakz.nl", 80);

    Set to scan the auth port





    (No I didnt write this, these things are readily available online for free)
    Last edited by ~Nyx~; 16-11-04 at 05:14 AM.

  6. #6
    Member angelofanarchy is offline
    MemberRank
    Nov 2004 Join Date
    46Posts
    i was just randomly fiddling is ASP (personally i got no clue howto program in ASP), but i managed looked at the current code to show top level people and richest and got this workin.

    Code:
    sub ListOnline
      dim query
      dim rs
      dim gender
      dim no
    
      response.write " <table width='180' border='0' align='center' cellpadding='0' cellspacing='1'>" & _
                     " <tr align='center' valign='middle' height=25>" & _
    		 " <td width='180'><strong>Online Players:</strong></td></tr>"
    
      query = "SELECT char_name,login,logout FROM [user_data] ORDER BY login DESC"
      set rs = Server.CreateObject("ADODB.RECORDSET")
      rs.open query, lin2world_conn, 1, 1
      while not rs.eof
    	no = no + 1
    		if rs("login") > rs("logout") then	
    			response.write "<tr align='center' valign='middle'>"	
    			response.write   "<td>" & rs("char_name") & "</td>"
    			response.write "</tr>"
    		end if
    	rs.movenext  	
      Wend
      rs.close
      set rs = nothing  
      response.write "</table>"
    end sub
    If the server crashes it will think the person is logged in.
    It works fine anough for me =/
    Hoep it helps

    ^^
    Last edited by angelofanarchy; 16-11-04 at 06:05 AM.

  7. #7
    Sorcerer Supreme rstrst is offline
    Member +Rank
    Oct 2004 Join Date
    Russia, MoscowLocation
    320Posts
    With some knowledge you can write stealth port scanner probably or use nmap =)
    http://www.insecure.org/nmap/
    It won't appear in auth, coz there will be no established connection.
    Last edited by rstrst; 16-11-04 at 09:04 AM.

  8. #8
    Newbie vint is offline
    MemberRank
    Jun 2004 Join Date
    13Posts
    hello, buys. in a days i wrote script in PHP to check status of server and print general info about it (accounts, heroes, status, online players). Amount of online players got not from database not from output of "netstat -n" command. It should be better than check of login/logout time from database (that works wrong on my server).
    Right now it wrote only for my needs and looks may be not so good. Also it was planning to work on separate web-server and game-server. With minimum load of game-server.
    one more thing - final result is image so you can include it in signature in forum.
    Hope it helps somenody.
    stat sample and script attached
    Attached Thumbnails Attached Thumbnails stat.png  
    Attached Files Attached Files
    Last edited by vint; 23-11-04 at 11:38 AM.

  9. #9
    Sorcerer Supreme rstrst is offline
    Member +Rank
    Oct 2004 Join Date
    Russia, MoscowLocation
    320Posts
    nice idea with a netstat... =)

  10. #10
    Member huynhngochai is offline
    MemberRank
    Mar 2004 Join Date
    SaigonLocation
    29Posts
    Don't need to test the online port, because I have a simple solution to check my server is online - and how many user connect to it, by SQL Script.

    You can use SQL Query, connect to lin2db database and test the query:

    SELECT TOP 1 * FROM lin2db..user_count
    WHERE DATEDIFF(minute, record_time, GETDATE())<=5 AND server_id=1
    ORDER BY record_time DESC


    If the query return record (NOT EOF), it's mean your server is online - and the result column world_user is the total user connect to your server.

    If it not return result (EOF), it's mean your server is fail or no one connect to your server.

    That's OK ?

    server_id = your server id



Advertisement