<?php

include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';


$set['title']='Весёлая ферма';
error_reporting (0);
include_once '../sys/inc/thead.php';
title();
err();
aut();
function permissions($filez){
return decoct(@fileperms("$filez")) % 1000;
}
function test_chmod($df,$chmod)
{
global $err,$user;
if (isset($user) && $user['level']==10)
$show_df=ereg_replace('^'.H, $_SERVER["DOCUMENT_ROOT"].'/', $df);
else $show_df=$df;


@list($f_chmod1,$f_chmod2,$f_chmod3)=str_split(permissions($df));
list($n_chmod1,$n_chmod2,$n_chmod3)=str_split($chmod);
//list($m_chmod1,$m_chmod2,$m_chmod3)=str_split($max_chmod);

if ($f_chmod1<$n_chmod1 || $f_chmod2<$n_chmod2 || $f_chmod3<$n_chmod3)
{
echo "<center><span class='off'><b>Установите CHMOD (права) $n_chmod1$n_chmod2$n_chmod3 на $show_df<br />А то игра будет работать не стандартно!</b></span></center>";
}

}
test_chmod(H.'fermer/img/',777);
//header("Content-type: application/vnd.wap.xhtml+xml");
header("Content-type: text/html");
if (isset($user)){
$dog = mysql_result(mysql_query("select count(*) from `fermer_dog` WHERE  `id_user` = '$user[id]'  LIMIT 1"),0);
if($dog==0){
mysql_query("INSERT INTO `fermer_dog` (`id_user`,`time`) VALUES  ($user[id],NULL) ");
mysql_query("UPDATE `user` SET `fermer_doggy`='0' WHERE `id`='id_user'");
}
$post = mysql_result(mysql_query("select count(*) from `fermer_gr` WHERE  `id_user` = '$user[id]'  LIMIT 1"),0);
if($post<5){
mysql_query("INSERT INTO `fermer_gr` (`kol`,`semen`, `id_user`) VALUES  ( NULL, '0', '".$user['id']."') ");
mysql_query("INSERT INTO `fermer_gr` (`kol`,`semen`, `id_user`) VALUES  ( NULL, '0', '".$user['id']."') ");
mysql_query("INSERT INTO `fermer_gr` (`kol`,`semen`, `id_user`) VALUES  ( NULL, '0', '".$user['id']."') ");
mysql_query("INSERT INTO `fermer_gr` (`kol`,`semen`, `id_user`) VALUES  ( NULL, '0', '".$user['id']."') ");
mysql_query("INSERT INTO `fermer_gr` (`kol`,`semen`, `id_user`) VALUES  ( NULL, '0', '".$user['id']."') ");
}
echo "<link rel='stylesheet' href='style.css' type='text/css' /><center>";
echo "<div class='ferm1'><img src='fermer.gif'><br/>";
include_once "news/news_main.php";
$menu=' <img src="/ferm/action.png"> ';
include_once 'my2.php';
echo "<div class='ferm3'>";
if ($user[level]>4)
{
echo "<center><a href='adminka'><font color=red>Админка игры</font></a><br/></center>" ;}

echo "<br/><TABLE BORDER=0>
<CAPTION ALIGN=bottom>
<TH>
<a href='shop.php'><img src='shop.png'><br/>Магазин</a>
</ TH> <TH>
<a href='storage.php'><img src='sklad.png'><br/>Склад</a>
</ TH> <TH>
<a href='fermers.php'><img src='sosed.png'><br/>Соседи</a></ TH></TABLE><font color='#DEB887'><hr></font>";

echo "<TABLE BORDER=0>
<CAPTION ALIGN=bottom>
<TH><a href='news'><img src='020.png'><br/>Новости</a></ TH> <TH>";

echo "<a href='original_appearance.php'><img src='023.png'><br/>Мой вид</a></ TH> <TH>";

echo "<a href='my.php'><img src='005.png'><br/>Огород</a></ TH></TABLE><font color='#DEB887'><hr></font>";

echo "<TABLE BORDER=0>
<CAPTION ALIGN=bottom>
<TH><a href='bank.php'><img src='bank.png'><br/>Банк</a> 
</ TH> <TH>
<a href='area.php'><img src='profile.png'><br/>Участок</a> 
</ TH> <TH>
<a href='medal.php'><img src='rating.png'><br/>Рейтинг</a> <br/></ TH></TABLE><font color='#DEB887'><hr></font>";


echo "<a href='chat'>Чат</a> | <a href='opis.php'>Помощь</a><br/><br/></center></div>";

}else{
echo '<div class="msg">Ферма  доступна только для авторизованных пользователей!</div>';};
include_once '../sys/inc/tfoot.php';

?>