* @category Mail
* @package Mail_IMAPv2
* @license BSD
* @version 0.1.0 Beta
* @copyright (c) Copyright 2004-2005, Richard York, All Rights Reserved.
* @since PHP 4.2.0
* @since C-Client 2001
* @tutorial http://www.smilingsouls.net/Mail_IMAP
*/
class Mail_IMAPv2_Debug extends Mail_IMAPv2 {
function Mail_IMAPv2_Debug($connection = NULL, $get_info = TRUE)
{
$this->Mail_IMAPv2($connection, $get_info);
if (isset($_GET['dump_mid'])) {
$this->debug($_GET['dump_mid']);
} else {
$this->error->push(Mail_IMAPv2_ERROR, 'error', array('method' => 'Mail_IMAPv2_Debug', 'error_string' => 'No mid was specified for debugging.'));
}
}
/**
* Dumps various information about a message for debugging. Specify $_GET
* variables to view information.
*
* Calling on the debugger exits script execution after debugging operations
* have been completed.
*
* @param int $mid $mid to debug
* @return void
* @access public
* @tutorial http://www.smilingsouls.net/Mail_IMAP?content=Mail_IMAP_Debug/debug
*/
function debug($mid = 0)
{
$this->_declareParts($mid);
if (isset($_GET['dump_mb_info'])) {
$this->dump($this->mailboxInfo);
}
if (isset($_GET['dump_cid'])) {
$this->dump($this->msg[$mid]['in']['cid']);
}
if (isset($_GET['dump_related'])) {
$this->dump($this->getRelatedParts($mid, $_GET['dump_related']));
}
if (isset($_GET['dump_msg']) && isset($_GET['dump_pid'])) {
$this->getParts($mid, $_GET['dump_pid']);
$this->dump($this->msg);
}
if (isset($_GET['dump_pid'])) {
$this->dump($this->structure[$mid]['pid']);
}
if (isset($_GET['dump_ftype'])) {
$this->dump($this->structure[$mid]['ftype']);
}
if (isset($_GET['dump_structure'])) {
$this->dump($this->structure[$mid]['obj']);
}
if (isset($_GET['test_pid'])) {
echo imap_fetchbody($this->mailbox, $mid, $_GET['test_pid'], NULL);
}
if (isset($_GET['dump_mb_list'])) {
$this->dump($this->getMailboxes());
}
if (isset($_GET['dump_headers'])) {
$this->dump($this->getHeaders($mid, $_GET['dump_headers'], TRUE));
}
if ($this->error->hasErrors()) {
$this->dump($this->error->getErrors(TRUE));
}
// Skip everything else in debug mode
exit;
}
/**
* Calls on var_dump and outputs with HTML
tags.
*
* @param mixed $thing $thing to dump.
* @return void
* @access public
* @tutorial http://www.smilingsouls.net/Mail_IMAP?content=Mail_IMAP_Debug/dump
*/
function dump(&$thing)
{
echo "\n";
var_dump($thing);
echo "\n";
}
}
?>