foreach ($images as $image) { $size = DetermineImageSize(POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_files" . DIRECTORY_SEPARATOR . $image); print "<td>{$size['1']} x {$size['0']}<br/>\n"; print "<img src='../wp-content/plugins/postie/test_files/{$image}' ></td>\n"; } ?> </tr> <tr> <?php if ($config["AUTO_SMART_SHARP"]) { ?> <th> AutoSharpened <br/><p>WARNING-This feature takes a lot of processing power</p></th> <?php foreach ($images as $image) { print "<td>"; ImageMagickSharpen(POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_files" . DIRECTORY_SEPARATOR . $image, $config["REALPHOTOSDIR"] . "Sharp-" . $image); print "<img src='" . $config["URLPHOTOSDIR"] . "/Sharp-" . $image . "'>"; print "</td>\n"; } ?> </tr> <?php } ?> <tr> <th> Scaled & Rotated</th> <?php foreach ($images as $image) { $result = ResizeImage(POSTIE_ROOT . DIRECTORY_SEPARATOR . "test_files" . DIRECTORY_SEPARATOR . $image, substr($image, -3, 3)); RotateImages(90, array(array(null, $config["REALPHOTOSDIR"] . $result[0], 'jpg'))); print "<td>";
function GetContent($part, &$attachments) { $config = GetConfig(); $meta_return = NULL; DecodeBase64Part($part); if (BannedFileName($part->ctype_parameters['name']) || BannedFileName($part->ctype_parameters['name'])) { return NULL; } if ($part->ctype_primary == "application" && $part->ctype_secondary == "octet-stream") { if ($part->disposition == "attachment") { $image_endings = array("jpg", "png", "gif", "jpeg", "pjpeg"); foreach ($image_endings as $type) { if (eregi(".{$type}\$", $part->d_parameters["filename"])) { $part->ctype_primary = "image"; $part->ctype_secondary = $type; break; } } } else { $mimeDecodedEmail = DecodeMIMEMail($part->body); FilterTextParts($mimeDecodedEmail); foreach ($mimeDecodedEmail->parts as $section) { $meta_return .= GetContent($section, $attachments); } } } if ($part->ctype_primary == "multipart" && $part->ctype_secondary == "appledouble") { $mimeDecodedEmail = DecodeMIMEMail("Content-Type: multipart/mixed; boundary=" . $part->ctype_parameters["boundary"] . "\n" . $part->body); FilterTextParts($mimeDecodedEmail); FilterAppleFile($mimeDecodedEmail); foreach ($mimeDecodedEmail->parts as $section) { $meta_return .= GetContent($section, $attachments); } } else { switch (strtolower($part->ctype_primary)) { case 'multipart': FilterTextParts($part); foreach ($part->parts as $section) { $meta_return .= GetContent($section, $attachments); } break; case 'text': HandleMessageEncoding($part->headers["content-transfer-encoding"], $part->ctype_parameters["charset"], $part->body); //go through each sub-section if ($part->ctype_secondary == 'enriched') { //convert enriched text to HTML $meta_return .= etf2HTML($part->body) . "\n"; } elseif ($part->ctype_secondary == 'html') { //strip excess HTML $meta_return .= HTML2HTML($part->body) . "\n"; } else { //regular text, so just strip the pgp signature if (ALLOW_HTML_IN_BODY) { $meta_return .= $part->body . "\n"; } else { $meta_return .= htmlentities($part->body) . "\n"; } $meta_return = StripPGP($meta_return); } break; case 'image': $file = GenerateImageFileName($config["REALPHOTOSDIR"], $part->ctype_secondary); //This makes sure there is no collision $ctr = 0; while (file_exists($file) && $ctr < 1000) { $file = GenerateImageFileName($config["REALPHOTOSDIR"], $part->ctype_secondary); $ctr++; } if ($ctr >= 1000) { die("Unable to find a name for images that does not collide\n"); } $fileName = basename($file); $fp = fopen($file, 'w'); fwrite($fp, $part->body); fclose($fp); @exec('chmod 755 ' . $file); if ($config["USE_IMAGEMAGICK"] && $config["AUTO_SMART_SHARP"]) { ImageMagickSharpen($file); } $mimeTag = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' -->'; $thumbImage = NULL; $cid = trim($part->headers["content-id"], "<>"); //cids are in <cid> if ($config["RESIZE_LARGE_IMAGES"]) { list($thumbImage, $fullImage) = ResizeImage($file, strtolower($part->ctype_secondary)); } $attachments["image_files"][] = array($thumbImage ? $config["REALPHOTOSDIR"] . $thumbImage : NULL, $config["REALPHOTOSDIR"] . $fileName, $part->ctype_secondary); if ($thumbImage) { $marime = DetermineImageSize($file); $marimex = $marime[0] + 20; $marimey = $marime[1] + 20; $attachments["html"][] .= $mimeTag . '<div class="' . $config["IMAGEDIV"] . '"><a href="' . $config["URLPHOTOSDIR"] . $fullImage . '" onclick="window.open(' . "'" . $config["URLPHOTOSDIR"] . $fullImage . "','" . "full_size_image" . "','" . "toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=1,height=" . $marimey . ",width=" . $marimex . "');" . "return false;" . '"><img src="' . $config["URLPHOTOSDIR"] . $thumbImage . '" alt="' . $part->ctype_parameters['name'] . '" title="' . $part->ctype_parameters['name'] . '" style="' . $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '" /></a></div>' . "\n"; if ($cid) { $attachments["cids"][$cid] = array($config["URLPHOTOSDIR"] . $fullImage, count($attachments["html"]) - 1); } } else { $attachments["html"][] .= $mimeTag . '<div class="' . $config["IMAGEDIV"] . '"><img src="' . $config["URLPHOTOSDIR"] . $fileName . '" alt="' . $part->ctype_parameters['name'] . '" style="' . $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '" /></div>' . "\n"; if ($cid) { $attachments["cids"][$cid] = array($config["URLPHOTOSDIR"] . $fileName, count($attachments["html"]) - 1); } } break; default: if (in_array(strtolower($part->ctype_primary), $config["SUPPORTED_FILE_TYPES"])) { //pgp signature - then forget it if ($part->ctype_secondary == 'pgp-signature') { break; } //other attachments save to FILESDIR $filename = $part->ctype_parameters['name']; $file = $config["REALFILESDIR"] . $filename; $fp = fopen($file, 'w'); fwrite($fp, $part->body); fclose($fp); @exec('chmod 755 ' . $file); $cid = trim($part->headers["content-id"], "<>"); //cids are in <cid> if ($part->ctype_secondary == "3gpp" || $part->ctype_secondary == "3gp" || $part->ctype_secondary == "3g2" || $part->ctype_secondary == "3gpp2") { if ($config["3GP_QT"]) { //Shamelessly borrowed from http://www.postneo.com/2003/12/19/embedding-3gpp-in-html $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' -->' . '<a href="' . $config["URLFILESDIR"] . $filename . '">Video' . '<object ' . 'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" ' . 'codebase="http://www.apple.com/qtactivex/qtplugin.cab" ' . 'width="128" ' . 'height="112"> ' . '<param name="src" VALUE="' . $config["URLFILESDIR"] . $filename . '"> ' . '<param name="autoplay" VALUE="false"> ' . '<param name="controller" VALUE="true"> ' . '<embed ' . 'src="' . $config["URLFILESDIR"] . $filename . '" ' . 'width="128" ' . 'height="112" ' . 'autoplay="true" ' . 'controller="true" ' . 'type="video/quicktime" ' . 'pluginspage="http://www.apple.com/quicktime/download/" ' . 'width="128" ' . 'height="150"></embed> ' . '</object></a>'; } else { if (file_exists($config["3GP_FFMPEG"])) { $fileName = basename($file); //options from http://www.getid3.org/phpBB2/viewtopic.php?p=1290& $scaledFileName = "thumb." . $fileName; $scaledFile = $config["REALPHOTOSDIR"] . $scaledFileName; @exec(escapeshellcmd($config["3GP_FFMPEG"]) . " -i " . escapeshellarg($file) . " -y -ss 00:00:01 -vframes 1 -an -sameq -f gif " . escapeshellarg($scaledFile)); @exec('chmod 755 ' . escapeshellarg($scaledFile)); $attachments["html"][] .= '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' --><div class="' . $config["3GPDIV"] . '"><a href="' . $config["URLPHOTOSDIR"] . $fileName . '"><img src="' . $config["URLPHOTOSDIR"] . $scaledFileName . '" alt="' . $part->ctype_parameters['name'] . '" style="' . $config["IMAGESTYLE"] . '" class="' . $config["IMAGECLASS"] . '" /></a></div>' . "\n"; } else { $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' --><div class="' . $config["ATTACHMENTDIV"] . '"><a href="' . $config["URLFILESDIR"] . $filename . '" class="' . $config["3GPCLASS"] . '">' . $part->ctype_parameters['name'] . '</a></div>' . "\n"; } } } elseif ($part->ctype_secondary == "x-shockwave-flash") { $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' -->' . '<object ' . 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' . 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" ' . 'width="" ' . 'height=""> ' . '<param name="movie" value="' . $config["URLFILESDIR"] . $filename . '"> ' . '<param name="quality" value="high"> ' . '<embed ' . 'src="' . $config["URLFILESDIR"] . $filename . '" ' . 'width="" ' . 'height="" ' . 'quality="high" ' . 'pluginspage="http://www.macromedia.com/go/getflashplayer" ' . 'type="application/x-shockwave-flash" ' . 'width="" ' . 'height=""></embed> ' . '</object>'; } else { $attachments["html"][] = '<!--Mime Type of File is ' . $part->ctype_primary . "/" . $part->ctype_secondary . ' --><a href="' . $config["URLFILESDIR"] . $filename . '">' . $part->ctype_parameters['name'] . '</a>' . "\n"; } if ($cid) { $attachments["cids"][$cid] = array($config["URLFILESDIR"] . $filename, count($attachments["html"]) - 1); } } break; } } return $meta_return; }