<?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']='Rating'; // заголовок страницы

include_once '../sys/inc/thead.php';
title();
err();
aut();


echo '<center><img src="/villa/images/villa.jpg" /> </center>';

if(isset($user)){



echo'<font color="red">Rating florists</font><br/>';
$x=mysql_query("SELECT * FROM `ferma` ORDER BY `um` DESC");

if(!mysql_num_rows($x)){echo 'Still no not one villa!!!';
}else{
echo 'Total villas: <b>'.mysql_num_rows($x).'</b>!<br/>';

while($row=mysql_fetch_assoc($x)){
$q=$row['dohod_1'];
$level=$row['level']+1;
$w=$row['dohod_2'];
$e=$row['dohod_3'];
$r=$row['dohod_4'];
$t=$row['dohod_5'];
$y=$row['dohod_6'];
$u=$row['dohod_7'];
$a=$row['dohod_8'];
$s=$row['dohod_9'];
$d=$row['dohod_10'];
$f=$row['dohod_11'];
$g=$row['dohod_12'];
$dohod=$q+$w+$e+$r+$t+$y+$u+$a+$s+$d+$f+$g;
echo '<hr/>
Name of the villa: <b><a href="info.php?id='.$row['id'].'">'.$row['name'].'</a></b> ( <font color="green"><b>'.$row['um'].'</b></font> ) [<a href="reit.php?act=del&'.$row['id'].'">[x]</a><br/>';
$data=date("d")-date("d",$row['date']);
echo 'Florist: '.$row['user'].'<br/>';
echo 'Level: '.$level.'<br/>';
echo 'Earnings: '.$dohod.'<br/>';
};

};

$act = (isset($_GET['act'])) ? htmlspecialchars($_GET['act']) : null;
switch ($act){
case 'del':
if($user['level']>2){
mysql_query("DELETE FROM `ferma` WHERE `id` ='".$_GET['id']."'");
echo "Ready, well done =)<br/>";

}else{echo "You do not belong here, get out!!!<br/>";};
break;
};



echo '<div class="msg"><a href="index.php">Home Page</a></div>';


}else{
echo '<div class="msg">The game is available only to authorized users!</div>';
};
include_once "kto.php";
include_once '../sys/inc/tfoot.php';
?>