File "vevent.php"
Full path: /www/ansys/ttest/accmes/vevent.php
File size: 3.53 KiB (3616 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
$selfile = isset($_POST["selfile"]) ? htmlspecialchars($_POST["selfile"]) : "";
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>運転監視イベント履歴</title>
</head>
<body>
<?php
$TERM_POS = array(
array("fname" => "38baeb388dc49f0f.txt", "name" => "nexus4"),
);
$EVID_TO_EVNAME = array(
"0" => "エンジン停止",
"1" => "アイドリング",
"2" => "急アクセル",
"3" => "急ブレーキ",
"4" => "急ハンドル"
);
if (strcmp($selfile, "") == 0)
{
$path = "./event";
// 端末選択
$files = array();
if ($dir = opendir($path))
{
while (($file = readdir($dir)) !== false)
{
if(($file != ".") && ($file != ".."))
{
$files[] = $file;
}
}
closedir($dir);
}
print "<table width=\"45%\" border=\"0\" bgcolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\">";
print "<tr>";
print "<td>";
print "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\">";
print "<tr bgcolor=\"#99CCFF\">";
print "<th width=\"45%\">ファイル名</th>";
print "<th width=\"20%\">所持者</th>";
print "<th width=\"35%\">最終更新</th>";
print "</tr>";
for($iCount = 0; $iCount < count($files); $iCount++)
{
print "<tr bgcolor=\"#FFFFFF\">";
print "<td>";
print "<form name=\"form_". $iCount. "\" method=\"post\" action=\"". $_SERVER["PHP_SELF"]. "\" style=\"display:inline\">";
print "<a href=\"javascript:form_". $iCount. ".submit()\">". $files[$iCount]. "</a>";
print "<input type=\"hidden\" name=\"selfile\" value=\"". $files[$iCount]. "\">";
print "</form>";
print "</td>";
print "<td align=\"center\">";
for($jCount = 0; $jCount < count($TERM_POS); $jCount++)
{
if (strcmp($TERM_POS[$jCount]["fname"], $files[$iCount]) == 0)
{
print $TERM_POS[$jCount]["name"];
break;
}
}
print "</td>";
print "<td align=\"center\">". date("Y-m-d H:i:s", filemtime("./event/". $files[$iCount])). "</td>";
print "</tr>";
}
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
print "<a href=\"./idx.html\">戻る";
}
else
{
// 運転監視ログ
$fpath = "./event/". $selfile;
$fp = fopen($fpath, "r");
if ($fp != NULL)
{
$index = 0;
$ard = array();
while(!feof($fp))
{
$line = trim(fgets($fp));
if (strcmp($line, "") != 0)
{
$stac = split("#", $line);
$ard[$index]["msec"] = $stac[0];
$ard[$index]["evid"] = $stac[1];
$ard[$index]["etc"] = $stac[2];
$index++;
}
}
fclose($fp);
}
print "<table width=\"45%\" border=\"0\" bgcolor=\"#000000\" cellspacing=\"0\" cellpadding=\"0\">";
print "<tr>";
print "<td>";
print "<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"3\">";
print "<tr bgcolor=\"#99CCFF\">";
print "<th width=\"35%\">発生時刻</th>";
print "<th width=\"20%\">運転監視イベント</th>";
print "<th width=\"45%\">内容</th>";
print "</tr>";
$cnt = count($ard);
for($iCount = $cnt - 1; $iCount >= 0; $iCount--)
{
print "<tr bgcolor=\"#FFFFFF\">";
print "<td align=\"center\">";
$spmsec = explode(".", $ard[$iCount]["msec"] / 1000);
print date("Y-m-d H:i:s", $spmsec[0]). ".". $spmsec[1]. "<br>";
print "</td>";
print "<td align=\"center\">";
print $EVID_TO_EVNAME[$ard[$iCount]["evid"]];
print "</td>";
print "<td>";
print $ard[$iCount]["etc"];
print "</td>";
print "</tr>";
}
print "</table>";
print "</td>";
print "</tr>";
print "</table>";
print "<a href=\"". $_SERVER["PHP_SELF"]. "\">ファイル選択に戻る</a>";
}
?>
</body>
</html>