File "output.php"
Full path: /www/ansys/qgis/011_yokohama/output/terminal/output.php
File size: 2.56 KiB (2619 bytes)
MIME-type: text/x-php
Charset: utf-8
<?php
//===============================================
// CommonUtilities
// 備考 :
// 更新 : 2013/05/31 KMK-Teraoka
//===============================================
$TERMINAL_TABLE = "qgis.ts_terminal";
$AVAILABILITY_SECONDS = 5 * 60;
$HOST = "192.168.100.153";
$DB = "ansys";
$USER = "postgres";
$PASS = "am#71ZJ*";
$CONST_ID = 12;
$APPLICATION_ID = 23;
$OBJECT_LIST = array(
"0" => array("select" => "android_id", "output" => "android_id"),
"1" => array("select" => "terminal_name", "output" => "terminal_name"),
"2" => array("select" => "lat", "output" => "lat"),
"3" => array("select" => "lon", "output" => "lon"),
"4" => array("select" => "direction", "output" => "direction"),
);
//================================================
// データベース接続
// 備考 :
// 更新 : 2012/10/18 KMK-Teraoka
//================================================
$conn = pg_connect("
host = ". $HOST. "
dbname = ". $DB. "
user = ". $USER. "
password= ". $PASS. "
");
//===============================================
// 現在時刻 - 一定秒を算出
// 備考 :
// 更新 : 2013/05/31 KMK-Teraoka
//===============================================
$availabilityDate = date("Y-m-d H:i:s", time() - $AVAILABILITY_SECONDS);
//===============================================
// AIS情報を取得する
// 備考 :
// 更新 : 2013/05/31 KMK-Teraoka
//===============================================
//20151019追加
$RTime = date("Y-m-d H:i:s" ,time() - 600);
$selectTerminal = "SELECT ";
$row = count($OBJECT_LIST);
for($iCount = 0; $iCount < $row; $iCount++)
{
if ($iCount > 0)
$selectTerminal .= ",";
$selectTerminal .= $OBJECT_LIST[$iCount]["select"];
}
$selectTerminal .= " FROM ". $TERMINAL_TABLE. "";
$selectTerminal .= " WHERE const_id='". $CONST_ID. "'";
$selectTerminal .= " AND app_id='". $APPLICATION_ID. "'";
$selectTerminal .= " AND android_id != '". "8041c3ba7d4843c1". "'";
$selectTerminal .= " AND mesdatetime > '". $RTime. "'";
$selectTerminal .= " ORDER BY android_id";
$selectTerminal .= ";";
$outputFname = "/www/ansys/rctm/002_hitachinaka_2/output/terminal/terminals.txt";
$fp = fopen($outputFname, "w");
$resTerminal = pg_query($conn, $selectTerminal);
$count = pg_num_rows($resTerminal);
for($iCount = 0; $iCount < $count; $iCount++)
{
$rowTerminal = pg_fetch_assoc($resTerminal, $iCount);
$write = "";
if ($iCount > 0)
$write .= "#";
for($kCount = 0; $kCount < $row; $kCount++)
{
if ($kCount > 0)
$write .= ",";
$write .= $rowTerminal[$OBJECT_LIST[$kCount]["output"]];
}
fputs($fp, $write);
}
fclose($fp);
?>