File "data.php"

Full path: /www/shinmoji/wg2/graph/data.php
File size: 2.97 KiB (3040 bytes)
MIME-type: text/x-php
Charset: utf-8

Download   Open   Back

<?php
//===============================================
//	CommonUtilities
//	備考		:	
//	更新		:	2012/11/29 KMK-Teraoka
//===============================================
$SCRIPT_TITLE = "運行管理システム 新門司";
$PENTA_OCEAN = "五洋建設株式会社";
$TAIL_PENTA_OCEAN = "penta-ocean";

$HOST = "192.168.100.153";
$DB = "cnbs";
$USER = "postgres";
$PASS = "am#71ZJ*";

	
// ===============================================
// GD処理準備
// 備考		:	
// 更新		:	2010/09/08 KMK T.Teraoka
// ===============================================
$img = imagecreatetruecolor(500,500);			//パレットの作成
$font1 = "/usr/share/fonts/vlgothic/VL-Gothic-Regular.ttf";

// 使用色の準備
$Black = imagecolorallocate($img, 0,0,0);
$White = imagecolorallocate($img, 255, 255, 255);
$Red =  imagecolorallocate($img, 255, 0, 0);

imagefill($img, 0, 0, $White);


//================================================
//	データベース接続
//	備考		:	
//	更新		:	2012/11/29 KMK-Teraoka
//================================================
$conn = pg_connect("
	host	=	". $HOST. "
	dbname	=	". $DB. "
	user	=	". $USER. "
	password=	". $PASS. "
");
if (!$conn)
{
	throw new Exception("データベースへの接続に失敗しました");
}

$hour_ = sprintf("%02d",rand(0,2));
$minu_ = sprintf("%02d",rand(0,59));
$sec_ =  sprintf("%02d",rand(0,59));

$test_date = "2015-01-30 " .$hour_ .":" .$minu_ .":" .$sec_ ;

//$sql = "SELECT * FROM shinmoji.wg_avg WHERE regdate < '" .$test_date ."'" ." ORDER BY regdate desc limit 1;";
$sql = "SELECT * FROM shinmoji.wg_avg ORDER BY regdate desc limit 1;";
$res = pg_query($conn,$sql)or die("SQL ERROR!!<br />". $sql.pg_last_error());
$row = pg_fetch_array($res,0);
//$Data = number_format($row['avg_3s'], 2, '.', '');
$Data = ($row['avg_3s'] -1000+30) / 2;
$Data = number_format($Data, 2, '.', '');
$Date_ = $row['regdate'];

// 更新時間をマップに表示する
$up_check = date("H:i:s" ,time());
imagefilledpolygon($img, array(10, 10, 10, 20, 55, 20, 55, 10), 4, $White);
//ImageTTFText ($img, 8, 0, 10, 20, $Black, $font1, $test_date);
ImageTTFText ($img, 8, 0, 10, 20, $Black, $font1, $Date_);


//データを表示する
imagettftext($img, 100, 0, 0,200, $Black, $font1, mb_convert_encoding($Data, "SJIS", "UTF8"));
// ===============================================
// 描画した画像を保存 & パレットを削除
// 備考		:	
// 更新		:	2010/09/08 KMK T.Teraoka
// ===============================================
header('Content-Type: image/png');

//	imagepng($img, $imgFileName);
imagepng($img);
imagedestroy($img);

//===============================================
//	Postgresql終了処理
//	備考		:	
//	更新		:	2012/10/19 KMK-Teraoka
//===============================================
pg_close($conn);

//===============================================
//	HTML終了処理
//	備考		:	
//	更新		:	2012/10/18 KMK-Teraoka
//===============================================
//print "</body>";
//print "</html>";

?>

PHP File Manager