コード例 #1
0
 /**
  * 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 = '';
     $regexp = '/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+$/';
     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;
 }
コード例 #2
0
ファイル: paloSantoEmail.class.php プロジェクト: hardikk/HNH
 /**
  * Actualizar la cuota del usuario indicado, tanto en cyrus como en la DB.
  * 
  * @param string    $username   Correo completo usuario@dominio.com
  * @param int       $newquota   Nueva cuota de correo a asignar
  * 
  * @return bool     VERDADERO en caso de éxito, FALSO en caso de error.
  */
 function setAccountQuota($username, $newquota)
 {
     $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 FALSE;
     }
     $cyr_conn = new cyradm();
     if (!$cyr_conn->imap_login()) {
         $this->errMsg = _tr('Failed to login to IMAP');
         return NULL;
     }
     $this->_DB->beginTransaction();
     $sPeticionSQL = 'UPDATE accountuser SET quota = ? WHERE username = ?';
     $bExito = $this->_DB->genQuery($sPeticionSQL, array($newquota, $username));
     if (!$bExito) {
         $this->errMsg = $this->_DB->errMsg;
     } else {
         $bExito = $cyr_conn->setmbquota('user/' . $username, $newquota);
         if (!$bExito) {
             $this->errMsg = $cyr_conn->getMessage();
         }
     }
     if ($bExito) {
         $this->_DB->commit();
     } else {
         $this->_DB->rollback();
     }
     $cyr_conn->imap_logout();
     return $bExito;
 }
コード例 #3
0
 function deleteSpamMessages($email, $dateSince)
 {
     global $CYRUS;
     $cyr_conn = new cyradm();
     $error_msg = "";
     $error = $cyr_conn->imap_login();
     $dataEmail = explode("@", $email);
     if ($error === FALSE) {
         $error_msg = "IMAP login error: {$error} <br>";
     } else {
         $seperator = '/';
         $bValido = $cyr_conn->command(". select \"user" . $seperator . $dataEmail[0] . $seperator . "Spam@" . $dataEmail[1] . "\"");
         if (!$bValido) {
             $error_msg = "Error selected Spam folder:" . $cyr_conn->getMessage() . "<br>";
         } else {
             $bValido = $cyr_conn->command(". SEARCH NOT SINCE {$dateSince}");
             // busca los email que no empiecen desde la fecha dada
             if (!$bValido) {
                 $error_msg = "error cannot be added flags Deleted to the messages of Spam folder for {$email}:" . $cyr_conn->getMessage() . "<br>";
             } else {
                 $sal = explode("SEARCH", $bValido[0]);
                 $uids = trim($sal[1]);
                 //ids de mensajes
                 if ($uids != "") {
                     //$bValido=$cyr_conn->command(". store 1:* +flags \Deleted");
                     $uids = trim($uids);
                     $uids = str_replace(" ", ",", $uids);
                     if (strlen($uids) > 100) {
                         $arrID = explode(",", "{$uids}");
                         $size = count($arrID);
                         $limitID = $arrID[0] . ":" . $arrID[$size - 1];
                         $bValido = $cyr_conn->command(". store {$limitID} +flags \\Deleted");
                     } else {
                         $bValido = $cyr_conn->command(". store {$uids} +flags \\Deleted");
                     }
                     // messages $uids = 1 2 4 5 7 8
                     if (!$bValido) {
                         $error_msg = "error cannot be deleted the messages of Spam folder for {$email}:" . $cyr_conn->getMessage() . "<br>";
                     } else {
                         $bValido = $cyr_conn->command(". expunge");
                         if (!$bValido) {
                             $error_msg = "error cannot be deleted the messages of Spam folder for {$email}:" . $cyr_conn->getMessage() . "<br>";
                         }
                         /*else{
                               $bValido=$cyr_conn->command(". noop");
                               if(!$bValido)
                                   $error_msg = "error cannot be deleted the messages of Spam folder for $email:".$cyr_conn->getMessage()."<br>";
                           }*/
                     }
                 }
             }
         }
         $cyr_conn->imap_logout();
     }
     return $error_msg;
 }