File "temrinal.php"

Full path: /www/ansys/qgis/007_honmoku/mapref/temrinal.php
File size: 1.2 KiB (1233 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
try
{
	$output = array();
	$addIndex = 0;
	
	$WORK_STATUS = 0;
	$enableSec = 600;
	$enableDateTime = date("Y-m-d H:i:s", time() - $enableSec);
	
	//データベース接続
	$HOST = "192.168.100.153";
	$DB = "ansys";
	$USER = "postgres";
	$PASS = "am#71ZJ*";
	
	$conn = pg_connect("
		host	=	". $HOST. "
		dbname	=	". $DB. "
		user	=	". $USER. "
		password=	". $PASS. "
	");
	
	$output[$addIndex++] = "0";
	
	$sql = "SELECT * FROM qgis.ts_terminal";
	$sql .= " WHERE app_id='17'";
	$sql .= " AND const_id='10'";
	$sql .= " AND mesdatetime >= '". $enableDateTime. "'";
	if (strcmp($WORK_STATUS, 0) != 0)
		$sql .= " AND work_status='". $WORK_STATUS. "'";
	$sql .= " ORDER BY regdatetime;";
	$res = pg_query($conn, $sql);
	if (!($resList = pg_query($conn, $sql)))
		throw new Exception("");
	
	$numTemrinal = pg_num_rows($res);
	for($iCount = 0; $iCount < $numTemrinal; $iCount++)
	{
		$row = pg_fetch_array($res, $iCount);
		$output[$addIndex++] = $row["terminal_name"]. ",". $row["lon"]. ",". $row["lat"]. ",". $row["work_status"];
	}
	
	$numoutput = count($output);
	for($iCount = 0; $iCount < $numoutput; $iCount++)
	{
		if ($iCount > 0)
			print "\\n";
		print $output[$iCount];
	}
}
catch(Exception $exc)
{
	print "";
}
?>

PHP File Manager