php if isset _GET hp1 if user gold 100 header Location shaman _SESSION

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
if(isset($_GET['hp1'])){
if($user['gold'] < 100){
header("Location: /shaman/");
$_SESSION['err'] = ' Недостаточно золота';
exit;
}
$hp30 = floor($user['max_health']*0.1);
$uhp30 = floor($user['max_health']*0.01);
$req = mysql_query("SELECT * FROM `bonus` WHERE `usr` = '$user[id]' and `name` = 'Бонус здоровья'");
$avto = mysql_num_rows($req);
if($avto==0){
$t=time()+3600;
$bonka = mysql_result(mysql_query("SELECT COUNT(*) FROM `logi` WHERE `user_id` = '".$user['id']."' and `text` = 'Бонус'"),0);
if($bonka==0){
mysql_query("INSERT INTO `logi` set `user_id` = '".$user['id']."', `text` = 'Бонус', `time` = '".$time."', `kol`='100', `kto`='-'");
} else {
mysql_query("UPDATE `logi` set `time` = '".$tm."', `kol`=`kol`+'100', `kto`='-' WHERE `user_id` = '".$user['id']."' and `text` = 'Бонус'");
}
//mysql_query("UPDATE `user` set `max_health` = `max_health` + '$hp30',`gold`=`gold`-'100' where `id` = '".$user['id']."'");
//mysql_query("INSERT INTO `bonus` set `usr` = ".$user['id'].", `name` = 'Бонус здоровья',`kol`='$hp30',`param`='max_health', `time` = '$t', `bonus`='+$uhp30 к здоровью', `image`='3',`typ`='0'");
$cache->write('bonus_hp_1'.$user['id'],1,$t);
///redir
} else{
header("Location: /shaman/");
$_SESSION['err'] = ' У вас уже есть бонус на здоровье';
exit;
}
header("Location: /shaman/");
$_SESSION['message'] = "Бонус активирован";
}
//////////////////////////////////////////
/*
$remq = mysql_query("SELECT * FROM `bonus` WHERE `time`<'".$time."' and `typ`='0' and `image`!='2' and `image`!='14' and `usr`='".$ank['id']."'");
$vtij = mysql_num_rows($remq);
if($vtij > 0){
While($pram = mysql_fetch_array($remq)){
mysql_query("DELETE FROM `bonus` WHERE `time`<'".$time."' and `typ`='0' and `image`!='2' and `image`!='14' and `usr`='".$ank['id']."'");
if($pram['param']!='max_health'){
mysql_query("UPDATE `user` set `".$pram['param']."` = `".$pram['param']."` - '".$pram['kol']."', `param`=`param`-'".$pram['kol']."' where `id` = '".$ank['id']."'");
} else {
mysql_query("UPDATE `user` set `".$pram['param']."` = `".$pram['param']."` - '".$pram['kol']."', `param`=`param`-('".$pram['kol']."'/'10') where `id` = '".$ank['id']."'");
}
}
header('location: ?');
}
*/
if (!empty($cache->read('bonus_hp_1'.$user['id'])))
{
$user['max_health'] +=floor($user['max_health']*0.1);
}