• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Showing Server Statistic using PHP file

Newbie Spellweaver
Joined
Aug 10, 2020
Messages
12
Reaction score
2
i am using curl becouse the game server and web server are not in same server

PHP:
// Total Account or Account.php

<?php
// Connect to the database
$serverName = "ServerName";
$connectionOptions = array(
    "Database" => "dnmembership",
    "UID" => "Username",
    "PWD" => "Password"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);

// Check connection
if ($conn === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Execute the SELECT query
$query = "SELECT COUNT(*) AS TotalCount FROM Accounts";
$result = sqlsrv_query($conn, $query);
if ($result === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Fetch the results
$row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
$totalCount = $row['TotalCount'];

// Print the results
echo "$totalCount";

// Free the result set
sqlsrv_free_stmt($result);

// Close the database connection
sqlsrv_close($conn);


PHP:
// Total Character or character.php

<?php
// Connect to the database
$serverName = "ServerName";
$connectionOptions = array(
    "Database" => "dnmembership",
    "UID" => "Username",
    "PWD" => "Password"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);

// Check connection
if ($conn === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Execute the SELECT query
$query = "SELECT COUNT(*) AS TotalCount FROM Characters";
$result = sqlsrv_query($conn, $query);
if ($result === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Fetch the results
$row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
$totalCount = $row['TotalCount'];

// Print the results
echo "$totalCount";

// Free the result set
sqlsrv_free_stmt($result);

// Close the database connection
sqlsrv_close($conn);

Code:
// Total Online or online.php

<?php

// Connect to the database
$serverName = "ServerName";
$connectionOptions = array(
    "Database" => "dnmembership",
    "UID" => "Username",
    "PWD" => "Password"
);
$conn = sqlsrv_connect($serverName, $connectionOptions);

// Check connection
if ($conn === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Execute the SELECT query
$query = "SELECT COUNT(*) AS TotalCount FROM DNAuth WHERE CertifyingStep > 0";
$result = sqlsrv_query($conn, $query);
if ($result === false) {
    die(print_r(sqlsrv_errors(), true));
}

// Fetch the results
$row = sqlsrv_fetch_array($result, SQLSRV_FETCH_ASSOC);
$totalCount = $row['TotalCount'];

// Print the results
echo "$totalCount";

// Free the result set
sqlsrv_free_stmt($result);

// Close the database connection
sqlsrv_close($conn);

i put that code into curl folder

to display it one by one into your homepage

PHP:
// add this on your index.php or any page you want to show the info

<?php
function ethernumAPI($method) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://localhost/curl/" . $method);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    curl_close($ch);     
    echo $output;
}
?>

call one by one

PHP:
<?php ethernumAPI("account.php"); ?>
PHP:
<?php ethernumAPI("character.php"); ?>
PHP:
<?php ethernumAPI("online.php"); ?>

1682913054718 - Showing Server Statistic using PHP file - RaGEZONE Forums


Data updated every the page refreshed
 

Attachments

You must be registered for see attachments list
Back
Top