Subversion-Projekte lars-tiefland.content-management

Revision

Blame | Letzte Änderung | Log anzeigen | RSS feed

<?php

    /**
     * @package   Content-management
     * @author    Lars Tiefland <tiefland@weban.de>
     * @copyright 2009 Webagentur Niewerth
     * @license   propietary http://www.weban.de
     * @version   $Rev$
     * @filesource
     * 
     */

    /**
     * 
     * @package   Content-management
     * @author    Lars Tiefland <tiefland@weban.de>
     * @copyright 2009 Webagentur Niewerth
     */

    // SVN: $Id: functions.common.php 51 2009-10-07 09:43:24Z tiefland $

    /**
     * This example provides a basic demonstration of how Mail_IMAP can be used to
     * view multipart messages.  See {@link connect} for extended documentation on
     * how to set the connection URI.
     *
     * This example is part of the message viewer. Here the headers are retrieved for 
     * a message part and the message part itself is displayed using an inline frame.
     *
     *
     * @author      Richard York <rich_y@php.net?>
     * @copyright   (c) Copyright 2004, Richard York, All Rights Reserved.
     * @package     Mail_IMAP
     * @subpackage  examples
     *
     */

    // Use an existing imap resource stream, or provide a URI abstraction.
    // Example of URI:
    // pop3://user:pass@mail.example.com:110/INBOX#notls
    //
    // If you are unsure of the URI syntax to use here,
    // use the Mail_IMAP_connection_wizard to find the right URI.
    // Or see docs for Mail_IMAP::connect
    //
    // The connection URI must also be set in:
    // IMAP.inbox.php.
    // IMAP.message_viewer.php
    // IMAP.part_viewer.php

    require_once 'Mail/IMAP.php';

    $connection = 'imap://rs:EW-ad-1055@mail.mediaran.de:143/INBOX';

    if ( !isset($_GET['dump_mid']) )
    {
        $msg = &new Mail_IMAP();
    }
    else
    {
        // Call on debuging automatically.
        include 'Mail/IMAP/Debug/Debug.php';
        $msg = &new Mail_IMAP_Debug( $connection );
        if ( $msg->error->hasErrors() )
        {
            $msg->dump( $msg->error->getErrors(true) );
        }
    }

    // Open up a mail connection
    if ( !$msg->connect($connection) )
    {
        echo $msg->alerts();
        echo $msg->errors();
        echo
            '<SPAN style="font-weight: bold;">Error:</SPAN> Unable to build a connection.';
    }

    // Get parts and headers
    $mid = $_GET['mid'];
    $pid = $_GET['pid'];

    $msg->getParts( $mid, $pid );
    $msg->getHeaders( $mid, $pid );

    function Mail_IMAP_do_address_line( &$msg, &$mid, $line )
    {
        $rtn = ( string )'';

        if ( !empty($msg->header[$mid][$line]) )
        {
            foreach ( $msg->header[$mid][$line] as $i => $address )
            {
                if ( isset($msg->header[$mid][$line . '_personal'][$i]) && !
                    empty($msg->header[$mid][$line . '_personal'][$i]) )
                {
                    $rtn .= "<SPAN title='" . $msg->header[$mid][$line][$i] .
                        "'>" . $msg->header[$mid][$line . '_personal'][$i] .
                        "</SPAN> ;\n";
                }
                else
                {
                    $rtn .= str_replace( '@', ' at ', $msg->header[$mid][$line][$i] ) .
                        "; \n";
                }
            }
        }
        return $rtn;
    }

    function Mail_IMAP_do_parts( &$msg, &$mid, $disp )
    {
        $rtn = ( string )'';

        if ( isset($msg->msg[$mid][$disp]['pid']) && count($msg->msg[$mid][$disp]['pid']) >
            0 )
        {
            foreach ( $msg->msg[$mid][$disp]['pid'] as $i => $inid )
            {
                $rtn .= "<A href=" . $_SERVER['PHP_SELF'] . "?mid='{$mid}&pid=" .
                    $msg->msg[$mid][$disp]['pid'][$i] . "' target='top'>" .
                    $msg->msg[$mid][$disp]['fname'][$i] . " " . $msg->msg[$mid][$disp]['ftype'][$i] .
                    " " . $msg->convertBytes( $msg->msg[$mid][$disp]['fsize'][$i] ) .
                    "</A><BR>\n";
            }
        }
        return $rtn;
    }

    echo "
    
        
            <TITLE> Mail_IMAP Inbox </TITLE>
            <LINK rel='stylesheet' type='text/css' href='IMAP.css' media='all'>
        
        
                <TABLE id='headerviewer'>
                                <TBODY><TR><TD class='header''> Subject: </TD><TD> " . $msg->header[$mid]['subject'] .
        " </TD></TR><TR><TD class='header'> To: </TD><TD>" . "\n" .
        Mail_IMAP_do_address_line( $msg, $mid, 'to' ) . "
                                        </TD></TR><TR><TD class='header'> Cc: </TD><TD>\n" .
        Mail_IMAP_do_address_line( $msg, $mid, 'cc' ) . "
                                        </TD></TR><TR><TD class='header'> From: </TD><TD>\n" .
        Mail_IMAP_do_address_line( $msg, $mid, 'from' ) . "
                                        </TD></TR><TR><TD class='header'> Received: </TD><TD>" . date( 'D d M, Y h:i:s',
        $msg->header[$mid]['udate'] ) .
        "</TD></TR><TR><TD class='header''> Inline Parts: </TD><TD>" .
        Mail_IMAP_do_parts( $msg, $mid, 'in' ) .
        "</TD></TR><TR><TD class='header'> Attachments: </TD><TD>" .
        Mail_IMAP_do_parts( $msg, $mid, 'at' ) . "</TD></TR></TBODY>
                </TABLE>
                <IFRAME src='IMAP.part_viewer.php?mid={$mid}&pid={$pid}' name='part' style='width: 100%; height: 400px;'></IFRAME>
        
        ";
?>