Changeset 1342 for branches/1.2/expressoMail1_2/inc/class.exporteml.inc.php
- Timestamp:
- 08/19/09 11:10:14 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.2/expressoMail1_2/inc/class.exporteml.inc.php
r711 r1342 186 186 } 187 187 188 function export_to_archive($id_msg,$folder) {189 $this->folder = $folder;190 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8");191 $tempDir = dirname( __FILE__ ) . '/../tmpLclAtt';192 193 $phpheader = "<?php header('Content-Type: text/plain');194 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');195 header('Pragma: public');196 header('Expires: 0'); // set expiration time197 header('Content-Disposition: attachment; filename=\"fonte_da_mensagem.txt\"');?>";198 199 $this->connectImap();200 $header = $this-> getHeader($id_msg);201 $body = $this-> getBody($id_msg);202 203 $file = "source_".md5(microtime()).".php";204 $f = fopen($tempDir.'/'.$file,"w");205 fputs($f,$phpheader.$header ."\r\n\r\n". $body);206 fclose($f);207 $urlPath = 'tmpLclAtt/'.$file;208 209 imap_close($this->mbox_stream);210 return $urlPath;211 }212 213 188 function remove_accents($string) { 214 189 /* … … 220 195 "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº°ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ", 221 196 "aaaaaeeeeiiiiooooouuuuc__________________________________________AAAAAEEEEIIIIOOOOOUUUUC"); 222 }223 224 function get_attachments_in_array($params) {225 $return_attachments = array();226 227 $id_number = $params['num_msg'];228 $attachments =unserialize(rawurldecode($params['s_attachments']));229 230 $tempDir = dirname( __FILE__ ) . '/../tmpLclAtt';231 // $tempDir = $_SERVER["DOCUMENT_ROOT"]."tmpLclAtt";232 $tempSubDir = md5(microtime());233 exec('mkdir ' . $tempDir . '/'.$tempSubDir.'; cd ' . $tempDir . '/'.$tempSubDir);234 235 $this-> folder = $params['folder'];236 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8");237 $this->connectImap();238 239 include_once("class.imap_attachment.inc.php");240 241 $imap_attachment = new imap_attachment();242 $attachments = $imap_attachment->download_attachment($this->mbox_stream, $id_number);243 244 245 246 foreach($attachments as $i => $attachment){247 if($i && $i == 'names')248 continue;249 $fileNameReal = $this->remove_accents($attachment['name']);250 $ContentType = $this->getFileType($fileNameReal);251 $fileName = $fileNameReal . ".php";252 $f = fopen($tempDir . '/'.$tempSubDir.'/'.$fileName,"wb");253 if(!$f)254 return $tempDir . '/'.$tempSubDir.'/'.$fileName;255 256 $fileContent = imap_fetchbody($this->mbox_stream, $id_number,$attachment['pid'], FT_UID);257 $urlPath = 'tmpLclAtt/'.$tempSubDir.'/'.$fileName;258 259 $headers = "<?php header('Content-Type: ".$ContentType."');260 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');261 header('Pragma: public');262 header('Expires: 0'); // set expiration time263 header('Content-Disposition: attachment; filename=\"". addslashes($fileNameReal) ."\"');\n echo ";264 265 if($attachment['encoding'] == 'base64') {266 $headers.=" imap_base64('".$fileContent."');?>";267 }268 else if($attachment['encoding'] == 'quoted_printable_decode') {269 $headers.=" quoted_printable_decode('".$fileContent."');?>";270 }271 else {272 $headers.=" '".$fileContent."';?>";273 }274 275 fputs($f,$headers);276 277 array_push($return_attachments,array('name' => $fileName,'url' => $urlPath,'pid' =>$attachment['pid']));278 fclose($f);279 }280 imap_close($this->mbox_stream);281 return $return_attachments;282 }283 284 private function getFileType($nameFile) {285 $strFileType = strrev(substr(strrev(strtolower($nameFile)),0,4));286 $ContentType = "application/octet-stream";287 if ($strFileType == ".asf")288 $ContentType = "video/x-ms-asf";289 if ($strFileType == ".avi")290 $ContentType = "video/avi";291 if ($strFileType == ".doc")292 $ContentType = "application/msword";293 if ($strFileType == ".zip")294 $ContentType = "application/zip";295 if ($strFileType == ".xls")296 $ContentType = "application/vnd.ms-excel";297 if ($strFileType == ".gif")298 $ContentType = "image/gif";299 if ($strFileType == ".jpg" || $strFileType == "jpeg")300 $ContentType = "image/jpeg";301 if ($strFileType == ".wav")302 $ContentType = "audio/wav";303 if ($strFileType == ".mp3")304 $ContentType = "audio/mpeg3";305 if ($strFileType == ".mpg" || $strFileType == "mpeg")306 $ContentType = "video/mpeg";307 if ($strFileType == ".rtf")308 $ContentType = "application/rtf";309 if ($strFileType == ".htm" || $strFileType == "html")310 $ContentType = "text/html";311 if ($strFileType == ".xml")312 $ContentType = "text/xml";313 if ($strFileType == ".xsl")314 $ContentType = "text/xsl";315 if ($strFileType == ".css")316 $ContentType = "text/css";317 if ($strFileType == ".php")318 $ContentType = "text/php";319 if ($strFileType == ".asp")320 $ContentType = "text/asp";321 if ($strFileType == ".pdf")322 $ContentType = "application/pdf";323 if ($strFileType == ".txt")324 $ContentType = "text/plain";325 if ($strFileType == ".log")326 $ContentType = "text/plain";327 if ($strFileType == ".wmv")328 $ContentType = "video/x-ms-wmv";329 if ($strFileType == ".sxc")330 $ContentType = "application/vnd.sun.xml.calc";331 if ($strFileType == ".odt")332 $ContentType = "application/vnd.oasis.opendocument.text";333 if ($strFileType == ".stc")334 $ContentType = "application/vnd.sun.xml.calc.template";335 if ($strFileType == ".sxd")336 $ContentType = "application/vnd.sun.xml.draw";337 if ($strFileType == ".std")338 $ContentType = "application/vnd.sun.xml.draw.template";339 if ($strFileType == ".sxi")340 $ContentType = "application/vnd.sun.xml.impress";341 if ($strFileType == ".sti")342 $ContentType = "application/vnd.sun.xml.impress.template";343 if ($strFileType == ".sxm")344 $ContentType = "application/vnd.sun.xml.math";345 if ($strFileType == ".sxw")346 $ContentType = "application/vnd.sun.xml.writer";347 if ($strFileType == ".sxq")348 $ContentType = "application/vnd.sun.xml.writer.global";349 if ($strFileType == ".stw")350 $ContentType = "application/vnd.sun.xml.writer.template";351 if ($strFileType == ".ps")352 $ContentType = "application/postscript";353 if ($strFileType == ".pps")354 $ContentType = "application/vnd.ms-powerpoint";355 if ($strFileType == ".odt")356 $ContentType = "application/vnd.oasis.opendocument.text";357 if ($strFileType == ".ott")358 $ContentType = "application/vnd.oasis.opendocument.text-template";359 if ($strFileType == ".oth")360 $ContentType = "application/vnd.oasis.opendocument.text-web";361 if ($strFileType == ".odm")362 $ContentType = "application/vnd.oasis.opendocument.text-master";363 if ($strFileType == ".odg")364 $ContentType = "application/vnd.oasis.opendocument.graphics";365 if ($strFileType == ".otg")366 $ContentType = "application/vnd.oasis.opendocument.graphics-template";367 if ($strFileType == ".odp")368 $ContentType = "application/vnd.oasis.opendocument.presentation";369 if ($strFileType == ".otp")370 $ContentType = "application/vnd.oasis.opendocument.presentation-template";371 if ($strFileType == ".ods")372 $ContentType = "application/vnd.oasis.opendocument.spreadsheet";373 if ($strFileType == ".ots")374 $ContentType = "application/vnd.oasis.opendocument.spreadsheet-template";375 if ($strFileType == ".odc")376 $ContentType = "application/vnd.oasis.opendocument.chart";377 if ($strFileType == ".odf")378 $ContentType = "application/vnd.oasis.opendocument.formula";379 if ($strFileType == ".odi")380 $ContentType = "application/vnd.oasis.opendocument.image";381 if ($strFileType == ".ndl")382 $ContentType = "application/vnd.lotus-notes";383 return $ContentType;384 197 } 385 198
Note: See TracChangeset
for help on using the changeset viewer.