X-Git-Url: https://git.llucax.com/software/sercom-old.git/blobdiff_plain/022a14d75aad2fa4daac42cbf325fbdf28628c99..8ae0a652137dc133865fb1e2839aa41d1ee0fb88:/src/sc_fetch?ds=inline diff --git a/src/sc_fetch b/src/sc_fetch index 9f14318..7b82bf9 100755 --- a/src/sc_fetch +++ b/src/sc_fetch @@ -90,7 +90,7 @@ while (1) { $mbox_errcount = 0; logs('Conectado como '.@$mconf['user']." a $mailbox", DEBUG); if (imap_num_msg($mbox) and $hdr = imap_headerinfo($mbox, 1)) { - logs(sprintf("Nuevo mail '%s' de %s", decode_header($hdr->subject), decode_header($hdr->subject))); + logs(sprintf("Nuevo mail '%s' de %s", decode_header($hdr->subject), decode_header($hdr->from))); @list($padron, $ej, $ent, $codigo) = validar_cabecera($hdr); if ($padron) { logs('Cabecera válida', DEBUG); @@ -186,7 +186,7 @@ EOT; function validar_cabecera($hdr) { // Subject: padron nro_ej nro_entrega clave_alumno $subject = decode_header($hdr->subject); - if (preg_match('/^\s*(\d{5})\s+([1-4])\.([12])\s+(.*)$/', $subject, $m)) { + if (preg_match('/^\s*(\d{5})\s+(\d)\.(\d)\s+(.*)$/', $subject, $m)) { return array_slice($m, 1, 5); } return false; @@ -201,8 +201,9 @@ function preparar_entrega($intento, $mbox, $msgid, $dir) { $fname = part_filename($part); if ($fname) { logs("Escribiendo archivo '$fname' [enc={$part->encoding}]", DEBUG); - $body = imap_fetchbody($mbox, $msgid, $id + 1); - if (!file_put_contents("$path/$fname", decode_body($body, $part->encoding))) return "Error al guardar el archivo $fname"; + $body = decode_body(imap_fetchbody($mbox, $msgid, $id + 1), $part->encoding); + if (!$body) return "El archivo '$fname' está vacío"; + if (!file_put_contents("$path/$fname", $body)) return "Error al guardar el archivo $fname"; } //if (part_is_source($part) $has_sources = true; //elseif (part_mime_type($part) == 'application/zip') $has_sources = true;