<?php
define( '_IN_JOHNCMS', 1 );
if ( isset( $_SESSION[ 'harvest' ] ) )
		{
				harvest( $_SESSION[ 'harvest' ] );
				unset( $_SESSION[ 'harvest' ] );
		}
if ( isset( $_SESSION[ 'rating' ] ) )
		{
				ratingg( $_SESSION[ 'rating' ] );
				unset( $_SESSION[ 'rating' ] );
		}
if ( isset( $_SESSION[ 'mon' ] ) )
		{
				mon( $_SESSION[ 'mon' ] );
				unset( $_SESSION[ 'mon' ] );
		}
if ( isset( $_SESSION[ 'km' ] ) )
		{
				km( $_SESSION[ 'km' ] );
				unset( $_SESSION[ 'km' ] );
		}
if ( $ku[ 'umoney' ] != 0 )
		{
				money( $ku[ 'umoney' ] );
		}
if ( isset( $_SESSION[ 'no_rubies' ] ) )
		{
				no_rubies( $_SESSION[ 'no_rubies' ] );
				unset( $_SESSION[ 'no_rubies' ] );
		}
if ( isset( $_SESSION[ 'no_money' ] ) )
		{
				no_money( $_SESSION[ 'no_money' ] );
				unset( $_SESSION[ 'no_money' ] );
		}
if ( isset( $_SESSION[ 'no_diam' ] ) )
		{
				no_diam( $_SESSION[ 'no_diam' ] );
				unset( $_SESSION[ 'no_diam' ] );
		}
$bigl = 75;
//Эсли в базе нету больше уровней
if ( $ku[ 'level' ] < $bigl )
		{
				//Полоса опыта
				if ( $ku[ 'polosa' ] == 0 )
						{
								$max  = $level[ 'rating' ];
								$tek  = $kr;
								$forl = ( $tek / $max ) * 100;
								echo '<div style="border:1px solid #55A855;border-radius:5px;margin-top:2px;">';
								echo '<div class="expline" style="width:' . $forl . '%;"/>';
								echo "</div>";
								echo "</div>";
						}
		}
//Монеты и т.д верх
if ( $ku[ 'verh' ] == 0 )
		{
				echo "<div class='event'><font color='yellow'><p align='right'><img width='16' height='16' src='images/icons/money.png' alt='o'> <span>$ku[money]</span> <img width='16' height='16' src='images/icons/ruby.png' alt='o'> <span>$ku[rubies]</span> <img width='16' height='16' src='images/icons/almaz.png' alt='o'> <span>$ku[almaz]</span></p></font></div>";
		}
if ( mysql_result( mysql_query( "SELECT COUNT(*) FROM `$db_base`.`kolhoz_gifts` WHERE `id_user` = '$ku[id]' AND `read` = '0'" ), 0 ) != 0 )
		{
				echo "<div class='feedback'><div>У вас новый подарок<br><a href='?presents=$ku[id]'>Смотреть</a><br></div></div>";
		}
//Приглашение в колхоз
if ( mysql_result( mysql_query( "SELECT COUNT(*) FROM `$db_base`.`kolhoz_collective_invite` WHERE `id_user` = '$ku[id]'" ), 0 ) != 0 )
		{
				$invite = mysql_fetch_array( mysql_query( "SELECT * FROM `$db_base`.`kolhoz_collective_invite` WHERE `id_user` = '$ku[id]'" ) );
				$cti    = mysql_fetch_array( mysql_query( "SELECT * FROM `$db_base`.`kolhoz_collective` WHERE `id` = '$invite[id_collective]'" ) );
				$who    = mysql_fetch_array( mysql_query( "SELECT * FROM `$db_base`.`kolhoz_user` WHERE `id` = '$invite[id_who]'" ) );
				if ( isset( $_GET[ 'invite_collective' ] ) && $_GET[ 'invite_collective' ] == 'yes' )
						{
								mysql_query( "DELETE FROM `$db_base`.`kolhoz_collective_invite` WHERE `id` = '$invite[id]'" );
								mysql_query( "INSERT INTO `$db_base`.`kolhoz_collective_user` SET `id_user` = '$ku[id]', `id_collective` = '$cti[id]', `time` = '$time', `status` = '7'" );
								mysql_query( "INSERT INTO `$db_base`.`kolhoz_collective_history` SET `id_user` = '$ku[id]', `id_who` = '$who[id]', `id_collective` = '$cti[id]', `time` = '$time', `type` = 'in', `dei` = 'who'" );
								header( "Location:?collective=$cti[id]" );
						}
				elseif ( isset( $_GET[ 'invite_collective' ] ) && $_GET[ 'invite_collective' ] == 'no' )
						{
								mysql_query( "DELETE FROM `$db_base`.`kolhoz_collective_invite` WHERE `id` = '$invite[id]'" );
						}
				else
						{
								echo "<div class='feedback'><div><span>";
								echo on_k( $who[ 'id' ] );
								echo " <a class='' href='?user=$who[id]'>" . nc( $who[ 'id' ] ) . "</a></span> приглашает Вас в свой колхоз <a href='?collective=$cti[id]'><span>" . hsc( $cti[ 'name' ] ) . "</span></a><br/>";
								echo "<img width='16' height='16' src='images/icons/tick.png' alt='o'> <a href='?myfarm&invite_collective=yes'>Принять</a><br/>";
								echo "<img width='16' height='16' src='images/icons/delete.png' alt='o'> <a href='?myfarm&invite_collective=no'>Отказаться</a>";
								echo "</div>\n
</div>";
						}
		}
if ( isset( $_SESSION[ 'msg' ] ) )
		{
				msg_game( $_SESSION[ 'msg' ] );
				unset( $_SESSION[ 'msg' ] );
		}
?>