can't get userlist via plugin

SupermanInNY

Verified User
Joined
Sep 28, 2004
Messages
419
Hi All,

I'm stuck on trying to build a simple plugin code:

I'm trying to build a plugin that shows the list of users.
When I'm in an Admin level, it needs to show only the Resellers.
When I'm in a Reseller Level, it should show only the users below it

While this is very simple in logic, I can't get it work.

I want to avoid using "username and password" in the plugin code. It should capture what level you are connecting through and identify itself to show the users below your level.

I don't care if it is in perl or PHP, I just need to get this basic functionality running.

I was wondering if anyone can assist me to get it started.

Also, where should the httpsocket.php file reside? this should be shared for all levels, so is there a 'public' area it can be put and then included?

Where did I get stuck?

I tried all sorts of samples that were shown here, but I get either a blank page or an array with just one entry in it.


Thanks,

-Alon.
 
Well,. the problem I've had with getting information was a simple line:

$sock->set_login('admin');

I previously had it as:

$sock->set_login('admin','passwordhere');

Ommiting the ,'passwordhere' worked, and immediately I started seeing results.
Silly little thing resolved thanks to John of DA.

And now for the PHP coders who can throw a quick resolution to my code:


include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('127.0.0.1',2222);
$sock->set_login('admin');

$sock->query('/CMD_API_ALL_USER_USAGE');
echo "<b>ALL_USER_USAGE</b>\n<br>";
$lines = explode("\n", $sock->fetch_body());
foreach ($lines as $line)
{
$username = strtok($line, '=');
$data = strstr($line, '=');

echo "\n<br><br>found data for $username<br>";
echo $data;
}
echo "<b>=== end of ALL_USER_USAGE ===</b>";
echo "<br><br>";
This works!
However, the answer I'm getting is a long string:

found data for mjhkj
=bandwidth=0.0000 / 5000&creator=admin&default=ding.com&ip=1.10.18.28&ips=&list=ding.com
&quota=0.1875 / 1000&suspended=No&type=reseller&vdomains=1 / 10


I need to extract the 'type' ($usertype) from that string.
Any coding pointers on how to extract it from that sting and echo it ?

basiclly parsing $data.

Thanks for any pointers.

-Alon.
 
Back
Top