View file sdark.mobi/clan/kazna.php

File size: 4.78Kb
<?php
require_once '../core/system.php';
$header = 'Казна клана';
require_once '../core/head.php';

$clan = mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`  = ".intval($_GET['id']).""));
if($clan['id']!=$user['clan'] && $user['prava']<4){$_SESSION['err'] = 'Ошибка'; header('Location: /');}
$gold = intval($_GET['sdat'])*100;
if(isset($_GET['sdat'])){
if($user['gold']<$gold){header('Location: /clan/kazna?id='.intval($_GET['id']).''); $err='Недостаточно золота';}
if(0>=$gold){header('Location: /clan/kazna?id='.intval($_GET['id']).''); $err='Ошибка';}
if(!isset($err)){
$_SESSION['message'] = 'Вы сдали <img src="/images/icon/gold.png">'.intval($_GET['sdat']).'';
header('Location: /clan/kazna?id='.intval($_GET['id']).'');
$ggold=$user['gold']-$gold;
$gggold=$clan['gold']+$gold;
$t=time(); 
$kl = intval($_GET['sdat']);
$cen=$kl*100;
$altar = mysql_result(mysql_query("SELECT COUNT(*) FROM `logi` WHERE `user_id` = '".$user['id']."' and `text` = 'казна'"),0);
if($altar==0){mysql_query("INSERT INTO `logi` set `user_id` = '".$user['id']."', `text` = 'казна', `time` = '".time()."', `kol`='$cen', `kto`='-'");}else{
mysql_query("UPDATE `logi` set  `time` = '".$tm."', `kol`=`kol`+'$cen', `kto`='-' WHERE `user_id` = '".$user['id']."' and `text` = 'казна'");}

mysql_query("INSERT INTO `zur_gold` set `kto` = '".$user['id']."', `kol`=".intval($_GET['sdat']).", `time` = '".$t."', `clan`='$id'");
mysql_query("UPDATE `user` set `gold` = '$ggold' where `id` = '".$user['id']."'");
mysql_query("UPDATE `clan` set `gold` = '$gggold' where `id` = '".$clan['id']."'");
}else{$_SESSION['err'] = $err;}}

$go=floor($clan['gold']/100);
$gold=$clan['gold'];
$b=mb_strlen($gold);
$z=$gold[$b-2].$gold[$b-1];
echo"<div class='d-grey'><div class='empty'></div>Сейчас в казне: <img src='/images/icon/gold.png'>$go <img src='/images/icon/silver.png'>$z<div class='empty'></div></div><hr>";
echo"<div class='foot center'>Сдать золото</br><div class='empty2'></div>
 <table  class='foot' width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody>
<tr>
<td width='16%'> <a class='big-but' href='/clan/kazna?id=".intval($_GET['id'])."&sdat=10'><div class='imgwrap'><img src='/images/icon/gold.png'></div>10</a></td>
<td width='16%'> <a class='big-but' href='/clan/kazna?id=".intval($_GET['id'])."&sdat=50'><div class='imgwrap'><img src='/images/icon/gold.png'></div>50</a></td>
<td width='16%'> <a class='big-but' href='/clan/kazna?id=".intval($_GET['id'])."&sdat=100'><div class='imgwrap'><img src='/images/icon/gold.png'></div>100</a></td>
<td width='16%'> <a class='big-but' href='/clan/kazna?id=".intval($_GET['id'])."&sdat=500'><div class='imgwrap'><img src='/images/icon/gold.png'></div>500</a></td>
<td width='16%'> <a class='big-but' href='/clan/kazna?id=".intval($_GET['id'])."&sdat=1000'><div class='imgwrap'><img src='/images/icon/gold.png'></div>1000</a></td>
<td width='16%'> <a class='big-but' href='/clan/kazna?id=".intval($_GET['id'])."&sdat=5000'><div class='imgwrap'><img src='/images/icon/gold.png'></div>5000</a></td></td></tbody></table>
</div></div><hr>";
echo"<div class='foot center'>Журнал</br><div class='empty2'></div></div><hr>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*)  FROM `zur_gold` WHERE `clan`=".intval($_GET['id']).""),0);
$k_page = k_page($k_post,10);
$page = page($k_page);
$start = 10*$page-10;
$q = mysql_query("SELECT * FROM `zur_gold` WHERE `clan`='".intval($_GET['id'])."'  ORDER BY `id` DESC LIMIT $start, 10");
while($post = mysql_fetch_array($q)) {
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = $post[kto] LIMIT 1"));
echo"<div class='foot'> <table   width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody>
<tr><td><a href='/user/$ank[id]/'>";
if($ank['prava']=="5"){$status="<font color='ffc22b'>[A]</font>";$color="#F7990D";}
if($ank['prava']=="4"){$status="<font color='ffc22b'>[a]</font>";$color="EBC621";}
if($ank['prava']=="3"){$status="<font color='ffc22b'>[M]</font>";}
if($ank['prava']=="2"){$status="<font color='ffc22b'>[m]</font>";}
echo online($ank['id']);
echo'<font color='.$ank['font'].'> '.$ank['nick'].'</font></a>';
if($ank['prava']>"1"){echo" $status";}echo', <img src="/images/icon/gold.png">'.$post['kol'].' ';
echo'</td><td><span class="float-right grey">'.vremja($post['time']).'</span></div></td></tbody></table></div><hr> ';
}
$avto = mysql_num_rows($q);
if($avto==0){echo"<div class='foot'>Пусто</div><hr>";}
if ($k_page>1){

str('?id='.intval($_GET['id']).'&',$k_page,$page); // Вывод страниц
echo "<hr>";

}
 echo"<div class='head center'><div class='empty2'></div>Все ваши вклады записываются в журнал.<div class='empty2'></div></div>";

require_once '../core/foot.php';
?>