douxi9245 2018-12-03 20:40
浏览 19

cPanel停放域不返回阵列

A password was changed and cPanel broke. Fixed the password and it's still broken! I have to iterate over parked domains. I've verified the user / password combination is correct via PuTTY.

<?php
include_once('cpanel_api_xml.php');
$domain = 'example.com';
$pass = '';//etc
$user = '';//etc
$xmlapi = new xmlapi('127.0.0.1');
$xmlapi->password_auth($user,$pass);
$domains_parked = $xmlapi->listparkeddomains($user);

foreach ($domains_parked as $k1=>$v1)
{
 if ($v1->domain == $domain) {$return = true; break;}
}
?>

That code generates the following error:

Invalid argument supplied for foreach()

Apparently $domains_parked is not even set! I've spent time looking at the function being called so without dumping all 86KB here is the cleaned up version of $xmlapi->listparkeddomains:

<?php
public function listparkeddomains($username, $domain = null)
{
 $args = array();
 if (!isset($username))
 {
  error_log("listparkeddomains requires that a user is passed to it");
  return false;
 }

 if (isset($domain))
 {
  $args['regex'] = $domain;
  return $this->api2_query($username, 'Park', 'listparkeddomains', $args);
 }

 return $this->api2_query($username, 'Park', 'listparkeddomains');
}
?>

I don't know what they're doing with setting a variable as the second parameter. I've called this function with and without and tested the reaction with a simple mail().

Next I tried calling the API in a more direct fashion:

$xmlapi->api2_query($username, 'Park', 'listparkeddomains')

That also does not work. Okay, let's try some really raw output testing:

echo "1:
";
print_r($xmlapi);
echo "2:
";
print_r($xmlapi->api2_query($user, 'Park', 'listparkeddomains'));
echo "3:
";
$domains_parked = $xmlapi->listparkeddomains($user);
print_r($domains_parked);
die();

That outputs the following:

1: xmlapi Object (

[debug:xmlapi:private] => 

[host:xmlapi:private] => 127.0.0.1

[port:xmlapi:private] => 4099

[protocol:xmlapi:private] => https

[output:xmlapi:private] => simplexml

[auth_type:xmlapi:private] => pass

[auth:xmlapi:private] => <pass>

[user:xmlapi:private] => <user>

[http_client:xmlapi:private] => curl ) 2: 3:

I have never encountered such fragile code though I have no choice but to use it. Some help please?

  • 写回答

1条回答 默认 最新

  • douhao3562 2018-12-03 21:59
    关注

    So cPanel version 74 killed off the whole XML API and it doesn't frigin tell you with any error messages. I can not objectively say in the least that cPanel provides a stable platform to build anything reliable upon. You can either intentionally gimp your server from automatically updating (and potentially miss out on security updates) or every so X iterations of time completely rewrite the code again...and again...and again.

    评论

报告相同问题?

悬赏问题

  • ¥15 echarts动画效果失效的问题。官网下载的例子。
  • ¥60 许可证msc licensing软件报错显示已有相同版本软件,但是下一步显示无法读取日志目录。
  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加