Plugin + API password change

floris

Verified User
Joined
Oct 23, 2005
Messages
94
I'm writing a plugin that among other things lists the domains a user owns. For this i make use of the API, with the user's username and the admin password.

The problem is the ability for the admin to change the password. As the password is hardcoded in the plugin.html, it will definitely break. What options are there to overcome this problem?
 
A few hours later, scanning endless sourcecode, etc. I found the solution.

$da = new HTTPSocket;
$da->connect("ssl://localhost",2222);
$da->set_login($_SERVER['USER']);

It appears you don't need to specify the admin password at all when you connect to localhost. I'm not sure if this works too when you connect to != localhost (but i suspect not).
 
As long as the plugin is runing under DirectAdmin's environment, it should be able to connect to the API and authenticate using session data.

You will only have access to API commands available for that paricular user level however.
 
Back
Top