knightzac19 / PHP-ArkData

This is a port of the C# ArkData library to PHP.
GNU General Public License v3.0
3 stars 1 forks source link

PHP ARK Server Data Reader

This is a port of AuthiQ's ARK Server Data Reader into PHP. It's 100% ported without anything left out and I have even fixed the 100 user limit for steam profiles. I also have imported xPaw's PHP-Source-Query as that is the main backend of the project. Please visit the repo to make sure your PHP environment is setup properly.

How to use it

If you use codeigniter then you need to use the ssq.php file that is included.

$this->load->library("ssq");
$this->load->library("arkdata",array("installLocation"=>"DIRECT LOCATION TO STEAM FILES"));
$this->arkdata->LoadSteam("STEAM API KEY HERE");
$this->arkdata->LoadOnlinePlayers();
$data['arkdata'] = $this->arkdata->getArkData();
$this->load->view('ark',$data);

To use it on a non-codeigniter instance, you can initialize it like any other class:

require_once("SourceQuery/bootstrap.php");
require_once("arkdata.php");
$arkdata = new Arkdata(array("installLocation"=>"DIRECT LOCATION TO STEAM FILES"));
$arkdata->LoadSteam("STEAM API KEY HERE");
$arkdata->LoadOnlinePlayers();
$arkdataresults = $arkdata->getArkData();

Enabling SSH (Beta)

Note: I take no responsibility if you somehow end up corrupting your saves or your web server dies from the stress of too many player files!

If you want to enable SSH you must have php_ssh2 installed and you have to have PHP 5.5+ or at least have ZipArchive support in your PHP installation. On the server that hosts ARK, you must have the zip application installed. Please run which zip and make sure it returns something.

To Enable SSH do add the following items to the array for the arkdata class:

"enableSSH" => true,
"SSHSettings" => array("host"=>'<HOST>',
                        "port"=> 22,
                        "known_host"=>"<HOST MD5 HASH>",
                        "pub_key_location"=>"<FULL PATH TO PUBLIC KEY>",
                        "priv_key_location"=>"<FULL PATH TO PRIVATE KEY>",
                        "key_user"=>"<USER KEY IS FOR>",
                        "cache_dir" => "<FULL PATH ON WEB SERVER FOR CACHE>"
                        )

Once you have it enabled and you have your SSH key all setup with your server, you will have to load the library at least once so you can get your host's MD5 HASH. It's not something you can just pull from the server, PHP will md5 it for you and you can put it in the known_host array option. If the key matches after you refresh, you will probably have to wait at least 2-3 minutes depending on the userbase you have and the connection speed between you and the server.

Using Cygwin on Windows

All you need to do is make sure your SSH server in Cygwin is setup correctly. The library will treat it like any other SSH server.

Please visit this tutorial page, http://docs.oracle.com/cd/E24628_01/install.121/e22624/preinstall_req_cygwin_ssh.htm#EMBSC281 to learn more on how to setup an SSH server in Cygwin. Disregard any specific things for Oracle on that page. To setup authorized key access to your cygwin server, you can just use the ssh-copy-id command from your web server (Linux can just use the ssh-copy-id command, if you have a windows web server, you can either put Cygwin on that server or just use the other method.) or you can just copy the contents of your public key into your cygwin user's authorized_keys file. (Ex. C:\Cygwin64\home\USER\.ssh\authorized_keys).

Timers

Timers are an easy way to see how fast data is being collected and they are stored in the 3rd array item from the getArkData() function. They will be in an array format as shown below.

array(
    'App' => 0.0143,
    'Steam' => 4.4331,
    'SSH' => 11.6214 //Only set if enabled...
    )

Known Issues

Upcoming Features