/**
  * Number of Recent Emails
  */
  function num_recent(){
    return imap_num_recent($this->link);
  }
示例#2
0
 public function getNewMessagesCount($imap)
 {
     $recentmessagecount = imap_num_recent($imap);
     //print_r($recentmessagecount);
     return $recentmessagecount;
 }
示例#3
0
 /**
  * Number of Recent Emails
  */
 function numRecent()
 {
     //debug('numRecent');
     return imap_num_recent($this->connection);
 }
@ini_set('display_errors', '0');
$mbox = imap_open("{" . $servidor . ":143/novalidate-cert}INBOX", $usuario, $senha);
$erro[] = imap_last_error();
if ($erro[0] == "Mailbox is empty") {
    echo "não tem nenhuma mensagem";
    exit;
} elseif ($erro[0] == "POP3 connection broken in response") {
    echo "Usuario ou a senha estao errados";
    exit;
} elseif ($erro[0] == "Host not found (#11004): pop3.{$servidor}") {
    echo "O servidor {$servidor} esta errado";
    exit;
}
if ($erro[0] == "") {
    $numero_mensagens = imap_num_msg($mbox);
    $numero_mens_nao_lidas = imap_num_recent($mbox);
    if ($numero_mensagens == 1) {
        echo "você tem {$numero_mensagens} mensagem<br />";
    } else {
        echo "você tem {$numero_mensagens} mensagens<br /><br />";
    }
    setlocale(LC_ALL, 'pt_BR');
    for ($i = 1; $i <= imap_num_msg($mbox); $i++) {
        date_default_timezone_set('America/Sao_Paulo');
        $headers = imap_header($mbox, $i);
        $data = str_replace(' ', ',', $headers->date);
        $data = explode(',', $data);
        switch ($data[3]) {
            case 'Jan':
                $mes = '01';
                break;
 function refresh($params)
 {
     $return = array();
     $return['new_msgs'] = 0;
     $folder = $params['folder'];
     $msg_range_begin = $params['msg_range_begin'];
     $msg_range_end = $params['msg_range_end'];
     $msgs_existent = $params['msgs_existent'];
     $sort_box_type = $params['sort_box_type'];
     $sort_box_reverse = $params['sort_box_reverse'];
     $msgs_in_the_server = array();
     $search_box_type = $params['search_box_type'] != "ALL" && $params['search_box_type'] != "" ? $params['search_box_type'] : false;
     $msgs_in_the_server = $this->get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse, $msg_range_begin, $msg_range_end);
     $msgs_in_the_server = array_keys($msgs_in_the_server);
     $num_msgs = count($msgs_in_the_server) - imap_num_recent($this->mbox);
     $dif = $params['msg_range_end'] - $params['msg_range_begin'] + 1;
     if (!count($msgs_in_the_server)) {
         $msg_range_begin -= $dif;
         $msg_range_end -= $dif;
         $msgs_in_the_server = $this->get_msgs($folder, $sort_box_type, $search_box_type, $sort_box_reverse, $msg_range_begin, $msg_range_end);
         $msgs_in_the_server = array_keys($msgs_in_the_server);
         $num_msgs = NULL;
         $return['msg_range_begin'] = $msg_range_begin;
         $return['msg_range_end'] = $msg_range_end;
     }
     $return['new_msgs'] = imap_num_recent($this->mbox);
     //Mensagens não lidas para sincronizar emails em diferentes clientes
     $unseens = array();
     $m_search = imap_search($this->mbox, 'UNSEEN');
     if ($m_search && is_array($m_search)) {
         foreach ($m_search as $m) {
             $unseens[] = imap_uid($this->mbox, $m);
         }
     }
     $return['unseens'] = $unseens;
     $msgs_in_the_client = explode(",", $msgs_existent);
     $msg_to_insert = array_diff($msgs_in_the_server, $msgs_in_the_client);
     if (count($msg_to_insert) > 0 && $return['new_msgs'] == 0 && $msgs_in_the_client[0] != "") {
         $aux = 0;
         while (array_key_exists($aux, $msg_to_insert)) {
             if ($msg_to_insert[$aux] > $msgs_in_the_client[0]) {
                 $return['new_msgs'] += 1;
             }
             ++$aux;
         }
     } else {
         if (count($msg_to_insert) > 0 && $msgs_in_the_server && $msgs_in_the_client[0] != "" && $return['new_msgs'] == 0) {
             $aux = 0;
             while (array_key_exists($aux, $msg_to_insert)) {
                 if ($msg_to_insert[$aux] == $msgs_in_the_server[$aux]) {
                     $return['new_msgs'] += 1;
                 }
                 ++$aux;
             }
         } else {
             if ($num_msgs < $msg_range_end && $return['new_msgs'] == 0 && count($msg_to_insert) > 0 && $msg_range_end == $dif) {
                 $return['tot_msgs'] = $num_msgs;
             }
         }
     }
     if (!count($msgs_in_the_server)) {
         return array();
     }
     $msg_to_delete = array_diff($msgs_in_the_client, $msgs_in_the_server);
     $msgs_to_exec = array();
     foreach ($msg_to_insert as $msg_number) {
         $msgs_to_exec[] = $msg_number;
     }
     //sort($msgs_to_exec);
     $i = 0;
     foreach ($msgs_to_exec as $msg_number) {
         $sample = false;
         if ((isset($this->prefs['preview_msg_subject']) || $this->prefs['preview_msg_subject'] === '1') && (isset($this->prefs['preview_msg_tip']) || $this->prefs['preview_msg_tip'] === '1')) {
             $sample = true;
         }
         $return[$i] = $this->get_info_head_msg($msg_number, $sample);
         //get the next msg number to append this msg in the view in a correct place
         $msg_key_position = array_search($msg_number, $msgs_in_the_server);
         $return[$i]['msg_key_position'] = $msg_key_position;
         if ($msg_key_position !== false && array_key_exists($msg_key_position + 1, $msgs_in_the_server) !== false) {
             $return[$i]['next_msg_number'] = $msgs_in_the_server[$msg_key_position + 1];
         } else {
             $return[$i]['next_msg_number'] = $msgs_in_the_server[$msg_key_position];
         }
         $return[$i]['msg_folder'] = $folder;
         ++$i;
     }
     $return['quota'] = $this->get_quota(array('folder_id' => $folder));
     $return['sort_box_type'] = $params['sort_box_type'];
     if (!$this->mbox || !is_resource($this->mbox)) {
         $this->open_mbox($folder);
     }
     $return['msgs_to_delete'] = $msg_to_delete;
     $return['offsetToGMT'] = $this->functions->CalculateDateOffset();
     if ($this->mbox && is_resource($this->mbox)) {
         imap_close($this->mbox);
     }
     return $return;
 }
示例#6
0
<?php

echo "Checking with no parameters\n";
imap_num_recent();
echo "Checking with incorrect parameter type\n";
imap_num_recent('');
imap_num_recent(false);
示例#7
0
 function num_recent()
 {
     if ($this->mbox) {
         return imap_num_recent($this->mbox);
     }
     return false;
 }
 /**
  * Count unread messages in mailbox
  *
  * @return integer
  */
 function countUnreadMessages()
 {
     parent::countUnreadMessages();
     return (int) imap_num_recent($this->getConnection());
 }
 public function getRecentMessage()
 {
     $recent = @imap_num_recent($this->connection);
     if ($recent === false) {
         $this->errMsg = "Imap_num_recent failed: " . @imap_last_error();
     }
     return $recent;
 }
示例#10
0
	function get_nb_msg_recent() {
		return @imap_num_recent($this->connect);
	}
示例#11
0
 /**
  * Count new messages in the currently selected mailbox
  * 
  * @return int
  */
 public function countNewMessages()
 {
     $this->connect();
     return imap_num_recent($this->_connection);
 }