Файл: inc/center/loto.php
Строк: 336
<?
$title='Колесо удачи';
include_once '../system/config.php';
if(isset($_GET['go'])){
if($ku['loto_time'] > time()){
$_SESSION['msg'] = 'У вас нет бесплатной попытки';
header('Location: /loto'); exit;
}
mysql_query("UPDATE `kolhoz_user` SET `loto_time` = '".(time()+7200)."' WHERE `id` = '".$ku['id']."'");
$rand = mt_rand(1,100);
if($rand <= 1){
$rub = 100;
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` +$rub WHERE `id` = '".$ku['id']."'");
mysql_query("INSERT INTO `his_loto` SET `id_user` = '".$ku['id']."', `kol` = '$rub', `time` = '".time()."'");
header('Location: /loto?rub='.$rub); exit;
}elseif($rand <= 2 and $ku['level'] >= 35){
$fantik = mysql_fetch_array(mysql_query("SELECT * FROM `collections` ORDER BY RAND()"));
mysql_query("INSERT INTO `collections_users` SET
`id_user` = '".$ku['id']."',
`name` = '".$fantik['name']."',
`type` = '".$fantik['type']."',
`type_2` = '".$fantik['type_2']."'");
header('Location: /loto?fantik='.$fantik['id']); exit;
}elseif($rand <= 3){
$rand_r = mt_rand(1,4);
if($rand_r == 4) $rub = 3;
if($rand_r == 3) $rub = 2;
if($rand_r == 2) $rub = 1;
if($rand_r == 1) $rub = 50;
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` +$rub WHERE `id` = '".$ku['id']."'");
mysql_query("INSERT INTO `his_loto` SET `id_user` = '".$ku['id']."', `kol` = '$rub', `time` = '".time()."'");
header('Location: /loto?rub='.$rub); exit;
}elseif($rand <= 4){
$rand_2 = mt_rand(1,2);
if($rand_2 == 1){
if($ku['hydropinics_time'] > time()){
mysql_query("UPDATE `kolhoz_user` SET `hydropinics_time` = ".($ku['hydropinics_time']+43200)." WHERE `id` = '".$ku['id']."'");
}else{
mysql_query("UPDATE `kolhoz_user` SET `hydropinics_time` = ".(time()+43200).", `hydropinics_type` = '300' WHERE `id` = '".$ku['id']."'");
}
header('Location: /loto?hydro'); exit;
}else{
if($ku['scarecrow_time'] > time()){
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = ".($ku['scarecrow_time']+43200)." WHERE `id` = '".$ku['id']."'");
}else{
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = ".(time()+43200)." WHERE `id` = '".$ku['id']."'");
}
header('Location: /loto?pug'); exit;
}
}elseif($rand <= 5){
$rand_3 = mt_rand(1000,100000000);
mysql_query("UPDATE `kolhoz_user` SET `rating` = `rating` +$rand_3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?rating='.$rand_3); exit;
}elseif($rand <= 6){
$req = mysql_query("SELECT * FROM `kolhoz_fishery_data` WHERE `type` = 'bait' ORDER BY RAND()");
$bait = mysql_fetch_array($req);
if(mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_user` WHERE `id_user` = "'.$ku['id'].'" AND `bait` = "'.$bait['id'].'"'), 0) < 1)
{
mysql_query("INSERT INTO `kolhoz_fishery_user` SET `id_user` = '".$ku['id']."', `bait` = '".$bait['id']."', `count` = 10");
}else{
mysql_query('UPDATE `kolhoz_fishery_user` SET `count` = `count` + "10" WHERE `id_user`="'.$ku['id'].'" AND `bait`="'.$bait['id'].'"');
}
header('Location: /loto?bait='.$bait['id']); exit;
}elseif($rand <= 15){
$req = mysql_query("SELECT * FROM `key_user` WHERE `id_user` = '$ku[id]'");
$rand_4 = mt_rand(1,5);
if($rand_4 == 1){
$name = 'normal';
}
if($rand_4 == 2){
$name = 'bronze';
}
if($rand_4 == 3){
$name = 'silver';
}
if($rand_4 == 4){
$name = 'gold';
}
if($rand_4 == 5){
$name = 'magic';
}
if(mysql_num_rows($req) == 0){
mysql_query("INSERT INTO `key_user` SET `id_user` = '".$ku['id']."', `".$name."` = 1");
}else{
mysql_query("UPDATE `key_user` SET `$name` = `$name` +1 WHERE `id_user` = '".$ku['id']."'");
}
header('Location: /loto?key='.$name); exit;
}elseif($rand <= 30){
$rand_5 = mt_rand(1,6);
$timee=time()+(3600*24*3);
if($rand_5==6){$nameChest='Проклятый';
$link='magic'; }
if($rand_5==5){$nameChest='Золотой';
$link='gold';}
if($rand_5==4){$nameChest='Серебрянный';
$link='silver';}
if($rand_5==3){$nameChest='Бронзовый';
$link='bronze';}
if($rand_5==2){$nameChest='Обычный';
$link='normal';}
if($rand_5==1){$nameChest='Открытый';
$link='open';}
mysql_query("INSERT INTO `chest` SET `id_user` = '".$ku['id']."', `type` = '$rand_5', `time` = '$timee'");
header('Location: /loto?chest='.$rand_5); exit;
}else{
$rand_4 = mt_rand(1000,10000);
mysql_query("UPDATE `kolhoz_user` SET `money` = `money` +$rand_4 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?money='.$rand_4); exit;
}
}
if(isset($_GET['rubine'])){
if($ku['rubies'] < 3){
$_SESSION['msg'] = 'У вас недостаточно рубин';
header('Location: /loto'); exit;
}
$rand = mt_rand(1,100);
if($rand <= 1){
$rub = 100;
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` +$rub WHERE `id` = '".$ku['id']."'");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
mysql_query("INSERT INTO `his_loto` SET `id_user` = '".$ku['id']."', `kol` = '$rub', `time` = '".time()."'");
header('Location: /loto?rub='.$rub); exit;
}elseif($rand <= 2){
$fantik = mysql_fetch_array(mysql_query("SELECT * FROM `collections` ORDER BY RAND()"));
mysql_query("INSERT INTO `collections_users` SET
`id_user` = '".$ku['id']."',
`name` = '".$fantik['name']."',
`type` = '".$fantik['type']."',
`type_2` = '".$fantik['type_2']."'");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?fantik='.$fantik['id']); exit;
}elseif($rand <= 3 and $ku['level'] >= 35){
$rand_r = mt_rand(1,4);
if($rand_r == 4) $rub = 3;
if($rand_r == 3) $rub = 2;
if($rand_r == 2) $rub = 1;
if($rand_r == 1) $rub = 50;
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` +$rub WHERE `id` = '".$ku['id']."'");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
mysql_query("INSERT INTO `his_loto` SET `id_user` = '".$ku['id']."', `kol` = '$rub', `time` = '".time()."'");
header('Location: /loto?rub='.$rub); exit;
}elseif($rand <= 4){
$rand_2 = mt_rand(1,2);
if($rand_2 == 1){
if($ku['hydropinics_time'] > time()){
mysql_query("UPDATE `kolhoz_user` SET `hydropinics_time` = ".($ku['hydropinics_time']+43200)." WHERE `id` = '".$ku['id']."'");
}else{
mysql_query("UPDATE `kolhoz_user` SET `hydropinics_time` = ".(time()+43200).", `hydropinics_type` = '300' WHERE `id` = '".$ku['id']."'");
}
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?hydro'); exit;
}else{
if($ku['scarecrow_time'] > time()){
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = ".($ku['scarecrow_time']+43200)." WHERE `id` = '".$ku['id']."'");
}else{
mysql_query("UPDATE `kolhoz_user` SET `scarecrow_time` = ".(time()+43200)." WHERE `id` = '".$ku['id']."'");
}
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?pug'); exit;
}
}elseif($rand <= 5){
$rand_3 = mt_rand(1000,100000000);
mysql_query("UPDATE `kolhoz_user` SET `rating` = `rating` +$rand_3 WHERE `id` = '".$ku['id']."'");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?rating='.$rand_3); exit;
}elseif($rand <= 6){
$req = mysql_query("SELECT * FROM `kolhoz_fishery_data` WHERE `type` = 'bait' ORDER BY RAND()");
$bait = mysql_fetch_array($req);
if(mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_user` WHERE `id_user` = "'.$ku['id'].'" AND `bait` = "'.$bait['id'].'"'), 0) < 1)
{
mysql_query("INSERT INTO `kolhoz_fishery_user` SET `id_user` = '".$ku['id']."', `bait` = '".$bait['id']."', `count` = 10");
}else{
mysql_query('UPDATE `kolhoz_fishery_user` SET `count` = `count` + "10" WHERE `id_user`="'.$ku['id'].'" AND `bait`="'.$bait['id'].'"');
}
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?bait='.$bait['id']); exit;
}elseif($rand <= 15){
$req = mysql_query("SELECT * FROM `key_user` WHERE `id_user` = '$ku[id]'");
$rand_4 = mt_rand(1,5);
if($rand_4 == 1){
$name = 'normal';
}
if($rand_4 == 2){
$name = 'bronze';
}
if($rand_4 == 3){
$name = 'silver';
}
if($rand_4 == 4){
$name = 'gold';
}
if($rand_4 == 5){
$name = 'magic';
}
if(mysql_num_rows($req) == 0){
mysql_query("INSERT INTO `key_user` SET `id_user` = '".$ku['id']."', `".$name."` = 1");
}else{
mysql_query("UPDATE `key_user` SET `$name` = `$name` +1 WHERE `id_user` = '".$ku['id']."'");
}
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?key='.$name); exit;
}elseif($rand <= 30){
$rand_5 = mt_rand(1,6);
$timee=time()+(3600*24*3);
if($rand_5==6){$nameChest='Проклятый';
$link='magic'; }
if($rand_5==5){$nameChest='Золотой';
$link='gold';}
if($rand_5==4){$nameChest='Серебрянный';
$link='silver';}
if($rand_5==3){$nameChest='Бронзовый';
$link='bronze';}
if($rand_5==2){$nameChest='Обычный';
$link='normal';}
if($rand_5==1){$nameChest='Открытый';
$link='open';}
mysql_query("INSERT INTO `chest` SET `id_user` = '".$ku['id']."', `type` = '$rand_5', `time` = '$timee'");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?chest='.$rand_5); exit;
}else{
$rand_4 = mt_rand(1000,10000);
mysql_query("UPDATE `kolhoz_user` SET `money` = `money` +$rand_4 WHERE `id` = '".$ku['id']."'");
mysql_query("UPDATE `kolhoz_user` SET `rubies` = `rubies` -3 WHERE `id` = '".$ku['id']."'");
header('Location: /loto?money='.$rand_4); exit;
}
}
if(isset($_GET['rub'])){
echo '<div class="block"><center>Вы выиграли <img src="/img/icons/ruby.png"> '.intval($_GET['rub']).'</center></div>';
}
if(isset($_GET['hydro'])){
echo '<div class="block"><center>Вы выиграли <img width="18" height="18" src="/img/hydropinics.png"> гидропоника на 24 часа</center></div>';
}
if(isset($_GET['pug'])){
echo '<div class="block"><center>Вы выиграли <img width="18" height="18" src="/img/scarecrow.png"> пугало на 24 часа</center></div>';
}
if(isset($_GET['rating'])){
echo '<div class="block"><center>Вы выиграли <img width="18" height="18" src="/img/icons/experience.png"> '.intval($_GET['rating']).' опыта</center></div>';
}
if(isset($_GET['bait'])){
$req = mysql_query("SELECT * FROM `kolhoz_fishery_data` WHERE `id` = '".intval($_GET['bait'])."'");
$bait = mysql_fetch_array($req);
echo '<div class="block"><center>Вы выиграли наживку <img width="18" height="18" src="/img/fishing/'.$bait['img'].'"> '.$bait['name'].'</center></div>';
}
if(isset($_GET['fantik'])){
$fantik = mysql_fetch_array(mysql_query("SELECT * FROM `collections` WHERE `id` = '".intval($_GET['fantik'])."'"));
echo '<div class="block"><table><td>
<td><img src="/img/colectibles/'.$fantik['type_2'].'.png"></td>
<td>Вы нашли новый фантик<br /><b>'.$fantik['name'].'</b>
</td></table></div>';
}
if(isset($_GET['chest'])){
if($_GET['chest']==6){$nameChest='Проклятый';
$link='magic'; }
if($_GET['chest']==5){$nameChest='Золотой';
$link='gold';}
if($_GET['chest']==4){$nameChest='Серебрянный';
$link='silver';}
if($_GET['chest']==3){$nameChest='Бронзовый';
$link='bronze';}
if($_GET['chest']==2){$nameChest='Обычный';
$link='normal';}
if($_GET['chest']==1){$nameChest='Открытый';
$link='open';}
echo '<div class="block"><center>Вы выиграли <img width="18" height="18" src="/img/icons/chest.png"> '.$nameChest.' сундук</center></div>';
}
if(isset($_GET['money'])){
echo '<div class="block"><center>Вы выиграли <img src="/img/icons/money.png"> '.intval($_GET['money']).'</center></div>';
}
if(isset($_GET['key'])){
if($_GET['key'] == 'normal'){
$name = 'Обычный ключ';
}
if($_GET['key'] == 'bronze'){
$name = 'Бронзовый ключ';
}
if($_GET['key'] == 'silver'){
$name = 'Серебрянный ключ';
}
if($_GET['key'] == 'gold'){
$name = 'Золотой ключ';
}
if($_GET['key'] == 'magic'){
$name = 'Проклятый ключ';
}
echo '<div class="block"><center>Вы выиграли <img width="18" height="18" src="/img/icons/key.png"> '.$name.'</center></div>';
}
if($ku['loto_time'] > time()) echo '<div class="block"><center>До следующей бесплатной попытки '.time_left($ku["loto_time"]-time()).'</center></div>';
echo '<img src="http://subdomain.test1.ru/img/loto/loto.png">';
echo '<div class="loto1">
'.($ku['loto_time'] < time() ? '<a class="loto2" href="/loto/go"><span class="loto3"><span><center>Крутить бесплатно</span> ' : '<a class="loto2" href="/loto/rubine"><span class="loto3"><span><center>Крутить за <img src="/img/icons/ruby.png"> 3</span> ').'
</span></center></a></div>';
echo '<center><div class="namelocal1" style="text-align: left;"><div class="namelocal2"><span class="spec-head2" style="text-align: center;">Последние 5 победителей</span></div>';
$req2 = mysql_query("SELECT * FROM `his_loto` ORDER BY `time` DESC LIMIT 5");
$count2 = mysql_num_rows($req2);
$i = 1;
while($his_loto = mysql_fetch_array($req2)){
$ank2 = mysql_fetch_array(mysql_query("SELECT `nick`,`pol` FROM `kolhoz_user` WHERE `id` = '".$his_loto['id_user']."'"));
if($ank2['pol'] == 1){
$pol = 'выиграл';
}else{
$pol = 'выиграла';
}
echo on_k($ank2['id']).' '.$ank2['nick'].' '.$pol.' <img src="/img/icons/ruby.png">'.$his_loto['kol'].' <img src="/img/icons/clock.png">'.time_left(time()-$his_loto['time']).' назад'.($i < $count2 ? '<hr>' : null);
$i++;
}
echo '</div></center><br />';
include_once '../system/foot.php';
?>