【问题标题】:PHP & cPanel - Is there a way to get total size of all emails on a users accountPHP & cPanel - 有没有办法获取用户帐户上所有电子邮件的总大小
【发布时间】:2013-12-05 10:16:52
【问题描述】:

我不确定这是否可能。有没有办法用 PHP 找出电子邮件帐户在 cPanel 服务器上占用了多少存储空间?

如果不是 PHP,有什么办法可以做到并显示在网站上?

我在一个目录中有磁盘使用的代码...但不确定如何计算使用的电子邮件存储空间。

注意: 我不是要求任何人为此编写代码。如果你有它/想要写它并想要分享它......我不会抱怨......但基本上试图找出它是否可能,也许在谷歌或其他东西上搜索什么。我已经以我知道的各种方式搜索了这个措辞,但目前还找不到解决方案,这就是我在这里询问的原因。

【问题讨论】:

  • 所以你想让我们为你写代码?
  • 看来你需要做很多谷歌搜索。
  • 没有。我试图弄清楚它是否可能/是否以前做过。我问有没有办法让它成为可能,而不是让任何人编写代码。我希望如果可能的话,它可能已经写好了。我已经搜索过,但在任何地方都找不到它

标签: php cpanel


【解决方案1】:

您可以使用 PHP 类与 cPanel 的 XML-API 进行交互

示例PHP代码如下:

<?php

include("xmlapi.php");

$ip = "localhost";

# The access has can be found on your server under WHM's "Setup remote access hash" section or at /root/.accesshash
$root_hash = 'MY HASH CODE HERE';

$xmlapi = new xmlapi($ip);
$xmlapi->hash_auth("MY WHM ACCOUNT USERNAME",$root_hash);
$xmlapi->return_xml(1);
$xmlapi->set_debug(1);

$username = CpanelUsername;

$xmlapi->accountsummary($username);

print $xmlapi->accountsummary($username);

?>

它会显示这个:

代码:

<accountsummary>
  <acct>
    <disklimit>200M</disklimit>
    <diskused>63M</diskused>
    <domain>domain.com</domain>
    <email>email@domain.com</email>
    <ip>IP</ip>
    <maxaddons>100</maxaddons>
    <maxftp>100</maxftp>
    <maxlst>100</maxlst>
    <maxparked>100</maxparked>
    <maxpop>100</maxpop>
    <maxsql>100</maxsql>
    <maxsub>100</maxsub>
    <owner>OWNER</owner>
    <partition>home</partition>
    <plan>PLAN</plan>
    <shell>/usr/local/cpanel/bin/noshell</shell>
    <startdate>STARTDATE</startdate>
    <suspended>0</suspended>
    <suspendreason>not suspended</suspendreason>
    <suspendtime></suspendtime>
    <theme>x3</theme>
    <unix_startdate>UNIX_STARTDATE</unix_startdate>
    <user>USER</user>
  </acct>
  <status>1</status>
  <statusmsg>Ok</statusmsg>
</accountsummary>

$diskused =  $xmlapi->accountsummary->acct->diskused;

print $diskused;

【讨论】:

  • 谢谢。我不知道有这样的东西存在。使用起来相当安全吗?
  • 是的,即使我已经为我的代码创建了电子邮件 qouta 等,您可以检查上述两个链接,然后使用:)
  • 好的,感谢您的代码示例!我会定义的。看看吧。
  • $diskused 现在是否包含电子邮件使用情况?我知道不久前我听说它没有,所以想验证他们确实改变了这个?另外,我可以使用另一个变量来查看电子邮件上使用的磁盘空间,还是仅限于您所说的 $diskused。
  • Disklimit 用作特定用户的 qouta,如果用户使用了 x 数量的磁盘然后可用空间 = (disklimit(quota) - diskused)。
猜你喜欢
  • 1970-01-01
  • 2014-09-08
  • 2017-07-21
  • 1970-01-01
  • 1970-01-01
  • 2016-10-06
  • 2019-07-29
  • 1970-01-01
  • 2018-02-07
相关资源
最近更新 更多