本文整理汇总了PHP中imap_ping函数的典型用法代码示例。如果您正苦于以下问题:PHP imap_ping函数的具体用法?PHP imap_ping怎么用?PHP imap_ping使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了imap_ping函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ping
/**
*
* @return booleam
*/
public function ping()
{
if (!imap_ping($this->connect)) {
$this->connect();
}
return true;
}
示例2: pingMailbox
public function pingMailbox()
{
if (!imap_ping($this->mbox)) {
return $this->reconnect();
}
return true;
}
示例3: ping
/**
* Ping the connection
*
* @return bool
*/
public function ping()
{
//init the catching
$this->exceptionThrower->start();
$success = imap_ping($this->mailbox);
$this->exceptionThrower->stop();
return $success;
}
示例4: open
function open()
{
//echo $this->serverstr;
if ($this->mbox && imap_ping($this->mbox)) {
return $this->mbox;
}
$this->mbox = @imap_open($this->serverstr, $this->username, $this->password);
return $this->mbox;
}
示例5: getImapStream
/**
* Get IMAP mailbox connection stream
* @param bool $forceConnection Initialize connection if it's not initialized
* @return null|resource
*/
public function getImapStream($forceConnection = true) {
if($forceConnection) {
if($this->imapStream && (!is_resource($this->imapStream) || !imap_ping($this->imapStream))) {
$this->disconnect();
$this->imapStream = null;
}
if(!$this->imapStream) {
$this->imapStream = $this->initImapStream();
}
}
return $this->imapStream;
}
示例6: get_imap_stream
/**
* Get IMAP mailbox connection stream
* @param bool $forceConnection Initialize connection if it's not initialized
* @return null|resource
*/
public function get_imap_stream($force_connection = true)
{
static $imap_stream;
if ($force_connection) {
if ($imap_stream && (!is_resource($imap_stream) || !imap_ping($imap_stream))) {
$this->disconnect();
$imap_stream = null;
}
if (!$imap_stream) {
$imap_stream = $this->_init_imap_stream();
}
}
return $imap_stream;
}
示例7: emailListener
function emailListener()
{
//$output = "<script>console.log( 'just got in' );</script>";
//echo $output;
$connection = establishConnection();
$dbConn = establishDBConnection();
//$output = "<script>console.log( 'set up connection' );</script>";
//$dbConn->query("INSERT INTO away_mentor (userID, tiStamp) VALUES (99897, NOW())");//test the db connection
//echo $output;//develop thread/loop
$messagestatus = "UNSEEN";
$countTo24 = 0;
while (true) {
echo "in check loop";
$emails = imap_search($connection, $messagestatus);
if ($emails) {
rsort($emails);
foreach ($emails as $email_number) {
echo "in email loop";
$header = imap_headerinfo($connection, $email_number);
$message = imap_fetchbody($connection, $email_number, 1.1);
if ($message == "") {
$message = imap_fetchbody($connection, $email_number, 1);
}
$emailaddress = substr($header->senderaddress, stripos($header->senderaddress, "<") + 1, stripos($header->senderaddress, ">") - (stripos($header->senderaddress, ">") + 1));
if (!detectOOOmessage($header->subject, $message, $emailaddress)) {
detectB00message($header->subject, $emailaddress);
}
imap_delete($connection, 1);
//this might bug out but should delete the top message that was just parsed
}
}
sleep(600);
//do check every 10 minutes
$countTo24 = $countTo24 + 1;
if ($countTo24 >= 144) {
$countTo24 = 0;
$dbConn->query("DELETE FROM away_mentor WHERE tiStamp <= DATE_ADD(CURRENT_DATE, INTERVAL -1 DAY)");
//delete mentors that have been away for more than 24 hours from the away list
//$command = Yii::app()->db->createCommand();
// $command->delete('away_mentor', 'tiStamp <= DATE_ADD(CURRENT_DATE , INTERVAL -1 DAY )');//this might bug the hell out deletes mentors on the away list that were put on over 24 hours ago
}
if (!imap_ping($connection)) {
$connection = establishConnection();
}
}
}
示例8: imap_reopen_folder
/**
* Helper to re-initialize the folder to speed things up
* Remember what folder is currently open and only change if necessary
*
* @param string $folderid id of the folder
* @param boolean $force re-open the folder even if currently opened
*
* @access protected
* @return boolean if folder is opened
*/
protected function imap_reopen_folder($folderid, $force = false)
{
// if the stream is not alive, we open it again
if (!@imap_ping($this->mbox)) {
$this->mbox = @imap_open($this->server, $this->username, $this->password, OP_HALFOPEN);
$this->mboxFolder = "";
}
// to see changes, the folder has to be reopened!
if ($this->mboxFolder != $folderid || $force) {
$s = @imap_reopen($this->mbox, $this->server . $folderid);
// TODO throw status exception
if (!$s) {
ZLog::Write(LOGLEVEL_WARN, sprintf("BackendIMAP->imap_reopen_folder('%s'): failed to change folder: %s", $folderid, implode(", ", imap_errors())));
return false;
}
$this->mboxFolder = $folderid;
}
return true;
}
示例9: isConnected
/**
* Check if the stream is connected
*
* @return bool
*/
protected function isConnected()
{
return $this->isConfigured() && $this->imapStream && is_resource($this->imapStream) && @imap_ping($this->imapStream);
}
示例10: checkConnection
/**
* Checks connection state and if not connected, reconnects
*/
public function checkConnection()
{
if (!imap_ping($this->stream)) {
$this->reconnect();
}
}
示例11: imap_ping
<?php
echo "Checking with no parameters\n";
imap_ping();
echo "Checking with incorrect parameter type\n";
imap_ping('');
imap_ping(false);
示例12: run
/**
* The main method we use to parse an IMAP inbox.
*/
public function run()
{
// $instance must be initialized before we go on!
if (self::$instance === false) {
return false;
}
// If safe mode isn't on, then let's set the execution time to unlimited
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
// Try to connect
$connect = $this->connect();
if (!$connect) {
return false;
}
// Total duration we should keep the IMAP stream alive for in seconds
$duration = bp_rbe_get_execution_time();
bp_rbe_log('--- Keep alive for ' . $duration / 60 . ' minutes ---');
bp_rbe_remove_imap_lock();
// Mark the current timestamp, mark the future time when we should close the IMAP connection;
// Do our parsing until $future > $now; re-mark the timestamp at end of loop... rinse and repeat!
for ($now = time(), $future = time() + $duration; $future > $now; $now = time()) {
// Get number of messages
$message_count = imap_num_msg($this->connection);
// If there are messages in the inbox, let's start parsing!
if ($message_count != 0) {
// According to this:
// http://www.php.net/manual/pl/function.imap-headerinfo.php#95012
// This speeds up rendering the email headers... could be wrong
imap_headers($this->connection);
bp_rbe_log('- Checking inbox -');
// Loop through each email message
for ($i = 1; $i <= $message_count; ++$i) {
// flush object cache if necessary
//
// we only flush the cache if the default object cache is in use
// why? b/c the default object cache is only meant for single page loads and
// since RBE runs in the background, we need to flush the object cache so WP
// will do a direct DB query for the next data fetch
if (!wp_using_ext_object_cache()) {
wp_cache_flush();
}
self::$html = false;
$content = self::body_parser($this->connection, $i);
$headers = $this->get_mail_headers($this->connection, $i);
$data = array('headers' => $headers, 'to_email' => BP_Reply_By_Email_Parser::get_header($headers, 'To'), 'from_email' => BP_Reply_By_Email_Parser::get_header($headers, 'From'), 'content' => $content, 'is_html' => self::$html, 'subject' => imap_utf8(BP_Reply_By_Email_Parser::get_header($headers, 'Subject')));
$parser = BP_Reply_By_Email_Parser::init($data, $i);
if (is_wp_error($parser)) {
//do_action( 'bp_rbe_imap_no_match', $this->connection, $i, $headers, $parser->get_error_code() );
do_action('bp_rbe_no_match', $parser, $data, $i, $this->connection);
}
// do something during the loop
// we mark the message for deletion here via this hook
do_action('bp_rbe_imap_loop', $this->connection, $i);
// unset some variables at the end of the loop
unset($content, $headers, $data, $parser);
}
// do something after the loop
do_action('bp_rbe_imap_after_loop', $this->connection);
}
// stop the loop if necessary
if (bp_rbe_should_stop()) {
if ($this->close()) {
bp_rbe_log('--- Manual termination of connection confirmed! Kaching! ---');
} else {
bp_rbe_log('--- Error - invalid connection during manual termination ---');
}
remove_action('shutdown', 'bp_rbe_spawn_inbox_check');
exit;
}
// Give IMAP server a break
sleep(10);
// If the IMAP connection is down, reconnect
if (!imap_ping($this->connection)) {
bp_rbe_log('-- IMAP connection is down, attempting to reconnect... --');
if (bp_rbe_is_connecting(array('clearcache' => true))) {
bp_rbe_log('--- RBE is already attempting to connect - stopping connection attempt ---');
continue;
}
// add lock marker before connecting
bp_rbe_add_imap_lock();
// attempt to reconnect
$reopen = BP_Reply_By_Email_Connect::init(array('reconnect' => true), $this->connection);
if ($reopen) {
bp_rbe_log('-- Reconnection successful! --');
} else {
bp_rbe_log('-- Reconnection failed! :( --');
bp_rbe_log('Cannot connect: ' . imap_last_error());
// cleanup RBE after failure
bp_rbe_cleanup();
remove_action('shutdown', 'bp_rbe_spawn_inbox_check');
exit;
}
}
// Unset some variables to clear some memory
unset($message_count);
}
//.........这里部分代码省略.........
示例13: check_mailbox
protected function check_mailbox()
{
imap_ping($this->conn);
$count = imap_num_msg($this->conn);
common_log(LOG_INFO, "Found {$count} messages");
if ($count > 0) {
$handler = new IMAPMailHandler();
for ($i = 1; $i <= $count; $i++) {
$rawmessage = imap_fetchheader($this->conn, $count, FT_PREFETCHTEXT) . imap_body($this->conn, $i);
$handler->handle_message($rawmessage);
imap_delete($this->conn, $i);
}
imap_expunge($this->conn);
common_log(LOG_INFO, "Finished processing messages");
}
return $count;
}
示例14: imapPing
/**
* prüft, ob die Connection noch aktiv ist, Exception falls keine Connection definiert ist,
* oder die Connection geschlossen wurde
* wenn reconnect = true, dann wird bei einer geschlossenen Connection die Connection neu aufgebaut
* @param boolean $reconnect
* @return boolean
*/
public function imapPing($reconnect = false)
{
if ($this->imap === null) {
throw new IMAPException(__METHOD__ . ' not connected');
}
$ret = imap_ping($this->imap);
if ($ret === false) {
if ($reconnect === true) {
$this->imap = $this->imapOpen($this->server . $this->mbox, $this->config->username, $this->config->password, OP_HALFOPEN);
$ret = imap_ping($this->imap);
if ($ret === false) {
throw new IMAPException(__METHOD__ . ' reconnect failed');
}
$this->reopenedConnection = true;
} else {
throw new IMAPException(__METHOD__ . ' not connected');
}
}
return true;
}
示例15: ping
public function ping()
{
if ($this->closed) {
return true;
}
imap_ping($this->resource);
}