"\n","\r\n" =>"\n",'
' =>"\n",'
'=>"\n",'
' =>"\n",'' =>"\n",':' =>':','*topic' =>'topic','%' =>'%');
$tagmukouka = array('<' =>"<",'>' =>">",'topic :' =>"(TOPIC)",);
$text = strtr($_POST['year'], $brbrbr);
$text = strtr($text, $tagmukouka);
$text = strip_tags($text);
$text = htmlspecialchars($text, ENT_QUOTES);
/*
単語を変更するstrtにより問答無用。
*/
$tangohenhen = explode(",", $_POST['kaimei']);
$tangohenhen_count = count($tangohenhen);
for($i = 0;$i < $tangohenhen_count;$i++){
$tangokaikai[$tangohenhen[$i]] = $tangohenhen[++$i];
}
$text = strtr($text,$tangokaikai);
// 時間除去、ユーザー発言以外の入退出、アナウンスなどを除去
$text = preg_replace("/^[0-9|:|\s]+/m", "", $text);
//$text = preg_replace("/^.*?(TOPIC).*?:(.*)/m", "($1)$2", $text);
$text = preg_replace("/^[^\[|\(|<].*/m", "", $text);
// 行頭改行と文章全体の終端改行を除去
$text = preg_replace("/^\n/m", "", $text);
$text = preg_replace("/$\n/", "", $text);
// 発言者、囲い、発言をそれぞれ抜き取り整理
$text = preg_replace("/^(<|\[|\()(.*?)(\]|\)|>)\s*(.*)/m", "$2: $4", $text);
$text = preg_replace("/(https?.*?)([[:space:] \n\r])/", ">$1$2", $text);
if (substr_count($text, "\n") < 2){
echo "行数、文字数が少なすぎるみたいです。";
return;
}
/*
単語を色変えするstrtにより問答無用。
*/
$tangocol = explode(",", $_POST['tokuteitango_color']);
$tangocol_count = count($tangocol);
for($i = 0;$i < $tangocol_count;$i++){
$tagtango[$tangocol[$i]] = '' . $tangocol[$i-1] . "";
}
$text = strtr($text,$tagtango);
/*
名前処理部分
*/
$values = explode("\n", $text);
$count = count($values);
// :ごとに分割して収納。名前と発言を分けている。収納先は$values[$i][$j]
for ($i = 0; $i < $count; $i++) {
$values[$i] = explode(":", $values[$i]);
}
$html="
".$values[$i][$j] . "
"; }elseif($values[$i][0] == $values[$i-1][0] and $values[$i][0] != $values[$i+1][0]){ //前の発言者と同じ、かつ次の発言者が違う人 $html .="".$values[$i][$j] . "
"; }elseif($values[$i][0] != $values[$i-1][0] and $values[$i][0] == $values[$i+1][0]){ //前の発言者が違う、かつ次の発言者が同じ $html .=''.$values[$i][$j] . "
"; }else{ //単一発言 $html .='