~の検出回数
$count = 0;
// HTML格納用バッファ
$buffer = array();
// 新型コロナウイルス関連のお知らせ格納フラグ
$coronaFlg = 0;
// 新型コロナウイルス関連最新のお知らせ更新日格納用
$coronaLastUp = array();
// ファイルを1行ずつ出力
if ($file) {
// 出力用フラグ
$isRead = false;
while ($line = fgets($file)) {
// 文字列の後ろの改行(\n)を削除
$line = rtrim($line);
// 先頭#の文章又は空行を飛ばす
if (preg_match('/^#.*/', $line) || $line == "" ) {
continue;
}
// コメント開始検知
if (preg_match('//', $line) ) {
// コメントフラグOFF
$commentOut = false;
}
// コメントフラグONの際にコメントを飛ばす
if ($commentOut == true) {
continue;
}
// renew-ico01かつが含まれている場合、かつvalid-switchが含まれている場合は、それ以降の$lineを出力する
if (strpos ($line, "renew-ico01") !== false) {
if (strpos ($line, "valid-switch") !== false) {
// 出力ON
$isRead = true;
}
}
// 新型コロナウイルス関連のお知らせ最終更新日保持用
if($coronaFlg == 1) {
if (strpos ($line, "time") !== false) {
array_push ($coronaLastUp, $line);
$coronaFlg = 2;
}
} elseif ($coronaFlg == 0) {
if (strpos ($line, "corona-switch") !== false) {
$coronaFlg = 1;
}
}
// 出力ONの場合
if ($isRead) {
// $lineをバッファに格納
array_push ($buffer, $line);
}
// 出力ON時に を検出した場合
if ($isRead && $line == "") {
// 出力OFF
$isRead = false;
// renew-ico01処理件数を加算
++$count;
}
}
// ファイルポインタをクローズ
fclose($file);
}
// 新型コロナウイルス関連のお知らせ出力
//echo '
';
//echo implode("\n", $coronaLastUp);
//echo '- 新型コロナウイルス関連のお知らせ
';
//echo '
';
// バッファに格納された文字列をHTML出力
echo implode("\n", $buffer);
}
?>
タグのhrefに指定されているファイルを保持する配列
$hrefFileList = array();
// HTMLタグ
~
の検出回数
$count = 0;
// 更新情報出力処理
{
// ファイルポインタをオープン
$file = fopen("shared/inc/inc_information.html", "r");
// ファイルの存在確認
if ( $file ) {
// 出力用フラグ
$isRead = false;
$yearflg = false;
// 更新アイコン初期化
$renewIco = 0;
// 最終更新日保持変数
$lastUpdated = "";
while ( $line = fgets( $file ) ) {
// 文字列の後ろの改行(\n)を削除
$line = trim( $line );
// 先頭#の文章又は空行を飛ばす
if ( preg_match( '/^#.*/', $line ) || $line == "" ) {
continue;
}
// コメント開始検知
if ( preg_match( '//', $line ) ) {
// コメントフラグOFF
$commentOut = false;
}
// コメントフラグONの際にコメントを飛ばす
if ($commentOut == true) {
continue;
}
// コロナ関連のお知らせではない
if (strpos($line, " corona-switch") === false) {
if (strpos($line, " renew-ico") !== false) {
if (strpos($line, " renew-ico01") !== false) {
// 重要アイコン
$renewIco = 1;
}
if (strpos($line, " renew-ico02") !== false) {
// お知らせアイコン
$renewIco = 2;
}
if (strpos($line, " renew-ico03") !== false) {
// 更新情報アイコン
$renewIco = 3;
}
if (strpos($line, " renew-ico04") !== false) {
// 採用情報アイコン
$renewIco = 4;
}
// 出力ON
$isRead = true;
//
ととを格納する一時バッファを初期化
$tempBuffer = array();
}
}
if (strpos($line, "", $lastUpdated . "", $line);
// 最終更新日保持変数を初期化
$lastUpdated = "";
}
// $lineをバッファに格納
array_push($tempBuffer, $line);
}
// 出力ON時に を検出した場合
if ($isRead && $line == "") {
// $tempBufferには
タグとタグとタグが格納されているので
// HTML格納用バッファに格納する
if (!empty($tempBuffer)) {
// 更新アイコンが「重要」の場合
if ($renewIco == 1) {
$buffer = array_merge($buffer, array(''), $tempBuffer, array('
'));
// 更新アイコンが「お知らせ」の場合
} elseif ($renewIco == 2) {
$buffer = array_merge($buffer, array(''), $tempBuffer, array('
'));
// 更新アイコンが「更新情報」の場合
} elseif ($renewIco == 3) {
$buffer = array_merge($buffer, array(''), $tempBuffer, array('
'));
// 更新アイコンが「採用情報」の場合
} elseif ($renewIco == 4) {
$buffer = array_merge($buffer, array(''), $tempBuffer, array('
'));
} else {
// 更新アイコンなしの場合
$buffer = array_merge($buffer, $tempBuffer);
}
}
// renew-ico処理件数を加算
++$count;
// 更新アイコン初期化
$renewIco = 0;
// 出力OFF
$isRead = false;
$yearflg = false;
// 10件出力したら終了
if ($count > 9) {
break;
}
}
}
// ファイルポインタをクローズ
fclose($file);
}
}
// HTML取得
$result = implode("\n", $buffer);
// 出力
if (count($buffer) > 0) {
echo <<