<?
	require_once( "inc/session.php" );
	require_once( "inc/common.inc" );
	require_once( "inc/db_pgsql.inc" );
	$serviceType = isset($_GET['service_type']) ? $_GET['service_type'] : $_POST['service_type'];	
	if($serviceType == "") $serviceType = 1;

	//$admin = $HTTP_COOKIE_VARS[SUID];
	$admin = $_COOKIE[SUID];
	if ($admin == "guru222") {
		$colspan = "7";
	}
	else {
		$colspan = "6";
	}

	$objConn = new DB_Sql;
?>
<html>
<head>
<title>######## SYSTEM-HOSTING SERVICE STATUS ######## </title>
<STYLE type=text/css>
TD { FONT-SIZE: 9pt; COLOR: #000000; FONT-FAMILY: 'ARIAL,굴림체'; TEXT-DECORATION: none; }
TR { FONT-SIZE: 9pt; COLOR: #000000; FONT-FAMILY: 'ARIAL,굴림체'; TEXT-DECORATION: none; }
TABLE { FONT-SIZE: 9pt; COLOR: #000000; FONT-FAMILY: 'ARIAL,굴림체'; TEXT-DECORATION: none; line-height : 120%}
INPUT { FONT-SIZE: 9pt; COLOR: #000000; FONT-FAMILY: 'ARIAL,굴림체'; TEXT-DECORATION: none; line-height : 120%}

</STYLE>
<meta http-equiv="Cache-Control" content="no-cache"/> 
<meta http-equiv="Expires" content="0"/> 
<meta http-equiv="Pragma" content="no-cache"/> 
<link rel="stylesheet" href="clockstyle.css" type="text/css">
<style type="text/css">
.box {width:147px; height:81px; font-size:9pt; font-family:"돋움체",FC1487; color:ffffff; background-image:url('./image/talk.gif'); padding:5;}
</style>
<style type="text/css">
#tooltip {position:absolute;
top:5;
left:5;
border:solid 3 ffccff;
background:ffffcc;
color:660066;
font-size:9pt;
width:580;
height:20;
padding:2;
overflow:hidden;
z-index:10;
display:none;
}
</style>
<? require "layer.js";?>
<script language="javascript1.2"  type="text/javascript" src="clock.js" ></script>
<script language="JScript">
var n = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;

function overTip(boxObj, userid) {
    if (ie) {
        var mailaddr = userid;
        boxObj.innerHTML = mailaddr + " 가 클립보드로 복사 되었습니다.";
        boxObj.style.pixelTop=event.y+document.body.scrollTop - 85;
        boxObj.style.pixelLeft=event.x+document.body.scrollLeft - 20;
        boxObj.style.visibility = "visible";
        boxObj.filters.item(0).stop();
        window.clipboardData.setData("Text", mailaddr);
    }
}

function outTip(boxObj) {
    if (ie) {
//      boxObj.style.visibility = "visible";
        boxObj.filters.item(0).transition = 23;
        boxObj.filters.item(0).apply();
        boxObj.style.visibility = "hidden";
        boxObj.filters.item(0).play();
    }
}

function neo_manage(what, neo_seq)
{
    window.open("neo_manage.html?mode=" + what + "&neo_seq=" + neo_seq, "neo_add_popup", "width=650, height=300, resizable");
}

function neo_del(neo_seq)
{
	if (confirm('정말 삭제하시겠습니까?'))
		document.location.href("neo_delete.html?neo_seq=" + neo_seq);
	else
		return;
}

function check_admin_pop()
{
	window.open("check_admin.html", "_box", "width=200, height=100, scrollbar=yes");
}

</script>
</head>

<body onLoad="UpdateClocks()">
<form name="frm" action=<?=$_SERVER['PHP_SELF']?> method=POST>
	<input type="hidden" name="service_type" value="<?= $serviceType ?>">
<table border="0" cellspacing="0" width="100%" background="images/topbg.gif">
  <tr class="ratNavText">
    <td ID="Clock0" width="25%" >   </td>
    <td ID="Clock1" width="25%" >   </td>
    <td ID="Clock2" width="25%" >   </td>
    <td ID="Clock3" width="25%" >   </td>
  </tr>
  <tr class="ratNavText">
    <td ID="Clock4" width="25%" >   </td>
    <td ID="Clock5" width="25%" >   </td>
    <td ID="Clock6" width="25%" >   </td>
    <td ID="Clock7" width="25%" >   </td>
  </tr>
</table>
<br>
<table border="0" cellspacing="1" width="630" align="center">
<tr align="center">
    <td> <h3>######## ICS STATUS ########<br>(222.122.136.110)</h3></td>
</tr>
</table>
<?php
require_once ("../inc/contact_neocast.html");
?>
<div id="tooltip" name="tooltip" width=400></div>
<div id="clboard" class="box" style="position:absolute; z-index:20; filter:revealTrans(duration=0); visibility:hidden;"></div>
<?
	$server_addr[0][0] = "127.0.0.1";
	$server_addr[0][1] = "30001";
	$server_addr[0][2] = "KT-IDC";

	$tot = count($server_addr);
?>
	<table border="0" cellspacing="1" width="800" align="center">
		<td valign=top>
			<table border=0 cellpadding=3 cellspacing=1 bgcolor="b2b2b2">
			<tr height="60">
				<td colspan="14" bgcolor="FFFFFF">
				<center><b>
				<font color="#000066" size="5">
					NEOCAST
					<br><br>
				</font>
				<font color="#000066" size="4">
					MNG SERVER IP: <?=$server_addr[0][0]?>
				</font>
				</b>
				</center>
				</td>
			</tr>
			<tr align="center">
				<td width="75" bgcolor="efefef" align="left"><b><font color="#000066">Name</font>
					<img src="images/bu14.gif" width=11 height=11>norm<br>
					<img src="images/bu77.gif" width=11 height=11>nomon<br>
					<img src="images/bu15.gif" width=11 height=11>fail<br>
					</b></td>
				<td width="90" bgcolor="efefef"><center><b><font color="#000066">Type</font></b></center></td>
				<td width="90" bgcolor="efefef"><center><b><font color="#000066">Server IP</font></b></center></td>
				<td width="110" bgcolor="efefef"><center><b><font color="#000066">Domain</font></b></center></td>
				<td width="25" bgcolor="efefef"><center><b><font color="#000066">Port</font></b></center></td>
				<td width="160" bgcolor="efefef"><center><b><font color="#000066">Status<br>Changed</font></b></center></td>
				<?
					if ($admin == "guru222")
						echo "<td width=\"150\" bgcolor=\"efefef\"><center><b><font color=\"#FF0000\">Manage</font></b></center></td>";
				?>
			</tr>
			<?php
				$strSql  = "SELECT neo_seq, status, neo_type, name, ip, port, domain, monitor_yn, update_datetime ";
				$strSql .= "FROM t_neo_server_index ";
				$strSql .= "WHERE deleted_yn = 'N' ";
				$strSql .= "ORDER BY neo_seq asc ";
				$objConn->query( $strSql );
				if( $objConn->nf() != 0 )
				{
					while( $objConn->next_record() )
					{
						$neo_seq = $objConn->f(0);
						$status = $objConn->f(1);
						$neo_type = $objConn->f(2);
						$name = $objConn->f(3);
						$ip_addr = $objConn->f(4);
						$port = $objConn->f(5);
						$domain = $objConn->f(6);
						$monitor_yn = $objConn->f(7);
						$upd_datetime = $objConn->f(8);

						if ($monitor_yn == 'Y')
						{
							if ($status == 1)
								$spic = "<img src=\"images/bu14.gif\" width=11 height=11>";
							else if ($status == 2)
								$spic = "<img src=\"images/bu15.gif\" width=11 height=11>";
						}
						else if ($monitor_yn == 'N') {
							$spic = "<img src=\"images/bu77.gif\" width=11 height=11>";
						}
			?>
			<tr>
				<td align="center" bgcolor="FFFFFF"><?=$spic?>&nbsp;<?=$name?></b></td>
				<td align="center" bgcolor="FFFFFF"><?=$neo_type?></b></td>
				<td align="center" bgcolor="FFFFFF"><span class="txt03" onMouseDown="overTip(clboard, '<?=$ip_addr?>')" onMouseOut="outTip(clboard)"><?=$ip_addr?></span></b></td>
				<td align="center" bgcolor="FFFFFF"><span class="txt03" onMouseDown="overTip(clboard, '<?=$domain?>')" onMouseOut="outTip(clboard)"><?=$domain?></b></td>
				<td align="center" bgcolor="FFFFFF"><?=$port?></b></td>
				<td align="center" bgcolor="FFFFFF"></b><?=noYear($upd_datetime)?></td>
				<?
	                if ($admin == "guru222")
					{
						echo "<td align=\"center\" bgcolor=\"FFFFFF\">";
						echo "<a href=\"javascript:neo_del('$neo_seq');\"><img src=\"images/neo_web/bt_del.gif\" border=\"0\"></a>&nbsp;&nbsp;";
						echo "<a href=\"javascript:neo_manage('mod', '$neo_seq');\"><img src=\"images/neo_web/bt_mod.gif\" border=\"0\"></a></b></td>";
					}
				?>
			</tr>
			<?
					}
				}
				$objConn->close();
				echo "<tr>";
				if ($admin == "guru222")
					echo "<td align=\"right\" colspan='$colspan' bgcolor=\"FFFFFF\"><a href=\"javascript:neo_manage('add', '0');\"><img src=\"images/neo_web/bt_add.gif\" border=\"0\"></a></td>";
				else
					echo "<td align=\"right\" colspan='$colspan' bgcolor=\"FFFFFF\"><a href=\"javascript:check_admin_pop();\"><img src=\"images/neo_web/bt_manage.gif\" border=\"0\"></a></td>";
				echo "</tr>";
			?>
			</table>
		</td>
	</table>
<?
////////////////////
//Print REFRESHER
////////////////////

extract($_POST);

$refresh_rate = $_REQUEST['refresh_rate'];

if($refresh_rate<1 || $refresh_rate>1000)
	$refresh_rate = 60;

?>
<br>
<table align="center">
	<tr>
	<td>
			Refresh Rate :
			<input type=text name=refresh_rate value=<?=$refresh_rate?>>
			<input type=submit value=SET>
			(MIN : 1, MAX : 1000)
			<input type="hidden" name="chk" value="0">
		</form>
	</td>
	</tr><tr>
	<td align=right>
		<form action=<?=$_SERVER['PHP_SELF']?> method=POST>
			<input type="hidden" name="service_type" value="<?= $serviceType?>">
			<input type=hidden name=refresh_rate value=30>
			<input type=submit value=RESET(30)>
		</form>
	</td>
	</tr>
</table>
<script language="javascript"  type="text/javascript" src="tooltip.js" ></script>
<script language=javascript>
function showtip(text) {
tooltip.innerText=text; 
tooltip.style.display="inline";
}
function hidetip() {
tooltip.style.display="none";
}
function movetip() {
tooltip.style.pixelTop=event.y+document.body.scrollTop; 
tooltip.style.pixelLeft=event.x+document.body.scrollLeft + 10;
}
document.onmousemove=movetip;
</script>
</body>
</html>
<META http-equiv="refresh" content="<?=$refresh_rate?>; url=<?=$PHP_SELF?>?refresh_rate=<?=$refresh_rate?>&service_type=<?= $serviceType ?>"> 
<?
	function nullTrim($tmp_str)
	{
		$return_str = "";
		$maxLength = strlen($tmp_str);

		for($i=0 ; $i < $maxLength ; $i++) {
			if(ord(substr($tmp_str, $i, 1)) != 0 || $tmp_str != " ") {
				$return_str .= substr($tmp_str, $i, 1);
			}
		}
		return $return_str;
	}
	
	function noYear($date)
	{
		$date = substr($date, 5, 14);

		return $date;
	}
?>
