$maxtext) $text = substr($text, 0, $maxtext)."..."; $text = str_replace(">",">",$text); $text = str_replace("<","<",$text); $text = str_replace("\r\n", "\r",$text); $text = str_replace("\r", "\n",$text); $text = preg_replace("/\n{2,}/", "\n\n", $text); $text = str_replace("\n", "
", $text); } // ファイル名を抽出 if (eregi("name=\"?([^\"\n]+)\"?",$m_head, $filereg)) { $filename = ereg_replace("[\t\r\n]", "", $filereg[1]); while (eregi("(.*)=\?iso-2022-jp\?B\?([^\?]+)\?=(.*)",$filename,$regs)) { $filename = $regs[1].base64_decode($regs[2]).$regs[3]; $filename = convert($filename); } if (!$original) $filename = time()."-".$filename; } // 添付データをデコードして保存 if (eregi("Content-Transfer-Encoding:.*base64", $m_head) && eregi($subtype, $sub)) { $tmp = base64_decode($m_body); if (!$filename) $filename = time().".$sub"; if (strlen($tmp) < $maxbyte && !eregi($viri, $filename) && $write) { $fp = fopen($tmpdir.$filename, "w"); fputs($fp, $tmp); fclose($fp); $attach = $filename; } else { $write = false; } } } if ($imgonly && $attach=="") $write = false; list($old,$otime,$osubj,$ofrom,,) = explode("<>", $lines[0]); // 連続投稿 if ($from == $ofrom && $now - $otime < $wtime) $write = false; $id = $old + 1; if(trim($subject)=="") $subject = $nosubject; $line = "$id<>$now<>$subject<>$from<>$text<>$attach<>\n"; if ($write) { array_unshift($lines, $line); $write2 = true; } elseif (file_exists($tmpdir.$filename)) { @unlink($tmpdir.$filename); } } // ログ最大行処理 if (count($lines) > $maxline) { for ($k=count($lines)-1; $k>=$maxline; $k--) { list($id,$tim,$sub,$fro,$tex,$at,) = explode("<>", $lines[$k]); if (file_exists($tmpdir.$at)) @unlink($tmpdir.$at); $lines[$k] = ""; } } //ログ書き込み if ($write2) { $fp = fopen($log, "w"); flock($fp, LOCK_EX); fputs($fp, implode('', $lines)); fclose($fp); } /* コマンドー送信!! */ function _sendcmd($cmd) { global $sock; fputs($sock, $cmd."\r\n"); $buf = fgets($sock, 512); if(substr($buf, 0, 3) == '+OK') { return $buf; } else { die($buf); } return false; } /* ヘッダと本文を分割する */ function mime_split($data) { $part = split("\r\n\r\n", $data, 2); $part[1] = ereg_replace("\r\n[\t ]+", " ", $part[1]); return $part; } /* メールアドレスを抽出する */ function addr_search($addr) { if (eregi("[-!#$%&\'*+\\./0-9A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+", $addr, $fromreg)) { return $fromreg[0]; } else { return false; } } /* 文字コードコンバートJIS→SJIS */ function convert($str) { if (function_exists('mb_convert_encoding')) { return mb_convert_encoding($str, "SJIS", "JIS,SJIS"); } elseif (function_exists('JcodeConvert')) { return JcodeConvert($str, 0, 2); } return true; } header("Location: $jump"); //echo ''; ?>