function isset_header($str = null, $name = null, $value = null, $debug = null) { if (!FUNC4::is_debug($debug)) { $debug = debug_backtrace(); } $err = array(); if (!(is_string($str) && $str != '')) { $err[] = 'invalid header type'; } if (!(is_string($name) && $name != '')) { $err[] = 'invalid name type'; } if ($value != null && !is_string($value)) { $err[] = 'invalid value type'; } if (count($err) > 0) { FUNC4::trace($debug, implode(', ', $err)); } else { $ret = false; if ($split = MIME4::split_header($str, $debug)) { foreach ($split as $tarr) { foreach ($tarr as $hname => $hvalue) { if (strtolower($hname) == strtolower($name)) { if ($value != null) { $ret = strtolower($hvalue) == strtolower($value); } else { $ret = $hvalue; } if ($ret) { break 2; break; } } } } } } return $ret; }
function _content($str = null, $debug = null) { if (!FUNC4::is_debug($debug)) { $debug = debug_backtrace(); } if (!(is_string($str) && $str != '')) { FUNC4::trace($debug, 'invalid content value'); } else { if (!($part = MIME4::split_message($str, $debug))) { return null; } if (!($harr = MIME4::split_header($part['header'], $debug))) { return null; } $body = array(); $clen = strlen('content-'); $encoding = false; foreach ($harr as $hnum) { if (substr(strtolower($hnum['name']), 0, $clen) == 'content-') { $name = strtolower(substr($hnum['name'], $clen)); if ($name == 'transfer-encoding') { $encoding = strtolower($hnum['value']); } else { if ($name == 'id') { $body[$name] = array('value' => trim($hnum['value'], '<>'), 'extra' => $hnum['content']); } else { $body[$name] = array('value' => $hnum['value'], 'extra' => $hnum['content']); } } } } if ($encoding == 'base64' || $encoding == 'quoted-printable') { $body['content'] = MIME4::decode_content($part['content'], $encoding, $debug); } else { if ($encoding) { $body['transfer-encoding'] = $encoding; } $body['content'] = $part['content']; } if (substr($body['content'], -2) == "\r\n") { $body['content'] = substr($body['content'], 0, -2); } else { if (substr($body['content'], -1) == "\n") { $body['content'] = substr($body['content'], 0, -1); } } return $body; } }