- Timestamp:
- 05/11/11 17:03:17 (13 years ago)
- File:
-
- 1 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 = '';
Note: See TracChangeset
for help on using the changeset viewer.