Overview

Packages

  • awl
    • AuthPlugin
    • AwlDatabase
    • Browser
    • classEditor
    • DataEntry
    • DataUpdate
    • EMail
    • iCalendar
    • MenuSet
    • PgQuery
    • Session
    • Translation
    • User
    • Utilities
    • Validation
    • vCalendar
    • vComponent
    • XMLDocument
    • XMLElement
  • None

Classes

  • AuthPlugin
  • AwlCache
  • AwlDatabase
  • AwlDBDialect
  • AwlQuery
  • AwlUpgrader
  • Browser
  • BrowserColumn
  • DBRecord
  • Editor
  • EditorField
  • EMail
  • EntryField
  • EntryForm
  • iCalComponent
  • iCalProp
  • MenuOption
  • MenuSet
  • Multipart
  • PgQuery
  • Session
  • SinglePart
  • User
  • Validation
  • vCalendar
  • vComponent
  • vObject
  • vProperty
  • XMLDocument
  • XMLElement

Functions

  • _awl_connect_configured_database
  • _CompareMenuSequence
  • auth_external
  • auth_other_awl
  • awl_get_fields
  • awl_replace_sql_args
  • awl_set_locale
  • awl_version
  • BuildXMLTree
  • check_by_regex
  • check_temporary_passwords
  • clean_string
  • connect_configured_database
  • dbg_error_log
  • dbg_log_array
  • define_byte_mappings
  • deprecated
  • duration
  • fatal
  • force_utf8
  • getCacheInstance
  • gzdecode
  • i18n
  • init_gettext
  • olson_from_tzstring
  • param_to_global
  • qpg
  • quoted_printable_encode
  • replace_uri_params
  • session_salted_md5
  • session_salted_sha1
  • session_simple_md5
  • session_validate_password
  • sql_from_object
  • sql_from_post
  • trace_bug
  • translate
  • uuid
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 
<?php

require_once('AWLUtilities.php');

class SinglePart {
  private $content;
  private $type;
  private $otherHeaders;
  private $disposition;
  private $id;

  public static $crlf = "\r\n";

  function __construct( $content, $type='text/plain', $otherHeaders=array() ) {
    $this->content = $content;
    $this->type = $type;
    $this->otherHeaders = $otherHeaders;
  }

  function render() {
    $result = 'Content-Type: '.$this->type.self::$crlf;
    $encoded = false;
    foreach( $this->otherHeaders AS $header => $value ) {
      $result .= $header.': '.$value.self::$crlf;
      if ( $header == 'Content-Transfer-Encoding' ) $encoded = true;
    }

    if ( $encoded )
       return $result . self::$crlf . $this->content;

    return $result . 'Content-Transfer-Encoding: base64' . self::$crlf
                    . self::$crlf
                    . base64_encode($this->content);
  }
}


class Multipart {

  private $parts; // Always good for a giggle :-)
  private $boundary;

  function __construct() {
    $this->parts = array();
    $this->boundary = uuid();
  }

  function addPart() {
    $args = func_get_args();
    if ( is_string($args[0]) ) {
      $newPart = new SinglePart( $args[0], (isset($args[1])?$args[1]:'text/plain'), (isset($args[2])?$args[2]:array()));
    }
    else
      $newPart = $args[0];

    $this->parts[] = $newPart;

    return $newPart;
  }


  function getMimeHeaders() {
    return 'MIME-Version: 1.0' . SinglePart::$crlf
          .'Content-Type: multipart/mixed; boundary='.$this->boundary . SinglePart::$crlf ;
  }

  function getMimeParts() {
    $result = '--' . $this->boundary . SinglePart::$crlf;
    foreach( $this->parts AS $part ) {
      $result .= $part->render() . SinglePart::$crlf . '--' . $this->boundary;
    }
    $result .= '--' . SinglePart::$crlf;
    return $result;
  }

}
AWL API documentation generated by ApiGen