Retrieve stats results, using PHP

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.

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

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…

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

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.