Your IP : 216.73.216.48


Current Path : /srv/www/vlevski/enter/p/
Upload File :
Current File : //srv/www/vlevski/enter/p/index.php

<?php
	header("Cache-Control: no-cache, must-revalidate");
	header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
	header('Access-Control-Allow-Origin: *');
	date_default_timezone_set("Europe/Sofia");
?><!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>
			Пропускателен режим СУ &quot;Васил Левски&quot; - Троян
		</title>
		<script src="./jquery-3.1.1.min.js"></script>
		<style>
			body
				{
					transform: scale(1.42);
					transform-origin: 42% 42%;
					overflow: hidden;
					background-color: #DDDDDD;
				}
		</style>
		<script>
			var iss=0;
			var ist=0;
			var isw=0;
			var iv01=0;
			var iv02=0;
			var iv03=0;
			var iv04=0;
			var iv05=0;
			var iv06=0;
			var iv07=0;
			var iv08=0;
			var iv09=0;
			var iv10=0;
			var iv11=0;
			var iv12=0;
			var iid=1;
			var c=0;
			var ep=0;
			var ts=0;
			var tsv=0;
			var oldcode="";
			var newcode="";
			var aes="";
			var shwerri=0;
			var sint;
			var iint="";
			var nonet=0;
			function ent(v)
			{
				document.getElementById("dt").value=v;
				shdk(1);
			}
			function shdk(fc)
				{
					var dtv=document.getElementById("dt").value;
					if (dtv!="")
						{
							l=dtv.length;
							if (l<19)
								{
									if (fc>0)
										{
											document.getElementById("dt").value="";
											//document.getElementById("dt").focus();
										}
									if (fc==0)
										{
											if (l>0)
												{
													setTimeout(function() { shdk(1); }, 500);
												}
										}
									else
										{
											fc=0;
										}
								}
							else
								{
									shd();
								}
						}
				}
			function newdays()
				{
					document.getElementById("aq").play();
					document.getElementById("nwd").style.display="block";
				}
			function newdayh()
				{
					document.getElementById("nwd").style.display="none";
					//document.getElementById("dt").focus();
				}
			function shwerr()
				{
					if (shwerri==0)
						{
							shwerri=1;
							document.getElementById("cperr").innerHTML=document.getElementById("rse").innerHTML;
							document.getElementById("cperr").style.display="block";
						}
					else
						{
							shwerri=0;
							document.getElementById("cperr").innerHTML="";
							document.getElementById("cperr").style.display="none";
							//document.getElementById("dt").focus();
						}
				}
			function snddata(entercode, timestamp, resposeid, lateid)
				{
					$("#rs").load("https://enter.vlevski.eu/data/response.php?e="+entercode+"&t="+timestamp+"", function(response, status, xhr)
							{
								if (status=="error")
									{
										document.getElementById("nm"+resposeid+"").innerHTML="Изчакване...";
										document.getElementById("rse").insertAdjacentHTML("afterbegin",""+entercode+","+timestamp+","+resposeid+"|");
										if (lateid==1)
											{
												isw++;
												ep=1;
												document.getElementById("cntnw").innerHTML=isw;
												document.getElementById("cntnw").style.backgroundColor="#990000";
												document.getElementById("cntnwl").style.backgroundImage="url('./l.gif')";
											}
										if (nonet==0)
											{
												nonet=1;
												sint=setInterval(function() { shd(); }, 2000);
											}
									}
								else
									{
										if (response=="wrong")
											{
												document.getElementById("nm"+resposeid+"").innerHTML="Няма такъв код";
												document.getElementById("im"+resposeid+"").src="./n.png";
												document.getElementById("aerr").play();
											}
										else
											{
												if (response!="")
													{
														document.getElementById("nm"+resposeid+"").innerHTML=response;
														document.getElementById("im"+resposeid+"").src="./y.png";
													}
												else
													{
														if (lateid==1)
															{
																document.getElementById("rse").insertAdjacentHTML("afterbegin",""+entercode+","+timestamp+","+resposeid+"|");
															}
													}
												if ((lateid==2) && (response!=""))
													{
														isw--;
														if (isw<=0)
															{
																isw=0;
																ep=0;
																document.getElementById("cntnw").style.backgroundColor="#99BB00";
																document.getElementById("cntnwl").style.backgroundImage="url('./y.png')";
															}
														document.getElementById("cntnw").innerHTML=isw;
													}
											}
									}
							});
				}
			function shd()
				{
					var dtv=document.getElementById("dt").value;
					l=dtv.length;
					if (l>19)
						{
							l=19;
							dtv=dtv.substr(0, 19);
						}
					if (iv01==0)
						{
							document.getElementById("cntnv01").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv01").style.backgroundColor="#CC0000";
						}
					if (iv02==0)
						{
							document.getElementById("cntnv02").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv02").style.backgroundColor="#CC0000";
						}
					if (iv03==0)
						{
							document.getElementById("cntnv03").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv03").style.backgroundColor="#CC0000";
						}
					if (iv04==0)
						{
							document.getElementById("cntnv04").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv04").style.backgroundColor="#CC0000";
						}
					if (iv05==0)
						{
							document.getElementById("cntnv05").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv05").style.backgroundColor="#CC0000";
						}
					if (iv06==0)
						{
							document.getElementById("cntnv06").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv06").style.backgroundColor="#CC0000";
						}
					if (iv07==0)
						{
							document.getElementById("cntnv07").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv07").style.backgroundColor="#CC0000";
						}
					if (iv08==0)
						{
							document.getElementById("cntnv08").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv08").style.backgroundColor="#CC0000";
						}
					if (iv09==0)
						{
							document.getElementById("cntnv09").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv09").style.backgroundColor="#CC0000";
						}
					if (iv10==0)
						{
							document.getElementById("cntnv10").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv10").style.backgroundColor="#CC0000";
						}
					if (iv11==0)
						{
							document.getElementById("cntnv11").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv11").style.backgroundColor="#CC0000";
						}
					if (iv12==0)
						{
							document.getElementById("cntnv12").style.backgroundColor="#555555";
						}
					else
						{
							document.getElementById("cntnv12").style.backgroundColor="#CC0000";
						}
					dtv=dtv.replace("С-СУЖЛТР", "S-SUVLTR");
					dtv=dtv.replace("Т-СУЖЛТР", "T-SUVLTR");
					dtv=dtv.replace("Ж-СУЖЛТР-ЖИСИТОР", "V-SUVLTR-VISITOR");
					aes=dtv.substr(2, 6);
					if ((aes!="SUVLTR") && (l>1))
						{
							document.getElementById("aerr").play();
							document.getElementById("dt").value="";
							//document.getElementById("dt").focus();
						}
					else
						{
							newcode=dtv;
							if ((oldcode=="V-SUVLTR-VISITOR-01") || (oldcode=="V-SUVLTR-VISITOR-02") || (oldcode=="V-SUVLTR-VISITOR-03") || (oldcode=="V-SUVLTR-VISITOR-04") || (oldcode=="V-SUVLTR-VISITOR-05") || (oldcode=="V-SUVLTR-VISITOR-06") || (oldcode=="V-SUVLTR-VISITOR-07") || (oldcode=="V-SUVLTR-VISITOR-08") || (oldcode=="V-SUVLTR-VISITOR-09") || (oldcode=="V-SUVLTR-VISITOR-10") || (oldcode=="V-SUVLTR-VISITOR-11") || (oldcode=="V-SUVLTR-VISITOR-12"))
								{
									var today=new Date();
									tsv=Math.round(today.getTime()/1000);											
									ts=ts+5;
									if (tsv>=ts)
										{
											oldcode="";
										}
								}
							if (newcode!=oldcode)
								{
									var today=new Date();
									ts=Math.round(today.getTime()/1000);
									document.getElementById("dt").value="";
									var dd=today.getDate();
									var mm=today.getMonth()+1;
									var yyyy=today.getFullYear();
									var hh=today.getHours();
									var ii=today.getMinutes();
									var ss=today.getSeconds();
									if (dd<10)
										{
											dd="0"+dd;
										}
									if (mm<10)
										{
											mm="0"+mm;
										}
									if (hh<10)
										{
											hh="0"+hh;
										}
									if (ii<10)
										{
											ii="0"+ii;
										}
									if (ss<10)
										{
											ss="0"+ss;
										}
									today=dd+"."+mm+"."+yyyy;
									hour=hh+":"+ii+":"+ss;
									if (l==19)
										{
											if (c==0)
												{
													bclr="#33DD33";
													clr="#000000;";
													c=1;
												}
											else
												{
													bclr="#005500";
													clr="#FFFFFF;";
													c=0;
												}
											document.getElementById("sh").insertAdjacentHTML("afterbegin", "<div id='rg"+iid+"' style='position: relative; margin-bottom: 2px; margin-top: 0px; margin-left: 0px; margin-right: 0px; width: 385px; height: 40px; color: "+clr+"; background-color: "+bclr+";'>"+dtv+"<br /><i><div id='nm"+iid+"'>Регистриране...</div></i><div style='position: absolute; width: 150px; height: 20px; top: 2px; right: 2px; text-align: right; margin-left: 230px; font-size: 12px; color: "+clr+";'>"+today+", "+hour+"</div><img src='./l.png' style='position: absolute; top: 18px; left: 360px; width: 20px; height: 20px; border: none;' id='im"+iid+"' />");
											snddata(dtv, ts, iid, 1);
										}
									var cs=dtv.replace("S-SUVLTR","");
									var ct=dtv.replace("T-SUVLTR","");
									var v01=dtv.replace("V-SUVLTR-VISITOR-01","");
									var v02=dtv.replace("V-SUVLTR-VISITOR-02","");
									var v03=dtv.replace("V-SUVLTR-VISITOR-03","");
									var v04=dtv.replace("V-SUVLTR-VISITOR-04","");
									var v05=dtv.replace("V-SUVLTR-VISITOR-05","");
									var v06=dtv.replace("V-SUVLTR-VISITOR-06","");
									var v07=dtv.replace("V-SUVLTR-VISITOR-07","");
									var v08=dtv.replace("V-SUVLTR-VISITOR-08","");
									var v09=dtv.replace("V-SUVLTR-VISITOR-09","");
									var v10=dtv.replace("V-SUVLTR-VISITOR-10","");
									var v11=dtv.replace("V-SUVLTR-VISITOR-11","");
									var v12=dtv.replace("V-SUVLTR-VISITOR-12","");
									if (cs!=dtv)
										{
											iss++;
											document.getElementById("cntns").innerHTML=iss;
										}
									if (ct!=dtv)
										{
											ist++;
											document.getElementById("cntnt").innerHTML=ist;
										}
									if (v01!=dtv)
										{
											if (iv01==0)
												{
													iv01=1;
												}
											else
												{
													iv01=0;
												}
										}
									if (v02!=dtv)
										{
											if (iv02==0)
												{
													iv02=1;
												}
											else
												{
													iv02=0;
												}
										}
									if (v03!=dtv)
										{
											if (iv03==0)
												{
													iv03=1;
												}
											else
												{
													iv03=0;
												}
										}
									if (v04!=dtv)
										{
											if (iv04==0)
												{
													iv04=1;
												}
											else
												{
													iv04=0;
												}
										}
									if (v05!=dtv)
										{
											if (iv05==0)
												{
													iv05=1;
												}
											else
												{
													iv05=0;
												}
										}
									if (v06!=dtv)
										{
											if (iv06==0)
												{
													iv06=1;
												}
											else
												{
													iv06=0;
												}
										}
									if (v07!=dtv)
										{
											if (iv07==0)
												{
													iv07=1;
												}
											else
												{
													iv07=0;
												}
										}
									if (v08!=dtv)
										{
											if (iv08==0)
												{
													iv08=1;
												}
											else
												{
													iv08=0;
												}
										}
									if (v09!=dtv)
										{
											if (iv09==0)
												{
													iv09=1;
												}
											else
												{
													iv09=0;
												}
										}
									if (v10!=dtv)
										{
											if (iv10==0)
												{
													iv10=1;
												}
											else
												{
													iv10=0;
												}
										}
									if (v11!=dtv)
										{
											if (iv11==0)
												{
													iv11=1;
												}
											else
												{
													iv11=0;
												}
										}
									if (v12!=dtv)
										{
											if (iv12==0)
												{
													iv12=1;
												}
											else
												{
													iv12=0;
												}
										}
									if (l==19)
										{
											iid++;
										}
									document.getElementById("dt").value="";
									//document.getElementById("dt").focus();
									oldcode=dtv;
								}
							else
								{
									document.getElementById("dt").value="";
									//document.getElementById("dt").focus();
								}
							if (isw==0)
								{
									if (nonet>0)
										{
											nonet=0;
										}
									clearInterval(sint);
								}
							else
								{
									ep=1;
								}
							if (ep>0)
								{
									var rset=document.getElementById("rse").innerHTML;
									var splt=rset.split("|");
									rset=rset.replace(""+splt[0]+"|","");
									var sndagain=splt[0].split(",");
									document.getElementById("rse").innerHTML=rset;
									snddata(sndagain[0], sndagain[1], sndagain[2], 2);
								}
						}
				}
		</script>
	</head>
	<body>
		<div style="position: relative; margin-left: 200px; width: 890px;">
			<div style="position: absolute; top: 0px; left: 0px; width: 890px; height: 525px; background-color: #000000; color: #FFFFFF; font-size: 15px; font-family: Verdana; z-index: 11; display: none;" id="nwd">
				<div style="position: absolute; top: 190px; left: 300px; width: 290px; height: 87px; background-color: #555500; color: #FFFFFF; border-radius: 10px; border: 1px solid #999999; font-size: 18px; font-family: Verdana; z-index: 12; text-align: center;" id="nwdq">
					Сигурни ли сте,<br />че започвате нов ден?
					<div style="position: absolute; top: 55px; left: 15px; width: 125px; height: 25px; background-color: #009900; color: #FFFFFF; border: 1px solid #FFFFFF; font-size: 20px; font-family: Verdana; z-index: 12; cursor: pointer; text-align: left;" onclick="location.reload();" id="nwdqy">
						<img src="./y.png" style="position: relative; width: 25px; height: 25px; border: none; float: left;" alt="" />&nbsp;&nbsp;&nbsp;&nbsp;ДА
					</div>
					<div style="position: absolute; top: 55px; left: 155px; width: 125px; height: 25px; background-color: #CC3333; color: #FFFFFF; border: 1px solid #FFFFFF; font-size: 20px; font-family: Verdana; z-index: 12; cursor: pointer; text-align: left;" onclick="newdayh();" id="nwdqn">
						<img src="./n.png" style="position: relative; width: 25px; height: 25px; border: none; float: left;" alt="" />&nbsp;&nbsp;&nbsp;&nbsp;НЕ
					</div>					
				</div>
			</div>
			<div style="position: absolute; top: 0px; left: 288px; width: 410px; height: 467px; background-color: #000000; color: #FFFFFF; font-size: 15px; font-family: Verdana; z-index: 10; overflow: auto; display: none;" id="cperr">
			</div>
			<div style="position: relative; margin-left: 0px; width: 700px; height: 527px; float: left; background-color: transparent;">
				<div style="position: relative; margin-left: 0px; width: 280px; height: 465px; font-size: 19px; font-family: Verdana; float: left; border: 1px solid black; text-align: center;">
					<img src="./logo.png" style="width: 260px; margin: 10px; float: left; border: none;" />
					<br />Пропускателна система
					<br />на СУ &quot;Васил Левски&quot;
					<br />Троян
					<select name="s" style="position: relative; width: 260px; height: 25px; background-color: transparent; color: #000000; font-size: 20px; float: left;" onclick="ent(this.value);" />
					<?php
						print("<option value=\"\">-- Моля изберете ученик --</option>");
						include("./conn.php");
						$cards=mysqli_query($db, "SELECT * FROM `students` WHERE `a`='1' ORDER by `n1` ASC, n2 ASC, n3 ASC");
						while ($singlecard=mysqli_fetch_row($cards))
						{
							print("<option value=\"".$singlecard[1]."\">".$singlecard[2]." ".$singlecard[3]." ".$singlecard[4]." - ".$singlecard[7]." клас</option>");
						}
					?>
					</select>
					<br />
					<br />
					<?php
						$t=time();
						$dt=date("d.m.Y г.", $t);
						print("<font style=\"font-size: 32px; font-weight: bold;\">".$dt."</font>");
					?>
					<br />
					<br />
					<form>
						<input id="dt" type="text" value="" style="position: relative; margin-left: 10px; width: 260px; height: 36px; font-size: 22px; font-family: Verdana; float: left; border: none; background-color: #00BB00; text-align: center;" autocomplete="off" onkeyup="shdk(0);" />
					</form>
				</div>
				<div style="position: relative; float: left; margin-left: 5px; width: 410px; height: 465px; border: 1px black solid; font-size: 16px; font-family: Verdana; overflow: auto;" id="sh">
				</div>
				<div style="position: relative; float: left; margin-left: 0px; margin-top: 5px; width: 697px; height: 50px; cursor: pointer; border: 1px black solid; font-size: 35px; font-family: Verdana; overflow: hidden; text-align: center; font-weight: bold; background-color: #116611; color: #FFFFFF;" onclick="newdays();" id="sh">
					Щракнете тук за нов ден
				</div>
				<div style="position: absolute; top: 0px; left: 0px; width: 1px; height: 1px; border: none; font-size: 4px; font-family: Verdana; overflow: hidden;" id="ae">
					<audio id="aerr" src="./x.mp3" type="audio/mpeg; codecs='mp3';"></audio>
					<audio id="aq" src="./q.mp3" type="audio/mpeg; codecs='mp3';"></audio>
				</div>
			</div>
			<div style="position: relative; float: left; margin-left: 5px; width: 185px; height: 527px; background-color: transparent; border: none; font-size: 14px; font-family: Verdana; overflow: hidden; text-align: center; font-weight: bold; color: #005500;" id="cnsl">
				Последно
				<br/>регистрирано лице
				<br />
				<br />
				<br />
				<br />
				<br />
				<br />
				Чакащи регистрации
				<br />
				<br />
				<br />
				<br />			
				<br />
				Регистрирани
				<br />ученици
				<br />
				<br />			
				<br />
				<br />
				<br />
				Регистрирани
				<br />служители
				<br />
				<br />
				<br />
				<br />
				<br />
				Външни лица
				<div style="position: absolute; top: 38px; left: 0px; width: 183px; height: 65px; border: 1px black solid; font-size: 16px; font-family: Verdana; overflow: hidden; text-align: center; z-index: 1;" id="rs">
				</div>
				<div style="position: absolute; top: 138px; left: 0px; width: 1px; height: 1px; font-size: 5px; font-family: Verdana; overflow: hidden; text-align: left; z-index: 2;" id="rse">
				</div>
				<div style="position: absolute; top: 138px; left: 0px; width: 183px; height: 45px; border: 1px black solid; font-size: 40px; font-family: Verdana; overflow: hidden; text-align: center; background-color: #99BB00; color: #FFFFFF; z-index: 1;" id="cntnw">
					0
				</div>
				<div style="position: absolute; top: 157px; left: 157px; width: 25px; height: 25px; border: none; font-size: 4px; font-family: Verdana; overflow: hidden; text-align: center; background-image: url('./code.png'); background-size: 25px 25px; background-position: center center; background-repeat: no-repeat; color: #000000; cursor: pointer; z-index: 2;" onclick="shwerr();" id="cntnwd">
				</div>
				<div style="position: absolute; top: 157px; left: 2px; width: 25px; height: 25px; border: none; font-size: 4px; font-family: Verdana; overflow: hidden; text-align: center; background-image: url('./y.png'); background-size: 25px 25px; background-position: center center; background-repeat: no-repeat; color: #000000; z-index: 2;" id="cntnwl">
				</div>
				<div style="position: absolute; top: 240px; left: 0px; width: 183px; height: 50px; border: 1px black solid; font-size: 40px; font-family: Verdana; overflow: hidden; text-align: center; z-index: 1;" id="cntns">
					0
				</div>
				<div style="position: absolute; top: 345px; left: 0px; width: 183px; height: 50px; border: 1px black solid; font-size: 40px; font-family: Verdana; overflow: hidden; text-align: center; color: #000099; z-index: 1;" id="cntnt">
					0
				</div>
				<div style="position: absolute; top: 427px; left: 0px; width: 183px; height: 95px; border: 1px black solid; font-size: 40px; font-family: Verdana; overflow: hidden; text-align: center; z-index: 1;" id="cntnv">
					<div style="position: relative; margin-left: 3px; margin-top: 3px; width: 178px; height: 92px;">
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv01">
							01
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv02">
							02
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv03">
							03
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv04">
							04
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv05">
							05
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv06">
							06
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv07">
							07
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv08">
							08
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv09">
							09
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv10">
							10
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv11">
							11
						</div>
						<div style="position: relative; margin: 2px; width: 40px; height: 26px; color: #FFFFFF; background-color: #555555; float: left; font-family: Verdana; font-size: 20px; text-align: center;" id="cntnv12">
							12
						</div>
					</div>
				</div>
			</div>
		</div>		
		<script>
			document.getElementById("rse").innerHTML="няма";
			//document.getElementById("dt").focus();
		</script> 
	</body>
</html>