Файл: tankon.mobi/tanks/avafoto.php
Строк: 234
<?
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';
include_once '../sys/inc/thead.php';
err();
aut();
echo '<link rel="stylesheet" href="style.css" type="text/css" />';
include_once 'function.php';
if (isset($user))$ank['id']=$user['id'];
if (isset($_GET['id']))$ank['id']=intval($_GET['id']);
$coes = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id`='".$ank['id']."'"));
if ($coes==0){header ("Location: /");}
$ank=get_user($ank['id']);
$tankss_code = mysql_fetch_array(mysql_query("SELECT * FROM `tanks` WHERE `id_u`='".$ank['id']."'"));
$proverka = mysql_query ( "SELECT * FROM `avatar_rating` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' LIMIT 1" );
if (! mysql_num_rows ( $proverka ) && isset($user) && $user['id'] != $ank['id']) {
$rls=1;
}elseif($user['id'] == $ank['id'] || $ank['id']=='NULL'){
echo'<table><tr>
<td style="width:50%;padding-right:2px;">
<div style="position:relative;">
<a class="simple-but mb5 gray" w:id="selectUssr" href="/avatars"><span><span>Аватар</span></span></a>
</div>
</td>
<td style="width:50%;padding:0 2px;">
<div style="position:relative;">
<div class="simple-but mb5 blue" w:id="selectGermany" href="/"><span><span>Фото</span></span></div>
</div>
</td>
</tr></table>
';
if($tanks_code['avafoto']==0){
if(isset($_POST['ok'])){
if(isset($_FILES['file']))
{
$type = $_FILES['file']['type'];
$size=$_FILES['file']['size'];
$sizes=1000000;
if ($type!=='image/jpeg' && $type!=='image/jpg' && $type!=='image/gif' && $type!=='image/png'){$err=1;err_game('Это не картинка');}
if ($size>$sizes){$err=1;err_game('Размер более 1mb');}
}
if (!isset($err))
{
$tmp = $_FILES['file']['tmp_name'];
mysql_query("UPDATE `tanks` SET `avafoto` = '".$tanks_code['id']."' WHERE `id` = '".$tanks_code['id']."'");
$id=mysql_insert_id();
$tmp = $_FILES['file']['tmp_name'];
move_uploaded_file($tmp, "../images/avatars/".$tanks_code['id'].".png");
header("location: /avafoto?yes");
}
}
if(isset($_GET['yes'])){
err_sms('Аватар установлен');
}
echo "<form method="post" enctype='multipart/form-data'>n";
echo'<div class="trnt-block p5" style="margin-bottom:3px">';
echo "<input type='file' name='file' />";
echo'</div><div class="bot">
<span class="input-but border"><span>';
echo "<input name='ok' value="Загрузить" class='w100' type="submit" /></span></span>
</div></form>";
}else{
if(isset($_GET['del'])){
echo'<table><tbody><tr><td class="w50"><a class="simple-but border" href="/avafoto?del&ok">
<span><span>Удалить</span></span></a></td>
<td class="w50"><a class="simple-but border" href="/avafoto">
<span><span>Отмена</span></span></a></td>
</tr></tbody></table></div></div></div>';
if (isset($_GET['ok']))
{
mysql_query("UPDATE `tanks` SET `avafoto` = '0' WHERE `id` = '".$tanks_code['id']."'");
mysql_query("DELETE FROM `avatar_rating` WHERE `id_ank` = '".$tanks_code['id']."'");
unlink("../images/avatars/".$tanks_code['id'].".png");
header("location: /avafoto");
}
}
echo'<a class="simple-but red" href="/avafoto?del"><span><span>Удалить фото</span></span></a>';
}
}
if($tankss_code['avafoto']!=0){
$one=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='1' AND `id_ank` = '$ank[id]'"),0);
$two=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='2' AND `id_ank` = '$ank[id]'"),0) * 2;
$three=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='3' AND `id_ank` = '$ank[id]'"),0) * 3;
$fout=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='4' AND `id_ank` = '$ank[id]'"),0) * 4;
$five=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='5' AND `id_ank` = '$ank[id]'"),0) * 5;
$ones=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='1' AND `id_ank` = '$ank[id]'"),0);
$twos=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='2' AND `id_ank` = '$ank[id]'"),0);
$threes=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='3' AND `id_ank` = '$ank[id]'"),0);
$fouts=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='4' AND `id_ank` = '$ank[id]'"),0);
$fives=mysql_result(mysql_query("SELECT COUNT(*) FROM `avatar_rating` WHERE `rating`='5' AND `id_ank` = '$ank[id]'"),0);
$alls = $ones + $twos + $threes + $fours + $fives;
$all = round(($one + $two + $three + $four + $five)/$alls);
if(isset($_GET['rait']))
{
$rait = intval($_GET['rait']);
if($rait<6){
$proverka1 = mysql_query ( "SELECT * FROM `avatar_rating` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' LIMIT 1" );
if (! mysql_num_rows ( $proverka1 ) && isset($user) && $user[id] != $ank[id]) {
echo'<table><tbody><tr><td class="w50"><a class="simple-but border" href="/avafoto?id='.$ank['id'].'&rait='.intval($_GET['rait']).'&ok">
<span><span>Оценить</span></span></a></td>
<td class="w50"><a class="simple-but border" href="/avafoto?id='.$ank['id'].'">
<span><span>Отмена</span></span></a></td>
</tr></tbody></table></div></div></div>';
if(isset($_GET['ok'])){
mysql_query("INSERT INTO `avatar_rating` (id_user, rating, id_ank) values('$user[id]','".my_esc($rait)."', '$ank[id]')");
$soob_help="Ваше фото оценил игрок [url=http://tankon.mobi/profile?id=".$user['id']."]".$user['nick']."[/url]";
mysql_query("INSERT INTO `kolhoz_mail` (`id_user`, `id_kont`, `msg`, `time`, `type`) values('$ank[id]', '0', '".my_esc($soob_help)."', '$time', 'to')");
header('Location:/avafoto?id='.$ank['id'].'');}
}
else
{
err_game('Вы уже оценили фото');
}
}
}
echo'<div class="trnt-block p5" style="margin-bottom:3px;">';
echo'<div class="medium white bold cntr"><img src="/images/icons/exp.png"> Рейтинг фото <font color="yellow">'.$all.'</font></div>';
echo'<img class="w100" style="border-radius:3px;" src="/images/avatars/'.$tankss_code['id'].'.png">';
$proverka1 = mysql_query ( "SELECT * FROM `avatar_rating` WHERE `id_user` = '$user[id]' AND `id_ank` = '$ank[id]' LIMIT 1" );
if (! mysql_num_rows ( $proverka1 ) && isset($user) && $user[id] != $ank[id]) {
if($rls=1){
echo'<div class="cntr">';
echo'<a href="?id='.$ank['id'].'&rait=1"><img src="/images/icons/1.png"></a>';
echo'<a href="?id='.$ank['id'].'&rait=2"><img src="/images/icons/2.png"></a>';
echo'<a href="?id='.$ank['id'].'&rait=3"><img src="/images/icons/3.png"></a>';
echo'<a href="?id='.$ank['id'].'&rait=4"><img src="/images/icons/4.png"></a>';
echo'<a href="?id='.$ank['id'].'&rait=5"><img src="/images/icons/5.png"></a>';
echo'</div>';
}}
echo'</div>';
}else{
echo'<div class="trnt-block p5" style="margin-bottom:3px;">';
echo'<div class="medium white bold cntr"><font color="yellow">Нет фото</font></div>';
echo'<img class="w100" style="border-radius:3px;" src="/images/avatars/noava.png">';
echo'</div>';
}
echo'<a class="simple-but gray" href="/profile?id='.$ank['id'].'"><span><span>В профиль</span></span></a>';
include_once 'foots.php';
?>