Changeset 3240
- Timestamp:
- 09/14/10 15:59:29 (14 years ago)
- Location:
- branches/2.2/expressoMail1_2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/expressoMail1_2/inc/class.exporteml.inc.php
r1936 r3240 262 262 } 263 263 264 function export_to_archive($id_msg,$folder) { 265 $this-> folder = $folder; 264 function export_to_archive($id_msg,$folder) { 265 $this-> folder = $folder; 266 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 267 268 $tempDir = $_SESSION['phpgw_info']['server']['temp_dir']; 269 270 $this->connectImap(); 271 $header = $this-> getHeader($id_msg); 272 $body = $this-> getBody($id_msg); 273 $name = md5($_SESSION[ 'phpgw_session' ][ 'session_id' ].microtime()); 274 275 $file = $_SESSION[ 'phpgw_session' ][ 'session_id' ].$name; 276 $f = fopen($tempDir . '/'.$file,"w"); 277 fputs($f,$header ."\r\n\r\n". $body); 278 fclose($f); 279 280 imap_close($this->mbox_stream); 281 return "inc/gotodownload.php?idx_file=".$tempDir . '/'.$file."&newfilename=fonte_da_mensagem.txt"; 282 283 } 284 285 function get_attachments_in_array($params) { 286 $return_attachments = array(); 287 288 $id_number = $params['num_msg']; 289 $attachments =unserialize(rawurldecode($params['s_attachments'])); 290 291 $tempDir = $_SESSION['phpgw_info']['server']['temp_dir']; 292 $this-> folder = $params['folder']; 266 293 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 267 268 $tempDir = dirname( __FILE__ ) . '/../tmpLclAtt';269 //$tempDir = ini_get("session.save_path");270 271 294 $this->connectImap(); 272 $header = $this-> getHeader($id_msg); 273 $body = $this-> getBody($id_msg); 274 275 //$file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".txt"; 276 $tempSubDir = md5($_SESSION[ 'phpgw_session' ][ 'session_id' ].microtime()); 277 $file = "source_".$tempSubDir.".txt"; 278 $f = fopen($tempDir.'/'.$file,"w"); 279 fputs($f,$header ."\r\n\r\n". $body); 280 fclose($f); 281 295 296 include_once("class.imap_attachment.inc.php"); 297 298 $imap_attachment = new imap_attachment(); 299 $attachments = $imap_attachment->download_attachment($this->mbox_stream, $id_number); 300 foreach($attachments as $i => $attachment){ 301 if($i && $i == 'names') 302 continue; 303 304 $fileName = $_SESSION[ 'phpgw_session' ][ 'session_id' ].md5($attachment['name'].microtime()); 305 $ContentType = $this->getFileType($fileNameReal); 306 $f = fopen($tempDir . '/'.$fileName,"wb"); 307 if(!$f) 308 return false; 309 310 $fileContent = imap_fetchbody($this->mbox_stream, $id_number,$attachment['pid'], FT_UID); 311 312 if($attachment['encoding'] == 'base64') { 313 $headers=imap_base64($fileContent); 314 } 315 else if($attachment['encoding'] == 'quoted_printable_decode') { 316 $headers=quoted_printable_decode($fileContent); 317 } 318 else { 319 $headers=$fileContent; 320 } 321 322 fputs($f,$headers); 323 324 $url = "inc/gotodownload.php?idx_file=".$tempDir .'/'.$fileName."&newfilename=".$attachment['name']; 325 array_push($return_attachments,array('name' => $fileName,'url' => $url,'pid' =>$attachment['pid'])); 326 fclose($f); 327 } 282 328 imap_close($this->mbox_stream); 283 return "inc/gotodownload.php?idx_file=".$tempDir.'/'.$file."&newfilename=fonte_da_mensagem.txt"; 284 285 /*$this->folder = $folder; 286 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 287 $tempDir = dirname( __FILE__ ) . '/../tmpLclAtt'; 288 289 $phpheader = "<?php header('Content-Type: text/plain'); 290 header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 291 header('Pragma: public'); 292 header('Expires: 0'); // set expiration time 293 header('Content-Disposition: attachment; filename=\"fonte_da_mensagem.eml\"');?>"; 294 295 $this->connectImap(); 296 $header = $this-> getHeader($id_msg); 297 $body = $this-> getBody($id_msg); 298 299 $tempSubDir = md5($_SESSION[ 'phpgw_session' ][ 'session_id' ].microtime()); 300 $file = "source_".$tempSubDir.".php"; 301 //$file = "source_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".php"; 302 $f = fopen($tempDir.'/'.$file,"w"); 303 fputs($f,$phpheader.$header ."\r\n\r\n". $body); 304 fclose($f); 305 $urlPath = 'tmpLclAtt/'.$file; 306 307 imap_close($this->mbox_stream); 308 return $urlPath;*/ 329 return $return_attachments; 309 330 } 331 310 332 311 333 function remove_accents($string) { … … 320 342 } 321 343 322 function get_attachments_in_array($params) { 323 $return_attachments = array(); 324 325 $id_number = $params['num_msg']; 326 $attachments =unserialize(rawurldecode($params['s_attachments'])); 327 328 $tempDir = dirname( __FILE__ ) . '/../tmpLclAtt'; 329 // $tempDir = $_SERVER["DOCUMENT_ROOT"]."tmpLclAtt"; 330 $tempSubDir = md5(microtime()); 331 exec('mkdir ' . $tempDir . '/'.$tempSubDir.'; cd ' . $tempDir . '/'.$tempSubDir); 332 333 $this-> folder = $params['folder']; 334 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 335 $this->connectImap(); 336 337 include_once("class.imap_attachment.inc.php"); 338 339 $imap_attachment = new imap_attachment(); 340 $attachments = $imap_attachment->download_attachment($this->mbox_stream, $id_number); 341 foreach($attachments as $i => $attachment){ 342 if($i && $i == 'names') 343 continue; 344 $fileNameReal = $this->remove_accents($attachment['name']); 345 $fileNameReal = trim($fileNameReal); 346 $ContentType = $this->getFileType($fileNameReal); 347 $fileName = $fileNameReal; 348 if(strpos($ContentType,"text")!==false || 349 strpos($ContentType,"image")!==false || 350 strpos($ContentType,"audio")!==false) 351 $fileName.= ".php"; 352 $f = fopen($tempDir . '/'.$tempSubDir.'/'.$fileName,"wb"); 353 if(!$f) 354 return $tempDir . '/'.$tempSubDir.'/'.$fileName; 355 356 $fileContent = imap_fetchbody($this->mbox_stream, $id_number,$attachment['pid'], FT_UID); 357 $urlPath = 'tmpLclAtt/'.$tempSubDir.'/'.$fileName; 358 359 if(strpos($ContentType,"text")!==false || 360 strpos($ContentType,"image")!==false || 361 strpos($ContentType,"audio")!==false) { 362 $headers = "<?php header('Content-Type: ".$ContentType."'); 363 header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 364 header('Pragma: public'); 365 header('Expires: 0'); // set expiration time 366 header('Content-Disposition: attachment; filename=\"". addslashes($fileNameReal) ."\"');\n echo "; 367 368 if($attachment['encoding'] == 'base64') { 369 $headers.="imap_base64('".$fileContent."');?>"; 370 } 371 else if($attachment['encoding'] == 'quoted_printable_decode') { 372 $headers.="quoted_printable_decode('".$fileContent."');?>"; 373 } 374 else { 375 $headers.="'".$fileContent."';?>"; 376 } 377 } 378 else { 379 if($attachment['encoding'] == 'base64') { 380 $headers=imap_base64($fileContent); 381 } 382 else if($attachment['encoding'] == 'quoted_printable_decode') { 383 $headers=quoted_printable_decode($fileContent); 384 } 385 else { 386 $headers=$fileContent; 387 } 388 } 389 390 fputs($f,$headers); 391 392 array_push($return_attachments,array('name' => $fileName,'url' => $urlPath,'pid' =>$attachment['pid'])); 393 fclose($f); 394 } 395 imap_close($this->mbox_stream); 396 return $return_attachments; 397 } 398 344 399 345 private function getFileType($nameFile) { 400 346 $strFileType = strrev(substr(strrev(strtolower($nameFile)),0,4)); -
branches/2.2/expressoMail1_2/inc/gotodownload.php
r3139 r3240 171 171 } 172 172 else 173 174 if (strstr($strFileName,$GLOBALS['phpgw']->session->sessionid)&&file_exists($strFileName)) 175 { 176 header("Content-Type: $ContentType"); 177 header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 178 header("Pragma: public"); 179 header("Expires: 0"); // set expiration time 180 header ("Content-Disposition: attachment; filename=\"". addslashes($newFileName)."\""); 181 readfile($strFileName); 182 }else{ 183 header("HTTP/1.1 404 Not Found"); 184 } 185 186 173 187 if (preg_match("#^".ini_get('session.save_path')."/(".$GLOBALS['phpgw']->session->sessionid."/)*[A-z]+_".$GLOBALS['phpgw']->session->sessionid."[A-z0-9]*(\.[A-z]{3,4})?$#",$strFileName)) 174 188 { 175 189 if ( ! preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) { 176 //reset time limit for big files 177 set_time_limit(0); 178 ob_end_flush(); 179 180 if ($fp = fopen ($strFileName, 'rb')) 181 { 182 $bufferSize=1024; 183 for ($i=$bufferSize; $i<=(filesize($strFileName)+$bufferSize); $i+=$bufferSize) 184 { 185 echo fread($fp, $i); 186 flush(); 187 } 188 fclose ($fp); 189 } 190 //readfile($strFileName); 190 //reset time limit for big files 191 set_time_limit(0); 192 ob_end_flush(); 193 194 if ($fp = fopen ($strFileName, 'rb')) 195 { 196 $bufferSize=1024; 197 for ($i=$bufferSize; $i<=(filesize($strFileName)+$bufferSize); $i+=$bufferSize) 198 { 199 echo fread($fp, $i); 200 flush(); 201 } 202 fclose ($fp); 203 } 204 //readfile($strFileName); 191 205 192 206 exec("rm -f ".escapeshellcmd(escapeshellarg($strFileName))); 193 207 } 194 else 208 else 195 209 readfile($strFileName); 196 210 } -
branches/2.2/expressoMail1_2/index.php
r3226 r3240 61 61 $_SESSION['phpgw_info']['expressomail']['ldap_server'] = $ldap_manager ? $ldap_manager->srcs[1] : null; 62 62 $_SESSION['phpgw_info']['expressomail']['user']['email'] = $GLOBALS['phpgw']->preferences->values['email']; 63 $_SESSION['phpgw_info']['server']['temp_dir'] = $GLOBALS['phpgw_info']['server']['temp_dir']; 63 64 64 65 $preferences = $GLOBALS['phpgw']->preferences->read();
Note: See TracChangeset
for help on using the changeset viewer.