Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Simple Server Status Information

Junior Spellweaver
Joined
May 18, 2014
Messages
151
Reaction score
57
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:
View attachment 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:
<?php   

require_once("status-server.php");  

$serverStatus = new ServerStatus();

?>

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

PHP:
<?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!
 

Attachments

You must be registered for see attachments list
Joined
Jul 17, 2007
Messages
665
Reaction score
103
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)
 
Junior Spellweaver
Joined
May 18, 2014
Messages
151
Reaction score
57
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.
 
Joined
Jul 17, 2007
Messages
665
Reaction score
103
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:

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();    
    }
}
 
Back
Top