Файл: inc/fish/fishing.php
Строк: 654
<?php
$title = 'Рыбалка';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/config.php';
error_reporting('1');
define("TIME", time());
$drimg = '/img/fishing/';
$dricns = '/img/icons/';
function redirect_fish($url, $msg){
if ($msg != '') $_SESSION['msg'] = $msg;
header('Location:'.$url);
echo "<script>document.location.href='".$url."';</script>";
exit;
}
function title_one($str){
return '<div class="event"><h1 class="title">'.$str.'</h1></div>';
}
function plural_form($number, $after){
$cases = array(2, 0, 1, 1, 1, 2);
$result = $number.' '.$after[ ($number%100>4 && $number%100 < 20) ? 2: $cases[min($number % 10, 5)] ];
return $result;
}
function progress_bar($progress, $value, $max_value){
return '<table class="wide_prg_tab"><tbody><tr>
<td class="prg">
<div>
<div class="ware_first">
<div class="exp_scnd2 exp_scnd2-2" style="width: '.$progress.'%"></div>
</div>
</div>
</td>
<td>
'.($value!='' && $max_value!='' ? '<div class="nowrap major-txt txt-lg"> '.$value.'<span class="minor">/</span>'.$max_value.'</div>' : null).'
</td>
</tr></tbody></table>'."n";
}
function str_fish($link='?',$k_page=1,$page=1){ // Вывод номеров страниц (только на первый взгляд кажется сложно ;))
if ($page < 1) $page = 1;
echo '<div class="pagerlight">'."n";
if ($page!=1)echo "<a class='pag' href="".$link."page/1/" n='Страница №1'>[1]</a>";
else echo "<a href='#' class='pag_two no_link'>[1]</a>";
for ($ot=-3; $ot<=3; $ot++){
if ($page+$ot>1 && $page+$ot<$k_page){
if ($ot==-3 && $page+$ot>2)echo " ..";
if ($ot!=0)echo " <a class='pag' href="".$link."page/".($page+$ot)."" n='Страница №".($page+$ot)."'>[".($page+$ot)."]</a>";
else echo " <a href='#' class='pag_two no_link'>[".($page+$ot)."]</a>";
if ($ot==3 && $page+$ot<$k_page-1)echo " ..";}}
if ($page!=$k_page)echo " <a class='pag' href="".$link."page/end/" n='Страница №$k_page'>[$k_page]</a>";
elseif ($k_page>1)echo " <a href='#' class='pag_two no_link'>[$k_page]</a>";
echo "</div>n";
}
# Сообщение при редиректе
if (isset($_SESSION['redirect_fish_msg'])){
echo '<div class="feedback">'.$_SESSION['redirect_fish_msg'].'</div>'."n";
unset($_SESSION['redirect_fish_msg']);
}
$locationGo = (int) $_GET['location'];
$iuser = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery` WHERE `id_user`="'.$ku['id'].'" AND `location`="'.$locationGo.'" LIMIT 1'));
echo $_GET['foodpay'];
$location = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="location" AND `id`="'.$locationGo.'" LIMIT 1'));
$rod = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="rod" and `id`="'.$iuser['rod'].'" LIMIT 1'));
if ($iuser['food_time'] >= TIME) $food = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="food" and `id`="'.$iuser['food'].'" LIMIT 1'));
$bait_user_vid = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_user` WHERE `id`="'.$ku['last_bait'.$locationGo.''].'" AND `id_user`="'.$ku['id'].'"'));
$baita_vid = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type` = "bait" AND `id` = "'.$bait_user_vid['bait'].'"'));
$bait = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="bait" and `id`="'.$bait_user_vid['bait'].'" LIMIT 1'));
#===================================#
// Прикормка
if (isset($_GET['foodpay']) && $iuser['rod'] > 0){
$gfood = (int) $_GET['foodpay'];
if ($gfood != ''){
$ifood = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="food" AND `id`="'.$gfood.'" LIMIT 1'));
if ($ifood['id'] != ''){
if ($ku['rubies'] >= $ifood['rubies']){
$count = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_korm` WHERE `id_user`="'.$ku['id'].'" AND `id_korm`="'.$gfood.'" LIMIT 1'),0);
if($count == 0){
mysql_query("INSERT INTO `kolhoz_fishery_korm` SET `id_user` = '".$ku['id']."', `id_korm` = '".$gfood."', `kol` = 1, `type` = 'food'");
}else{
mysql_query("UPDATE `kolhoz_fishery_korm` SET `kol` = `kol` +1 WHERE `id_user` = '".$ku['id']."' and `id_korm` = '".$gfood."'");
}
//mysql_query('UPDATE `kolhoz_fishery` SET `food`="'.$ifood['id'].'", `food_time`="'.(TIME + $ifood['time']).'" WHERE `id_user`="'.$ku['id'].'" AND `location`="'.$locationGo.'"');
$ku['rubies'] = minus_rubies($ifood['rubies']);
//operation_rubies($ifood['rubies'], 'покупка прикормки, рыбалка');
//$msg = 'Вкусно запахло, сейчас все рыбы соберутся. Всю прикормку съедят через <span class="time_left_fish_timer">'.time_left($ifood['time'])."</span>";
$msg = 'Подкормка куплена и отправлена в амбар';
} else {
$_SESSION['no_rubies'] = ($ifood['rubies']-$ku['rubies']);
}
redirect_fish('/fishery/location/'.$locationGo.'/foodpay/', $msg);
}
}
echo title_one('<a href="/fishery/location/'.$locationGo.'/">Рыбалка</a> / Выбор прикормки');
echo '<div class="block"><div class="content">'."n";
$k_post = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_data` WHERE `type`="food"'), 0);
if ($k_post > 0){
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$sql = mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="food" ORDER BY `id` ASC LIMIT '.$start.', '.$set['p_str']);
while ($fooda = mysql_fetch_array($sql)){
if ($hr === true) echo '<hr>'."n";
echo '<div>'."n";
echo '<img style="border-radius: 5px" width="48" height="48" src="'.$drimg.$fooda['img'].'" alt="o" class="portrait">'."n";
echo '<div class="blue sdw">'.$fooda['name'].' на '.time_left($fooda['time']).'</div>'."n";
echo '<div>Ускоряет клёв на <span>'.$fooda['interest'].'%</span>, <img width="16" height="16" src="/img/ctime.png" class="va-m" alt="[]"> действует <span class="time_left_fish_timer">'.time_left($fooda['time']).'</span></div>'."n";
$q=mysql_query("SELECT * FROM `kolhoz_fishery_korm` WHERE `id_user` = '$ku[id]' and `type` = 'food' and `id_korm` = ".$fooda['id']."");
if(mysql_num_rows($q)>0){
$korm=mysql_fetch_array($q);
echo 'В амбаре '.$korm['kol'].'<br />';
}
echo '<div><img class="va-m" src="'.$dricns.'seat.png" alt="[]"> <a href="/fishery/location/'.$locationGo.'/foodpay/'.$fooda['id'].'">Купить</a> за <img src="'.$dricns.'ruby.png" class="va-m" alt="[]"> <span>'.plural_form($fooda['rubies'], array('рубин','рубина','рубинов')).'</span></div>'."n";
echo '<div style="clear:both"></div>'."n";
echo '</div>'."n";
$hr = true;
}
if ($k_page > 1) {
echo '<hr>'."n";
str_fish('/fishery/location/'.$locationGo.'/foodpay/', $k_page, $page);
}
} else echo '<div>Нет прикормки в списке.</div>'."n";
echo '</div></div>'."n";
echo '<center><div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/warehouse/snasti"><span class="spec-head1">В амбар</span></a></div></center>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
}
#===================================#
// Наживка
if (isset($_GET['bait'])){
$gbait = intval($_GET['bait']);
if ($gbait != '')
{ $gbait_user = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_user` WHERE `bait` = "'.$gbait.'" AND `id_user` = "'.$ku['id'].'"'));
$ibait = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="bait" AND `id`="'.$gbait.'" LIMIT 1'));
if ($ibait['id'] != '' && isset($_GET['buy']))
{
if($ibait['coins']>0)
{
if ($ku['money'] >= $ibait['coins'])
{
if(mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_user` WHERE `id_user` = "'.$ku['id'].'" AND `bait` = "'.$ibait['id'].'"'), 0) < 1)
{
mysql_query('INSERT INTO `kolhoz_fishery_user` SET `id_user`="'.$ku['id'].'", `bait`="'.$ibait['id'].'", `count` = "10"');
}
else
{
mysql_query('UPDATE `kolhoz_fishery_user` SET `count` = `count` + "10" WHERE `id_user`="'.$ku['id'].'" AND `bait`="'.$ibait['id'].'"');
}
$ku['money'] = minus_money($ibait['coins']);
$msg = "Наживка $ibait[name] (10шт) куплена. Используйте наживку.";
}
else
{
$_SESSION['no_money'] = ($ibait['money']-$ku['money']);
}
}
else
{
if ($ku['rubies'] >= $ibait['rubies'])
{
if(mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_user` WHERE `id_user` = "'.$ku['id'].'" AND `bait` = "'.$ibait['id'].'"'), 0) < 1)
{
mysql_query('INSERT INTO `kolhoz_fishery_user` SET `id_user`="'.$ku['id'].'", `bait`="'.$ibait['id'].'", `count` = "10"');
}
else
{
mysql_query('UPDATE `kolhoz_fishery_user` SET `count` = `count` + "10" WHERE `id_user`="'.$ku['id'].'" AND `bait`="'.$ibait['id'].'"');
}
$ku['rubies'] = minus_rubies($ibait['rubies']);
}
else
{
$_SESSION['no_rubies'] = ($ibait['rubies']-$ku['rubies']);
}
}
$bait_user_red = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_user` WHERE `bait`="'.$ibait['id'].'" AND `id_user`="'.$ku['id'].'"'));
redirect_fish('/fishery/location/'.$locationGo.'/bait/', $msg);
}
}
$usebait = intval($_GET['use']);
if ($usebait != '')
{
$use_user = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_user` WHERE `bait` = "'.$gbait.'" AND `id_user` = "'.$ku['id'].'" AND `count` > "0"'));
if ($use_user['id'] != '')
{
mysql_query('UPDATE `kolhoz_user` SET `last_bait'.$locationGo.'`="'.$use_user['id'].'" WHERE `id`="'.$ku['id'].'"');
$msg = "Наживка $ibait[name] (10шт) куплена.";
$_SESSION['msg'] = $msg;
redirect_fish('/fishery/location/'.$locationGo.'/', $msg);
}
}
echo title_one('<a href="/fishery/location/'.$locationGo.'/">Рыбалка</a> / Выбор наживка');
echo '<div class="block"><div class="content">'."n";
$k_post = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_data` WHERE `type`="bait"'), 0);
if ($k_post > 0){
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$sql = mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="bait" ORDER BY `id` ASC LIMIT '.$start.', '.$set['p_str']);
while ($baita = mysql_fetch_array($sql)){
if ($hr === true) echo '<hr>'."n";
$bait_user = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_user` WHERE `bait`="'.$baita['id'].'" AND `id_user`="'.$ku['id'].'"'));
echo '<div>'."n";
echo '<img style="border-radius: 5px" width="65" height="65" src="'.$drimg.$baita['img'].'" alt="o" class="portrait">'."n";
echo '<div class="blue sdw">'.$baita['name'].'</div>'."n";
echo '<div>'.($bait_user['count'] > 0?'У вас в запасе '.$bait_user['count'].' шт.':'В упаковке 10 шт.').'</div>';
echo '<div>Рыба клюет через <span class="time_left_fish_timer">'.time_left_fish($baita['time']).'</span></div>'."n";
echo '<div><img class="va-m" src="'.$dricns.'seat.png" alt="[]"> <a href="/fishery/location/'.$locationGo.'/bait/'.$baita['id'].'/buy/">Купить</a> за ';
if(!empty($baita['coins']))
{
echo '<img src="'.$dricns.'money.png" class="va-m" alt="[]"> <span>'.plural_form($baita['coins'], array('монету','монеты','монет')).'</span></div>'."n";
}
else
{
echo '<img src="'.$dricns.'ruby.png" class="va-m" alt="[]"> <span>'.plural_form($baita['rubies'], array('рубин','рубина','рубинов')).'</span></div>'."n";
}
echo '<div style="clear:both"></div>'."n";
echo '</div>'."n";
$hr = true;
}
if ($k_page > 1) {
echo '<hr>'."n";
str_fish('/fishery/location/'.$locationGo.'/bait/', $k_page, $page);
}
} else echo '<div>Нет наживка в списке.</div>'."n";
echo '</div></div>'."n";
echo '<center><div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/warehouse/snasti"><span class="spec-head1">В амбар</span></a></div></center>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
}
#===================================#
// Удочка
if (isset($_GET['rodpay'])){
$grod = (int) $_GET['rodpay'];
if ($grod != ''){
$irod = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="rod" AND `id`="'.$grod.'" LIMIT 1'));
if ($irod['id'] != ''){
if (isset($_GET['ok'])){
if ($ku['rubies'] >= $irod['rubies']){
//mysql_query('UPDATE `kolhoz_fishery` SET `rod`="'.$irod['id'].'" WHERE `id_user`="'.$ku['id'].'" AND `location`="'.$locationGo.'"');
mysql_query("INSERT INTO `kolhoz_fishery_rod` SET
`id_user` = '".$ku['id']."',
`id_rod` = '".$irod['id']."',
`lom` = ".$irod['lom'].",
`lom_max` = ".$irod['lom_max']."");
$ku['rubies'] = minus_rubies($irod['rubies']);
//operation_rubies($irod['rubies'], 'покупка удочки, рыбалка');
$msg = 'Удочка '.$irod['name'].' успешно куплена и отправлена в амбар';
} else {
$_SESSION['no_rubies'] = ($irod['rubies']-$ku['rubies']);
}
redirect_fish('/fishery/location/'.$locationGo.'/rodpay/', $msg);
}
podtv('/fishery/location/'.$locationGo.'/rodpay/'.$irod['id'].'/ok', '/fishery/location/'.$locationGo.'/rodpay/');
echo "</div>";
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
}
}
echo title_one('<a href="/fishery/location/'.$locationGo.'/">Рыбалка</a> / Магазин удочек');
if(isset($_GET['id_boy'])){
$sql = mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="rod" and `id` = "'.intval($_GET['id_boy']).'"');
$roda = mysql_fetch_array($sql);
echo '<li class="message"><div class="content">'."n";
echo '<div>'."n";
echo '<img style="border-radius: 5px" width="48" height="48" src="'.$drimg.$roda['img'].'" alt="o" class="portrait2">'."n";
echo '<div class="blue sdw">'.$roda['name'].'</div>'."n";
echo '<div>'.$roda['description'].'</div>'."n";
echo '<div>Вероятность срыва рыбы <span>'.$roda['interest'].'%</span>.</div>'."n";
if($roda['shans_1'] != 0){
$shans_1 = mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_fishery_data` WHERE `id` = '".$roda['shans_1']."'"));
}
if($shans_1['name'] != '') echo '<div><b>Бонус: шанс '.$roda['shans_1_v'].'% выловить '.$shans_1['name'].'</b></div>'."n";
echo '<div>'.($iuser['rod'] == $roda['id'] ? '<span class="minor"><center>Эта удочка вами уже используется.</center></span>' : '<img class="va-m" src="'.$dricns.'cart.png" alt="[]"> <a href="/fishery/location/'.$locationGo.'/rodpay/'.$roda['id'].'">Купить</a> за <img src="'.$dricns.'ruby.png" class="va-m" alt="[]"> <span>'.plural_form($roda['rubies'], array('рубин','рубина','рубинов')).'</span>').'</div>'."n";
echo '<div style="clear:both"></div>'."n";
echo '</div>'."n";
echo '</div></li>'."n";
echo '<center><div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/fishery/location/1/rodpay/"><span class="spec-head1">В магазин</span></a></div></center>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php'; exit;
}
echo '<li class="message"><div class="content">'."n";
$k_post = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_data` WHERE `type`="rod"'), 0);
if ($k_post > 0){
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$sql = mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="rod" ORDER BY `rubies` LIMIT '.$start.', '.$set['p_str']);
while ($roda = mysql_fetch_array($sql)){
if ($hr === true) echo '<hr>'."n";
echo '<center><img style="border-radius: 5px" width="70" height="70" src="'.$drimg.$roda['img'].'" alt="o">';
echo '<div class="blue sdw">'.$roda['name'].'</div>'."n";
echo '<div class="blue sdw">Цена: <img src="'.$dricns.'ruby.png" class="va-m" alt="[]"> <span>'.plural_form($roda['rubies'], array('рубин','рубина','рубинов')).'</span>'.'</div>';
echo '<div class="blue sdw"><a href="/fishery/location/1/rodpay/?id_boy='.$roda['id'].'">Подробнее</a></div>'."n";
echo '</center><div style="clear:both"></div>'."n";
$hr = true;
}
if ($k_page > 1) {
echo '<hr>'."n";
str_fish('/fishery/location/'.$locationGo.'/rodpay/', $k_page, $page);
}
} else echo '<div>Нет удочек в списке.</div>'."n";
echo '</div></li>'."n";
echo '<center><div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/warehouse/snasti"><span class="spec-head1">В амбар</span></a></div></center>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
}
#===================================#
$bait_tf = ($iuser['food_time'] > TIME ? $bait['time'] - ($bait['time'] * $food['interest'] / 100) : $bait['time']);
$ttb_time = ($iuser['rod_time'] + $bait_tf) - TIME;
$ttb_prog = (TIME - $iuser['rod_time']) / ($bait_tf / 100);
// Закинуть удочку
if (isset($_GET['ttbGo']) && $bait_user_vid['count'] > 0 && $iuser['rod_act'] < 1 && $iuser['rod'] > 0){
mysql_query('UPDATE `kolhoz_fishery` SET `rod_act`="1", `rod_time`="'.TIME.'" WHERE `id_user`="'.$ku['id'].'" and `location` = "'.$locationGo.'"');
$count = $bait_user_vid['count'] - 1;
mysql_query('UPDATE `kolhoz_fishery_user` SET `count` = "'.$count.'" WHERE `id` = "'.$ku['last_bait'.$locationGo.''].'"');
redirect_fish('/fishery/location/'.$locationGo.'/', 'Удочка заброшена! '.$bait['name'].' потрачен.');
}
// Вытащить удочку
if (isset($_GET['ttbStop']) && $iuser['rod_act'] > 0 && $iuser['rod'] > 0){
mysql_query('UPDATE `kolhoz_fishery` SET `rod_act`="0", `rod_time`="0", `bait`="0" WHERE `id_user`="'.$ku['id'].'" AND `location`="'.$locationGo.'"');
if ($ttb_prog >= 100)
{
$fishWarLim = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_warehouse` WHERE `id_user` = "'.$ku['id'].'" AND `fish` = "1"'), 0);
if($fishWarLim < 10)
{
if (mt_rand(1, 100) > $rod['interest']) // Вероятьность удочки
{
if($rod['shans_1'] > 0){
if(mt_rand(1,100) <= $rod['shans_1_v']){
$id_fish = $rod['shans_1'];
}
}
$sql = mysql_query('SELECT `id` FROM `kolhoz_fishery_data` WHERE `type`="fish" ORDER BY `id` ASC');
$dataFish = array();
while ($fish = mysql_fetch_array($sql)) $dataFish[] = $fish['id'];
if($id_fish < 1){
$caught = mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_fishery_data` WHERE `type`='fish' and `id`= '".$dataFish[mt_rand(0, count($dataFish)-1)]."'"));
}else{
$caught = mysql_fetch_array(mysql_query("SELECT * FROM `kolhoz_fishery_data` WHERE `id` = '".$id_fish."'"));
}
$msg = '<div><img width="48" height="48" src="'.$drimg.$caught['img'].'" alt="[]" class="portrait">
<div class="blue sdw">Пойман '.$caught['name'].'!</div>
<div style="clear:both"></div></div>';
$fishWar = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_warehouse` WHERE `id_user` = "'.$ku['id'].'" AND `id_plant` = "'.$caught['id'].'" AND `fish` = "1" LIMIT 1'));
if(mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_warehouse` WHERE `id_user` = "'.$ku['id'].'" AND `id_plant` = "'.$caught['id'].'" AND `fish` = "1"'), 0) < 1)
{
mysql_query('INSERT INTO `kolhoz_warehouse` SET `id_user` = "'.$ku['id'].'", `fish` = "1", `id_plant` = "'.$caught['id'].'", `count` = "1"');
}
else
{
$count = $fishWar['count'] + 1;
mysql_query('UPDATE `kolhoz_warehouse` SET `count` = "'.$count.'" WHERE `id_user`="'.$ku['id'].'" AND `id_plant`="'.$caught['id'].'" AND `fish` = "1"');
}
mysql_query("UPDATE `kolhoz_user` SET `rating` = `rating` +".$caught['rating']." WHERE `id` = '".$ku['id']."'");
if($fish['type_fish'] == 2){
mysql_query("UPDATE `kolhoz_user` SET `turnir_fish` = `turnir_fish` +1 WHERE `id` = '".$ku['id']."'");
}
mysql_query("UPDATE `kolhoz_fishery_rod` SET `lom` = `lom` -1 WHERE `id_user` = '".$ku['id']."' and `id_rod` = '".$rod['id']."'");
$_SESSION['rating'] = $caught['rating'];
} else {
$foiled = array(
'Ушла твоя рыбка! Кончай зевать, раз начало клевать!',
'Сорвалась! Ухи сегодня не будет...',
'Сорвалась рыбка! Есть терпение, будет и умение...',
'Улов сорвался! Был бы омут, а черти будут.'
);
$msg = '<div><img width="48" height="48" src="'.$drimg.'fell_fish.png" alt="[]" class="portrait"><div>'.$foiled[mt_rand(0,3)].'</div><div style="clear:both"></div></div>';
}
}else{
$msg = 'Ваш Садок переполнен! Продайте рыбу';
}
}
else
{
$early = array(
'Слишком рано! Дай рыбе заглотить наживку получше!',
'Не хочешь ждать? Купи наживку получше!',
'Пусто! А с наживкой получше рыбалка шла бы веселее.',
'Не по рыбе наживка - купи получше!',
'Слишком рано! Улов сорвался.'
);
$msg = $early[mt_rand(0,4)];
}
redirect_fish('/fishery/location/'.$locationGo.'/', $msg);
}
$req_rod = mysql_query("SELECT * FROM `kolhoz_fishery_rod` WHERE `id_user` = '".$ku['id']."' and `id_rod` = '".$iuser['rod']."'");
$my_rod = mysql_fetch_array($req_rod);
if($my_rod['lom'] == 1){
mysql_query("DELETE FROM `kolhoz_fishery_rod` WHERE `id_user` = '".$ku['id']."' and `id_rod` = '".$iuser['rod']."'");
mysql_query("UPDATE `kolhoz_fishery` SET `rod` = 0, `rod_time` = 0, `rod_act` = 0 WHERE `id_user` = '".$ku['id']."' and `rod` = '".$iuser['rod']."'");
redirect_fish('/fishery/location/'.$locationGo.'/', 'Ваша удочка сломалась!');
}
if ($locationGo != '' && $iuser['time_location'] > $time){
echo '<div class="menu-foot">';
echo title_one($location['name']);
if($location['id'] == 1){
echo '<div class="blocklocname2"><span class="spec-head6"><center>До конца рыбалки <img src="/img/icons/clock.png" class="va-m" alt="[]">'.time_left($iuser['time_location']-TIME).'</center></span>';
}else{
echo '<div class="blocklocname2"><span class="spec-head6"><center>Рыбалка</center></span>';
}
if(($bait_user_vid['count'] == "0" || $ku['last_bait'.$locationGo.''] == "0") && $iuser['rod_act'] == '0')
{
echo '<a href="/fishery/location/'.$locationGo.'/bait/" class="f-panel-btn-active"><div class="f-panel-btn-text-fish buy-bait"></div></a>';
}
else
{
if($iuser['rod_act'] == '0' && $iuser['rod'] > 0)
{
echo '<a href="/fishery/location/'.$locationGo.'/ttbGo" class="f-panel-btn-active"><div class="f-panel-btn-icon-active-fish cast"></div><div class="f-panel-btn-text-fish cast"></div></a>';
}
elseif($iuser['rod_act'] == '1' && $iuser['rod'] > 0)
{
echo '<a href="/fishery/location/'.$locationGo.'/ttbStop" class="f-panel-btn-active"><div class="f-panel-btn-icon-active-fish stretch"></div>';
if($ttb_time > '0')
{
echo '<div class="f-panel-btn-time-lock">'.time_left_fish($ttb_time).'</div></a><a href="/fishery/location/'.$locationGo.'/"><img class="right" src="img/refreshS.png"></a>';
}
else
{
echo '<div class="f-panel-btn-text-fish stretch"></div></a>';
}
}
elseif($iuser['rod'] == '0')
{
echo '<a href="/fishery/location/'.$locationGo.'/rodpay" class="f-panel-btn-active"><div class="f-panel-btn-icon-active-fish cast"></div><div class="f-panel-btn-text-fish buy-fish"></div></a>';
}
}
if($iuser['food_time'] < TIME && $bait_user_vid['count'] != "0" && $iuser['rod'] > 0)
{
echo '<a href="/warehouse/snasti?id_loc='.$locationGo.'" class="f-panel-btn-active"><div class="f-panel-btn-text-fish buy-lure"></div></a>';
}
echo '<div class="timings">';
if($bait_user_vid['count'] == "0" || $ku['last_bait'.$locationGo.''] == "0")
{
echo '<div class="f-panel-btn-active2 left"><img style="border-radius: 5px" width="65" height="65" src="'.$drimg.''.($ku['last_bait'.$locationGo.''] > "0"?''.$baita_vid['img'].'':'bread.png').'" alt="o"><span class="c-brown">Не выбрана</span></div>';
}
else
{
echo '<div class="f-panel-btn-active2 left">';
echo '<img style="border-radius: 5px" width="65" height="65" src="'.$drimg.$baita_vid['img'].'" alt="o">';
echo '<span class="c-brown"> '.$bait_user_vid['count'].' шт. </span>';
if($iuser['rod_act'] == '0')
{
echo '<a href="/warehouse/snasti?id_loc='.$locationGo.'"><span class="c-brown" style="text-decoration: underline;">сменить </span></a>';
}
echo '</div>';
}
$iname = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `id`="'.$iuser['food'].'"'));
echo '<div class="f-panel-btn-active2 right icon"><img width="53" style="border-radius: 5px" src="'.$drimg.($iname['img'] != '' ? $iname['img'] : 'flagsS.png').'" alt="o" class="portrait">';
if($iuser['food_time'] > TIME)
{
echo '<span class="c-brown right-text">'.time_left_fish($iuser['food_time'] - TIME).'<a href="/warehouse/snasti?id_loc='.$locationGo.'"><span class="c-brown" style="text-decoration: underline;"> сменить</span></a></span>';
}
else
{
echo '<span class="c-brown">Нет прикормки</span>';
if($iuser['rod'] > 0)
{
echo '<a href="/warehouse/snasti?id_loc='.$locationGo.'"><br><span class="c-brown right" style="text-decoration: underline;">сменить </span></a></span>';
}
}
echo '</div></div></div>';
if($locationGo == 1){
echo '<div>'.($iuser['rod_act'] > 0 ? '<img alt="" src="/ImgStyle/loc1.png">':'<img alt="" src="/img/fishing/1_loc.png">').'</div>';
}else{
echo '<div>'.($iuser['rod_act'] > 0 ? '<img alt="" src="/ImgStyle/loc_act.png">':'<img alt="" src="/ImgStyle/loc.png">').'</div>';
}
echo '<center><div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/warehouse/snasti?id_loc='.$locationGo.'"><span class="spec-head1">Сменить удочку</span></a></div></center>';
echo '<center><div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/fishery/"><span class="spec-head1">Выбор места рыбалки</span></a></div></center>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
}
$buy_a_license = (int) $_GET['buy_a_license'];
if ($buy_a_license != '')
{
$info_loc = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="location" and `id`="'.$buy_a_license.'" LIMIT 1'));
if ($info_loc['id'] != '')
{
$time_loc = (int) $_GET['time_loc'];
if (isset($_GET['time_loc']) && $ku['level'] >= $info_loc['level'])
{
if($time_loc == '12')
{
$timee_loc = 43200+$time;
$cena = ($info_loc['id'] == 1 ? 12 : 500);
}
if($time_loc == '24')
{
$timee_loc = 86400+$time;
$cena = ($info_loc['id'] == 1 ? 24 : 1000);
}
if($time_loc == '36')
{
$timee_loc = 129600+$time;
$cena = ($info_loc['id'] == 1 ? 32 : 1334);
}
if($buy_a_license == 2){
$timee_loc = (604800*99)+$time;
}
if (isset($_GET['ok']))
{
if($buy_a_license == 1 and $mc['id'] < 1){
redirect_fish('/fishery/','Эта локация доступна для пользователей состоящих в колхозе'); exit;
}
if($buy_a_license == 2){
$cena = 0;
}
if ($ku['rubies'] >= $cena)
{
mysql_query('UPDATE `kolhoz_fishery` SET `time_location` = "'.$timee_loc.'" WHERE `id_user` = "'.$ku['id'].'" AND `location` = "'.$buy_a_license.'"');
$ku['rubies'] = minus_rubies($cena);
if($buy_a_license == 1){
mysql_query("UPDATE `kolhoz_collective` SET `rubies` = `rubies` +$cena WHERE `id` = '".$mc['id']."'");
mysql_query("UPDATE `kolhoz_collective_user` SET `rubies` = `rubies` +$cena WHERE `id_user` = '".$ku['id']."'");
}
if($info_loc['id'] == 1){
$msg = 'Лицензия на '.$info_loc['name'].' куплена на '.time_left($timee_loc - TIME);
}else{
$msg = '';
}
}
else
{
$_SESSION['no_rubies'] = ($cena-$ku['rubies']);
}
redirect_fish('/fishery/location/'.$buy_a_license.'/', $msg);
}
echo '<div><img src="/ImgStyle/lake-details.jpg"/></div>';
echo '<center><div class="blocklocname"><span class="spec-head6">'.$info_loc['name'].'</span>
<a class="blockloctime" href="/fishery/buyALicense/'.$info_loc['id'].'/time_loc/12/ok"><span class="spec-head5">12 ч за <img src="'.$dricns.'ruby.png"> '.($info_loc['id'] == 1 ? 12 : 500).'</span></a>';
echo '<a class="blockloctime" href="/fishery/buyALicense/'.$info_loc['id'].'/time_loc/24/ok"><span class="spec-head5">24 ч за <img src="'.$dricns.'ruby.png"> '.($info_loc['id'] == 1 ? 24 : 1000).'</span></a>';
echo '<a class="blockloctime" href="/fishery/buyALicense/'.$info_loc['id'].'/time_loc/36/ok"><span class="spec-head5">36 ч за <img src="'.$dricns.'ruby.png"> '.($info_loc['id'] == 1 ? 32 : 1334).'</span></a></div></center>';
echo '<center><div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/fishery/"><span class="spec-head1">Выбор места рыбалки</span></a></div></center>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
}
echo '
<div><img src="/img/fishing/'.$info_loc['id'].'_loc.png"/></div>';
echo '<center><div class="namelocal1">
<div class="namelocal">
<span class="spec-head2">'.$info_loc['name'].'</span>
</div>';
if($info_loc['id'] != 2){
echo '<div class="spec-head3">Предыдущий срок аренды истек. Можно арендовать место еще раз.</div>';
}else{
echo '<div class="spec-head3">'.$info_loc['name'].' доступна для всех игроков достигших '.$info_loc['level'].' уровня.</div>';
}
if ($ku['level'] >= $info_loc['level'])
{
echo '<a href="'.($info_loc['id'] != 2 ? '/fishery/buyALicense/'.$info_loc['id'].'/time_loc' : '/fishery/buyALicense/2/time_loc/36/ok').'"><div class="actloc"><span class="spec-head4">'.($info_loc['id'] != 2 ? 'Активировать' : 'Рыбачить').'</span></div></a>';
}
else
{
echo '<div style="font-size:20px; padding:4px 0px 12px 0px;">Доступно с <span class="tomato bold"><font color="red"><b>'.$info_loc['level'].'</b></font>-го</span> уровня.</div>'."n";
}
echo '</div>';
echo '<div style="padding:5px 0px 0px 0px;" ><a class="blockloctime" href="/fishery/"><span class="spec-head1">Выбор места рыбалки</span></a></div></center>';
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
}
}
echo '<img src="http://'.$_SERVER['HTTP_HOST'].'/img/logo.gif">';
echo '<div class="block">';
echo title_one('Выбор места рыбалки');
echo '<div class="block"><div class="content">'."n";
$req = mysql_query('SELECT * FROM `kolhoz_fishery` WHERE `id_user`="'.$ku['id'].'" and `time_location` > "'.time().'" and `rod_act` = "1"');
if(mysql_num_rows($req) > 0){
$my_fish = mysql_fetch_array($req);
redirect_fish('/fishery/location/'.$my_fish['location'],'Для смены локации, вытяните удочку'); exit;
}
$k_post = mysql_result(mysql_query('SELECT COUNT(`id`) FROM `kolhoz_fishery_data` WHERE `type`="location"'), 0);
if ($k_post > 0){
$k_page = k_page($k_post, $set['p_str']);
$page = page($k_page);
$start = $set['p_str'] * $page - $set['p_str'];
$sql = mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="location" ORDER BY `id` ASC LIMIT '.$start.', '.$set['p_str']);
while ($loc = mysql_fetch_array($sql))
{
$iuserLoc = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery` WHERE `id_user` = "'.$ku['id'].'" AND `time_location` > "$time" AND `rod_act` = "1" AND `location`="'.$loc['id'].'"'),0);
if ($iuserLoc['food_time'] >= $time) $foodFoot = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="food" and `id`="'.$iuserLoc['food'].'" LIMIT 1'));
$bait_user_vid = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_user` WHERE `id`="'.$ku['last_bait'.$loc['id'].''].'" AND `id_user`="'.$ku['id'].'"'));
$baitLoc = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery_data` WHERE `type`="bait" and `id`="'.$bait_user_vid['bait'].'" LIMIT 1'));
$bait_tfLoc = ($iuserLoc['food_time'] > $time ? $baitLoc['time'] - ($baitLoc['time'] * $foodFoot['interest'] / 100) : $baitLoc['time']);
$ttb_timeLoc = ($iuserLoc['rod_time'] + $bait_tfLoc) - $time;
$loc_act = mysql_fetch_array(mysql_query('SELECT * FROM `kolhoz_fishery` WHERE `id_user`="'.$ku['id'].'" AND `location`="'.$loc['id'].'" LIMIT 1'));
if($loc_act['time_location'] >= TIME)
{
echo '<a href="/fishery/location/'.$loc['id'].'">';
}
else
{
echo '<a href="/fishery/buyALicense/'.$loc['id'].'">';
}
echo '<div class="btn-spec-select1">'."n";
echo '<img src="/img/fishing/'.$loc['id'].'_fish.png" class="portrait mt10"/><span class="spec-head1">'.$loc['name'].''.($ttb_timeLoc < 1 && $iuserLoc['rod_act'] == '1'?"<font color='red'><b>(!)</b></font>":null).'</span>';
echo '<span class="link-g3">'.$loc['description'].'';
echo '</span>';
echo '<div style="clear:both"></div></div></a>';
}
if ($k_page > 1) {
echo '<hr>'."n";
str_fish('/fishery/', $k_page, $page);
}
} else echo '<div>Нет локаций в списке.</div>'."n";
echo '</div></div>'."n";
include_once $_SERVER['DOCUMENT_ROOT'].'/inc/system/foot.php';
?>