コード例 #1
0
ファイル: index.php プロジェクト: lordbasex/elastix-gui
function obtener_quota_usuario($username, $module_name)
{
    include_once "configs/email.conf.php";
    include_once "libs/cyradm.php";
    global $CYRUS;
    global $arrPermission;
    $cyr_conn = new cyradm();
    $cyr_conn->imap_login();
    $edit_quota = _tr("Edit quota");
    $quota = $cyr_conn->getquota("user/" . $username);
    $tamano_usado = _tr("Could not query used disc space");
    if (is_array($quota) && count($quota) > 0) {
        if ($quota['used'] != "NOT-SET") {
            $q_used = $quota['used'];
            $q_total = $quota['qmax'];
            if (!$q_total == 0) {
                $q_percent = number_format(100 * $q_used / $q_total, 2);
                $q_usada = $q_used < 1024 ? "{$q_used} KB" : $q_used / 1024 . " MB ";
                $q_total = $q_total < 1024 ? "{$q_total} KB" : $q_total / 1024 . " MB ";
                /*if(in_array('edit_user',$arrPermission)){
                      $tamano_usado=" $q_usada / <a href='#' onclick=changes_email_quota('$username') title='$edit_quota'> $q_total </a> ($q_percent%)";
                  }else*/
                $tamano_usado = " {$q_usada} / {$q_total} ({$q_percent}%)";
            } else {
                $tamano_usado = _tr("Could not obtain used disc space");
            }
        } else {
            $tamano_usado = _tr("Size is not set");
        }
    }
    return $tamano_usado;
}
コード例 #2
0
ファイル: email.php プロジェクト: jeremy-cayrasso/dtc
function getCyrusUsedQuota($id)
{
    global $pro_mysql_pop_table;
    $q = "SELECT fullemail FROM {$pro_mysql_pop_table} WHERE autoinc='{$id}';";
    $r = mysql_query($q) or die("Cannot query {$q} line: " . __LINE__ . " file " . __FILE__ . " sql said:" . mysql_error());
    $n = mysql_num_rows($r);
    if ($n != 1) {
        die("Cannot find created email line " . __LINE__ . " file " . __FILE__);
    }
    $a = mysql_fetch_array($r);
    $fullemail = $a["fullemail"];
    // login to cyradm
    $cyr_conn = new cyradm();
    $error = $cyr_conn->imap_login();
    if ($error != 0) {
        die("imap_login Error {$error}");
    }
    // get the quota used
    $cyrus_quota = $cyr_conn->getquota("user/" . $fullemail);
    /*
    $max_quota=$cyrus_quota['qmax'];
    $quota_used=$cyrus_quota['used'];
    $percent=100*$quota_used/$max_quota;
    */
    $value = $cyrus_quota['used'];
    $happen = "/ " . $cyrus_quota['qmax'] . " (" . round(100 * $cyrus_quota['used'] / $cyrus_quota['qmax'], 2) . "%)";
    $cyrq = array("value" => $value, "happen" => $happen);
    return $cyrq;
}
コード例 #3
0
ファイル: paloSantoEmail.class.php プロジェクト: hardikk/HNH
 /**
  * Obtener la cuota del correo del usuario indicado.
  * 
  * @param string    $username   Correo completo usuario@dominio.com
  * 
  * @return mixed    Arreglo (used,qmax) o NULL en caso de error
  */
 function getAccountQuota($username)
 {
     $this->errMsg = '';
     $bPostfixElastix2 = isPostfixToElastix2();
     $regexp = $bPostfixElastix2 ? '/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+$/' : '/^([a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*)$/';
     if (!preg_match($regexp, $username)) {
         $this->errMsg = _tr('Username is not valid');
         return NULL;
     }
     $cyr_conn = new cyradm();
     if (!$cyr_conn->imap_login()) {
         $this->errMsg = _tr('Failed to login to IMAP');
         return NULL;
     }
     $quota = $cyr_conn->getquota('user/' . $username);
     $cyr_conn->imap_logout();
     return $quota;
 }