)(.*)/"; break; case 2: $pat= "/^\\d{4}\\D+0?$month\\D+0?$mday(?:[\\s:,]|<>)(.*)/"; break; case 3: $pat= "/^\\d{4}\\D+0?$month\\D+\\d+(?:[\\s:,]|<>)(.*)/"; break; case 5: $pat= "/^(.+)/"; break; default: $pat= "/^\\d{4}\\D+\\d+\\D+0?$mday(?:[\\s:,]|<>)(.*)/"; } // メッセージファイルから条件に該当するメッセージを取得 $msg= ''; if (file_exists($datafile) and $fp=fopen($datafile, "rb")){ while (!feof($fp)){ if (!preg_match($pat, fgets($fp), $match)) continue; $a_msg[]= $match[1]; } fclose($fp); count($a_msg) and $msg= $a_msg[rand(0, count($a_msg)-1)]; } $msg == "" and $msg= $default_msg; // メッセージ成形 if ($tate){ $msg= mb_convert_encoding($msg, "UTF-8", "SJIS,EUC-JP,UTF-8,JIS"); $tbl= $tmp= ''; $i= 0; foreach (preg_split('//i', $msg) as $line){ $tmp= ++$i % 2 ? '' : ''; preg_match_all('/([\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc]|[\x09\x0a\x0d\x20-\x7e\xa1-\xdf])/', $line, $match); foreach ($match[1] as $wchar){ $tmp.= $wchar . '
'; } $tmp.= ''; $tbl= $tmp . $tbl; } $msg= '
' . $tbl . "
\n"; } // メッセージ表示 echo '

'; echo $msg == "" ? $default_msg : $msg; echo '

'; ?>