<?php

include 'include.php';

	//Панель управления
	//$datac = GetData('gamers.data'); //получение стволов
	if(isset($_POST['login']))
	{
		//авторизация
		if($_POST['pass'] == GetAdminPass())
		{
			AuthAdmin();
			echo '1';
			die();
		}
		else
		{
			echo '0';
			die();
		}
	}
	
	if(isset($_POST['command']))
	{
		//записываем комманду в файл комманд
		$idcommand = $_POST['id'];
		$values = $_POST['values'];
		//$datac = GetData('command.data');
		
		$currtime = time(); //время регистрации команды
		
		/*if(strlen($datac) > 0)
		{
			$newdata = $datac.'|'.$idcommand.'#'.$values;
		}
		else
		{
			$newdata = $idcommand.'#'.$values;
		}*/
		
		$newdata[0] = $idcommand;
		$newdata[1] = $values;
		$newdata[2] = $currtime;
		$objectser = $newdata;
		$dataserial = json_encode($objectser); //упаковываем в json
		
		WriteData($dataserial, 'command.data');
		
		echo $currtime; //возвращаем время посыла команды, чтобы по нему отслеживать ответ
		die();
	}
	
	if(isset($_POST['waiting_response']))
	{
		//проверяем есть ли ответ
		$timecommand = $_POST['timecommand'];

		$datac = GetData('response.data');
		$Response = explode('###',$datac);
		if($Response[0] == $timecommand)
		{
			//наш ответ
			$Otv = $Response[1];
		}
		else
		{
			$Otv = '-1';
		}
		echo $Otv;
		die();
	}
	
	if(isset($_POST['getcurrdevice']))
	{
		$panel = GetCurrDevice();
		echo $panel;
		die();
	}
	
	if(isset($_POST['geteditcurrdevice']))
	{
		$panel = GetCurrDeviceEditPar();
		echo $panel;
		die();
	}
	
	$jquery = GetJQuery();
	$bootstrap = GetBootstrap();
	
	$wfpan = '<html><head>';
	$wfpan.= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
	$wfpan.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">';
	$wfpan.= '<link rel="icon" type="image/png" href="/favicon.ico" />';
	$wfpan.=  '<title>Панель управления</title>';
	$wfpan.= <<<HTML
	<script type="text/javascript">
	
var is_ep = 0;
var curriddev = 0;		
var start_waiting = 0;	
		
function LoadData()
{
	$.ajax({
		'type': 'POST',
		'async': true,
		'global': false,
		'timeout': 75000,
		'data':{'getdata':'1'}, 
		'url': 'index.php',
		'success': function (data) {
			val = data;
			passtp = 0;
			count_error_load = 0;
			$('#tablestat').html(val);
			setTimeout("LoadData()",5000);
		},
		error: function(msg){
			count_error_load++;
			setTimeout("LoadData()",5000);
			if(count_error_load > 6)
			{
				//минуту нет связи
				$('.errorcon').remove();
				var bodyhtml = $('#tablestat').html();
				$('#tablestat').html('<div class="errorcon">Потеряна связь с сервером...</div>'+bodyhtml);
			}
		}
	});
}
	
	/*! jQuery v1.11.2 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
	$jquery
	
	$(document).ready(function(){
		$('.passwordok').click(function(){
			$.ajax({
				'type': 'POST',
				'async': true,
				'global': false,
				'timeout': 75000,
				'data':{'login':'1','pass':$('.password').val()}, 
				'url': 'admin.php',
				'success': function (data) {
					if(data == '1')
					{
						setTimeout("document.location.href='admin.php'", 10);
					}
					else
					{
						$('.errorlogin').html('Неверный пароль');
					}	
				},
				error: function(msg){
					$('.errorlogin').html('Ошибка авторизации');
				}
			});
		});
		$('#respawn').click(function(){
			PostCommandWF(0,'');
		});
		$('#killall').click(function(){
			PostCommandWF(1,'');
		});
		$('#startgame').click(function(){
			PostCommandWF(2,'');
		});
		$('#stopgame').click(function(){
			PostCommandWF(3,'');
		});
		$('.getdevconf').click(function(){
			var idgdc = $(this).attr('id');
			var idgdcm = idgdc.split('-');
			curriddev = idgdcm[1];
			PostCommandWF(4,idgdcm[1]);
		});
	});
	
	function PostCommandWF(command,values)
	{
		$.ajax({
			'type': 'POST',
			'async': true,
			'global': false,
			'timeout': 75000,
			'data':{'command':'1','id':command,'values':values}, 
			'url': 'admin.php',
			'success': function (data) {
				$('.overlay').show();
				start_waiting = new Date().getTime();

				setTimeout("WaitingResponse(" + command + " , " + data + ")", 500);
			},
			error: function(msg){
				
			}
		});
	}
	
	function WaitingResponse(command, timecom)
	{
		$.ajax({
			'type': 'POST',
			'async': true,
			'global': false,
			'timeout': 75000,
			'data':{'waiting_response':'1','timecommand':timecom}, 
			'url': 'admin.php',
			'success': function (data) {
				if(data != '-1')
				{
					//ответ получен
					$('.overlay').hide();
					switch(command)
					{
						case 2:
						if(data == 1)
						{
							$('#stopgame').unbind('click');
							$('#startgame').unbind('click');
							
							$('.startstop').html('<div id="stopgame" class="adminbutton" style="display:block;padding:10px;cursor:pointer;background:#eee;border:1px solid #053e1d">Остановить игру</div>');
							
							$('#stopgame').click(function(){
								PostCommandWF(3,'');
							});
						}
							break;
						case 3:
						if(data == 1)
						{
							$('#stopgame').unbind('click');
							$('#startgame').unbind('click');
							
							$('.startstop').html('<div id="startgame" class="adminbutton" style="display:block;padding:10px;cursor:pointer;background:#eee;border:1px solid #727272">Запустить игру</div><a id="startconfigurator" class="adminbutton" href="admin.php?a=configurator" style="display:block;padding:10px;cursor:pointer;background:#eee;border:1px solid #727272">Конфигуратор</a>');
							
							$('#startgame').click(function(){
								PostCommandWF(2,'');
							});
						}
							break;
						case 4:
							is_ep = 0;
							if(data == 1)
							{
								GetCurrDevice();
							}
							else
							{
								$('.confpanel').html('Ошибка. <a href="admin.php">Вернуться в админпанель</a>');
							}
							break;
						case 5:
							if(data == 1)
							{
								$('.loadconf').unbind('click');
								$('.confpanel').html('<div style="margin:0 auto;width:300px;text-align:center;font-weight:bold;font-size:18px;"><div style="color:darkgreen;">Параметр успешно изменён</div><button class="loadconf adminbutton" style="margin:0 auto;">ОК</button></div>');
								$('.loadconf').click(function(){
									PostCommandWF(4,curriddev);
								});
								
							}
							else
							{
								$('.confpanel').html('Ошибка. <a href="admin.php">Вернуться в админпанель</a>');
							}
							break;
					}
				}
				else
				{
					var currtime = new Date().getTime();
					if(currtime < (start_waiting + 30000))
					{
						setTimeout("WaitingResponse("+ command + ", " + timecom + ")", 500);
					}
					else
					{
						$('.overlay').hide();
						
					}

				}
			},
			error: function(msg){
				
			}
		});
	}
	
	function GetCurrDevice()
	{
		$('.savepar').unbind('click');
		$('.cancelsp').unbind('click');
		$('.adminparedit').unbind('click');
		

		$.ajax({
			'type': 'POST',
			'async': true,
			'global': false,
			'timeout': 75000,
			'data':{'getcurrdevice':'1'}, 
			'url': 'admin.php',
			'success': function (data) {
				if(data != '-1')
				{
					//ответ получен
					$('.overlay').hide();
					$('.confpanel').html(data);
					$('.adminparedit').click(function(){
							if(is_ep == 0)
							{
								var idparm1 = $(this).attr('id');
								var idparm = idparm1.split('-');
								var idpar = idparm[1];
								$.ajax({
									'type': 'POST',
									'async': true,
									'global': false,
									'timeout': 75000,
									'data':{'geteditcurrdevice':'1','idpar':idpar}, 
									'url': 'admin.php',
									'success': function (data) {
										if(data != '-1')
										{
											//ответ получен
											$('#'+idparm1).html(data);
											$('#'+idparm1).removeClass('adminbutton');
											$('#'+idparm1).removeClass('adminparedit');
											$('#'+idparm1).addClass('adminlabel');
											
											$('.savepar').click(function(){
												var idsp = $(this).attr('id');
												var idsp1 = idsp.split('-');
												var value = $('#par-' + idsp1[1]).val();
												PostCommandWF(5,curriddev + '|' + idsp1[1] + '|' + value);

												
											});
											
											$('.cancelsp').click(function(){
												$('.overlay').show();
												PostCommandWF(4,curriddev);
												
											});
										}
										else
										{
											$('#'+idparm1).html('Ошибка. <a href="admin.php">Вернуться в админпанель</a>');
										}
									},
									error: function(msg){
										$('#'+idparm1).html('Обрыв связи. <a href="admin.php">Вернуться в админпанель</a>');
									}
								});
								is_ep = 1;
							}
							else
							{
							
							}
					});
				}
				else
				{
					$('.overlay').hide();
					$('.confpanel').html('Ошибка. <a href="admin.php">Вернуться в админпанель</a>');
				}
			},
			error: function(msg){
				$('.overlay').hide();
				$('.confpanel').html('Обрыв связи. <a href="admin.php">Вернуться в админпанель</a>');
			}
		});
		
	}
	</script>
HTML;

	
	$adminpanel = GetAdminPanel();
	
	$wfpan.= '<style>'.$bootstrap.'</style>';
	$wfpan.= '<style>';
	
	$wfpan.= 'table{border-collapse:collapse;font-weight:bold;font-size:18px;}td{border:1px solid #333;}tr.headtable{background:#4473ab;color:#fff;font-size:12px;}tr.team{background:#e6decd;}td.center{text-align:center;} .errorcon{display:block;font-size:18px;color:darkred;padding:5px;}.adminbutton{display:block;padding:5px;cursor:pointer;background:#eee;border:1px solid #ccc;border-radius:5px;color:#333;}.adminbutton:hover{background:#ddd;border:1px solid #aaa;color:#000;}.password{border:1px solid #444;background:#eee;width:300px;padding:8px;}.password:focus{border:1px solid #222;background:#fff;}.acenter{text-align:center;}table.adminpanel{border:0;width:100%;}table.adminpanel td{border:0;} .overlay{display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:#333;opacity:0.5;z-index:10;} hr{background:#333;border:1px solid #333;} .confpanel{padding:5px;}.adminlabel{display:block;padding:5px;cursor:pointer;background:#fff;border:1px solid #ccc;color:#333;}';
	$wfpan.= '</style>';
	$wfpan.=  '';
	$wfpan.=  '</head><body><div class="overlay"></div><div id="adminpanel">'.$adminpanel.'</div></body></html>';
	echo $wfpan;
	
	
	function GetData($file)
	{
		$filename = $file;
			
		$f=fopen($filename,"r");
		flock($f,LOCK_EX);
		if(filesize($filename)==0)
		{
			$data = null;
		}
		else
		{
			$data=fread($f,filesize($filename));

			if($data == null)
			{
				echo 'Ошибка чтения файла '.$filename.'<br>';
			}
		}
		
		flock($f,LOCK_UN);
		fclose($f);
		
		return $data; 
	}
	
function WriteData($data, $file)
{
	$serial_data = $data;
	$filename = $file;
	
	$f=fopen($filename,"a+"); //открываем на чтение и запись
	flock($f,LOCK_EX);              //блокируем

	
	ftruncate($f,0);
	fwrite($f,$serial_data);
	fflush($f);
	flock($f,LOCK_UN);   //разблокируем
	fclose($f);
}

function GetAdminPanel()
{	
	$is_login = 1;
	if(isset($_COOKIE['adminp']))
	{
		if($_COOKIE['adminp'] == md5(GetAdminPass()))
		{
			$is_login = 0; //авторизованы
		}
	}
	
	$datac = GetData('isstartgame.data');
	if(strlen($datac) == 0)
	{
		$is_startgame = 0;
	}
	else
	{
		$is_startgame = $datac;
	}
	
	if(isset($_GET['a']))
	{
		if($_GET['a'] == 'configurator')
		{
			$adminpanel = GetConfigurator();
			return $adminpanel;
		}
	}
	
	if($is_login == 0)
	{
		$adminpanel = '<div style="display:block;margin-top:10px;">';
		$adminpanel.='<table class="adminpanel"><tr><td style="width:50%;">';
		$adminpanel.='<div id="respawn" class="adminbutton" style="display:block;padding:10px;cursor:pointer;background:#eee;">Оживить</div>';
		$adminpanel.='</td><td style="width:50%;">';
		$adminpanel.='<div id="killall" class="adminbutton" style="display:block;padding:10px;cursor:pointer;background:#eee;">Убить всех</div>';
		$adminpanel.='</td></tr>';
		$adminpanel.='<tr><td style="width:100%;" colspan="2">';
		if($is_startgame == 1)
		{
			$adminpanel.='<div class="startstop"><div id="stopgame" class="adminbutton" style="display:block;padding:10px;cursor:pointer;background:#eee;border:1px solid #053e1d">Остановить игру</div></div>';
		}
		else
		{
			$adminpanel.='<div class="startstop"><div id="startgame" class="adminbutton" style="display:block;padding:10px;cursor:pointer;background:#eee;border:1px solid #727272">Запустить игру</div><a id="startconfigurator" class="adminbutton" href="admin.php?a=configurator" style="display:block;padding:10px;cursor:pointer;background:#eee;border:1px solid #727272">Конфигуратор</a></div>';
			$adminpanel.= '';
		}
		$adminpanel.='</td>';
		$adminpanel.='</tr>';
		$adminpanel.='</table>';
		$adminpanel.='</div>';
		$adminpanel.='<a href="index.php" style="display:block;color:gray;margin-top:20px;">Онлайн-статистика</a>';
	}
	else
	{
		$adminpanel = '<p>Пароль для доступа к панели управления:</p><p><input type="text" value="" class="password" /></p><p><div class="adminbutton passwordok acenter" style="max-width:200px;">Войти</div><div class="errorlogin"></div></p>';
	}
	return $adminpanel;
}

//конфигуратор
function GetConfigurator()
{
	
	$playersinfo = GetData('players.data');
	$MasPlayers = json_decode($playersinfo);
	
	$PlayersAss = null;
	
	$CurrPlayer = null;
	$panel = '<div class="confpanel"><table style="width:100%;" class="table table-bordered">';
	for($loop1 = 0; $loop1 < sizeof($MasPlayers); $loop1++)
	{
		$currplayer = $MasPlayers[$loop1];
		$nameplayer = $currplayer[1][7];
		$idplayer = $currplayer[0][0];
		$panel.='<tr><td>';
		$panel.= '<div class="adminbutton getdevconf" id="player-'.$idplayer.'">'.$nameplayer.'</div>';
		$panel.='</td></tr>';
	}
	$panel.='</table></div>';
	$panel.='<hr><a href="admin.php" class="pull-right" style="margin-right:10px;">Вернуться к административной панели</a>';
	
	return $panel;
}

function GetCurrDevice()
{
	$datac = GetData('ccd.data');
	$ConfDevice = json_decode($datac, true);
	$ConfDeviceAss = GetDeviseAss($ConfDevice);
	
	$datac2 = GetData('pd.data');
	$ConfData = json_decode($datac2, true);
	
	$playersinfo = GetData('players.data');
	$MasPlayers = json_decode($playersinfo);
	
	$CurrPlayer = null;
	for($loop1 = 0; $loop1 < sizeof($MasPlayers); $loop1++)
	{
		if($ConfDeviceAss['Id'] == $MasPlayers[$loop1][0][0])
		{
			$CurrPlayer = $MasPlayers[$loop1];
			break;
		}
	}
	
	$ConfDataAss = null;
	for($loop1 = 0; $loop1 < sizeof($ConfData); $loop1++)
	{
		$ConfDataAss[$ConfData[$loop1][0]]['is_readonly'] = $ConfData[$loop1][1];
		$ConfDataAss[$ConfData[$loop1][0]]['start'] = $ConfData[$loop1][2];
		$ConfDataAss[$ConfData[$loop1][0]]['finish'] = $ConfData[$loop1][3];
		$ConfDataAss[$ConfData[$loop1][0]]['name'] = $ConfData[$loop1][4];
		$ConfDataAss[$ConfData[$loop1][0]]['type'] = $ConfData[$loop1][5];
		$ConfDataAss[$ConfData[$loop1][0]]['list'] = $ConfData[$loop1][6];
		$ConfDataAss[$ConfData[$loop1][0]]['index'] = $ConfData[$loop1][7];
		
		$ConfDataAssRO[$ConfData[$loop1][0]] = $ConfData[$loop1][7]/*$ConfData[$loop1][1]*/;
	}
	
	asort($ConfDataAssRO);

	
	$panel = '<div class="panel panel-primary" style="padding:10px;">Конфигурация игрока '.$CurrPlayer[1][7].' </div></div>';
	foreach($ConfDataAssRO as $key => $value)
	{
		if($key == 'ConfByte')
		{
			continue;
		}
		for($loop1 = 0; $loop1 < sizeof($ConfData); $loop1++)
		{
			$currid = $ConfData[$loop1][0];
			if($key == $currid)
			{
				if($ConfDeviceAss[$currid] < 0)
				{
					continue;
				}
				$cval = $ConfDeviceAss[$currid];
				$list = $ConfDataAss[$currid]['list'];
				if($list != null)
				{
					$listm = explode('#',$list);
					
					for($loop1 = 0; $loop1 < sizeof($listm); $loop1++)
					{
						$listm2 = explode('|',$listm[$loop1]);
						if(!isset($listm2[1]))
						{
							continue;
						}
						$listass[$listm2[0]] = $listm2[1];
					}
					$cval = $listass[$ConfDeviceAss[$currid]];
				}
				
				if($ConfDataAss[$currid]['is_readonly'] == 0)
				{
					$panel.='<div class="adminbutton adminparedit" id="adminparedir-'.$currid.'"><div style="font-weight:bold;">'.$ConfDataAss[$currid]['name'].'</div>';
					$panel.='<div>'.$cval.'</div></div>';
				}
				else
				{
					$panel.='<div class="adminlabel"><div style="font-weight:bold;">'.$ConfDataAss[$currid]['name'].'</div>';
					$panel.='<div>'.$cval.'</div></div>';
				}

				break;
			}
			//$panel.='<hr>';
		}
	}
	$panel.='<a href="admin.php?a=configurator" class="pull-right" style="margin-right:10px;">Вернуться к списку игроков</a>';
	if($panel == '')
	{
		$panel = -1;
	}
	return $panel;
}

//изменение параметра
function GetCurrDeviceEditPar()
{
	if(!isset($_POST['idpar']))
	{
		return ' --- ';
	}
	$datac = GetData('ccd.data');
	$ConfDevice = json_decode($datac, true);
	$ConfDeviceAss = GetDeviseAss($ConfDevice);
	
	$CurrParZ = $ConfDeviceAss[$_POST['idpar']];
	
	$datac2 = GetData('pd.data');
	$ConfData = json_decode($datac2, true);
	
	$ConfDataAss = null;
	for($loop1 = 0; $loop1 < sizeof($ConfData); $loop1++)
	{
		$ConfDataAss[$ConfData[$loop1][0]]['is_readonly'] = $ConfData[$loop1][1];
		$ConfDataAss[$ConfData[$loop1][0]]['start'] = $ConfData[$loop1][2];
		$ConfDataAss[$ConfData[$loop1][0]]['finish'] = $ConfData[$loop1][3];
		$ConfDataAss[$ConfData[$loop1][0]]['name'] = $ConfData[$loop1][4];
		$ConfDataAss[$ConfData[$loop1][0]]['type'] = $ConfData[$loop1][5];
		$ConfDataAss[$ConfData[$loop1][0]]['list'] = $ConfData[$loop1][6];
		$ConfDataAss[$ConfData[$loop1][0]]['index'] = $ConfData[$loop1][7];
		
		$ConfDataAssRO[$ConfData[$loop1][0]] = $ConfData[$loop1][1];
	}
	
	$infopar = $ConfDataAss[$_POST['idpar']];
	
	$list = $infopar['list'];
	$listass = null;
	if($list != null)
	{
		$listm = explode('#',$list);
		
		for($loop1 = 0; $loop1 < sizeof($listm); $loop1++)
		{
			$listm2 = explode('|',$listm[$loop1]);
			if(!isset($listm2[1]))
			{
				continue;
			}
			$listass[$listm2[0]] = $listm2[1];
		}
	}
	
	if($infopar['type'] == 0)
	{
		$panel = '<div><strong>'.$infopar['name'].'</strong></div><select style="padding:5px;" name="par" id="par-'.$_POST['idpar'].'">';
		for($loop1 = $infopar['start']; $loop1 <= $infopar['finish']; $loop1++)
		{
			if($CurrParZ == $loop1)
			{
				$sel = ' selected="selected"';
			}
			else
			{
				$sel = '';
			}
			if(sizeof($listass) > 1)
			{
				$panel.='<option'.$sel.' value="'.$loop1.'">';
				$panel.= $listass[$loop1];
			}
			else
			{
				$panel.='<option'.$sel.' value="'.$loop1.'">';
				$panel.= $loop1;
			}

			$panel.='</option>';
		}
		$panel.='</select>';
		$panel.='<button type="submit" class="savepar btn btn-primary" id="savepar-'.$_POST['idpar'].'" style="margin-left:10px;">Сохранить</button>';
		$panel.='<button type="button" class="cancelsp btn">Отменить</button>';
	}
	return $panel;
}

function GetDeviseAss($ConfDevice)
{
	$ConfDeviceAss = null;
	$ConfDeviceAss['Version'] = $ConfDevice[0];
	$ConfDeviceAss['Serial'] = $ConfDevice[1];
	$ConfDeviceAss['Id'] = $ConfDevice[2];
	$ConfDeviceAss['Id_Team'] = $ConfDevice[3];
	$ConfDeviceAss['Power'] = $ConfDevice[4];
	$ConfDeviceAss['BatteryLevel_s'] = $ConfDevice[5];
	$ConfDeviceAss['BatteryLevel_p'] = $ConfDevice[6];
	$ConfDeviceAss['ConfByte'] = $ConfDevice[7];
	$ConfDeviceAss['CountHolder'] = $ConfDevice[8];
	$ConfDeviceAss['CountBullets'] = $ConfDevice[9];
	$ConfDeviceAss['TimeAuto'] = $ConfDevice[10];
	$ConfDeviceAss['TurnCount'] = $ConfDevice[11];
	$ConfDeviceAss['TimeReload'] = $ConfDevice[12];
	$ConfDeviceAss['TimeKill'] = $ConfDevice[13];
	$ConfDeviceAss['TimerRound'] = $ConfDevice[14];
	$ConfDeviceAss['TimerRespawn'] = $ConfDevice[15];
	$ConfDeviceAss['TimeShock'] = $ConfDevice[16];
	$ConfDeviceAss['TimeInvulnerability'] = $ConfDevice[17];
	$ConfDeviceAss['SecureProtocol'] = $ConfDevice[18];
	$ConfDeviceAss['GameMode'] = $ConfDevice[19];
	$ConfDeviceAss['RecoveryAfterResuscitation'] = $ConfDevice[20];
	$ConfDeviceAss['TimeOffWithoutABandage'] = $ConfDevice[21];
	$ConfDeviceAss['Version_firmware'] = $ConfDevice[22];
	$ConfDeviceAss['Milage'] = $ConfDevice[23];
	$ConfDeviceAss['FrequencyBand'] = $ConfDevice[24];
	$ConfDeviceAss['feedback2'] = $ConfDevice[25];
	$ConfDeviceAss['theSoundOfAFlyingBullet'] = $ConfDevice[26];
	$ConfDeviceAss['VibrationFlyingBullets'] = $ConfDevice[27];
	$ConfDeviceAss['DelayShooting'] = $ConfDevice[28];
	$ConfDeviceAss['Slips'] = $ConfDevice[29];
	$ConfDeviceAss['PowerSignalS'] = $ConfDevice[30];
	$ConfDeviceAss['PowerSignalP'] = $ConfDevice[31];
	$ConfDeviceAss['Version_firmware_P'] = $ConfDevice[32];
	$ConfDeviceAss['TypeBattaryS'] = $ConfDevice[33];
	$ConfDeviceAss['TypeBattaryP'] = $ConfDevice[34];
	$ConfDeviceAss['TypeTranportStat'] = $ConfDevice[35];
	$ConfDeviceAss['TimerControlP'] = $ConfDevice[36];
	$ConfDeviceAss['TimerControlP_P'] = $ConfDevice[37];
	$ConfDeviceAss['Recoil'] = $ConfDevice[38];
	$ConfDeviceAss['ColorTeamBandage'] = $ConfDevice[39];
	$ConfDeviceAss['FullCycleOfRecharging'] = $ConfDevice[40];
	$ConfDeviceAss['DamageCoefficient1'] = $ConfDevice[41];
	$ConfDeviceAss['DamageCoefficient2'] = $ConfDevice[42];
	$ConfDeviceAss['DamageCoefficient3'] = $ConfDevice[43];
	$ConfDeviceAss['DamageCoefficient4'] = $ConfDevice[44];
	$ConfDeviceAss['ReleasePriority'] = $ConfDevice[45];
	$ConfDeviceAss['TypeVibro'] = $ConfDevice[46];
	$ConfDeviceAss['RGBregim'] = $ConfDevice[47];
	$ConfDeviceAss['HitLose'] = $ConfDevice[48];
	return $ConfDeviceAss;
}

//Админская авторизация
function AuthAdmin()
{
	$pass = GetAdminPass();
	setcookie ("adminp", md5($pass), time()+60*60*24);
}

function GetAdminPass()
{
	$pass = '{PASSWORD}';
	return $pass;
}
?>

