Example #1
0
try {
    $board = $config->getBoard($boardid);
    if (!$board->mayRead($session->getAuth())) {
        throw new Exception("Keine Berechtigung!");
        exit;
    }
    $connection = $board->getConnection();
    if ($connection === null) {
        throw new Exception("Board enthaelt keine Group!");
    }
    $connection->open($session->getAuth());
    $group = $connection->getGroup();
    $connection->close();
    $message = $group->getMessage($messageid);
    if ($message === false) {
        $attachment = $session->getAttachment($partid);
    } else {
        $attachment = $message->getAttachment($partid);
    }
    if ($attachment === null) {
        throw new Exception("Attachment ungueltig!");
    }
    $disposition = $attachment->getDisposition();
    $filename = $attachment->getFilename();
    // Fix for images
    if (preg_match("\$^image/\$", $attachment->getMimeType())) {
        $disposition = "inline";
    }
    // see RFC 2616 for these Headers
    header("Content-Type: " . $attachment->getMimeType());
    header("Content-Length: " . $attachment->getLength());