Simple Server Status Information

Results 1 to 5 of 5
  1. #1
    Proficient Member w3bm4ster is offline
    MemberRank
    May 2014 Join Date
    CanadaLocation
    154Posts

    thumbs up Simple Server Status Information

    Hello RZ!

    I decided to develop a script that show some infos about Server Status. Currently, this script show:
    • Server Status: Online or Offline
    • Registered Accounts
    • Players Online / Record of Players Online


    Cons about this script is that you will don't need to break your mind trying to adapt into your current layout. You just need to pass the property and you're done. =)

    Download here:
    server-status_en.rar

    How to use:
    1 - Open the ConfigWrapper.php and add your data. (MySQL data, IP/Port of your server, etc).

    2 - Import the "online_record.sql"

    3 - In your site, add at the top:
    PHP Code:
    <?php   

    require_once("status-server.php");  

    $serverStatus = new ServerStatus();

    ?>
    And to show in your site. You just need to do as follow:

    PHP Code:
    <?php    
     
    echo "Server Status: $serverStatus->server_is_online <br />";     
     echo 
    "Registered Accounts: $serverStatus->registered_accounts <br />";     
     echo 
    "Players Online: $serverStatus->players_online ($serverStatus->players_online_record)"
    ?>
    Very simple. If you want to improve and/or have any suggestions or requests to the script. Please do this below and hit the Like Button!


  2. #2
    Account Upgraded | Title Enabled! shadowvzs is offline
    MemberRank
    Jul 2007 Join Date
    RomaniaLocation
    678Posts

    Re: Simple Server Status Information

    I checked your script, I am quite unfamiliar with pdo (I used mysqli) but look to me (beginer) it's clean.
    Btw if you did online count the is just a step to count gm online :)

    (Btw just a tip, you could put the error message into variable n into config file to be same place where user set the port etc so can use english error msg)

  3. #3
    Proficient Member w3bm4ster is offline
    MemberRank
    May 2014 Join Date
    CanadaLocation
    154Posts

    Re: Simple Server Status Information

    Quote Originally Posted by shadowvzs View Post
    I checked your script, I am quite unfamiliar with pdo (I used mysqli) but look to me (beginer) it's clean.
    Btw if you did online count the is just a step to count gm online :)

    (Btw just a tip, you could put the error message into variable n into config file to be same place where user set the port etc so can use english error msg)
    Oh! I forgot to translate the error message, is Brazilian Portuguese. About GM Online I'll add in script, I just want to think a way to make this easier like this informations above.

  4. #4
    Account Upgraded | Title Enabled! shadowvzs is offline
    MemberRank
    Jul 2007 Join Date
    RomaniaLocation
    678Posts

    Re: Simple Server Status Information

    Quote Originally Posted by w3bm4ster View Post
    Oh! I forgot to translate the error message, is Brazilian Portuguese. About GM Online I'll add in script, I just want to think a way to make this easier like this informations above.

    if you want i give few example what you can transform:

    Spoiler:

    if (isset($_GET['day'])){
    $days=intval($_GET['day']);
    if (($days > 0)&&($days<36500)){
    $query="SELECT uid FROM point WHERE lastlogin >= ( CURDATE() - INTERVAL $days DAY ) AND uid <> $AdminId";
    $statement = $link->prepare($query);
    $statement->execute();
    $statement->bind_result($id1);
    $statement->store_result();
    $result = $statement->num_rows;
    if (!$result) {
    echo "<script>alert('Do not exist user with that much inactive day since last login date.');</script>";
    exit;
    }else{
    $refresh=true;
    while($statement->fetch()) {
    DeleteUserAccount ($link, $id1);
    }
    echo "<script>alert('".$result." user deleted.');</script>";
    }
    $statement->close();
    }else{
    echo "<script>alert('Day must be between 0 and 36500');</script>";
    }
    }
    //if ($days==0){
    // $query="SELECT uid FROM point WHERE zoneid IS NOT NULL";
    //}else{
    // $query="SELECT uid FROM point WHERE lastlogin >= ( CURDATE() - INTERVAL $days DAY)";
    //}
    its delete account whos older than x day, same query could be used for who was active in last x day etc


    or a function for filter accounts
    Code:
    function ListUsers ($link, $sType, $txt ){
        echo"<script>
        var table = parent.document.getElementById('UserTable');
        var row;
        var cell;
        table.innerHTML = '';
        </script>";
        $sTypeTxt = "";
        if ($sType==1){
            $statement = $link->prepare("SELECT ID, name, truename, email FROM users");
            $sTypeTxt = "All User";
        }elseif ($sType==2){
            $statement = $link->prepare("SELECT ID, name, truename, email FROM users WHERE idnumber=?");
            $statement->bind_param('s', $txt);
            $sTypeTxt = "IP address";
        }elseif ($sType==3){
            $statement = $link->prepare("SELECT ID, name, truename, email FROM users WHERE ID=?");
            $statement->bind_param('i', $txt);
            $sTypeTxt = "Account Id";
        }elseif ($sType==4){
            $statement = $link->prepare("SELECT ID, name, truename, email FROM users WHERE name LIKE CONCAT(?,'%') OR truename LIKE CONCAT(?,'%')");
            $statement->bind_param('ss', StrToLower($txt), $txt);
            $sTypeTxt = "User or Real name";
        }elseif ($sType==5){
            $statement = $link->prepare("SELECT ID, name, truename, email FROM users WHERE email=?");
            $statement->bind_param('s', $txt);
            $sTypeTxt = "Email address";
        }elseif ($sType==6){
            $statement = $link->prepare("SELECT users.ID, users.name, users.truename, users.email FROM users INNER JOIN point ON users.ID=point.uid WHERE point.zoneid IS NOT NULL");
            $sTypeTxt = "Online User";
        }elseif ($sType==7){    
            $query = "SELECT users.ID, users.name, users.truename, users.email FROM users INNER JOIN point ON users.ID=point.uid WHERE point.lastlogin >= ( CURDATE() - INTERVAL $txt DAY)";
            $statement = $link->prepare($query);
            $sTypeTxt = "Was On in last $txt day";
        }elseif ($sType==8){
            $statement = $link->prepare("SELECT users.ID, users.name, users.truename, users.email FROM users INNER JOIN auth ON users.ID=auth.userid WHERE auth.zoneid = '1' GROUP BY auth.userid");
            $sTypeTxt = "Game Master";
        }elseif ($sType==9){
            $statement = $link->prepare("SELECT users.ID, users.name, users.truename, users.email FROM users INNER JOIN auth ON users.ID=auth.userid WHERE auth.zoneid = '1'  INNER JOIN point ON users.ID=point.uid WHERE point.zoneid IS NOT NULL GROUP BY auth.userid");
            $sTypeTxt = "Game Master";
        }
        if ($sType >0){
            $statement->execute();
            $statement->bind_result($id1, $name1, $rname1, $email1);
            $statement->store_result();
            $result = $statement->num_rows;
            if (!$result) {
                if ($result==0){
                    echo "<script>
                        row = table.insertRow(-1);
                        cell = row.insertCell(0);
                        cell.innerHTML='<span style=\'font-size:12px;\'><i> Sorry but no result, from <b>[$sTypeTxt]</b> list </i></span>';
                    </script>";    
                }else{
                    echo "<script>alert('Error: Query failed to execute!');</script>";
                }
                exit;
            }else{
                while($statement->fetch()) {
                    $RankColor="<font color=#0000ff>";
                    if (((CountMysqlRows($link, 5, $id1))>0)||($sType==8)){
                        $RankColor="<font color=#ff0000>";
                    }
                    echo "<script>
                        row = table.insertRow(-1);
                        cell = row.insertCell(0);
                        cell.innerHTML='<a style=\'text-decoration:none;font-size:14px;font-family:arial;\' href=\'javascript:void(0);\' title=\'Name: ".$rname1." and email: ".$email1."\' onClick=document.getElementById(\'worker\').src=\'../worker.php?do=loadId&id=".$id1."\';document.getElementById(\'LoadUserId\').value=\'".$id1."\';>$RankColor".$name1."</font> <i><font color=\'black\' size=\'2\'>[".$id1."]</font></i></a>';
                    </script>";        
                }   
            }
            $statement->close();    
        }
    }

  5. #5

    Re: Simple Server Status Information

    vlw manito pedroka



Advertisement