mgufrone / cpanel-php

CPanel/WHM API for PHP
MIT License
158 stars 91 forks source link

Undefined offset: 0 #11

Closed ghost closed 8 years ago

ghost commented 8 years ago

I has get error when dumpzone.

in Cpanel.php line 343 at HandleExceptions->handleError('8', 'Undefined offset: 0', '/home/nginx/domains/xxx/public/vendor/gufy/cpanel-php/src/Gufy/CpanelPhp/Cpanel.php', '343', array('action' => 'dumpzone', 'arguments' => array('domain' => 'xxx.com'), 'host' => 'https://10.0.0.3:2087', 'client' => object(Client))) in Cpanel.php line 343

Resolve: change 'query' => count($arguments) > 1 ? $arguments : $arguments[0], to 'query' => $arguments,

Please check it :)

mgufrone commented 8 years ago

is this happen when the $arguments is null?

ghost commented 8 years ago

no, this happen when is has one item in array.

mgufrone commented 8 years ago

Try it again

ghost commented 8 years ago

tks guy :)

mgufrone commented 8 years ago

Use dev-master instead, i still haven't pushed it as a tag. :+1:

twouters commented 8 years ago

This is still a problem because the $arguments parameter of __call() is always an enumerated array containing the parameters passed to the method.

$accounts = listaccts(['searchtype'=>'domain', 'search'=>'', 'exact', 'search'=>'helloworld.com']);

This would result in the following $arguments:

array(1) {
  [0]=>
  array(3) {
    ["searchtype"]=>
    string(6) "domain"
    ["search"]=>
    string(14) "helloworld.com"
    [0]=>
    string(5) "exact"
  }
}

Which results in the following POST request:

> POST /json-api/listaccts?0%5Bsearchtype%5D=domain&0%5Bsearch%5D=helloworld.com&0%5B0%5D=exact HTTP/1.1
ponasromas commented 7 years ago

Hello,

This issue still not resolved. There is code like this:

include_once ('class.cpanel.php');

$cpanel = new Cpanel();

$account_info = $cpanel->callWHMApi('accountsummary',
    [
,    'domain'        => "domain.tld"
    ]
);

if ( isset($account_info) ) {
    $result = json_decode ( $account_info, true );
    $results = $result[ 'data' ][ 'acct' ][0];

    $cgi_domain = $results[ 'domain' ];
    $cgi_inodes = $results[ 'inodesused' ];
    $cgi_mailboxes = $results[ 'maxpop' ];
    $cgi_mailsperhour = $results[ 'max_email_per_hour' ];
    $cgi_outgoingmail = $results[ 'outgoing_mail_suspended' ];
    $cgi_suspended = $results[ 'suspended' ];
    $cgi_suspend_reason = $results[ 'suspendreason' ];
    $cgi_ip = $results[ 'ip' ];
    $cgi_plan = $results[ 'plan' ];
    $cgi_user = $results[ 'user' ];
    $cgi_diskused = $results[ 'diskused' ];
    $cgi_maxsql = $results[ 'maxsql' ];
    $cgi_disklimit = $results[ 'diskused' ];
}   

Code executed and result received, but with notice:

Notice: Undefined offset: 0

Sure, I can use "@" to supress that dirty notice, but it's not the best way...