<?php
/* Script security */
if(!defined("MONENGINE")) {
	header("Location: index.php");
	exit();
}
/* Other code */

$vkcom  = '<div id="vk_comments"></div>
<script type="text/javascript">
VK.Widgets.Comments("vk_comments", {limit: 15, width: "772", attach: "*"});
</script>';
require_once LOCALE.LOCALESET."serv.php";

$server_id = $_GET['id'];
	
$take_server = dbquery("SELECT * FROM ".DB_SERVERS." WHERE server_id = ".mysql_real_escape_string($server_id)."");
if(mysql_num_rows($take_server) == 0) {
	displayMessage('Выбранный сервер не существует, либо был удалён.', 'error');
} else {
	$server_data = dbarray_fetch($take_server);

	$site = "";	
	if($server_data['server_site'] !="") {
		$site = "<a href='http://".$server_data['server_site']."' target='_blank'>".$server_data['server_site']." </a>";
	}
		
	$icq = "";
	if($server_data['server_icq'] !="") {
		$icq = $server_data['server_icq']." <img src='http://status.icq.com/online.gif?icq=".$server_data['server_icq']."&img=26'>";
	}
	$skype = "";
	if($server_data['server_skype'] !="") {
		$skype = $server_data['server_skype']."";
	}
	$timetop = "";
	if($server_data['server_top_time'] !="") {
	$timetop = $server_data['server_top_time']." ".date("d.m.Y [H:i]", $server_data['server_top_time'])." ";
	}
	$status="<font color='#red'><b>Offline</b></font>";
	if($server_data['server_status'] == 1) $status = "<font color='#green'><b>Online</b></font>";

	$last_update = $settings['last_update'];
	$time_diff = time() - $last_update;
	
	if($time_diff >= 60) {
		$time_lasted = floor($time_diff / 60)." минут";
	} else {
		$time_lasted = $time_diff." секунд";
	}
	
	
	
	echo "<div id='blockid_3'></div>	
      <div class='hero-unit'>
	  <div class='hero-head'>
      <h4>Информация о сервере <b>{$server_data['server_name']}</b></h4>
	  </div>";

	echo "<table style='font-family:Tahoma;font-size: 9pt;' class='tborder' cellpadding='6' cellspacing='1' border='0' width='100%' align='center'><tbody><tr>";
	
	
	$percent_loaded = floor(($server_data['server_players'] / $server_data['server_maxplayers']) * 100);
	
	switch($percent_loaded) {
		case ($percent_loaded <= 40):
			$load_color = 'green';
			break;
		case ($percent_loaded <= 80):
			$load_color = 'yellow';
			break;
		case ($percent_loaded <= 100):
			$load_color = 'red';
			break;
		default:
			$load_color = 'green';
			break;
	}



		echo "<td align='left' valign='top' width='35%'>
<div align='center' alt='' class='bs-docs-example2'>
<img class='desc' style='padding: 5px;border-radius: 5px;' src='/images/maps/cs16/{$server_data['server_map']}.jpg' width='350' height='120'>
<table border='0' width='75%' cellspacing='0' cellpadding='0'>
<tbody>
<tr>
<td colspan='32' height='18'>
<div align='left'>
<strong>Скопируйте и вставьте в консоль чтобы присоединиться</strong>
<input style='width: 95%;' type='text' value='connect {$server_data['server_ip']}' size='40' maxlength='35' onclick='this.focus();this.select()'>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</td>";

	echo "<td style='padding: 5px;' align='left' valign='top' width='35%'>
     <div alt='Информация' class='bs-docs-example'>	  
<div style='word-wrap: break-word;'>
    <div class='row-fluid'>
        <div class='span12'>
            <table class='table table-bordered'>
                <tbody>
				<tr><td> ID сервера:</td><td>{$server_data['server_id']}</td></tr>
				<tr><td> Название сервера:</td><td>{$server_data['server_name']} $status</td></tr>
                <tr><td> Адрес сервера:</td><td>{$server_data['server_ip']}</td></tr>
				<tr><td> ICQ админа:</td><td><strong>".((!empty($icq)) ? "$icq" : "Неуказан")."</strong></td></tr>
				<tr><td> Сайт сервера:</td><td><strong>".((!empty($site)) ? "$site" : "Неуказан")."</strong></td></tr>
                <tr><td> Игроки сервера:</td><td>{$server_data['server_players']}/{$server_data['server_maxplayers']} | сервер заполнен на $percent_loaded%</td></tr>
                <tr><td> Карта:</td><td><span class='label'><strong>{$server_data['server_map']}</strong></span></td></tr>
                <tr><td> Сервер добавлен:</td><td>".@date("d.m.Y H:i", $server_data['server_regdata'])."</td></tr>
				<tr><td> Сервер:</td><td>".(($server_data['server_status'] == 1) ? "Работает" : "Не работает")." с ".@date("d.m.Y H:i", $server_data['status_change'])."<br /></td></tr>
               </tbody></table></div></div></div></div></td>
<td style='padding: 5px;' align='left' valign='top' width='30%'>
<div alt='Описание' class='bs-docs-example'>
<div class='perenos'>	
".(!empty($server_data['about']) ? "<span style='color:#999999;'>{$server_data['about']}</span>" : "")."</div></div>
<div alt='Платные услуги' class='bs-docs-example'>
<div class='perenos'>		
<div style='padding-top: 1px;'>
<span class='label label-important'>Топ статус</span> До: ".(!empty($server_data['server_top_time']) ? "".date("d.m.Y H:i", $server_data['server_top_time'])."" : "Не активна")." [ <a href='http://mon.primalsm.in.ua/pay'>Продлить</a> ]
</div>

<div style='padding-top: 7px;'>
<span class='label label-important'>VIP статус</span> До: ".(!empty($server_data['server_vip_time']) ? "".date("d.m.Y H:i", $server_data['server_vip_time'])."" : "Не активна")." [ <a href='http://mon.primalsm.in.ua/pay'>Продлить</a> ]
</div>

<div style='padding-top: 7px;'>
<span class='label label-important'>Выделение</span> До: ".(!empty($server_data['server_color_time']) ? "".date("d.m.Y H:i", $server_data['server_color_time'])."" : "Не активна")." [ <a href='http://mon.primalsm.in.ua/pay'>Продлить</a> ]</div>
</div></div>
<div align='center' alt='Своя инфа' class='bs-docs-example'>
<div class='perenos'>	
туцтуц
<br>
<a href='#' class='btn btn-primary'>#</a>
</div>
</div>
</td>";
	echo "<!--".$vkcom."<br>--></div></tbody></table>";
}

?>