<?
if($ku['id']!=4004040)
{
    echo'<div class="block">Ивент завершен.</div>';
    include_once'inc/foot.php';
}
 $puzzle= mysql_fetch_array(mysql_query("SELECT * FROM `puzzle` WHERE `id_user` = '$ku[id]'"));
if(isset($_GET['go']) && ($puzzle['time']<$time))
{
    $rand1=rand(1,3);
    $rand2=rand(1,16);
    $puzzle='puzzle_'.$rand1.'_'.$rand2.'';
    $lolkek=($time+1800);
    mysql_query("UPDATE `puzzle` SET `$puzzle` = '1', `time` ='$lolkek'  WHERE `id_user` = '$ku[id]'");
    $_SESSION['msg']='Выпал кусочек: [img]/puzzle/'.$rand1.'_'.$rand2.'_on.png[/img] (Пазл: '.$rand1.', кусочек '.$rand2.')';
header("location:/?puzzle");
    
}
echo'<div class="event"><h1>Новогодний Пазл</h1></div>';
echo'<div class="block"><span class="title">Каждые 30 минут</span> Вы можете получить кусочек пазла*
<li class="pavelgrey">За каждый полностью собранный пазл, Вы получите соотвествующие награды:
<li class="pavelgrey">1 пазл - <img width="25" src="/images/pets/85.png"><span class="title"> Пони (3 шт.)</span>, <span class="title"><img width="20" src="/worldkassa/fermoney.png"> 25, <img width="20" src="/images/icons/experience.png"> Бонус опыта (100%)</span>
<li class="pavelgrey">2 пазл - <img width="25" src="/images/pets/89.png"><span class="title"> Морж (3 шт.)</span>, <span class="title"><img width="20" src="/worldkassa/fermoney.png"> 50, <img width="20" src="https://cdn0.iconfinder.com/data/icons/kameleon-free-pack-rounded/110/Medal-2-20.png"> VIP Статус (7 дней)</span>
<li class="pavelgrey">3 пазл - <img width="25" src="/images/pets/86.png"><span class="title"> Пума (3 шт.)</span>, <span class="title"><img width="20" src="/worldkassa/fermoney.png"> 75, <img width="20" src="/images/icons/ruby.png"> 201 600</span>
<li class="pavelgrey">Пазлы действуют до <span class="title">10 января включительно</span>.
<li class="pavelgrey">* Кусочки могут повторяться, но собрать каждый пазл можно 1 раз.
</div>';
if($puzzle['time']<$time)echo'<div class="block"><img src="/images/icons/ticket.png"> <a href="/?puzzle&go">Использовать шанс</a></div>';
if($puzzle['time']>=$time)echo'<div class="block"><img src="/images/icons/ticket.png"> Шанс будет доступен через <span class="title">'.time_left($puzzle['time']-$time).'</span></div>';
$summa1=$puzzle['puzzle_1_1']+$puzzle['puzzle_1_2']+$puzzle['puzzle_1_3']+$puzzle['puzzle_1_4']+$puzzle['puzzle_1_5']+$puzzle['puzzle_1_6']+$puzzle['puzzle_1_7']+$puzzle['puzzle_1_8']+$puzzle['puzzle_1_9']+$puzzle['puzzle_1_10']+$puzzle['puzzle_1_11']+$puzzle['puzzle_1_12']+$puzzle['puzzle_1_13']+$puzzle['puzzle_1_14']+$puzzle['puzzle_1_15']+$puzzle['puzzle_1_16'];
$summa2=$puzzle['puzzle_2_1']+$puzzle['puzzle_2_2']+$puzzle['puzzle_2_3']+$puzzle['puzzle_2_4']+$puzzle['puzzle_2_5']+$puzzle['puzzle_2_6']+$puzzle['puzzle_2_7']+$puzzle['puzzle_2_8']+$puzzle['puzzle_2_9']+$puzzle['puzzle_2_10']+$puzzle['puzzle_2_11']+$puzzle['puzzle_2_12']+$puzzle['puzzle_2_13']+$puzzle['puzzle_2_14']+$puzzle['puzzle_2_15']+$puzzle['puzzle_2_16'];
$summa3=$puzzle['puzzle_3_1']+$puzzle['puzzle_3_2']+$puzzle['puzzle_3_3']+$puzzle['puzzle_3_4']+$puzzle['puzzle_3_5']+$puzzle['puzzle_3_6']+$puzzle['puzzle_3_7']+$puzzle['puzzle_3_8']+$puzzle['puzzle_3_9']+$puzzle['puzzle_3_10']+$puzzle['puzzle_3_11']+$puzzle['puzzle_3_12']+$puzzle['puzzle_3_13']+$puzzle['puzzle_3_14']+$puzzle['puzzle_3_15']+$puzzle['puzzle_3_16'];
if(isset($_GET['puzzle1']) && ($summa1==16) && ($puzzle['prize1']<1))
{
   mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '85'");
        mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '85'");
        mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '85'");
	       
mysql_query("UPDATE `puzzle` SET `prize1` = '1'  WHERE `id_user` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `fermoney` = `fermoney` + '25', `expbonus` = `expbonus` + '100' WHERE `id` = '$ku[id]'");
$_SESSION['msg']='Подарок зачислен! Счастливого нового года!';
header("location:/?puzzle");
}
if(isset($_GET['puzzle3']) && ($summa3==16) && ($puzzle['prize3']<1))
{
   mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '86'");
        mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '86'");
        mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '86'");
	    
mysql_query("UPDATE `puzzle` SET `prize3` = '1'  WHERE `id_user` = '$ku[id]'");
mysql_query("UPDATE `kolhoz_user` SET `fermoney` = `fermoney` + '75', `rubies` = `rubies` + '201600' WHERE `id` = '$ku[id]'");
$_SESSION['msg']='Подарок зачислен! Счастливого нового года!';
header("location:/?puzzle");
}
if(isset($_GET['puzzle2']) && ($summa2==16) && ($puzzle['prize2']<1))
{
  mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '89'");
        mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '89'");
        mysql_query("INSERT INTO `kolhoz_petground` SET `id_user` = '$ku[id]', `id_pet` = '89'");
	        
mysql_query("UPDATE `puzzle` SET `prize2` = '1'  WHERE `id_user` = '$ku[id]'");
$timee=(3600*24*7);
mysql_query("UPDATE `kolhoz_user` SET `fermoney` = `fermoney` + '50', `time_vip` = '".($ku['time_vip']>$time?"".($ku['time_vip']+$timee)."":"".($time+$timee)."")."' WHERE `id` = '$ku[id]'");
$_SESSION['msg']='Подарок зачислен! Счастливого нового года!';
header("location:/?puzzle");
}
if($summa1==16 && $puzzle['prize1']<1)echo'<div class="block"><img src="/images/icons/present.png"> <a href="/?puzzle&puzzle1">Получить награду за пазл #1</a></div>';
if($summa2==16 && $puzzle['prize2']<1)echo'<div class="block"><img src="/images/icons/present.png"> <a href="/?puzzle&puzzle2">Получить награду за пазл #2</a></div>';
if($summa3==16 && $puzzle['prize3']<1)echo'<div class="block"><img src="/images/icons/present.png"> <a href="/?puzzle&puzzle3">Получить награду за пазл #3</a></div>';

echo'<div class="block"><center>Новогодний пазл #1 <span class="title">('.$summa1.' / 16)</span></center>';
echo'<br><center>';
if($puzzle['puzzle_1_1']<1)
{
    echo' <img width="20%" src="/puzzle/1_1_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_1_on.png">';

}
if($puzzle['puzzle_1_2']<1)
{
    echo' <img width="20%" src="/puzzle/1_2_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_2_on.png">';

}
if($puzzle['puzzle_1_3']<1)
{
    echo' <img width="20%" src="/puzzle/1_3_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_3_on.png">';

}
if($puzzle['puzzle_1_4']<1)
{
    echo' <img width="20%" src="/puzzle/1_4_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_4_on.png">';

}
echo'<li class="pavelgrey">';
if($puzzle['puzzle_1_5']<1)
{
    echo' <img width="20%" src="/puzzle/1_5_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_5_on.png">';

}
if($puzzle['puzzle_1_6']<1)
{
    echo' <img width="20%" src="/puzzle/1_6_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_6_on.png">';

}
if($puzzle['puzzle_1_7']<1)
{
    echo' <img width="20%" src="/puzzle/1_7_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_7_on.png">';

}
if($puzzle['puzzle_1_8']<1)
{
    echo' <img width="20%" src="/puzzle/1_8_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_8_on.png">';

}
echo'<li class="pavelgrey">';

if($puzzle['puzzle_1_9']<1)
{
    echo' <img width="20%" src="/puzzle/1_9_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_9_on.png">';

}
if($puzzle['puzzle_1_10']<1)
{
    echo' <img width="20%" src="/puzzle/1_10_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_10_on.png">';

}
if($puzzle['puzzle_1_11']<1)
{
    echo' <img width="20%" src="/puzzle/1_11_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_11_on.png">';

}
if($puzzle['puzzle_1_12']<1)
{
    echo' <img width="20%" src="/puzzle/1_12_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_12_on.png">';

}
echo'<li class="pavelgrey">';
if($puzzle['puzzle_1_13']<1)
{
    echo' <img width="20%" src="/puzzle/1_13_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_13_on.png">';

}
if($puzzle['puzzle_1_14']<1)
{
    echo' <img width="20%" src="/puzzle/1_14_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_14_on.png">';

}
if($puzzle['puzzle_1_15']<1)
{
    echo' <img width="20%" src="/puzzle/1_15_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_15_on.png">';

}
if($puzzle['puzzle_1_16']<1)
{
    echo' <img width="20%" src="/puzzle/1_16_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/1_16_on.png">';

}
echo'</div></center>';
///////////////////


echo'<div class="block"><center>Новогодний пазл #2 <span class="title">('.$summa2.' / 16)</span></center>';
echo'<br><center>';
if($puzzle['puzzle_2_1']<1)
{
    echo' <img width="20%" src="/puzzle/2_1_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_1_on.png">';

}
if($puzzle['puzzle_2_2']<1)
{
    echo' <img width="20%" src="/puzzle/2_2_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_2_on.png">';

}
if($puzzle['puzzle_2_3']<1)
{
    echo' <img width="20%" src="/puzzle/2_3_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_3_on.png">';

}
if($puzzle['puzzle_2_4']<1)
{
    echo' <img width="20%" src="/puzzle/2_4_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_4_on.png">';

}
echo'<li class="pavelgrey">';
if($puzzle['puzzle_2_5']<1)
{
    echo' <img width="20%" src="/puzzle/2_5_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_5_on.png">';

}
if($puzzle['puzzle_2_6']<1)
{
    echo' <img width="20%" src="/puzzle/2_6_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_6_on.png">';

}
if($puzzle['puzzle_2_7']<1)
{
    echo' <img width="20%" src="/puzzle/2_7_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_7_on.png">';

}
if($puzzle['puzzle_2_8']<1)
{
    echo' <img width="20%" src="/puzzle/2_8_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_8_on.png">';

}
echo'<li class="pavelgrey">';

if($puzzle['puzzle_2_9']<1)
{
    echo' <img width="20%" src="/puzzle/2_9_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_9_on.png">';

}
if($puzzle['puzzle_2_10']<1)
{
    echo' <img width="20%" src="/puzzle/2_10_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_10_on.png">';

}
if($puzzle['puzzle_2_11']<1)
{
    echo' <img width="20%" src="/puzzle/2_11_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_11_on.png">';

}
if($puzzle['puzzle_2_12']<1)
{
    echo' <img width="20%" src="/puzzle/2_12_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_12_on.png">';

}
echo'<li class="pavelgrey">';
if($puzzle['puzzle_2_13']<1)
{
    echo' <img width="20%" src="/puzzle/2_13_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_13_on.png">';

}
if($puzzle['puzzle_2_14']<1)
{
    echo' <img width="20%" src="/puzzle/2_14_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_14_on.png">';

}
if($puzzle['puzzle_2_15']<1)
{
    echo' <img width="20%" src="/puzzle/2_15_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_15_on.png">';

}
if($puzzle['puzzle_2_16']<1)
{
    echo' <img width="20%" src="/puzzle/2_16_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/2_16_on.png">';

}
echo'</div></center>';
echo'<div class="block"><center>Новогодний пазл #3 <span class="title">('.$summa3.' / 16)</span></center>';
echo'<br><center>';
if($puzzle['puzzle_3_1']<1)
{
    echo' <img width="20%" src="/puzzle/3_1_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_1_on.png">';

}
if($puzzle['puzzle_3_2']<1)
{
    echo' <img width="20%" src="/puzzle/3_2_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_2_on.png">';

}
if($puzzle['puzzle_3_3']<1)
{
    echo' <img width="20%" src="/puzzle/3_3_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_3_on.png">';

}
if($puzzle['puzzle_3_4']<1)
{
    echo' <img width="20%" src="/puzzle/3_4_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_4_on.png">';

}
echo'<li class="pavelgrey">';
if($puzzle['puzzle_3_5']<1)
{
    echo' <img width="20%" src="/puzzle/3_5_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_5_on.png">';

}
if($puzzle['puzzle_3_6']<1)
{
    echo' <img width="20%" src="/puzzle/3_6_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_6_on.png">';

}
if($puzzle['puzzle_3_7']<1)
{
    echo' <img width="20%" src="/puzzle/3_7_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_7_on.png">';

}
if($puzzle['puzzle_3_8']<1)
{
    echo' <img width="20%" src="/puzzle/3_8_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_8_on.png">';

}
echo'<li class="pavelgrey">';

if($puzzle['puzzle_3_9']<1)
{
    echo' <img width="20%" src="/puzzle/3_9_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_9_on.png">';

}
if($puzzle['puzzle_3_10']<1)
{
    echo' <img width="20%" src="/puzzle/3_10_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_10_on.png">';

}
if($puzzle['puzzle_3_11']<1)
{
    echo' <img width="20%" src="/puzzle/3_11_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_11_on.png">';

}
if($puzzle['puzzle_3_12']<1)
{
    echo' <img width="20%" src="/puzzle/3_12_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_12_on.png">';

}
echo'<li class="pavelgrey">';
if($puzzle['puzzle_3_13']<1)
{
    echo' <img width="20%" src="/puzzle/3_13_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_13_on.png">';

}
if($puzzle['puzzle_3_14']<1)
{
    echo' <img width="20%" src="/puzzle/3_14_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_14_on.png">';

}
if($puzzle['puzzle_3_15']<1)
{
    echo' <img width="20%" src="/puzzle/3_15_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_15_on.png">';

}
if($puzzle['puzzle_3_16']<1)
{
    echo' <img width="20%" src="/puzzle/3_16_off.png">';
}else{
        echo' <img width="20%" src="/puzzle/3_16_on.png">';

}
echo'</div></center>';