Retrieve stats results, using PHP

#1

Is it possible to retrieve the results from the stats command, using this php class?
I’ve already changed the port to 4711 in the class, but failed to get the results.

<?php
require_once "telnet.class.php";

$telnet = new Telnet();

$telnet->Connect();

// code to get the result...

$telnet->Disconnect();
?>

Thanks for your time and effort.

#2

Reddit thread: https://www.reddit.com/r/pihole/comments/bwg1p3/retrieve_stats_results_using_php_possible/

#5

I looked at the documentation, tested the telnet command on the pihole, they provide the expected result. That is where I got the idea to retrieve the data, using PHP + telnet.

The goal is to retrieve these results, using stats.php, retrieved from the webserver (lighttpd). I’ve created a new directory, to avoid conflicts with the admin web application, so no problem there. I test the php scripts, using sudo php <path to script>/stats.php
I’ve tried just about any telnet PHP class I could find, using the provided examples, if any. Some classes require a login, I can’t figure out what to use for username and password, thus the login always fails. Other classes simply timeout or return nothing.

Thus the above question: Is it even possible, using the above mentioned PHP telnet class, or is there a better one, preferably with examples on how to use the class…

#6

Given that telnet is usable over normal telnet, it is possible to use via other telnet APIs.