Changeset 4348 for sandbox/2.2.0.2/expressoMail1_2
- Timestamp:
- 05/11/11 17:03:17 (13 years ago)
- Location:
- sandbox/2.2.0.2/expressoMail1_2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.2.0.2/expressoMail1_2/inc/class.exporteml.inc.php
r4192 r4348 15 15 var $folder; 16 16 var $mbox_stream; 17 var $tempDir; 18 19 function ExportEml() { 20 21 //TODO: modificar o caminho hardcodificado '/tmp' para o definido na configuracao do expresso 22 //$this->tempDir = $GLOBALS['phpgw_info']['server']['temp_dir']; 23 $this->tempDir = '/tmp'; 24 } 17 25 18 26 function connectImap(){ … … 59 67 60 68 //$subject = ereg_replace('/', '\'', $subject); 61 $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ";62 $to = "aaaaaeeeeiiiiooooouuuuc__________________________________________ AAAAAEEEEIIIIOOOOOUUUUC";69 $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 70 $to = "aaaaaeeeeiiiiooooouuuuc______________________________________________AAAAAEEEEIIIIOOOOOUUUUC"; 63 71 $subject = strtr($subject,$from,$to); 64 $file = $subject."_".$id.".eml"; 72 73 $subject = eregi_replace("[^a-zA-Z0-9_]", "_", $subject); 74 $file = $subject."_".$id.".eml"; 65 75 } else{ 66 76 // Se mensagem for arquivada localmente, $subject (assunto da mensagem) … … 68 78 69 79 if($subject && $i){ 70 $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ";71 $to = "aaaaaeeeeiiiiooooouuuuc__________________________________________ AAAAAEEEEIIIIOOOOOUUUUC";80 $from = "áàâãäéèêëíìîïóòôõöúùûüç?\"!@#$%š&*()-=+Ž`[]{}~^,<>;:/?\\|¹²³£¢¬§ªº° .ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ"; 81 $to = "aaaaaeeeeiiiiooooouuuuc______________________________________________AAAAAEEEEIIIIOOOOOUUUUC"; 72 82 $subject = strtr($subject,$from,$to); 73 //$subject = ereg_replace(':', '_', $subject); 74 //$subject = ereg_replace('/', '_', $subject); 75 $file = $subject."_".$i.".eml"; 83 84 $subject = eregi_replace("[^a-zA-Z0-9_]", "_", $subject); 85 86 // é necessário que a sessão faça parte do nome do arquivo para que o mesmo não venha vazio o.O 87 $file = $subject."_".$i."_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".eml"; 76 88 } else{ 77 89 $file = "email_".$_SESSION[ 'phpgw_session' ][ 'session_id' ].".eml"; … … 124 136 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 125 137 $fileNames = ""; 126 $tempDir = ini_get("session.save_path");138 $tempDir = $this->tempDir; 127 139 $this->connectImap(); 128 140 … … 167 179 // Rommel Cysne (rommel.cysne@serpro.gov.br) 168 180 // em 17/12/2008. 181 // 182 // Funcao alterada para que, quando houver 183 // apenas um arquivo a ser exportado, 184 // não seja criado em zip 169 185 function makeAll($params) { 170 186 // Exportacao de mensagens arquivadas localmente 171 if($params['l_msg'] == "t"){ 187 if($params['l_msg'] == "t") 188 { 172 189 // Recebe todos os subjects e bodies das mensagens locais selecionadas para exportacao 173 190 // e gera arrays com os conteudos separados; … … 175 192 $array_subjects = explode('@@',$params['subjects']); 176 193 $array_ids = explode(',', $params['msgs_to_export']); 177 $tempDir = ini_get("session.save_path");178 // Para cada mensagem selecionada sera gerado um arquivo .eml cujo titulo sera o assunto (subject) da mesma;194 $tempDir = $this->tempDir; 195 179 196 include_once("class.imap_functions.inc.php"); 180 197 $imapf = new imap_functions(); 198 199 // quando houver apenas um arquivo, exporta o .eml sem coloca-lo em zip 200 if (count($array_ids)==1) 201 { 202 $sEMLData=$imapf->treat_base64_from_post($array_mesgs[$i]); 203 $fileName=$this->CreateFileEml($sEMLData, $tempDir,'',$array_subjects[$i],$i); 204 return $tempDir.'/'.$fileName; 205 } 206 207 // Para cada mensagem selecionada sera gerado um arquivo .eml cujo titulo sera o assunto (subject) da mesma; 181 208 foreach($array_ids as $i=>$id) { 182 209 $sEMLData=$imapf->treat_base64_from_post($array_mesgs[$i]); … … 203 230 204 231 return $file; 205 232 233 } else 206 234 // Exportacao de mensagens da caixa de entrada (imap) - processo original do Expresso 207 } else{ 208 $this-> folder = $params['folder']; 209 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 210 $array_ids = explode(',', $params['msgs_to_export']); 211 $error = False; 212 $fileNames = ""; 213 $tempDir = ini_get("session.save_path"); 214 $this->connectImap(); 215 for($i = 0; $i < count($array_ids); $i++) { 216 $header = $this-> getHeader($array_ids[$i]); 217 $body = $this-> getBody($array_ids[$i]); 218 $sEMLData = $this -> parseEml($header, $body); 219 $fileName = $this -> CreateFileEml($sEMLData, $tempDir, $array_ids[$i]); 220 221 if(!$fileName) { 222 $error = True; 223 break; 224 } 225 else 226 $fileNames .= "\"".$fileName."\" "; 227 228 } 229 imap_close($this->mbox_stream); 230 231 232 $nameFileZip = 'False'; 233 if($fileNames && !$error) { 234 $nameFileZip = $this -> createFileZip($fileNames, $tempDir); 235 if($nameFileZip) 236 $file = $tempDir.'/'.$nameFileZip; 237 else { 235 { 236 $this-> folder = $params['folder']; 237 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","UTF-8"); 238 $array_ids = explode(',', $params['msgs_to_export']); 239 $error = False; 240 $fileNames = ""; 241 $tempDir = $this->tempDir; 242 $this->connectImap(); 243 244 // quando houver apenas um arquivo, exporta o .eml sem coloca-lo em zip 245 if (count($array_ids)==1) 246 { 247 $header = $this->getHeader($array_ids[0]); 248 $body = $this->getBody($array_ids[0]); 249 $sEMLData = $this->parseEml($header, $body); 250 $fileName = $this->CreateFileEml($sEMLData, $tempDir, $array_ids[0]."_".$_SESSION[ 'phpgw_session' ][ 'session_id' ]); 251 252 imap_close($this->mbox_stream); 253 if (!$fileName) { 254 return false; 255 } else { 256 return $tempDir.'/'.$fileName; 257 } 258 } 259 260 for($i = 0; $i < count($array_ids); $i++) 261 { 262 $header = $this-> getHeader($array_ids[$i]); 263 $body = $this-> getBody($array_ids[$i]); 264 $sEMLData = $this -> parseEml($header, $body); 265 $fileName = $this -> CreateFileEml($sEMLData, $tempDir, $array_ids[$i]); 266 267 if(!$fileName) 268 { 269 $error = True; 270 break; 271 } else { 272 $fileNames .= "\"".$fileName."\" "; 273 } 274 } 275 imap_close($this->mbox_stream); 276 277 $nameFileZip = 'False'; 278 if($fileNames && !$error) 279 { 280 $nameFileZip = $this -> createFileZip($fileNames, $tempDir); 281 if($nameFileZip) 282 { 283 $file = $tempDir.'/'.$nameFileZip; 284 } else { 285 $file = false; 286 } 287 } 288 else 289 { 238 290 $file = false; 239 } 240 } 241 else 242 $file = false; 243 244 return $file; 245 } 291 } 292 293 return $file; 294 } 246 295 } 247 296 … … 250 299 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","ISO_8859-1"); 251 300 $id_number = $params['msgs_to_export']; 252 $tempDir = ini_get("session.save_path"); 253 301 $tempDir = $this->tempDir; 254 302 $this->connectImap(); 255 303 $header = $this-> getHeader($id_number); … … 283 331 $this->folder = mb_convert_encoding($this->folder, "UTF7-IMAP","ISO_8859-1"); 284 332 285 $tempDir = $ _SESSION['phpgw_info']['server']['temp_dir'];333 $tempDir = $this->tempDir; 286 334 287 335 $this->connectImap(); … … 471 519 $attachments =unserialize(rawurldecode($params['s_attachments'])); 472 520 473 $tempDir = ini_get("session.save_path");521 $tempDir = $this->tempDir; 474 522 $tempSubDir = $_SESSION['phpgw_session']['session_id']; 475 523 $fileNames = ''; -
sandbox/2.2.0.2/expressoMail1_2/inc/gotodownload.php
r3369 r4348 8 8 } 9 9 require_once '../../header.inc.php'; 10 10 //TODO: alterar a string /tmp logo abaixo, pelo caminho temporario configurado no expresso 11 $GLOBALS['phpgw_info']['server']['download_temp_dir'] = "/tmp"; 11 12 12 13 $msg_number = $_GET['msg_number']; 13 14 $idx_file = $_GET['idx_file']; 14 15 $newfilename = html_entity_decode(rawurldecode($_GET['newfilename'])); 15 16 $msg_part = $_GET['msg_part']; 16 17 $msg_folder = $_GET['msg_folder']; … … 162 163 header("Expires: 0"); // set expiration time 163 164 header ("Content-Disposition: attachment; filename=\"". addslashes($newFileName)."\""); 165 164 166 if($fileContent) { 165 167 if($encoding == 'base64') … … 171 173 } 172 174 else 173 174 if (strstr($strFileName,$GLOBALS['phpgw']->session->sessionid)&&file_exists($strFileName)) 175 { 176 $tempDir = $GLOBALS['phpgw_info']['server']['download_temp_dir']; 177 if (preg_match("#^".$tempDir."/(".$GLOBALS['phpgw']->session->sessionid."/)*[A-z0-9_]+_".$GLOBALS['phpgw']->session->sessionid."[A-z0-9]*(\.[A-z]{3,4})?$#",$strFileName)) 175 178 { 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"); 179 //avoid stuck request 180 session_write_close(); 181 182 //reset time limit for big files 183 set_time_limit(0); 184 ob_end_flush(); 185 186 if ($fp = fopen ($strFileName, 'rb')) 187 { 188 $bufferSize=1024; 189 for ($i=$bufferSize; $i<=(filesize($strFileName)+$bufferSize); $i+=$bufferSize) { 190 echo fread($fp, $i); 191 flush(); 192 } 193 fclose ($fp); 194 } 195 196 //removendo pelo php, garante a suportabilidade cross-platform 197 cleanup( dirname( $strFileName ) ); 184 198 } 185 186 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)) 199 else 188 200 { 189 if ( ! preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$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); 205 206 exec("rm -f ".escapeshellcmd(escapeshellarg($strFileName))); 201 if (preg_match("#^".dirname( __FILE__ ) . '/../tmpLclAtt'."/source_#",$strFileName)) { 202 readfile($strFileName); 207 203 } 208 else209 readfile($strFileName);210 204 } 205 } 211 206 } 212 207 ?> -
sandbox/2.2.0.2/expressoMail1_2/js/main.js
r4312 r4348 2366 2366 2367 2367 function export_all_selected_msgs(){ 2368 var msgs_to_export = this.get_selected_messages(); 2369 2368 2370 if (openTab.type[currentTab] > 1){ 2369 source_msg(currentTab,current_folder); 2370 return; 2371 } 2372 var msgs_to_export = this.get_selected_messages(); 2371 msgs_to_export = currentTab.substr(0,(currentTab.length - 2)); 2372 } 2373 2373 2374 2374 var handler_export_all_selected_msgs = function(data){ … … 2377 2377 write_msg(get_lang('Error compressing messages (ZIP). Contact the administrator.')); 2378 2378 } 2379 else 2380 download_attachments(null, null, data, null,null,'mensagens.zip'); 2379 else 2380 { 2381 if (data.substr(data.length-3, 3) == "zip") { 2382 download_attachments(null, null, data, null, null,'mensagens.zip'); 2383 } else if (data.substr(data.length-3, 3) == "eml") { 2384 //extracts the file name from file path 2385 var string_start = data.lastIndexOf("/") + 1; 2386 var string_length = data.length - string_start; 2387 var fname = data.substr(string_start, string_length); 2388 //extracts the session_id from file name 2389 var string_end = data.lastIndexOf("_") - 5; 2390 fname = fname.substr(0, string_end).concat(".eml"); 2391 download_attachments(null, null, data, null, null, fname); 2392 } else { 2393 download_attachments(null, null, data, null, null, 'mensagens'); 2394 } 2395 } 2381 2396 } 2382 2397
Note: See TracChangeset
for help on using the changeset viewer.