Maildecoding Fehler?

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Maildecoding Fehler?

    Hallo, ich hab ne neue maildecoder-klasse gefunden, da die von tbt nicht richtig funzt.

    Ich bekomm folgenden Fehler :

    Warning: Variable passed to each() is not an array or object in /srv/www/htdocs/web8/html/test/config/maildecoder.class.php on line 16

    Zeile 16 ist :

    while ( list(, $line) = each($body) ) {

    was bedeutet der fehler??? und wie kann ich den beheben!

    PHP-Code:
    class MimeDecoder {
        var 
    $attachments;
        var 
    $text_version;

        
    # This accepts the body of a message (in Array form, split on n) and the
        # MIME encoded boundary.

        # This returns a two dimensional array, with the \'ContentType\', \'filename\',
        # \'ContentTypeEncoding\' and the attachment \'data\' for each indexed
        # attachment.
        
    function MimeDecode($body$boundary) {

        
    $attach_no = -1;

    while ( list(, 
    $line) = each($body) ) {

        
    $line trim($line);

        if ( 
    strstr($line"--$boundary") ) {
            
    $this->attachments['number'] = ++$attach_no;
            continue;
        }

        if ( !
    $this->attachments[$attach_no]['ContentType'] &&
             
    preg_match("/^Content-Type: ([w-/]*);?(.*)?/"$line$matches) ) {
            
    $this->attachments[$attach_no]['ContentType'] = trim($matches[1]);
            if ( 
    $matches[2] &&
                 
    preg_match("/name=\"(.*)\"/i"$matches[2],
                            
    $new_match)) {
                if (!
    $this->attachments[$attach_no]['filename'])
                    
    $this->attachments[$attach_no]['filename']=trim($new_match[1]);
            }
            continue;
        }

        if ( !
    $this->attachments[$attach_no]['filename'] &&
             
    preg_match("/name=\"(.*)\"/i"$line$matches) ) {
            
    $this->attachments[$attach_no]['filename'] = trim($matches[1]);
            continue;
        }

        if ( !
    $this->attachments[$attach_no]['ContentTransferEncoding'] &&
             
    preg_match("/^Content-Transfer-Encoding: (.*)/"$line$matches) ) {
            
    $this->attachments[$attach_no]['ContentTransferEncoding'] = trim($matches[1]);
            continue;
        }


        if ( !
    $line && !$this->attachments[$attach_no]['data'] ) {
            
    $data[0] = "";
            while ( list (, 
    $line) = each($body) ) {
                
    $line trim($line);
                
    $line preg_replace("/< */? *HTML *>/i"""$line);
                if (
    strstr($line$boundary)) {
                    
    prev($body);
                    break;
                }
                
    array_push($data$line."n");
            }

            
    # Decode attachment data before leaving...
            # Base64 encoded messages...
            
    if ( !strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'], "base64") ) {
                
    $this->attachments[$attach_no]['data'][0] = "";
                foreach (
    $data as $linearray_push($this->attachments[$attach_no]['data'],  base64_decode($line));

            
    # Quoted-Printable encoded messages
            
    } else if ( !strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'],"quoted-printable") ) {
                
    $this->attachments[$attach_no]['data'][0] = "";
                foreach (
    $data as $linearray_push($this->attachments[$attach_no]['data'],  quoted_printable_decode($line));

            
    # 7 or 8 bit \"encoding\"
            
    } else if ( !strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'],"7bit") || 
    !
    strcasecmp($this->attachments[$attach_no]['ContentTransferEncoding'], "8bit") ) {
                
    $this->attachments[$attach_no]['data'] = $data;

            
    # defualt to just dumping the data
            
    } else {
                
    $this->attachments[$attach_no]['data'] = $data;
            }
            
    $data NULL;
            continue;

        }

    # end foreach

        
    # end MimeDecode



    Danke im voraus für die hilfe!!!
    Zuletzt geändert von TriphunEM; 09.07.2005, 14:35.

  • #2
    1. bitte code umbrechen: http://www.php-resource.de/forum/sho...threadid=50454
    2. so schwer ist es doch nicht:
    "Variable passed to each() is not an array or object" -> http://babelfish.altavista.com/babel...bject&lp=en_de
    also wird $body nicht stimmen.

    Kommentar


    • #3
      Wie der Kommentar schon sagt:
      "This accepts the body of a message (in Array form, split on \n) and the MIME encoded boundary."

      Kommentar


      • #4
        danke. das prob hab ich gelöst!

        ich bekomm aber in dieser zeile

        preg_match("/^Content-Type: ([w-/]*);?(.*)?/", $line, $matches) ) {

        diesen fehler :

        Warning: Unknown modifier ']' in c:\_myfiles\websites\www.blabla.com v4.0\config\maildecode.class.php on line 26

        ich kenn mich leider ne so gut mir regex aus!
        ????

        Kommentar


        • #5
          Code:
          w-/


          der delimiter darf nicht unescaped im ausdruck auftauchen.
          also:
          Code:
          w-\/

          Kommentar


          • #6
            danke, wenn ich das aber escape kommt die fehlermeldung :


            Warning: Compilation failed: range out of order in character class at offset 20 in c:\_myfiles\websites\www.blabla.com v4.0\config\maildecode.class.php on line 26

            ???
            Zuletzt geändert von TriphunEM; 09.07.2005, 15:47.

            Kommentar


            • #7
              der bereich von 'w' bis '/' ist ja auch unsinn, aber du musst doch wenigstens wissen, was du an dieser stelle brauchst, oder?

              Kommentar


              • #8
                sorry, das script ist nicht von mir. ich versuch es nur anzuwenden!
                es ist bloß blöd das es ne geht, weil das strato auf einer cd veröffentlicht hat!

                Hast du ne idee, wie man das richtig machen kann???

                Kommentar


                • #9
                  http://www.phpbuilder.com/snippet/do...snippet&id=452

                  wenn du die copy-paste-methode vorziehst, wende dich nächstes mal an den autor des scriptes.

                  Kommentar


                  • #10
                    wenn ich wüßte wer das ist, würde ich es tun!

                    Kommentar


                    • #11
                      PEAR Maildecoder hat Macke!

                      Hallo, benutze folgende Maildeocoding-Klasse :
                      http://www.phpguru.org/static/mime.decode.html

                      Leider finde ich auch keine andere Klasse! Diese Funktioniert zwar gut, aber der Body haut nicht hin!

                      Der Bodytext der eMail war :
                      ja das ist ein Test,
                      mal kucken obs geht!

                      MfG

                      TriphunEM
                      aber in dem folgenden print_r code bekomm ich ich den Body zum Teil in eine undefinierten Array wieder und da nur ein bissl text und zu mal fehlen die ersten buchstaben :

                      [] => Array
                      (
                      [0] => a das ist ein Test,
                      [1] => al kucken obs geht!
                      )
                      und der rest bekomm ich im Array namens Body :

                      [body] => MfG

                      TriphunEM
                      Versteh das überhaupt nicht!!! Kann mir einer helfen, woran das liegen könnte????

                      Array
                      (
                      [0] => stdClass Object
                      (
                      [headers] => Array
                      (
                      [return-path] =>
                      [x-original-to] => info@testmail.com
                      [delivered-to] => web1p1@h140118.serverkompetenz.net
                      [received] => from [127.0.0.1] (unknown [82.222.72.104]) by h140118.serverkompetenz.net (Postfix) with ESMTP id 2642D920001 for ; Sun, 10 Jul 2005 10:30:12 +0200 (CEST)
                      [message-id] => <42D0DDE9.1080609@testdomain.de>
                      [date] => Sun, 10 Jul 2005 10:35:53 +0200
                      [from] => "irgendjemand"
                      [reply-to] => info@testdomain.de
                      [organization] => irgendeine
                      [user-agent] => Mozilla Thunderbird 1.0.2 (Windows/20050317)
                      [x-accept-language] => de-DE, de, en-us, en
                      [mime-version] => 1.0
                      [to] => info@testdomain.de
                      [subject] => Test 2
                      [content-type] => text/plain; charset=ISO-8859-15; format=flowed
                      [content-transfer-encoding] => 7bit
                      [x-uidl] => O8Y"!p?C"!*[@"!0IE"!
                      [status] => RO
                      [] => Array
                      (
                      [0] => a das ist ein Test,
                      [1] => al kucken obs geht!
                      )

                      )

                      [ctype_primary] => text
                      [ctype_secondary] => plain
                      [ctype_parameters] => Array
                      (
                      [charset] => ISO-8859-15
                      [format] => flowed
                      )

                      [body] => MfG

                      TriphunEM
                      )
                      )

                      Kommentar


                      • #12
                        gut hat sich erledigt. lag nicht an der klassen sondern am mailempfang und dem boundary!

                        Kommentar

                        Lädt...
                        X