API Usage in Skins

mikeyg6754

Verified User
Joined
Jan 23, 2012
Messages
20
Hello,
I would like to be able to retrieve Server Stats in a skin that I am working on. It seems that all the stats that I am looking to use individually are contained within the |STATS| variable.
I saw the CMD_ADMIN_STATS in the API and it looks like this would be perfect. I am just unsure of how I should go about retrieving the variables from the Skin.

Thanks in advance for the help!
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,932
Location
GMT +7.00
Hello,

And what is your question? Note, API can be used anywhere where you want it, and custom PHP code can be used within Directadmin skins. All you need to start learning API you can find here: http://directadmin.com/api.html
 

mikeyg6754

Verified User
Joined
Jan 23, 2012
Messages
20
If I were to use CMD_ADMIN_STATS how would I get the results to the page, would I have to use CURL ?
 

mikeyg6754

Verified User
Joined
Jan 23, 2012
Messages
20
Ok, I've looked at this class and it looks like it might work. My only problem now is:

$sock->connect('yoursite.com',2222);
$sock->set_login('admin','password');

How can I get the current login data in order to connect?
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,932
Location
GMT +7.00
If I'm not mistaken, you can connect to 127.0.0.1

PHP:
$sock->connect('127.0.0.1',2222);
within the current session without need to authenticate additionally.
 

mikeyg6754

Verified User
Joined
Jan 23, 2012
Messages
20
When I put the following in my content_main.html it ends up printing part of the code on screen.
Maybe I'm doing something wrong. I've tried to change the file extensions of index and content_main to php and update them in the files_admin.conf but that did not change anything.
PHP:
<?php
	include '|HTM_SOCKET|';

	$sock = new HTTPSocket;

	$sock->connect('127.0.0.1',2222);

	$sock->query('/CMD_API_SHOW_ALL_USERS');
	$result = $sock->fetch_parsed_body();

?>
Here is exactly what I am getting.



I appreciate your help!
 
Top