Omen

PHP Server Query?

3 posts in this topic

On 11/18/2016 at 7:57 AM, Omen said:

Has anyone figured out how to pull server information from a web host with PHP?

 

I am basically looking to get minimal data about my servers. 

Player count and a list of connected players.

 

I found this, but cannot seem to get it to work. https://github.com/Austinb/GameQ

 

 

Share this post


Link to post
Share on other sites

Config.php

<?php
// This is an example of config.php
$dbhost = 'localhost';
$dbuser = '';
$dbpass = '';
?>

Opendb.php

<?php
// This is an example opendb.php
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db("exile", $conn);
?>

Call the config & opendb in example index.php

<?php
include 'config.php';
include 'opendb.php';
?>

Strings to Request stuff out of the database:

Total Players:
<?php
$result = mysql_query("SELECT * FROM player");
$online = mysql_num_rows($result);
echo ''.$online, '';
?>
Total Vehicles: 						
<?php
$result2 = mysql_query("SELECT * FROM vehicle");
$online2 = mysql_num_rows($result2);
echo ''.$online2, '';
?>
Total Territorys:
<?php
$result3 = mysql_query("SELECT * FROM territory");
$online3 = mysql_num_rows($result3);
echo ''.$online3, '';
?>
Total Clans:
<?php
$result4 = mysql_query("SELECT * FROM clan");
$online4 = mysql_num_rows($result4);
echo ''.$online4, '';
?>
Newest Player:
<?php
$select2 = mysql_query("SELECT `name` FROM `account` ORDER BY `first_connect_at` DESC LIMIT 1;");
$r2 = mysql_fetch_array($select2);
echo ''.$r2['name'].'';
?>
Newest Clan:
<?php
$select0 = mysql_query("SELECT `name` FROM `clan` ORDER BY `created_at` DESC LIMIT 1;");
$r0 = mysql_fetch_array($select0);
echo ''.$r0['name'].'';
?>
Newest Territory:
<?php
$select1 = mysql_query("SELECT `name` FROM `territory` ORDER BY `created_at` DESC LIMIT 1;");
$r1 = mysql_fetch_array($select1);
echo ''.$r1['name'].'';
?>

to give u a little example.

  • Like 1

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.