Просмотр файла Pages/go.php

Размер файла: 3.43Kb
<?php
$query = $mysqli->query("SELECT `id`,`hosts` FROM `sait` WHERE `status` <> '0' AND `id` = '".$id."'");
if($query->num_rows > 0)
	{
	    $sait = $query->fetch_assoc();
	    $mysqli->query("UPDATE `sait` SET `in` = (`in` + 1), `allIn` = (`allIn` + 1) WHERE `id` = '".$id."'");
	    $mysqli->query("UPDATE `statisic` SET `value` = (`value` + 1) WHERE `name` = 'in'");
	    $mysqli->query("UPDATE `statisic` SET `value` = (`value` + 1) WHERE `name` = 'allIn'");
	    $day = $mysqli->query("SELECT * FROM `days` WHERE `sid` = '".$id."' AND `month` = '".date("m")."'");
	    if($day->num_rows > 0)
		    {
			    $dayRow = $day->fetch_assoc();
			    if(!empty($dayRow[''.date("d").'']))
				    {
					    $dayArray = explode('|',$dayRow[''.date("d").'']);
					    $mysqli->query("UPDATE `days` SET `".date("d")."` = '".$dayArray[0]."|".$dayArray[1]."|".($dayArray[2] + 1)."|".$dayArray[3]."' WHERE `sid` = '".$id."' AND `month` = '".date("m")."'");
				    }
			    else
				    {
					    $mysqli->query("UPDATE `days` SET `".date("d")."` = '0|0|1|0' WHERE `sid` = '".$id."' AND `month` = '".date("m")."'");
				    }
		    }
	    else
		    {
			    $mysqli->query("INSERT INTO `days` SET `sid` = '".$id."', `month` = '".date("m")."', `".date("d")."` = '0|0|1|0'");
		    }
	    $month = $mysqli->query("SELECT * FROM `month` WHERE `sid` = '".$id."'");
	    if($month->num_rows > 0)
		    {
			    $monthRow = $month->fetch_assoc();
			    if(!empty($monthRow[''.date("m").'']))
				    {
					    $monthArray = explode('|',$monthRow[''.date("m").'']);
					    $mysqli->query("UPDATE `month` SET `".date("m")."` = '".$monthArray[0]."|".$monthArray[1]."|".($monthArray[2] + 1)."|".$monthArray[3]."' WHERE `sid` = '".$id."'");
				    }
			    else
				    {
					    $mysqli->query("UPDATE `month` SET `".date("m")."` = '0|0|1|0' WHERE `sid` = '".$id."'");
				    }
		    }
	    else
		    {
			    $mysqli->query("INSERT INTO `month` SET `sid` = '".$id."', `".date("m")."` = '0|0|1|0'");
		    }
	    $hour = (int)date("H");
	    if($hour == 23)
		    {
			    $hourD = '23:00-00:00';
		    }
	    else
		    {
			    if(strlen($hour) == 1)
				    {															
					    $hourr = '0'.$hour;														
				    }
			    else
				    {
					    $hourr = $hour;										
				    }
			    if(strlen($hour + 1) == 1)
				    {
					    $hour2 = '0'.($hour + 1);
				    }
			    else
				    {
					    $hour2 = $hour + 1;
				    }
			    $hourD = ''.$hourr.':00-'.$hour2.':00';
		    }
	    $hours = $mysqli->query("SELECT * FROM `hours` WHERE `sid` = '".$id."'");
	    if($hours->num_rows > 0)
		    {
			    $hoursRow = $hours->fetch_assoc();
			    if(!empty($hoursRow[''.$hourD.'']))
				    {
					    $hoursArray = explode('|',$hoursRow[''.$hourD.'']);
					    $mysqli->query("UPDATE `hours` SET `".$hourD."` = '".$hoursArray[0]."|".$hoursArray[1]."|".($hoursArray[2] + 1)."|".$hoursArray[3]."' WHERE `sid` = '".$id."'");
				    }
			    else
				    {
					    $mysqli->query("UPDATE `hours` SET `".$hourD."` = '0|0|1|0' WHERE `sid` = '".$id."'");
				    }
		    }
	    else
		    {
			    $mysqli->query("INSERT INTO `hours` SET `sid` = '".$id."', `".$hourD."` = '0|0|1|0'");
		    }
	    $page = ceil($mysqli->query("SELECT `id` FROM `sait` WHERE `status` = '1' AND `ban` = '0' AND `hosts` <= '".$sait['hosts']."'")->num_rows / $pages);
	    header('Location: http://'.$home.'/'.$page);	
      }
?>