当前位置: 首页>>代码示例>>PHP>>正文


PHP imap_sort函数代码示例

本文整理汇总了PHP中imap_sort函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_sort函数的具体用法?PHP imap_sort怎么用?PHP imap_sort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了imap_sort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInbox

 public function getInbox($page = 1, $perPage = 25, $sort = null)
 {
     if (!$this->isConnect) {
         return false;
     }
     $start = $page == 1 ? 0 : $page * $perPage - ($perPage - 1);
     $order = 0;
     $by = SORTDATE;
     if (is_array($sort)) {
         $order = $this->sortBy['order'][$sort[0]];
         $by = $this->sortBy['by'][$sort[1]];
     }
     $sorted = imap_sort($this->stream, $by, $order);
     $mails = array_chunk($sorted, $perPage);
     $mails = $mails[$page - 1];
     $mbox = imap_check($this->stream);
     $inbox = imap_fetch_overview($this->stream, implode($mails, ','), 0);
     if (!is_array($inbox)) {
         return false;
     }
     if (is_array($inbox)) {
         $temp_inbox = [];
         foreach ($inbox as $msg) {
             $temp_inbox[$msg->msgno] = $msg;
         }
         foreach ($mails as $msgno) {
             $this->inbox[$msgno] = $temp_inbox[$msgno];
         }
     }
     return $this->inbox;
 }
开发者ID:nahidz,项目名称:imapx,代码行数:31,代码来源:imapxPHP.php

示例2: findMails

function findMails($name, $mailbox)
{
    if (strlen($name) === 0 || $name == "_") {
        return array();
    }
    $mailsIds = imap_sort($mailbox->getImapStream(), SORTARRIVAL, true, SE_UID, 'TO "' . $name . '@"');
    return $mailsIds;
}
开发者ID:Git-Host,项目名称:disposable-email-imap,代码行数:8,代码来源:index.php

示例3: getAllMessages

 public function getAllMessages($imap, $dsn)
 {
     $status = imap_status($imap, $dsn, SA_ALL);
     $msgs = imap_sort($imap, SORTDATE, 1, SE_UID);
     foreach ($msgs as $msguid) {
         $msgno = imap_msgno($imap, $msguid);
         $messages[$msgno] = imap_headerinfo($imap, $msgno);
     }
     return $messages;
 }
开发者ID:maniargaurav,项目名称:OpenDesk,代码行数:10,代码来源:mail.php

示例4: listMessages

 function listMessages($page = 1, $per_page = 25, $sort = null)
 {
     $limit = $per_page * $page;
     $start = $limit - $per_page + 1;
     $start = $start < 1 ? 1 : $start;
     $limit = $limit - $start != $per_page - 1 ? $start + ($per_page - 1) : $limit;
     $info = imap_check($this->marubox);
     $limit = $info->Nmsgs < $limit ? $info->Nmsgs : $limit;
     if (true === is_array($sort)) {
         $sorting = array('direction' => array('asc' => 0, 'desc' => 1), 'by' => array('date' => SORTDATE, 'arrival' => SORTARRIVAL, 'from' => SORTFROM, 'subject' => SORTSUBJECT, 'size' => SORTSIZE));
         $by = true === is_int($by = $sorting['by'][$sort[0]]) ? $by : $sorting['by']['date'];
         $direction = true === is_int($direction = $sorting['direction'][$sort[1]]) ? $direction : $sorting['direction']['desc'];
         $sorted = imap_sort($this->marubox, $by, $direction);
         $msgs = array_chunk($sorted, $per_page);
         $msgs = $msgs[$page - 1];
     } else {
         $msgs = range($start, $limit);
         //just to keep it consistent
     }
     $result = imap_fetch_overview($this->marubox, implode($msgs, ','), 0);
     if (false === is_array($result)) {
         return false;
     }
     foreach ($result as $k => $r) {
         $result[$k]->subject = $this->_imap_utf8($r->subject);
         $result[$k]->from = $this->_imap_utf8($r->from);
         $result[$k]->to = $this->_imap_utf8($r->to);
         $result[$k]->body = $this->getBody($r->msgno);
     }
     //sorting!
     if (true === is_array($sorted)) {
         $tmp_result = array();
         foreach ($result as $r) {
             $tmp_result[$r->msgno] = $r;
         }
         $result = array();
         foreach ($msgs as $msgno) {
             $result[] = $tmp_result[$msgno];
         }
     }
     $return = array('res' => $result, 'start' => $start, 'limit' => $limit, 'sorting' => array('by' => $sort[0], 'direction' => $sort[1]), 'total' => imap_num_msg($this->marubox));
     $return['pages'] = ceil($return['total'] / $per_page);
     return $return;
 }
开发者ID:tmlsoft,项目名称:main,代码行数:44,代码来源:receivemail.class.php

示例5: read_inbox

 function read_inbox($params)
 {
     $sort = $params['sort'] == 'DESC' ? 1 : 0;
     switch ($params['order']) {
         case 'message_date':
             $idlist = imap_sort($this->imap, SORTARRIVAL, $sort, SE_UID);
             break;
         case 'message_from':
             $idlist = imap_sort($this->imap, SORTFROM, $sort, SE_UID);
             break;
         case 'message_subject':
             $idlist = imap_sort($this->imap, SORTSUBJECT, $sort, SE_UID);
             break;
         default:
             $idlist = imap_sort($this->imap, SORTARRIVAL, 1, SE_UID);
     }
     foreach ($idlist as $uid) {
         $msg = imap_headerinfo($this->imap, imap_msgno($this->imap, $uid));
         $messages[] = array('id' => $uid, 'from' => $msg->from[0]->mailbox, 'status' => $this->_msg_status($msg), 'date' => $msg->udate, 'subject' => $msg->Subject);
     }
     return $messages;
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:22,代码来源:class.somessenger_imap.inc.php

示例6: import

 /**
  * @param int|null $limit
  * @param User $user
  */
 public function import($limit = 3, User $user)
 {
     // making the work of Fetch package
     $messages = imap_sort($this->imap->getImapStream(), SORTARRIVAL, 1, SE_UID, $this->getImapSearch($user));
     if ($limit != null) {
         $messages = array_slice($messages, 0, $limit);
     }
     foreach ($messages as &$message) {
         $message = new Message($message, $this->imap);
     }
     unset($message);
     foreach ($messages as $message) {
         $data = $this->parseData($message);
         foreach ($data as $purchase) {
             try {
                 $this->purchase_service->save($purchase, $user);
             } catch (\Exception $e) {
                 continue;
             }
         }
     }
 }
开发者ID:shina,项目名称:control-my-budget,代码行数:26,代码来源:MailImportAbstract.php

示例7: imap_check

}
$boxinfo = imap_check($mbox);
if (!is_object($boxinfo) || !isset($boxinfo->Nmsgs)) {
    die("COULD NOT GET MAILBOX INFO\r\n");
}
if ($boxinfo->Driver != 'imap') {
    die("THIS SCRIPT HAS ONLY BEEN TESTED WITH IMAP MAILBOXES\r\n");
}
if ($boxinfo->Nmsgs < 1) {
    die("NO NEW MESSAGES\r\n");
}
echo "Fetching {$boxinfo->Mailbox}\r\n";
echo "{$boxinfo->Nmsgs} messages, {$boxinfo->Recent} recent\r\n";
// Helps clean up the mailbox, especially if a desktop client is interracting with it also
imap_expunge($mbox);
foreach ((array) imap_sort($mbox, SORTARRIVAL, 1) as $message_id) {
    // Detect a disconnect...
    if (!imap_ping($mbox)) {
        die("REMOTE IMAP SERVER HAS GONE AWAY\r\n");
    }
    // Fetch this message, fix the line endings, this makes a 1:1 copy of the message in ram
    // that, in my tests, matches the filesystem copy of the message on the imap server
    // ( tested with debian / postfix / dovecot )
    $r = processmail(str_replace("\r\n", "\n", imap_fetchheader($mbox, $message_id, FT_INTERNAL) . imap_body($mbox, $message_id)));
    // stop when we reach the first duplicate
    if (!$r) {
        break;
    }
    echo '.';
    imap_setflag_full($mbox, $message_id, '\\SEEN');
    continue;
开发者ID:bi0xid,项目名称:bach,代码行数:31,代码来源:spress-imap-pull.php

示例8: aff_mail

function aff_mail($servr, $user, $passwd, $folder, $mail, $verbose, $lang, $sort, $sortdir)
{
    $mailhost = $servr;
    require 'conf.php';
    require 'check_lang.php';
    global $attach_tab;
    //	GLOBAL $PHP_SELF;
    $glob_body = '';
    $subject = $from = $to = $cc = '';
    if (setlocale(LC_TIME, $lang_locale) != $lang_locale) {
        $default_date_format = $no_locale_date_format;
    }
    $current_date = strftime($default_date_format, time());
    $pop = @imap_open('{' . $mailhost . '}' . $folder, $user, $passwd);
    // Finding the next and previous message number
    $sorted = imap_sort($pop, $sort, $sortdir);
    for ($i = 0; $i < sizeof($sorted); $i++) {
        if ($mail == $sorted[$i]) {
            $prev_msg = $sorted[$i - 1];
            $next_msg = $sorted[$i + 1];
            break;
        }
    }
    // END finding the next and previous message number
    $num_messages = @imap_num_msg($pop);
    $ref_contenu_message = @imap_header($pop, $mail);
    $struct_msg = @imap_fetchstructure($pop, $mail);
    if (sizeof($struct_msg->parts) > 0) {
        GetPart($struct_msg, NULL, $display_rfc822);
    } else {
        GetSinglePart($struct_msg, htmlspecialchars(imap_fetchheader($pop, $mail)), @imap_body($pop, $mail));
    }
    if ($verbose == 1 && $use_verbose == 1) {
        $header = htmlspecialchars(imap_fetchheader($pop, $mail));
    } else {
        $header = '';
    }
    $tmp = array_pop($attach_tab);
    if (preg_match('/text/html/i', $tmp['mime']) || preg_match('/text/plain/i', $tmp['mime'])) {
        if ($tmp['transfer'] == 'QUOTED-PRINTABLE') {
            $glob_body = imap_qprint(imap_fetchbody($pop, $mail, $tmp['number']));
        } elseif ($tmp['transfer'] == 'BASE64') {
            $glob_body = base64_decode(imap_fetchbody($pop, $mail, $tmp['number']));
        } else {
            $glob_body = imap_fetchbody($pop, $mail, $tmp['number']);
        }
        $glob_body = remove_stuff($glob_body, $lang, $tmp['mime']);
    } else {
        array_push($attach_tab, $tmp);
    }
    @imap_close($pop);
    if ($struct_msg->subtype != 'ALTERNATIVE' && $struct_msg->subtype != 'RELATED') {
        switch (sizeof($attach_tab)) {
            case 0:
                $link_att = '';
                break;
            case 1:
                $link_att = '<tr><td align="right" valign="top" class="mail">' . $html_att . '</td><td bgcolor="' . $glob_theme->mail_properties . '" class="mail">' . link_att($mailhost, $mail, $attach_tab, $display_part_no) . '</td></tr>';
                break;
            default:
                $link_att = '<tr><td align="right" valign="top" class="mail">' . $html_atts . '</td><td bgcolor="' . $glob_theme->mail_properties . '" class="mail">' . link_att($mailhost, $mail, $attach_tab, $display_part_no) . '</td></tr>';
                break;
        }
    }
    $subject_array = imap_mime_header_decode($ref_contenu_message->subject);
    for ($j = 0; $j < count($subject_array); $j++) {
        $subject .= $subject_array[$j]->text;
    }
    $from_array = imap_mime_header_decode($ref_contenu_message->fromaddress);
    for ($j = 0; $j < count($from_array); $j++) {
        $from .= $from_array[$j]->text;
    }
    $to_array = imap_mime_header_decode($ref_contenu_message->toaddress);
    for ($j = 0; $j < count($to_array); $j++) {
        $to .= $to_array[$j]->text;
    }
    $cc_array = imap_mime_header_decode($ref_contenu_message->ccaddress);
    for ($j = 0; $j < count($cc_array); $j++) {
        $cc .= $cc_array[$j]->text;
    }
    $content = array('from' => htmlspecialchars($from), 'to' => htmlspecialchars($to), 'cc' => htmlspecialchars($cc), 'subject' => htmlspecialchars($subject), 'date' => change_date(chop($ref_contenu_message->udate), $lang), 'att' => $link_att, 'body' => $glob_body, 'body_mime' => $tmp['mime'], 'body_transfer' => $tmp['transfer'], 'header' => $header, 'verbose' => $verbose, 'prev' => $prev_msg, 'next' => $next_msg);
    return $content;
}
开发者ID:patmark,项目名称:care2x-tz,代码行数:83,代码来源:functions.php

示例9: intval

 }
 $homedisplay = intval($homedisplay);
 $prev_currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
 $GLOBALS['phpgw_info']['flags']['currentapp'] = $current_app;
 if (intval($homedisplay)) {
     $boemailadmin = CreateObject('emailadmin.bo');
     $emailadmin_profile = $boemailadmin->getProfileList();
     $_SESSION['phpgw_info']['expressomail']['email_server'] = $boemailadmin->getProfile($emailadmin_profile[0]['profileID']);
     $_SESSION['phpgw_info']['expressomail']['user'] = $GLOBALS['phpgw_info']['user'];
     $_SESSION['phpgw_info']['expressomail']['server'] = $GLOBALS['phpgw_info']['server'];
     $expressoMail = CreateObject($current_app . '.imap_functions');
     $mbox_stream = $expressoMail->open_mbox(False, false);
     if (!$mbox_stream) {
         $portalbox = CreateObject('phpgwapi.listbox', array('title' => "<font color=red>" . lang('Connection failed with %1 Server. Try later.', lang('Mail')) . "</font>", 'primary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 'secondary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 'tertiary' => $GLOBALS['phpgw_info']['theme']['navbar_bg'], 'width' => '100%', 'outerborderwidth' => '0', 'header_background_image' => $GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website', 'bg_filler')));
     } else {
         $messages = imap_sort($mbox_stream, SORTARRIVAL, true, SE_UID, UNSEEN);
         $num_new_messages = count($messages);
         $subjects = array();
         foreach ($messages as $idx => $message) {
             if ($idx == 10) {
                 break;
             }
             $header = @imap_headerinfo($mbox_stream, imap_msgno($mbox_stream, $message), 80, 255);
             if (!is_object($header)) {
                 return false;
             }
             $date_msg = date("d/m/Y", $header->udate);
             if (date("d/m/Y") == $date_msg) {
                 $date = date("H:i", $header->udate);
             } else {
                 $date = $date_msg;
开发者ID:cjvaz,项目名称:expressomail,代码行数:31,代码来源:hook_home.inc.php

示例10: getSortedMessages

 public function getSortedMessages($path)
 {
     $result = array();
     if ($mailbox = $this->openMailbox($path)) {
         if ($sortedMessages = imap_sort($mailbox, SORTDATE, 0, SE_UID)) {
             for ($i = 0; $i < count($sortedMessages); $i++) {
                 if ($messages = imap_fetch_overview($mailbox, $sortedMessages[$i], FT_UID)) {
                     if (!@$messages[$i]->deleted) {
                         $result[] = new BrIMAPMailMessage($this, $path, $messages[0]);
                     }
                 }
             }
         }
     }
     return $result;
 }
开发者ID:jagermesh,项目名称:bright,代码行数:16,代码来源:BrIMAP.php

示例11: sortMails

 /**
  * Gets mails ids sorted by some criteria
  *
  * Criteria can be one (and only one) of the following constants:
  *  SORTDATE - mail Date
  *  SORTARRIVAL - arrival date (default)
  *  SORTFROM - mailbox in first From address
  *  SORTSUBJECT - mail subject
  *  SORTTO - mailbox in first To address
  *  SORTCC - mailbox in first cc address
  *  SORTSIZE - size of mail in octets
  *
  * @param int $criteria
  * @param bool $reverse
  * @return array Mails ids
  */
 public function sortMails($criteria = SORTARRIVAL, $reverse = true)
 {
     return imap_sort($this->getImapStream(), $criteria, $reverse, SE_UID);
 }
开发者ID:ladybirdweb,项目名称:momo-email-listener,代码行数:20,代码来源:Mailbox.php

示例12: globalDelete

 /**
  * Function to delete messages in a mailbox, based on date
  * NOTE: this is global ... will affect all mailboxes except any that have 'sent' in the mailbox name
  */
 public function globalDelete()
 {
     $dateArr = split('-', $this->deleteMsgDate);
     // date format is yyyy-mm-dd
     $delDate = mktime(0, 0, 0, $dateArr[1], $dateArr[2], $dateArr[0]);
     $port = $this->port . '/' . $this->service . '/' . $this->serviceOption;
     $mboxt = imap_open('{' . $this->mailhost . ":" . $port . '}', $this->mailboxUserName, $this->mailboxPassword, OP_HALFOPEN);
     $list = imap_getmailboxes($mboxt, '{' . $this->mailhost . ":" . $port . '}', "*");
     $mailboxFound = false;
     if (is_array($list)) {
         foreach ($list as $key => $val) {
             // get the mailbox name only
             $nameArr = split('}', imap_utf7_decode($val->name));
             $nameRaw = $nameArr[count($nameArr) - 1];
             if (!stristr($nameRaw, 'sent')) {
                 $mboxd = imap_open('{' . $this->mailhost . ":" . $port . '}' . $nameRaw, $this->mailboxUserName, $this->mailboxPassword, CL_EXPUNGE);
                 $messages = imap_sort($mboxd, SORTDATE, 0);
                 $i = 0;
                 $check = imap_mailboxmsginfo($mboxd);
                 foreach ($messages as $message) {
                     $header = imap_header($mboxd, $message);
                     $fdate = date("F j, Y", $header->udate);
                     // purge if prior to global delete date
                     if ($header->udate < $delDate) {
                         imap_delete($mboxd, $message);
                     }
                     $i++;
                 }
                 imap_expunge($mboxd);
                 imap_close($mboxd);
             }
         }
     }
 }
开发者ID:natxet,项目名称:PHPMailer-BMH,代码行数:38,代码来源:BounceMailHandler.php

示例13: getOrderedMessages

 /**
  * Returns the emails in the current mailbox as an array of ImapMessage objects
  * ordered by some ordering
  *
  * @see    http://php.net/manual/en/function.imap-sort.php
  * @param  int       $orderBy
  * @param  bool      $reverse
  * @param  int       $limit
  * @return Message[]
  */
 public function getOrderedMessages($orderBy, $reverse, $limit)
 {
     $msgIds = imap_sort($this->getImapStream(), $orderBy, $reverse ? 1 : 0, SE_UID);
     return array_map(array($this, 'getMessageByUid'), array_slice($msgIds, 0, $limit));
 }
开发者ID:kamaroly,项目名称:Fetch,代码行数:15,代码来源:Server.php

示例14: sort

 function sort($stream, $criteria, $reverse = '', $options = '', $msg_info = '')
 {
     return imap_sort($stream, $criteria, $reverse, $options);
 }
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:4,代码来源:class.mail_dcom_nntp.inc.php

示例15: getMessageNumbers

 /**
  * Recuperation UID
  *
  * @param int $sort SORTDATE | SORTARRIVAL |..
  * @return void
  **/
 public function getMessageNumbers(SearchExpression $search = null, $sort = \SORTARRIVAL, $reverse = false, $charset = null)
 {
     $this->init();
     $query = $search ? (string) $search : 'ALL';
     $messageNumbers = imap_sort($this->connection->getResource(), $sort, (int) $reverse, \SE_UID | \SE_NOPREFETCH, $query, $charset);
     if (false == $messageNumbers) {
         // imap_search can also return false
         $messageNumbers = array();
     }
     return $messageNumbers;
 }
开发者ID:gbcogivea,项目名称:imap,代码行数:17,代码来源:Mailbox.php


注:本文中的imap_sort函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。