View file sdark.mobi/master/accelerate.php

File size: 2.64Kb
<?
require_once'../core/system.php';
echo only_reg();
echo ban();
echo blok();
$header='Ускорение работы';
require_once'../core/head.php';

if($user['level'] < 7){
header('location: /'); 
$_SESSION['err'] = 'Доступно только с 7 уровня';
}

$lot = intval($_GET['id']);
echo "</div><div class='foot center'><table  class='d-grey' width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody><tr>";
$req = mysql_query("SELECT * FROM `master` WHERE `usr` = '$user[id]' and `lot` = '$lot'");
$master = mysql_fetch_array($req);
$koll=$master['time']-time();
//$kolll=ceil($koll/3600);
$kolll=ceil($koll/4500); //14400
echo '<div class="inpc-ar"><div class="empty2"></div>Вы уверены, что хотите ускорить работу за <img src="/images/icon/gold.png">'.$kolll.'? (<font color="#D5D539">-25%</font>)</div><div class="empty2"></div>
<td width="40%"><a class="big-but" href="/master/accelerate?id='.abs(intval($_GET['id'])).'&yes"><div class="imgwrap"><img src="/images/icon/ok.png"></div>Ускорить работу</a></td>';
echo '<td width="40%"><a class="big-but" href="/master/"><div class="imgwrap"><img src="/images/icon/error.png"></div>Отмена</a></td></tbody></table></div></div>';
echo "</div>";

if(isset($_GET['yes'])) {
$req = mysql_query("SELECT * FROM `master` WHERE `usr` = '$user[id]' and `lot` = '$lot'");
$master = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){
header("Location: /master/");
$_SESSION['err'] = 'Ошибка';
exit;
}
if($master['time'] < $time){	
$_SESSION['err'] = 'Ошибка';
header("Location: /master/");
exit;
}
$goldik=$kolll*100;
if($user['gold']<$goldik){
header("Location: /master/");
$_SESSION['err'] = 'Недостаточно золота';
exit;
}

$t=time();
$rest = mysql_result(mysql_query("SELECT COUNT(*) FROM `logi` WHERE `user_id` = '".$user['id']."' and `text` = 'ускорение'"),0);
if($rest==0){mysql_query("INSERT INTO `logi` set `user_id` = '".$user['id']."', `text` = 'ускорение', `time` = '".$t."', `kol`='$goldik', `kto`='-'");}else{
mysql_query("UPDATE `logi` set `time` = '".$tm."', `kol`=`kol`+'$goldik', `kto`='-' WHERE `user_id` = '".$user['id']."' and `text` = 'ускорение'");}
mysql_query("DELETE FROM `master` WHERE `lot` = '".$lot."' and `usr` = '".$user[id]."'");
mysql_query("UPDATE `user` SET  `$master[img]`=`$master[img]`+'$master[kol]', `master`=`master`+'$master[kol]', `gold`=`gold`-'$goldik' WHERE `id`='$user[id]'");
header("Location: /master/");//,`snow`=`snow`+'$master[kol]'  
$_SESSION['message'] = " Работа завершена";
}
require_once'../core/foot.php';
?>