File "list.php"

Full path: /www/ttest/nagoya/wamap/list.php
File size: 6.44 KiB (6594 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
function html($tabs, $print)
{
	for($i = 0; $i < $tabs; $i++)
		print "\t";
	print $print. "\n";
}

function getDirectoryList($target)
{
	$ret = array();
	$scdir = scandir($target);
	foreach($scdir as $file)
	{
		if (strcmp($file, ".") == 0 || strcmp($file, "..") == 0)
			continue;
		else if (is_dir($target. "/". $file))
			$ret[] = $file;
	}
	return $ret;
}

function getFileList($target)
{
	$ret = array();
	$files = scandir($target);
	foreach($files as $file)
	{
		if (strcmp($file, ".") == 0 || strcmp($file, "..") == 0)
			continue;
		else if (is_file($target. "/". $file))
			$ret[] = $file;
	}
	return $ret;
}

function pre_dump($print)
{
	print "<pre>";
	var_dump($print);
	print "</pre>";
}

function put($data)
{
	if (strcmp($data, "") == 0)
		return "&nbsp;";
	return $data;
}

function getFileInfo($file)
{
	
}

function getWorkerInfo()
{
	$ret = array();
	$fpath = "../common/id.txt";
	$contents = file($fpath);
	
	$length = count($contents);
	for($i = 0; $i < $length; $i++)
	{
		$info = explode(",", trim($contents[$i]));
		$ret[$i] = array("id" => $info[0], "name" => $info[3], "mgrs" => $info[2], "mxrd" => $info[1]);
	}
	return $ret;
}

function getName($mxrdid, $info)
{
	
	$len = count($info);
	
	for($i = 0; $i < $len; $i++)
	{
		if (strcmp($info[$i]["mxrd"], $mxrdid) == 0)
		{
			return $info[$i]["name"];
		}
	}
	return "";
}
function getId($mxrdid, $info)
{
	$len = count($info);
	for($i = 0; $i < $len; $i++)
	{
		if (strcmp($info[$i]["mxrd"], $mxrdid) == 0)
		{
			return $info[$i]["id"];
		}
	}
	return "";
}

//$winfo = getWorkerInfo();

//pre_dump($winfo);

// GETパラメータ受け取り
$seldate = isset($_GET["date"]) ? htmlspecialchars($_GET["date"]) : "";
$selworker = isset($_GET["worker"]) ? htmlspecialchars($_GET["worker"]) : "";

//print $seldate. "<br>";
//print $selworker. "<br>";

// const
$DIR = "../output";
$DVIEW = array(
	"-1"	=>	"フラグXのため除外",
	"0"		=>	"判定不可",
	"1"		=>	"場外",
	"2"		=>	"入場"
);

// html
html(0, "<!DOCTYPE html>");
html(0, "<html>");

// head
html(1, "<head>");
html(2, "<meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\">");
html(2, "<link rel=\"shortcut icon\" href=\"/ansys/config/favicon.ico\">");
html(2, "<title>航跡波警報システム-履歴閲覧-</title>");

html(2, "<script type=\"text/javascript\">");
?>
function boxCheck()
{
	var seldate = document.getElementById("hseldate").value;
	//チェックされた項目を記録する変数
	var str = "";
	//for文でチェックボックスを1つずつ確認
	for(i = 0; i < tblmain.rows.length - 1; i++)
	{
		if(document.chbox.elements[i].checked)
		{
			if(str != "")
				str = str + ",";
			str = str + document.chbox.elements[i].value;
		}
	}
	
	if(str != "")
	{
		document.location = "http://penta-02.ptgw.net/ttest/nagoya/wamap/wamap.php?date=" + seldate + "&all=false&rows=" + str;
	}
}

function allView()
{
	var seldate = document.getElementById("hseldate").value;
	document.location = "http://penta-02.ptgw.net/ttest/nagoya/wamap/wamap.php?date=" + seldate + "&all=true&rows=";
}

function chkOn()
{
	for(i = 0; i < tblmain.rows.length - 1; i++)
	{
		document.chbox.elements[i].checked = true;
	}
}
function chkOff()
{
	for(i = 0; i < tblmain.rows.length - 1; i++)
	{
		document.chbox.elements[i].checked = false;
	}
}

<?php
html(2, "</script>");


html(1, "</head>");

// body
html(1, "<body>");

// header
html(2, "<center>");
html(3, "<font size=\"3\">");
html(4, "<b>航跡波警報システム-履歴閲覧-</b><br>");
html(4, "<b>【五洋建設株式会社】</b><br>");
html(3, "</font>");
html(2, "</center>");
html(2, "<hr>");

if (strcmp($seldate, "") == 0)
{
	// 日付一覧を表示
	$datedirs = getFileList($DIR);
	$cntdir = count($datedirs);
	
	html(2, "<table border=\"1\" style=\"width:30%;\">");
	html(3, "<tr bgcolor=\"#FF9999\">");
	html(4, "<th>日付選択</th>");
	html(3, "</tr>");
	for($i = 0; $i < $cntdir; $i++)
	{
		$bgc = "#ffff99";
		if (($i % 2) == 0)
			$bgc = "#feefff";
		
		$view = explode(".", $datedirs[$i]);
		if (strcmp($view[1], "csv") != 0)
			continue;
		html(3, "<tr bgcolor=\"". $bgc. "\">");
		html(4, "<td><a href=\"". $_SERVER["PHP_SELF"]. "?date=". $datedirs[$i]. "\">". $view[0]. "</a></td>");
		html(3, "</tr>");
	}
	html(2, "</table>");
}
else
{
	// データを表示
	$datas = file($DIR. "/". $seldate);
	//pre_dump($datas);
	html(2, "<a href=\"". $_SERVER["PHP_SELF"]. "\">日付選択に戻る</a><br>");
	
	html(2, "<input type=\"button\" value=\"全件表示\" onclick=\"allView()\">");
	html(2, "<input type=\"button\" value=\"確認\" onclick=\"boxCheck()\">");
	html(2, "<input type=\"button\" value=\"全件ON\" onclick=\"chkOn()\">");
	html(2, "<input type=\"button\" value=\"全件OFF\" onclick=\"chkOff()\">");
	
	html(2, "<form name=\"chbox\">");
	//警報,mmsi,船名,緯度,経度,速度[kt],速度[m/s],方位角[°],波高[m],船の長さ[m]
	html(2, "<table border=\"1\" style=\"width:100%;\" id=\"tblmain\">");
	html(3, "<tr bgcolor=\"#FF9999\">");
	html(4, "<th style=\"width:*%;\">表示</th>");
	html(4, "<th style=\"width:*%;\">警報</th>");
	html(4, "<th style=\"width:*%;\">mmsi</th>");
	html(4, "<th style=\"width:*%;\">船名</th>");
	html(4, "<th style=\"width:*%;\">緯度</th>");
	html(4, "<th style=\"width:*%;\">経度</th>");
	html(4, "<th style=\"width:*%;\">速度[kt]</th>");
	html(4, "<th style=\"width:*%;\">速度[m/s]</th>");
	html(4, "<th style=\"width:*%;\">方位角[°]</th>");
	html(4, "<th style=\"width:*%;\">波高[m]</th>");
	html(4, "<th style=\"width:*%;\">船のながさ[m]</th>");
	html(3, "</tr>");
	
	$length = count($datas);
	for($i = 0; $i < $length; $i++)
	{
		if ($i == 0)
			continue;
		$bgc = "#ffff99";
		if (($i % 2) == 0)
			$bgc = "#feefff";
		
		$data = explode(",", trim($datas[$i]));
		//pre_dump($data);
		
		html(3, "<tr align=\"center\" bgcolor=\"". $bgc. "\">");
		html(4, "<td><input type=\"checkbox\" value=\"". $i. "\"></td>");
		for($j = 0; $j < 10; $j++)
		{
			html(4, "<td>". $data[$j]. "</td>");
		}
		html(3, "</tr>");
	}
	html(2, "</table>");
	html(2, "</form>");
	html(2, "<input type=\"button\" value=\"確認\" onclick=\"boxCheck()\">");
	html(2, "<input type=\"hidden\" id=\"hseldate\" value=\"". $seldate. "\">");
	
	html(2, "<a href=\"". $_SERVER["PHP_SELF"]. "\">日付選択に戻る</a></br>");
}

// footer
html(2, "<hr>");
html(2, "<center>");
html(3, "<font size=\"3\" color=\"#000000\" face=\"Arial\">");
html(4, "<b><i>penta-ocean</i></b>");
html(3, "</font>");
html(2, "</center>");

// html end
html(1, "</body>");
html(0, "</html>");
?>

PHP File Manager