forked from extern/egroupware
formatting
This commit is contained in:
parent
2a6ff0ffd4
commit
3861b64b16
@ -21,8 +21,10 @@
|
|||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
class msg extends msg_base
|
class msg extends msg_base
|
||||||
{
|
{
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* data analysis specific to IMAP data communications
|
* data analysis specific to IMAP data communications
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -90,7 +92,7 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function imap_read_port
|
@function imap_read_port
|
||||||
@abstract reads data from an IMAP server until the line that begins with the specified param "cmd_tag"
|
@abstract reads data from an IMAP server until the line that begins with the specified param "cmd_tag"
|
||||||
@ -179,7 +181,7 @@
|
|||||||
$this->server_last_error_str = $line;
|
$this->server_last_error_str = $line;
|
||||||
// what should we return here IF there was a NO or BAD error ?
|
// what should we return here IF there was a NO or BAD error ?
|
||||||
// how about an empty array, how about FALSE ??
|
// how about an empty array, how about FALSE ??
|
||||||
|
|
||||||
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
||||||
// empty the array
|
// empty the array
|
||||||
$return_me = Array();
|
$return_me = Array();
|
||||||
@ -197,7 +199,7 @@
|
|||||||
$this->server_last_error_str = 'imap unknown error in imap_read_port: "'.$line.'"';
|
$this->server_last_error_str = 'imap unknown error in imap_read_port: "'.$line.'"';
|
||||||
// what should we return here IF there was a NO or BAD error ?
|
// what should we return here IF there was a NO or BAD error ?
|
||||||
// how about an empty array, how about FALSE ??
|
// how about an empty array, how about FALSE ??
|
||||||
|
|
||||||
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
||||||
// empty the array
|
// empty the array
|
||||||
$return_me = Array();
|
$return_me = Array();
|
||||||
@ -210,7 +212,7 @@
|
|||||||
}
|
}
|
||||||
return $return_me;
|
return $return_me;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function report_svr_data
|
@function report_svr_data
|
||||||
@abstract reports server data array for debugging purposes
|
@abstract reports server data array for debugging purposes
|
||||||
@ -231,7 +233,7 @@
|
|||||||
echo 'imap: '.$calling_func_name.': last server completion line: "'.htmlspecialchars($this->server_last_ok_response).'"<br>';
|
echo 'imap: '.$calling_func_name.': last server completion line: "'.htmlspecialchars($this->server_last_ok_response).'"<br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function server_last_error
|
@function server_last_error
|
||||||
@abstract implements IMAP_LAST_ERROR
|
@abstract implements IMAP_LAST_ERROR
|
||||||
@ -246,8 +248,7 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: call to server_last_error<br>'; }
|
if ($this->debug >= 1) { echo 'imap: call to server_last_error<br>'; }
|
||||||
return $this->server_last_error_str;
|
return $this->server_last_error_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Functions NOT YET IMPLEMENTED
|
* Functions NOT YET IMPLEMENTED
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -348,8 +349,7 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: call to not-yet-implemented socket function: search<br>'; }
|
if ($this->debug >= 1) { echo 'imap: call to not-yet-implemented socket function: search<br>'; }
|
||||||
return $empty_return;
|
return $empty_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* OPEN and CLOSE Server Connection
|
* OPEN and CLOSE Server Connection
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -393,10 +393,10 @@
|
|||||||
$cmd_tag = 'L001';
|
$cmd_tag = 'L001';
|
||||||
$full_command = $cmd_tag.' LOGIN "'.quotemeta($user).'" "'.quotemeta($pass).'"';
|
$full_command = $cmd_tag.' LOGIN "'.quotemeta($user).'" "'.quotemeta($pass).'"';
|
||||||
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
||||||
|
|
||||||
if ($this->debug >= 2) { echo 'imap: open: write_port: '. htmlspecialchars($full_command) .'<br>'; }
|
if ($this->debug >= 2) { echo 'imap: open: write_port: '. htmlspecialchars($full_command) .'<br>'; }
|
||||||
if ($this->debug >= 2) { echo 'imap: open: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
if ($this->debug >= 2) { echo 'imap: open: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
||||||
|
|
||||||
if(!$this->write_port($full_command))
|
if(!$this->write_port($full_command))
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: open: could not write_port<br>'; }
|
if ($this->debug >= 1) { echo 'imap: open: could not write_port<br>'; }
|
||||||
@ -407,7 +407,7 @@
|
|||||||
// server can spew some b.s. hello messages before the official response
|
// server can spew some b.s. hello messages before the official response
|
||||||
// read the server data
|
// read the server data
|
||||||
$response_array = $this->imap_read_port($expecting);
|
$response_array = $this->imap_read_port($expecting);
|
||||||
|
|
||||||
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
||||||
if (count($response_array) == 0)
|
if (count($response_array) == 0)
|
||||||
{
|
{
|
||||||
@ -425,7 +425,7 @@
|
|||||||
if ($this->debug >= 2) { $this->report_svr_data($response_array, 'open', True); }
|
if ($this->debug >= 2) { $this->report_svr_data($response_array, 'open', True); }
|
||||||
if ($this->debug >= 1) { echo 'imap: open: Successful IMAP Login<br>'; }
|
if ($this->debug >= 1) { echo 'imap: open: Successful IMAP Login<br>'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// now that we have logged in, php's IMAP_OPEN would now select the desired folder
|
// now that we have logged in, php's IMAP_OPEN would now select the desired folder
|
||||||
if ($this->debug >= 2) { echo 'imap: open: php IMAP_OPEN would now select desired folder: "'. htmlspecialchars($folder) .'"<br>'; }
|
if ($this->debug >= 2) { echo 'imap: open: php IMAP_OPEN would now select desired folder: "'. htmlspecialchars($folder) .'"<br>'; }
|
||||||
// php's IMAP_OPEN also selects the desired folder (mailbox) after the connection is established
|
// php's IMAP_OPEN also selects the desired folder (mailbox) after the connection is established
|
||||||
@ -440,24 +440,24 @@
|
|||||||
function close($flags="")
|
function close($flags="")
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: Entering Close<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Entering Close<br>'; }
|
||||||
|
|
||||||
$cmd_tag = 'c001';
|
$cmd_tag = 'c001';
|
||||||
$full_command = $cmd_tag.' LOGOUT';
|
$full_command = $cmd_tag.' LOGOUT';
|
||||||
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
||||||
|
|
||||||
if ($this->debug >= 2) { echo 'imap: close: write_port: "'. htmlspecialchars($full_command) .'"<br>'; }
|
if ($this->debug >= 2) { echo 'imap: close: write_port: "'. htmlspecialchars($full_command) .'"<br>'; }
|
||||||
if ($this->debug >= 2) { echo 'imap: close: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
if ($this->debug >= 2) { echo 'imap: close: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
||||||
|
|
||||||
if(!$this->write_port($full_command))
|
if(!$this->write_port($full_command))
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: close: could not write_port<br>'; }
|
if ($this->debug >= 1) { echo 'imap: close: could not write_port<br>'; }
|
||||||
$this->error();
|
$this->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
// server can spew some b.s. goodbye message before the official response
|
// server can spew some b.s. goodbye message before the official response
|
||||||
// read the server data
|
// read the server data
|
||||||
$response_array = $this->imap_read_port($expecting);
|
$response_array = $this->imap_read_port($expecting);
|
||||||
|
|
||||||
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
||||||
if (count($response_array) == 0)
|
if (count($response_array) == 0)
|
||||||
{
|
{
|
||||||
@ -468,7 +468,7 @@
|
|||||||
echo $this->server_last_error().'<br>';
|
echo $this->server_last_error().'<br>';
|
||||||
}
|
}
|
||||||
if ($this->debug >= 1) { echo 'imap: Leaving Close with error<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Leaving Close with error<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -492,29 +492,29 @@
|
|||||||
function reopen($stream_notused, $fq_folder, $flags='')
|
function reopen($stream_notused, $fq_folder, $flags='')
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: Entering reopen<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Entering reopen<br>'; }
|
||||||
|
|
||||||
// fq_folder is a "fully qualified folder", seperate the parts:
|
// fq_folder is a "fully qualified folder", seperate the parts:
|
||||||
$svr_data = array();
|
$svr_data = array();
|
||||||
$svr_data = $this->distill_fq_folder($fq_folder);
|
$svr_data = $this->distill_fq_folder($fq_folder);
|
||||||
$folder = $svr_data['folder'];
|
$folder = $svr_data['folder'];
|
||||||
if ($this->debug >= 1) { echo 'imap: reopen: folder value is: ['.$folder.']<br>'; }
|
if ($this->debug >= 1) { echo 'imap: reopen: folder value is: ['.$folder.']<br>'; }
|
||||||
|
|
||||||
$cmd_tag = 'r001';
|
$cmd_tag = 'r001';
|
||||||
$full_command = $cmd_tag.' SELECT "'.$folder.'"';
|
$full_command = $cmd_tag.' SELECT "'.$folder.'"';
|
||||||
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
||||||
|
|
||||||
if ($this->debug >= 2) { echo 'imap: reopen: write_port: "'. htmlspecialchars($full_command) .'"<br>'; }
|
if ($this->debug >= 2) { echo 'imap: reopen: write_port: "'. htmlspecialchars($full_command) .'"<br>'; }
|
||||||
if ($this->debug >= 2) { echo 'imap: reopen: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
if ($this->debug >= 2) { echo 'imap: reopen: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
||||||
|
|
||||||
if(!$this->write_port($full_command))
|
if(!$this->write_port($full_command))
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: reopen: could not write_port<br>'; }
|
if ($this->debug >= 1) { echo 'imap: reopen: could not write_port<br>'; }
|
||||||
$this->error();
|
$this->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the server data
|
// read the server data
|
||||||
$response_array = $this->imap_read_port($expecting);
|
$response_array = $this->imap_read_port($expecting);
|
||||||
|
|
||||||
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
||||||
if (count($response_array) == 0)
|
if (count($response_array) == 0)
|
||||||
{
|
{
|
||||||
@ -525,7 +525,7 @@
|
|||||||
echo $this->server_last_error().'<br>';
|
echo $this->server_last_error().'<br>';
|
||||||
}
|
}
|
||||||
if ($this->debug >= 1) { echo 'imap: Leaving reopen with error<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Leaving reopen with error<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -568,7 +568,7 @@
|
|||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: Entering listmailbox<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Entering listmailbox<br>'; }
|
||||||
$mailboxes_array = Array();
|
$mailboxes_array = Array();
|
||||||
|
|
||||||
// prepare params, seperate wildcards "*" or "%" from param $pattern
|
// prepare params, seperate wildcards "*" or "%" from param $pattern
|
||||||
// LIST param 1 is empty or is a mailbox reference string withOUT any wildcard
|
// LIST param 1 is empty or is a mailbox reference string withOUT any wildcard
|
||||||
// LIST param 2 is empty or is the wildcard either "%" or "*"
|
// LIST param 2 is empty or is the wildcard either "%" or "*"
|
||||||
@ -604,7 +604,7 @@
|
|||||||
$cmd_tag = 'X001';
|
$cmd_tag = 'X001';
|
||||||
$full_command = $cmd_tag.' LIST '.$list_params;
|
$full_command = $cmd_tag.' LIST '.$list_params;
|
||||||
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
||||||
|
|
||||||
if ($this->debug >= 2) { echo 'imap: listmailbox: write_port: ['. htmlspecialchars($full_command) .']<br>'; }
|
if ($this->debug >= 2) { echo 'imap: listmailbox: write_port: ['. htmlspecialchars($full_command) .']<br>'; }
|
||||||
if ($this->debug >= 2) { echo 'imap: listmailbox: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
if ($this->debug >= 2) { echo 'imap: listmailbox: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
||||||
|
|
||||||
@ -613,10 +613,10 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: listmailbox: could not write_port<br>'; }
|
if ($this->debug >= 1) { echo 'imap: listmailbox: could not write_port<br>'; }
|
||||||
$this->error();
|
$this->error();
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the server data
|
// read the server data
|
||||||
$response_array = $this->imap_read_port($expecting);
|
$response_array = $this->imap_read_port($expecting);
|
||||||
|
|
||||||
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
// TEST THIS ERROR DETECTION - empty array = error (BAD or NO)
|
||||||
if (count($response_array) == 0)
|
if (count($response_array) == 0)
|
||||||
{
|
{
|
||||||
@ -627,13 +627,13 @@
|
|||||||
echo $this->server_last_error().'<br>';
|
echo $this->server_last_error().'<br>';
|
||||||
}
|
}
|
||||||
if ($this->debug >= 1) { echo 'imap: Leaving listmailbox with error<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Leaving listmailbox with error<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($this->debug >= 2) { $this->report_svr_data($response_array, 'reopen', True); }
|
if ($this->debug >= 2) { $this->report_svr_data($response_array, 'reopen', True); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete all text except the folder name
|
// delete all text except the folder name
|
||||||
for ($i=0; $i<count($response_array); $i++)
|
for ($i=0; $i<count($response_array); $i++)
|
||||||
{
|
{
|
||||||
@ -664,13 +664,13 @@
|
|||||||
$mailboxes_array[$next_pos] = $folder_name;
|
$mailboxes_array[$next_pos] = $folder_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->debug >= 2) { $this->report_svr_data($mailboxes_array, 'listmailbox INTERNAL_mailboxes_array', False); }
|
if ($this->debug >= 2) { $this->report_svr_data($mailboxes_array, 'listmailbox INTERNAL_mailboxes_array', False); }
|
||||||
if ($this->debug >= 1) { echo 'imap: Leaving listmailbox<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Leaving listmailbox<br>'; }
|
||||||
//return '';
|
//return '';
|
||||||
return $mailboxes_array;
|
return $mailboxes_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OBSOLETED
|
// OBSOLETED
|
||||||
function fix_folder($folder)
|
function fix_folder($folder)
|
||||||
{
|
{
|
||||||
@ -698,17 +698,17 @@
|
|||||||
}
|
}
|
||||||
return $folder;
|
return $folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Mailbox Status and Information
|
* Mailbox Status and Information
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
function mailboxmsginfo($stream_notused='')
|
function mailboxmsginfo($stream_notused='')
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: mailboxmsginfo<br>'; }
|
if ($this->debug >= 1) { echo 'imap: mailboxmsginfo<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function mailboxmsginfo($folder='')
|
function mailboxmsginfo($folder='')
|
||||||
{
|
{
|
||||||
@ -730,10 +730,10 @@
|
|||||||
{
|
{
|
||||||
$mailbox = $folder;
|
$mailbox = $folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
$info->messages = $this->num_msgs($mailbox);
|
$info->messages = $this->num_msgs($mailbox);
|
||||||
$info->size = $this->total($this->fetch_field(1,$info->messages,'RFC822.SIZE'));
|
$info->size = $this->total($this->fetch_field(1,$info->messages,'RFC822.SIZE'));
|
||||||
|
|
||||||
if ($info->messages)
|
if ($info->messages)
|
||||||
{
|
{
|
||||||
return $info;
|
return $info;
|
||||||
@ -744,7 +744,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function status
|
@function status
|
||||||
@abstract implements php function IMAP_STATUS
|
@abstract implements php function IMAP_STATUS
|
||||||
@ -773,11 +773,11 @@
|
|||||||
// build the query string
|
// build the query string
|
||||||
$query_str = '';
|
$query_str = '';
|
||||||
$available_options = Array(
|
$available_options = Array(
|
||||||
SA_MESSAGES => 'MESSAGES',
|
SA_MESSAGES => 'MESSAGES',
|
||||||
SA_RECENT => 'RECENT',
|
SA_RECENT => 'RECENT',
|
||||||
SA_UNSEEN => 'UNSEEN',
|
SA_UNSEEN => 'UNSEEN',
|
||||||
SA_UIDNEXT => 'UIDNEXT',
|
SA_UIDNEXT => 'UIDNEXT',
|
||||||
SA_UIDVALIDITY => 'UIDVALIDITY'
|
SA_UIDVALIDITY => 'UIDVALIDITY'
|
||||||
);
|
);
|
||||||
@reset($available_options);
|
@reset($available_options);
|
||||||
while(list($key,$value) = each($available_options))
|
while(list($key,$value) = each($available_options))
|
||||||
@ -788,22 +788,22 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query_str = trim($query_str);
|
$query_str = trim($query_str);
|
||||||
|
|
||||||
$cmd_tag = 's001';
|
$cmd_tag = 's001';
|
||||||
//$full_command = $cmd_tag.' STATUS '.$svr_data['folder'].' (MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)';
|
//$full_command = $cmd_tag.' STATUS '.$svr_data['folder'].' (MESSAGES RECENT UIDNEXT UIDVALIDITY UNSEEN)';
|
||||||
$full_command = $cmd_tag.' STATUS "'.$svr_data['folder'].'" ('.$query_str.')';
|
$full_command = $cmd_tag.' STATUS "'.$svr_data['folder'].'" ('.$query_str.')';
|
||||||
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
$expecting = $cmd_tag; // may be followed by OK, NO, or BAD
|
||||||
|
|
||||||
if ($this->debug >= 2) { echo 'imap: status: write_port: "'. htmlspecialchars($full_command) .'"<br>'; }
|
if ($this->debug >= 2) { echo 'imap: status: write_port: "'. htmlspecialchars($full_command) .'"<br>'; }
|
||||||
if ($this->debug >= 2) { echo 'imap: status: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
if ($this->debug >= 2) { echo 'imap: status: expecting: "'. htmlspecialchars($expecting) .'" followed by OK, NO, or BAD<br>'; }
|
||||||
|
|
||||||
if(!$this->write_port($full_command))
|
if(!$this->write_port($full_command))
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: status: could not write_port<br>'; }
|
if ($this->debug >= 1) { echo 'imap: status: could not write_port<br>'; }
|
||||||
$this->error();
|
$this->error();
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
// read the server data
|
// read the server data
|
||||||
$response_array = $this->imap_read_port($expecting);
|
$response_array = $this->imap_read_port($expecting);
|
||||||
|
|
||||||
@ -817,7 +817,7 @@
|
|||||||
echo $this->server_last_error().'<br>';
|
echo $this->server_last_error().'<br>';
|
||||||
}
|
}
|
||||||
if ($this->debug >= 1) { echo 'imap: Leaving status with error<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Leaving status with error<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
// STATUS should only return 1 line of data
|
// STATUS should only return 1 line of data
|
||||||
if (count($response_array) > 1)
|
if (count($response_array) > 1)
|
||||||
@ -829,12 +829,12 @@
|
|||||||
echo $this->server_last_error().'<br>';
|
echo $this->server_last_error().'<br>';
|
||||||
}
|
}
|
||||||
if ($this->debug >= 1) { echo 'imap: Leaving status with error<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Leaving status with error<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we get here we have valid server data
|
// if we get here we have valid server data
|
||||||
if ($this->debug >= 2) { $this->report_svr_data($response_array, 'status', True); }
|
if ($this->debug >= 2) { $this->report_svr_data($response_array, 'status', True); }
|
||||||
|
|
||||||
// initialize structure
|
// initialize structure
|
||||||
$info = new mailbox_status;
|
$info = new mailbox_status;
|
||||||
$info->messages = '';
|
$info->messages = '';
|
||||||
@ -842,20 +842,20 @@
|
|||||||
$info->unseen = '';
|
$info->unseen = '';
|
||||||
$info->uidnext = '';
|
$info->uidnext = '';
|
||||||
$info->uidvalidity = '';
|
$info->uidvalidity = '';
|
||||||
|
|
||||||
//typical server data:
|
//typical server data:
|
||||||
// * STATUS INBOX (MESSAGES 15 RECENT 1 UNSEEN 2 UIDNEXT 17 UIDVALIDITY 1005967489)
|
// * STATUS INBOX (MESSAGES 15 RECENT 1 UNSEEN 2 UIDNEXT 17 UIDVALIDITY 1005967489)
|
||||||
// data starts after the mailbox name, which could actually have similar strings as the status querey
|
// data starts after the mailbox name, which could actually have similar strings as the status querey
|
||||||
// get data the includes and follows the opening paren
|
// get data the includes and follows the opening paren
|
||||||
$status_data_raw = strstr($response_array[0], '(');
|
$status_data_raw = strstr($response_array[0], '(');
|
||||||
|
|
||||||
// snarf any of the 5 possible pieces of data if they are present
|
// snarf any of the 5 possible pieces of data if they are present
|
||||||
$status_data['messages'] = $this->snarf_status_data($status_data_raw, 'MESSAGES');
|
$status_data['messages'] = $this->snarf_status_data($status_data_raw, 'MESSAGES');
|
||||||
$status_data['recent'] = $this->snarf_status_data($status_data_raw, 'RECENT');
|
$status_data['recent'] = $this->snarf_status_data($status_data_raw, 'RECENT');
|
||||||
$status_data['unseen'] = $this->snarf_status_data($status_data_raw, 'UNSEEN');
|
$status_data['unseen'] = $this->snarf_status_data($status_data_raw, 'UNSEEN');
|
||||||
$status_data['uidnext'] = $this->snarf_status_data($status_data_raw, 'UIDNEXT');
|
$status_data['uidnext'] = $this->snarf_status_data($status_data_raw, 'UIDNEXT');
|
||||||
$status_data['uidvalidity'] = $this->snarf_status_data($status_data_raw, 'UIDVALIDITY');
|
$status_data['uidvalidity'] = $this->snarf_status_data($status_data_raw, 'UIDVALIDITY');
|
||||||
|
|
||||||
// fill structure and unset any unfilled data elements
|
// fill structure and unset any unfilled data elements
|
||||||
if ($status_data['messages'] != '')
|
if ($status_data['messages'] != '')
|
||||||
{
|
{
|
||||||
@ -901,7 +901,7 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: Leaving status<br>'; }
|
if ($this->debug >= 1) { echo 'imap: Leaving status<br>'; }
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
function snarf_status_data($status_raw_str='',$snarf_this='')
|
function snarf_status_data($status_raw_str='',$snarf_this='')
|
||||||
{
|
{
|
||||||
// bogus data detection
|
// bogus data detection
|
||||||
@ -912,10 +912,10 @@
|
|||||||
}
|
}
|
||||||
// fallback value
|
// fallback value
|
||||||
$return_data = '';
|
$return_data = '';
|
||||||
|
|
||||||
//typical server data:
|
//typical server data:
|
||||||
// * STATUS INBOX (MESSAGES 15 RECENT 1 UNSEEN 2 UIDNEXT 17 UIDVALIDITY 1005967489)
|
// * STATUS INBOX (MESSAGES 15 RECENT 1 UNSEEN 2 UIDNEXT 17 UIDVALIDITY 1005967489)
|
||||||
|
|
||||||
// see if $snarf_this is in the raw data
|
// see if $snarf_this is in the raw data
|
||||||
$data_mini_str = stristr($status_raw_str, $snarf_this);
|
$data_mini_str = stristr($status_raw_str, $snarf_this);
|
||||||
if ($data_mini_str != False)
|
if ($data_mini_str != False)
|
||||||
@ -947,7 +947,7 @@
|
|||||||
}
|
}
|
||||||
return $return_data;
|
return $return_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
// OBSOLETED
|
// OBSOLETED
|
||||||
function num_msg($folder='')
|
function num_msg($folder='')
|
||||||
{
|
{
|
||||||
@ -957,7 +957,7 @@
|
|||||||
}
|
}
|
||||||
return $this->status_query($folder,'MESSAGES');
|
return $this->status_query($folder,'MESSAGES');
|
||||||
}
|
}
|
||||||
|
|
||||||
// OBSOLETED
|
// OBSOLETED
|
||||||
function total($field)
|
function total($field)
|
||||||
{
|
{
|
||||||
@ -969,19 +969,19 @@
|
|||||||
}
|
}
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Message Sorting
|
* Message Sorting
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
// options/flags are:
|
// options/flags are:
|
||||||
//SE_UID Return UIDs instead of sequence numbers
|
//SE_UID Return UIDs instead of sequence numbers
|
||||||
//SE_NOPREFETCH Don't prefetch searched messages.
|
//SE_NOPREFETCH Don't prefetch searched messages.
|
||||||
function sort($stream_notused='',$criteria=SORTARRIVAL,$reverse=False,$options='')
|
function sort($stream_notused='',$criteria=SORTARRIVAL,$reverse=False,$options='')
|
||||||
{
|
{
|
||||||
if ($this->debug >= 1) { echo 'imap: sort<br>'; }
|
if ($this->debug >= 1) { echo 'imap: sort<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function sort($folder='',$criteria=SORTDATE,$reverse=False,$options='')
|
function sort($folder='',$criteria=SORTDATE,$reverse=False,$options='')
|
||||||
{
|
{
|
||||||
@ -1029,7 +1029,7 @@
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
uasort($field_list,array($this,"ssort_decending"));
|
uasort($field_list,array($this,"ssort_decending"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif(!$reverse)
|
elseif(!$reverse)
|
||||||
{
|
{
|
||||||
@ -1051,7 +1051,7 @@
|
|||||||
return $return_array;
|
return $return_array;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
*
|
*
|
||||||
* Message Structural Information
|
* Message Structural Information
|
||||||
@ -1063,7 +1063,7 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: fetchstructure<br>'; }
|
if ($this->debug >= 1) { echo 'imap: fetchstructure<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function fetchstructure($msgnum)
|
function fetchstructure($msgnum)
|
||||||
{
|
{
|
||||||
@ -1098,8 +1098,7 @@
|
|||||||
return $this->header;
|
return $this->header;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Message Envelope (Header Info) Data
|
* Message Envelope (Header Info) Data
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -1108,12 +1107,11 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: header<br>'; }
|
if ($this->debug >= 1) { echo 'imap: header<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* More Data Communications (dcom) With IMAP Server
|
* More Data Communications (dcom) With IMAP Server
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* DELETE a Message From the Server
|
* DELETE a Message From the Server
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -1122,8 +1120,7 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: delete<br>'; }
|
if ($this->debug >= 1) { echo 'imap: delete<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Get Message Headers From Server
|
* Get Message Headers From Server
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -1133,7 +1130,7 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: fetchheader<br>'; }
|
if ($this->debug >= 1) { echo 'imap: fetchheader<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_header($start,$stop,$element)
|
function fetch_header($start,$stop,$element)
|
||||||
{
|
{
|
||||||
if(!$this->write_port('a001 FETCH '.$start.':'.$stop.' RFC822.HEADER'))
|
if(!$this->write_port('a001 FETCH '.$start.':'.$stop.' RFC822.HEADER'))
|
||||||
@ -1169,8 +1166,7 @@
|
|||||||
$response = $this->read_port();
|
$response = $this->read_port();
|
||||||
return $field_element;
|
return $field_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function fetch_field($start,$stop,$element)
|
function fetch_field($start,$stop,$element)
|
||||||
{
|
{
|
||||||
if(!$this->write_port('a001 FETCH '.$start.':'.$stop.' '.$element))
|
if(!$this->write_port('a001 FETCH '.$start.':'.$stop.' '.$element))
|
||||||
@ -1188,9 +1184,8 @@
|
|||||||
$response = $this->read_port();
|
$response = $this->read_port();
|
||||||
}
|
}
|
||||||
return $field_element;
|
return $field_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* Get Message Body (Parts) From Server
|
* Get Message Body (Parts) From Server
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
@ -1199,7 +1194,7 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: fetchbody<br>'; }
|
if ($this->debug >= 1) { echo 'imap: fetchbody<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@function get_body
|
@function get_body
|
||||||
@abstract implements IMAP_BODY
|
@abstract implements IMAP_BODY
|
||||||
@ -1210,7 +1205,5 @@
|
|||||||
if ($this->debug >= 1) { echo 'imap: get_body<br>'; }
|
if ($this->debug >= 1) { echo 'imap: get_body<br>'; }
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* phpGroupWare Email - POP3 Mail Wrapper for Imap Enabled PHP *
|
* phpGroupWare Email - POP3 Mail Wrapper for Imap Enabled PHP *
|
||||||
* http://www.phpgroupware.org/ * *
|
* http://www.phpgroupware.org/ *
|
||||||
* -------------------------------------------------------------------------*
|
* -------------------------------------------------------------------------*
|
||||||
* This library is part of phpGroupWare (http://www.phpgroupware.org) *
|
* This library is part of phpGroupWare (http://www.phpgroupware.org) *
|
||||||
* This library is free software; you can redistribute it and/or modify it *
|
* This library is free software; you can redistribute it and/or modify it *
|
||||||
@ -161,7 +161,7 @@
|
|||||||
{
|
{
|
||||||
echo 'CALL TO LOGIN IN CLASS MSG POP3'.'<br>'.'userid='.$GLOBALS['phpgw_info']['user']['preferences']['email']['userid'];
|
echo 'CALL TO LOGIN IN CLASS MSG POP3'.'<br>'.'userid='.$GLOBALS['phpgw_info']['user']['preferences']['email']['userid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
error_reporting(error_reporting() - 2);
|
error_reporting(error_reporting() - 2);
|
||||||
if($folder!='INBOX')
|
if($folder!='INBOX')
|
||||||
{
|
{
|
||||||
@ -205,4 +205,3 @@
|
|||||||
return $folder_str;
|
return $folder_str;
|
||||||
}
|
}
|
||||||
} // end of class msg
|
} // end of class msg
|
||||||
|
|
||||||
|
@ -21,178 +21,197 @@
|
|||||||
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
class msg extends msg_base
|
/* $Id$ */
|
||||||
{
|
|
||||||
var $db;
|
|
||||||
var $folder;
|
|
||||||
var $start_msg;
|
|
||||||
var $end_msg;
|
|
||||||
|
|
||||||
function mode_reader()
|
class msg extends msg_base
|
||||||
{
|
{
|
||||||
return $this->msg2socket('mode reader','^20[01]',&$response);
|
var $db;
|
||||||
}
|
var $folder;
|
||||||
|
var $start_msg;
|
||||||
|
var $end_msg;
|
||||||
|
|
||||||
function login ($user,$passwd,$server,$port,$folder = '')
|
function mode_reader()
|
||||||
{
|
|
||||||
global $phpgw;
|
|
||||||
|
|
||||||
$this->db = $phpgw->db;
|
|
||||||
|
|
||||||
if(@!$server)
|
|
||||||
{
|
{
|
||||||
echo 'Error: Configuration Error! The administrator has not configured the NNTP Server.';
|
return $this->msg2socket('mode reader','^20[01]',&$response);
|
||||||
}
|
|
||||||
|
|
||||||
if(@!$port)
|
|
||||||
{
|
|
||||||
$port = 119;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->open_port($server,$port,15))
|
function login ($user,$passwd,$server,$port,$folder = '')
|
||||||
{
|
{
|
||||||
$this->error();
|
$this->db = $GLOBALS['phpgw']->db;
|
||||||
}
|
|
||||||
$this->read_port();
|
|
||||||
|
|
||||||
if ($user <> '' && $passwd <> '')
|
if(@!$server)
|
||||||
{
|
{
|
||||||
if (!$this->msg2socket('authinfo user '.$user,'^381',&$response))
|
echo 'Error: Configuration Error! The administrator has not configured the NNTP Server.';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(@!$port)
|
||||||
|
{
|
||||||
|
$port = 119;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->open_port($server,$port,15))
|
||||||
{
|
{
|
||||||
$this->error();
|
$this->error();
|
||||||
}
|
}
|
||||||
if (!$this->msg2socket('authinfo pass '.$passwd,'^281',&$response))
|
$this->read_port();
|
||||||
|
|
||||||
|
if ($user <> '' && $passwd <> '')
|
||||||
|
{
|
||||||
|
if (!$this->msg2socket('authinfo user '.$user,'^381',&$response))
|
||||||
|
{
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
|
if (!$this->msg2socket('authinfo pass '.$passwd,'^281',&$response))
|
||||||
|
{
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$this->mode_reader())
|
||||||
{
|
{
|
||||||
$this->error();
|
$this->error();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!$this->mode_reader())
|
|
||||||
{
|
|
||||||
$this->error();
|
|
||||||
}
|
|
||||||
if(!$folder)
|
|
||||||
{
|
|
||||||
$folder = $this->get_first_folder();
|
|
||||||
if(!$folder)
|
if(!$folder)
|
||||||
{
|
{
|
||||||
$this->error();
|
$folder = $this->get_first_folder();
|
||||||
|
if(!$folder)
|
||||||
|
{
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$this->folder = $folder;
|
||||||
|
$this->mailbox = $this->get_mailbox_name($folder);
|
||||||
|
$this->num_msgs = $this->num_msg($this->mailbox);
|
||||||
|
$this->start_msg = $this->first_message($this->mailbox);
|
||||||
|
$this->end_msg = $this->last_message($this->mailbox);
|
||||||
|
echo 'Successful connection to '.$this->mailbox."<br>\n";
|
||||||
}
|
}
|
||||||
$this->folder = $folder;
|
|
||||||
$this->mailbox = $this->get_mailbox_name($folder);
|
|
||||||
$this->num_msgs = $this->num_msg($this->mailbox);
|
|
||||||
$this->start_msg = $this->first_message($this->mailbox);
|
|
||||||
$this->end_msg = $this->last_message($this->mailbox);
|
|
||||||
echo 'Successful connection to '.$this->mailbox."<br>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
function fix_folder($folder='')
|
function fix_folder($folder='')
|
||||||
{
|
|
||||||
if($folder=='')
|
|
||||||
{
|
{
|
||||||
$mailbox = $this->mailbox;
|
if($folder=='')
|
||||||
}
|
|
||||||
elseif(is_int($folder))
|
|
||||||
{
|
|
||||||
$mailbox = $this->get_mailbox_name($folder);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mailbox = $folder;
|
|
||||||
}
|
|
||||||
return $mailbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_first_folder()
|
|
||||||
{
|
|
||||||
if(@!$GLOBALS['phpgw_info']['user']['preferences']['nntp'])
|
|
||||||
{
|
|
||||||
$this->set_error('Configuration','User Preferences','You have not set your user preferences in NNTP.');
|
|
||||||
$this->error();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$pref = @each($GLOBALS['phpgw_info']['user']['preferences']['nntp']);
|
|
||||||
return $pref[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_mailbox_name($folder)
|
|
||||||
{
|
|
||||||
$active = False;
|
|
||||||
$this->db->query('SELECT name,active FROM newsgroups WHERE con='.$folder,_LINE__,__FILE__);
|
|
||||||
if ($this->db->num_rows() > 0)
|
|
||||||
{
|
|
||||||
$this->db->next_record();
|
|
||||||
$mailbox = $this->db->f('name');
|
|
||||||
}
|
|
||||||
if ($this->db->f('active') != 'Y')
|
|
||||||
{
|
|
||||||
$GLOBALS['phpgw']->preferences->delete('nntp',$folder);
|
|
||||||
$GLOBALS['phpgw']->preferences->save_repository();
|
|
||||||
|
|
||||||
$this->set_error('Administration','Automatic Disabling','The newsgroup '.$mailbox.' is not activated by the Administrator.');
|
|
||||||
$this->error();
|
|
||||||
}
|
|
||||||
return $mailbox;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_mailbox_counts($folder='',$index=1)
|
|
||||||
{
|
|
||||||
$mailbox = $this->fix_folder($folder);
|
|
||||||
if (!$this->msg2socket('group '.$mailbox,'^211',&$response))
|
|
||||||
{
|
|
||||||
$this->error();
|
|
||||||
}
|
|
||||||
$temp_array = explode(' ',$response);
|
|
||||||
return $temp_array[$index];
|
|
||||||
}
|
|
||||||
|
|
||||||
function num_msg($folder='')
|
|
||||||
{
|
|
||||||
if(($folder == '' || $folder == $this->mailbox) && isset($this->num_msgs))
|
|
||||||
{
|
|
||||||
return $this->num_msgs;
|
|
||||||
}
|
|
||||||
return $this->get_mailbox_counts($folder,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
function first_message($folder='')
|
|
||||||
{
|
|
||||||
if(($folder == '' || $folder == $this->mailbox) && isset($this->start_msg))
|
|
||||||
{
|
|
||||||
return $this->start_msg;
|
|
||||||
}
|
|
||||||
return $this->get_mailbox_counts($folder,2);
|
|
||||||
}
|
|
||||||
|
|
||||||
function last_message($folder='')
|
|
||||||
{
|
|
||||||
if(($folder == '' || $folder == $this->mailbox) && isset($this->end_msg))
|
|
||||||
{
|
|
||||||
return $this->end_msg;
|
|
||||||
}
|
|
||||||
return $this->get_mailbox_counts($folder,3);
|
|
||||||
}
|
|
||||||
|
|
||||||
function mailboxmsginfo($folder='')
|
|
||||||
{
|
|
||||||
$info = new msg_mb_info;
|
|
||||||
if($folder=='' || $folder==$this->mailbox || $folder==$this->folder)
|
|
||||||
{
|
|
||||||
if(isset($this->num_msgs))
|
|
||||||
{
|
{
|
||||||
$info->messages = $this->num_msgs;
|
$mailbox = $this->mailbox;
|
||||||
|
}
|
||||||
|
elseif(is_int($folder))
|
||||||
|
{
|
||||||
|
$mailbox = $this->get_mailbox_name($folder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($folder==$this->folder)
|
$mailbox = $folder;
|
||||||
{
|
|
||||||
$this->mailbox = $this->get_mailbox_name($folder);
|
|
||||||
}
|
|
||||||
$info->messages = $this->num_msg($this->mailbox);
|
|
||||||
}
|
}
|
||||||
|
return $mailbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_first_folder()
|
||||||
|
{
|
||||||
|
if(@!$GLOBALS['phpgw_info']['user']['preferences']['nntp'])
|
||||||
|
{
|
||||||
|
$this->set_error('Configuration','User Preferences','You have not set your user preferences in NNTP.');
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$pref = @each($GLOBALS['phpgw_info']['user']['preferences']['nntp']);
|
||||||
|
return $pref[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_mailbox_name($folder)
|
||||||
|
{
|
||||||
|
$active = False;
|
||||||
|
$this->db->query('SELECT name,active FROM newsgroups WHERE con='.$folder,_LINE__,__FILE__);
|
||||||
|
if ($this->db->num_rows() > 0)
|
||||||
|
{
|
||||||
|
$this->db->next_record();
|
||||||
|
$mailbox = $this->db->f('name');
|
||||||
|
}
|
||||||
|
if ($this->db->f('active') != 'Y')
|
||||||
|
{
|
||||||
|
$GLOBALS['phpgw']->preferences->delete('nntp',$folder);
|
||||||
|
$GLOBALS['phpgw']->preferences->save_repository();
|
||||||
|
|
||||||
|
$this->set_error('Administration','Automatic Disabling','The newsgroup '.$mailbox.' is not activated by the Administrator.');
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
|
return $mailbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_mailbox_counts($folder='',$index=1)
|
||||||
|
{
|
||||||
|
$mailbox = $this->fix_folder($folder);
|
||||||
|
if (!$this->msg2socket('group '.$mailbox,'^211',&$response))
|
||||||
|
{
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
|
$temp_array = explode(' ',$response);
|
||||||
|
return $temp_array[$index];
|
||||||
|
}
|
||||||
|
|
||||||
|
function num_msg($folder='')
|
||||||
|
{
|
||||||
|
if(($folder == '' || $folder == $this->mailbox) && isset($this->num_msgs))
|
||||||
|
{
|
||||||
|
return $this->num_msgs;
|
||||||
|
}
|
||||||
|
return $this->get_mailbox_counts($folder,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function first_message($folder='')
|
||||||
|
{
|
||||||
|
if(($folder == '' || $folder == $this->mailbox) && isset($this->start_msg))
|
||||||
|
{
|
||||||
|
return $this->start_msg;
|
||||||
|
}
|
||||||
|
return $this->get_mailbox_counts($folder,2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function last_message($folder='')
|
||||||
|
{
|
||||||
|
if(($folder == '' || $folder == $this->mailbox) && isset($this->end_msg))
|
||||||
|
{
|
||||||
|
return $this->end_msg;
|
||||||
|
}
|
||||||
|
return $this->get_mailbox_counts($folder,3);
|
||||||
|
}
|
||||||
|
|
||||||
|
function mailboxmsginfo($folder='')
|
||||||
|
{
|
||||||
|
$info = new msg_mb_info;
|
||||||
|
if($folder=='' || $folder==$this->mailbox || $folder==$this->folder)
|
||||||
|
{
|
||||||
|
if(isset($this->num_msgs))
|
||||||
|
{
|
||||||
|
$info->messages = $this->num_msgs;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($folder==$this->folder)
|
||||||
|
{
|
||||||
|
$this->mailbox = $this->get_mailbox_name($folder);
|
||||||
|
}
|
||||||
|
$info->messages = $this->num_msg($this->mailbox);
|
||||||
|
}
|
||||||
|
$info->size = 0;
|
||||||
|
if ($info->messages)
|
||||||
|
{
|
||||||
|
return $info;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mailbox = $this->fix_folder($folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
$info->messages = $this->num_msgs($mailbox);
|
||||||
$info->size = 0;
|
$info->size = 0;
|
||||||
|
|
||||||
|
$this->num_msgs($this->mailbox);
|
||||||
|
|
||||||
if ($info->messages)
|
if ($info->messages)
|
||||||
{
|
{
|
||||||
return $info;
|
return $info;
|
||||||
@ -202,123 +221,104 @@
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
function fetch_field($start,$stop,$element)
|
||||||
{
|
{
|
||||||
$mailbox = $this->fix_folder($folder);
|
if (!$this->msg2socket('XHDR '.$element.' '.$start.'-'.$stop,'^221',&$response))
|
||||||
|
{
|
||||||
|
$this->error();
|
||||||
|
}
|
||||||
|
|
||||||
|
$field_element = Array();
|
||||||
|
while ($line = $this->read_port())
|
||||||
|
{
|
||||||
|
$line = chop($line);
|
||||||
|
if ($line == '.')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$breakpos = strpos($line,' ');
|
||||||
|
|
||||||
|
$field_element[intval(substr($line,0,$breakpos-1))] = $this->phpGW_quoted_printable_decode2(substr($line,$breakpos+1));
|
||||||
|
}
|
||||||
|
return $field_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
$info->messages = $this->num_msgs($mailbox);
|
function status($folder='',$options=SA_ALL)
|
||||||
$info->size = 0;
|
|
||||||
|
|
||||||
$this->num_msgs($this->mailbox);
|
|
||||||
|
|
||||||
if ($info->messages)
|
|
||||||
{
|
{
|
||||||
|
$info = new mailbox_status;
|
||||||
|
$info->messages = $this->num_msg($folder);
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fetch_field($start,$stop,$element)
|
function sort($folder='',$criteria=SORTDATE,$reverse=False,$options='')
|
||||||
{
|
|
||||||
if (!$this->msg2socket('XHDR '.$element.' '.$start.'-'.$stop,'^221',&$response))
|
|
||||||
{
|
{
|
||||||
$this->error();
|
if($folder == '' || $folder == $this->mailbox)
|
||||||
}
|
|
||||||
|
|
||||||
$field_element = Array();
|
|
||||||
while ($line = $this->read_port())
|
|
||||||
{
|
|
||||||
$line = chop($line);
|
|
||||||
if ($line == '.')
|
|
||||||
{
|
{
|
||||||
break;
|
$mailbox = $this->mailbox;
|
||||||
}
|
$start_msg = $this->start_msg;
|
||||||
$breakpos = strpos($line,' ');
|
$end_msg = $this->end_msg;
|
||||||
|
|
||||||
$field_element[intval(substr($line,0,$breakpos-1))] = $this->phpGW_quoted_printable_decode2(substr($line,$breakpos+1));
|
|
||||||
}
|
|
||||||
return $field_element;
|
|
||||||
}
|
|
||||||
|
|
||||||
function status($folder='',$options=SA_ALL)
|
|
||||||
{
|
|
||||||
$info = new mailbox_status;
|
|
||||||
$info->messages = $this->num_msg($folder);
|
|
||||||
return $info;
|
|
||||||
}
|
|
||||||
|
|
||||||
function sort($folder='',$criteria=SORTDATE,$reverse=False,$options='')
|
|
||||||
{
|
|
||||||
if($folder == '' || $folder == $this->mailbox)
|
|
||||||
{
|
|
||||||
$mailbox = $this->mailbox;
|
|
||||||
$start_msg = $this->start_msg;
|
|
||||||
$end_msg = $this->end_msg;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mailbox = $this->fix_folder($folder);
|
|
||||||
$start_msg = $this->first_message($mailbox);
|
|
||||||
$end_msg = $this->last_message($mailbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch($criteria)
|
|
||||||
{
|
|
||||||
case SORTDATE:
|
|
||||||
$old_list = $this->fetch_field($start_msg,$end_msg,'Date');
|
|
||||||
$field_list = $this->convert_date_array($old_list);
|
|
||||||
break;
|
|
||||||
case SORTARRIVAL:
|
|
||||||
break;
|
|
||||||
case SORTFROM:
|
|
||||||
$field_list = $this->fetch_field($start_msg,$end_msg,'From');
|
|
||||||
break;
|
|
||||||
case SORTSUBJECT:
|
|
||||||
$field_list = $this->fetch_field($start_msg,$end_msg,'Subject');
|
|
||||||
break;
|
|
||||||
case SORTTO:
|
|
||||||
$field_list = $this->fetch_field($start_msg,$end_msg,'To');
|
|
||||||
break;
|
|
||||||
case SORTCC:
|
|
||||||
$field_list = $this->fetch_field($start_msg,$end_msg,'cc');
|
|
||||||
break;
|
|
||||||
case SORTSIZE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
@reset($field_list);
|
|
||||||
if($criteria == SORTSUBJECT)
|
|
||||||
{
|
|
||||||
if(!$reverse)
|
|
||||||
{
|
|
||||||
uasort($field_list,array($this,"ssort_ascending"));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uasort($field_list,array($this,"ssort_decending"));
|
$mailbox = $this->fix_folder($folder);
|
||||||
}
|
$start_msg = $this->first_message($mailbox);
|
||||||
|
$end_msg = $this->last_message($mailbox);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($criteria)
|
||||||
|
{
|
||||||
|
case SORTDATE:
|
||||||
|
$old_list = $this->fetch_field($start_msg,$end_msg,'Date');
|
||||||
|
$field_list = $this->convert_date_array($old_list);
|
||||||
|
break;
|
||||||
|
case SORTARRIVAL:
|
||||||
|
break;
|
||||||
|
case SORTFROM:
|
||||||
|
$field_list = $this->fetch_field($start_msg,$end_msg,'From');
|
||||||
|
break;
|
||||||
|
case SORTSUBJECT:
|
||||||
|
$field_list = $this->fetch_field($start_msg,$end_msg,'Subject');
|
||||||
|
break;
|
||||||
|
case SORTTO:
|
||||||
|
$field_list = $this->fetch_field($start_msg,$end_msg,'To');
|
||||||
|
break;
|
||||||
|
case SORTCC:
|
||||||
|
$field_list = $this->fetch_field($start_msg,$end_msg,'cc');
|
||||||
|
break;
|
||||||
|
case SORTSIZE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
@reset($field_list);
|
||||||
|
if($criteria == SORTSUBJECT)
|
||||||
|
{
|
||||||
|
if(!$reverse)
|
||||||
|
{
|
||||||
|
uasort($field_list,array($this,"ssort_ascending"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uasort($field_list,array($this,"ssort_decending"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif(!$reverse)
|
||||||
|
{
|
||||||
|
asort($field_list);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
arsort($field_list);
|
||||||
|
}
|
||||||
|
$return_array = Array();
|
||||||
|
@reset($field_list);
|
||||||
|
$i = 1;
|
||||||
|
while(list($key,$value) = each($field_list))
|
||||||
|
{
|
||||||
|
$return_array[] = $key;
|
||||||
|
echo '('.$i++.') Field: <b>'.$value."</b>\t\tMsg Num: <b>".$key."</b><br>\n";
|
||||||
|
}
|
||||||
|
@reset($return_array);
|
||||||
|
return $return_array;
|
||||||
}
|
}
|
||||||
elseif(!$reverse)
|
|
||||||
{
|
|
||||||
asort($field_list);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
arsort($field_list);
|
|
||||||
}
|
|
||||||
$return_array = Array();
|
|
||||||
@reset($field_list);
|
|
||||||
$i = 1;
|
|
||||||
while(list($key,$value) = each($field_list))
|
|
||||||
{
|
|
||||||
$return_array[] = $key;
|
|
||||||
echo '('.$i++.') Field: <b>'.$value."</b>\t\tMsg Num: <b>".$key."</b><br>\n";
|
|
||||||
}
|
|
||||||
@reset($return_array);
|
|
||||||
return $return_array;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user