Using CMD_API_SUBDOMAINS with correct password i've got error "Unable to show subdomains" but with incorrect password i've got an empty output.
Using for example CMD_API_SHOW_DOMAINS i got same output when password isn't correct as when user doesn't have any domains.
<?php
include_once('httpsocket.php');
$server_ip="127.0.0.1";
$server_login="userbob";
$server_pass="SECRET_PASS";
$server_host="127.0.0.1";
$server_ssl=true;
$server_port="2222";
$sock = new HTTPSocket;
if ($server_ssl) {
$sock->connect("ssl://".$server_host, $server_port);
} else {
$sock->connect($server_host, $server_port);
}
$sock->set_login($server_login,$server_pass);
$sock->query('/CMD_API_SHOW_DOMAINS',array());
$result = $sock->fetch_parsed_body();
var_dump($result);
array(1) {
["list"]=>
array(1) {
[0]=>
string(8) "domain.com"
}
}
array(0) {
}
if(isset($result) && empty($result) || !empty($result['list'])){
echo "logged in";
$sock->query('/CMD_API_SHOW_USERS');
$result = $sock->fetch_parsed_body();
if(isset($result) && empty($result) || !empty($result['list'])){
echo "reseller";
}
else{
echo "not reseller";
}
}
else{
echo "not logged in";
}
Could you tell me is it secure to validate output like this:
Thanks.PHP:if(isset($result) && empty($result) || !empty($result['list'])){ echo "logged in"; } else{ echo "not logged in"; }
$result = $sock->fetch_parsed_body();
Success Returns | url encoded array in list[] |
Failure Returns | Nothing to break here. No domains returns empty list |
array(0) {
}
$sock->query('/CMD_API_DOMAIN',
array(
'action' => 'create',
'domain' => '',
'ubandwidth' => 'unlimited',
'uquota' => 'unlimited',
'ssl' => 'OFF',
'cgi' => 'ON',
'php' => 'ON'
));
if(!empty($result['details'])){
//logged in
}