mysql_query("INSERT INTO `house`(`owner`,`type`,`starttime`,`endtime`,`balance`,`weekcost`) VALUES ('".mysql_real_escape_string($u->info['id'])."','".mysql_real_escape_string($_GET['arenda'])."','".time()."','".(time()+604800)."','1','1')");
mysql_query("UPDATE `users` SET `money` = `money`-1 WHERE `id` = '".mysql_real_escape_string($u->info['id'])."';");
$level=2;
$u->info['money']-=1;
$objaga['balance']=1;
$objaga['endtime']=time()+604800;
$err="<FONT COLOR=red><B>Вы арендовали 'Койку в общежитии' за 1 кр.<BR></B></FONT><BR>";
mysql_query("INSERT INTO `house`(`owner`,`type`,`starttime`,`endtime`,`balance`,`weekcost`) VALUES ('".mysql_real_escape_string($u->info['id'])."','".mysql_real_escape_string($_GET['arenda'])."','".time()."','".(time()+604800)."','3','3')");
mysql_query("UPDATE `users` SET `money` = `money`-3 WHERE `id` = '".mysql_real_escape_string($u->info['id'])."';");
$level=2;
$u->info['money']-=3;
$objaga['balance']=3;
$objaga['endtime']=time()+604800;
$err="<FONT COLOR=red><B>Вы арендовали 'Койку с тумбочкой' за 3 кр.<BR></B></FONT><BR>";
mysql_query("INSERT INTO `house`(`owner`,`type`,`starttime`,`endtime`,`balance`,`weekcost`) VALUES ('".mysql_real_escape_string($u->info['id'])."','".mysql_real_escape_string($_GET['arenda'])."','".time()."','".(time()+604800)."','10','10')");
mysql_query("UPDATE `users` SET `money` = `money`-10 WHERE `id` = '".mysql_real_escape_string($u->info['id'])."';");
$level=2;
$u->info['money']-=10;
$objaga['balance']=10;
$objaga['endtime']=time()+604800;
$err="<FONT COLOR=red><B>Вы арендовали 'Койку со шкафом' за 10 кр.<BR></B></FONT><BR>";
$err="<FONT COLOR=red><B>Слишком много текста... такое не сохранить.<BR></B></FONT><BR>";
}else{
mysql_query("UPDATE `house` SET `notes` = '".mysql_real_escape_string($_POST['notes'])."' WHERE `owner` = '".mysql_real_escape_string($u->info['id'])."';");
mysql_query("UPDATE `eff_users` SET `sleeptime`=".time().",`deactiveLast` = ( `deactiveTime` - ".time()." ) WHERE `uid`='".mysql_real_escape_string($u->info['id'])."' AND `no_Ace` = 0 AND `delete` = 0");
mysql_query('UPDATE `items_users` SET `time_sleep` = "'.time().'" WHERE `uid` = "'.$u->info['id'].'" AND `delete` < 1001 AND `data` LIKE "%|sleep_moroz=1%"');
$sp=mysql_query('SELECT * FROM `items_users` WHERE `time_sleep` > 0 AND `uid` = "'.$u->info['id'].'" AND `delete` < 1001 AND `data` LIKE "%|sleep_moroz=1%"');
while($pl=mysql_fetch_array($sp)){
$tm_add=time()-$pl['time_sleep'];
mysql_query('UPDATE `items_users` SET `time_sleep` = "0",`time_create` = "'.($pl['time_create']+$tm_add).'" WHERE `id` = "'.$pl['id'].'" LIMIT 1');
}
$sp=mysql_query('SELECT `id`,`deactiveTime`,`deactiveLast` FROM `eff_users` WHERE `v1` LIKE "pgb%" AND `delete` = "0" AND `deactiveTime` > 0 AND `uid` = "'.$u->info['id'].'" ORDER BY `timeUse` DESC');
mysql_query("UPDATE `eff_users` SET `deactiveTime` = ".(time()+$pl['deactiveLast'])." WHERE `id`='".$pl['id']."' ");
}
$sp=mysql_query('SELECT `id`,`sleeptime`,`timeUse` FROM `eff_users` WHERE `uid`="'.mysql_real_escape_string($u->info['id']).'" AND `no_Ace` = 0 AND `sleeptime` > 0 AND `delete` = 0');
mysql_query("UPDATE `eff_users` SET `timeUse`='".$timeUsen."',`sleeptime`='0',`delete`='0' WHERE `id`='".$pl['id']."' ");
}
//mysql_query("UPDATE `eff_users` SET `timeUse`=(".time()."-`sleeptime`),`sleeptime`='' WHERE `uid`='".mysql_real_escape_string($u->info['id'])."' AND `id_eff`>=1 AND `id_eff`<=28 AND `id_eff`!=2 AND `id_eff`!=3 AND `id_eff`!=4 AND `id_eff`!=5 AND `id_eff`!=6 AND `id_eff`!=24 AND `sleeptime`>0");
mysql_query('UPDATE `actions` SET `vars` = "unsleep" WHERE `id` = "'.$sleep['id'].'" LIMIT 1');
$cageid=mysql_fetch_array(mysql_query("SELECT `pet_in_cage` FROM `users_animal` WHERE `pet_in_cage` = '1' AND `uid` = '".mysql_real_escape_string($u->info['id'])."'"));
if(!$cageid){$petcage=1;}else{
$cageid=mysql_fetch_array(mysql_query("SELECT `pet_in_cage` FROM `users_animal` WHERE `pet_in_cage` = '2' AND `uid` = '".mysql_real_escape_string($u->info['id'])."'"));
if(!$cageid){
$petcage=2;
}else{
$petcage=0;
}
}
if($petcage>0){
mysql_query("UPDATE `users_animal` SET `pet_in_cage` = '".$petcage."' WHERE `pet_in_cage` = '0' AND `id` = '".mysql_real_escape_string($id)."'");
mysql_query("UPDATE `users` SET `animal` = '0' WHERE `id` = '".mysql_real_escape_string($u->info['id'])."'");
mysql_query("UPDATE `users_animal` SET `pet_in_cage` = '0' WHERE (`pet_in_cage` = '1' OR `pet_in_cage` = '2') AND `id` = '".mysql_real_escape_string($_GET['pet_id'])."'");
mysql_query("UPDATE `users` SET `animal` = '".mysql_real_escape_string($_GET['pet_id'])."' WHERE `id` = '".mysql_real_escape_string($u->info['id'])."'");
}else{
$cageid=mysql_fetch_array(mysql_query("SELECT `pet_in_cage` FROM `users_animal` WHERE `pet_in_cage` = '1' AND `id` = '".mysql_real_escape_string($id)."'"));
mysql_query("UPDATE `users_animal` SET `pet_in_cage` = '".$cageid['pet_in_cage']."' WHERE `pet_in_cage` = '0' AND `id` = '".mysql_real_escape_string($_GET['pet_id'])."'");
mysql_query("UPDATE `users_animal` SET `pet_in_cage` = '0' WHERE (`pet_in_cage` = '1' OR `pet_in_cage` = '2') AND `id` = '".mysql_real_escape_string($_GET['pet_id'])."'");
mysql_query("UPDATE `users` SET `animal` = '".mysql_real_escape_string($_GET['pet_id'])."' WHERE `id` = '".mysql_real_escape_string($u->info['id'])."'");
//$err = '<FONT COLOR=red><B>УВас уже есть зверь ;)<BR></B></FONT><BR>';
}
}*/
$pet=mysql_fetch_array(mysql_query("SELECT `id`, `sex`, `name`, `level`, `obraz` FROM `users_animal` WHERE `pet_in_cage` = '0' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' AND `delete` = 0 LIMIT 1;"));
if($pet['id']!=$u->info['animal']){
$u->info['animal']=$pet['id'];
mysql_query('UPDATE `users` SET `animal` = "'.$pet['id'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
}
if(isset($_GET['pet_id'])){
$id=(int)$_GET['pet_id'];
if($_GET['pet_id']<0){
$id=-$id;
//Помещаем зверя в общагу
$cageid=mysql_fetch_array(mysql_query("SELECT `id`,`name` FROM `users_animal` WHERE `pet_in_cage` = '0' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' AND `id` = '".mysql_real_escape_string($id)."' LIMIT 1"));
if(isset($cageid['id'])){
$cageid1=mysql_fetch_array(mysql_query("SELECT `id` FROM `users_animal` WHERE `pet_in_cage` = '1' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' LIMIT 1"));
if(isset($cageid1['id'])){
$cageid2=mysql_fetch_array(mysql_query("SELECT `id` FROM `users_animal` WHERE `pet_in_cage` = '2' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' LIMIT 1"));
if(isset($cageid2['id'])){
mysql_query('UPDATE `users_animal` SET `pet_in_cage` = "0" WHERE `id` = "'.$cageid2['id'].'" LIMIT 1');
mysql_query('UPDATE `users_animal` SET `pet_in_cage` = "2" WHERE `id` = "'.$cageid['id'].'" LIMIT 1');
}else{
mysql_query('UPDATE `users_animal` SET `pet_in_cage` = "2" WHERE `id` = "'.$cageid['id'].'" LIMIT 1');
}
}else{
mysql_query('UPDATE `users_animal` SET `pet_in_cage` = "1" WHERE `id` = "'.$cageid['id'].'" LIMIT 1');
}
$err='<FONT COLOR=red><B>Вы успешно поместили "'.$cageid['name'].'" в общежитие!<BR></B></FONT><BR>';
}else{
$err='<FONT COLOR=red><B>Зверь не найден в инвентаре!<BR></B></FONT><BR>';
}
}else{
//Забираем зверя из общаги
$cageid=mysql_fetch_array(mysql_query("SELECT `id`,`name`,`pet_in_cage` FROM `users_animal` WHERE `pet_in_cage` > '0' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' AND `id` = '".mysql_real_escape_string($id)."' LIMIT 1"));
if(isset($cageid['id'])){
if($u->info['animal']>0){
mysql_query('UPDATE `users_animal` SET `pet_in_cage` = "'.$cageid['pet_in_cage'].'" WHERE `id` = "'.$u->info['animal'].'" LIMIT 1');
mysql_query('UPDATE `users_animal` SET `pet_in_cage` = "0" WHERE `id` = "'.$cageid['id'].'" LIMIT 1');
}else{
mysql_query('UPDATE `users_animal` SET `pet_in_cage` = "0" WHERE `id` = "'.$cageid['id'].'" LIMIT 1');
}
$err='<FONT COLOR=red><B>Вы успешно забрали "'.$cageid['name'].'" из общежитие!<BR></B></FONT><BR>';
}else{
$err='<FONT COLOR=red><B>Зверь не найден в общежитии!<BR></B></FONT><BR>';
}
}
}
$pet=mysql_fetch_array(mysql_query("SELECT `id`, `sex`, `name`, `level`, `obraz` FROM `users_animal` WHERE `pet_in_cage` = '0' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' AND `delete` = 0 LIMIT 1;"));
if($pet['id']!=$u->info['animal']){
mysql_query('UPDATE `users` SET `animal` = "'.$pet['id'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
}
$cage1=mysql_fetch_array(mysql_query("SELECT `id`, `sex`, `name`, `level`, `obraz`,`pet_in_cage` FROM `users_animal` WHERE `pet_in_cage` = '1' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' AND `delete` = 0 LIMIT 1;"));
$cage2=mysql_fetch_array(mysql_query("SELECT `id`, `sex`, `name`, `level`, `obraz`,`pet_in_cage` FROM `users_animal` WHERE `pet_in_cage` = '2' AND `uid` = '".mysql_real_escape_string($u->info['id'])."' AND `delete` = 0 LIMIT 1;"));
$chest=$u->genInv(7,'`iu`.`uid`="'.$u->info['id'].'" AND `iu`.`delete`="0" AND `im`.`type` != "28" AND `im`.`type` != "38" AND `im`.`type` != "39" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="1" ORDER BY `lastUPD` DESC');
$invertory=$u->genInv(8,'`iu`.`uid`="'.$u->info['id'].'" AND `iu`.`delete`="0" AND `im`.`type` != "28" AND `im`.`type` != "38" AND `im`.`type` != "39" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" ORDER BY `lastUPD` DESC');
$itmAll=$u->genInv(10,'`iu`.`uid`="'.$u->info['id'].'" AND `iu`.`delete`="0" AND (`im`.`type` = "28" OR `im`.`type` = "38" OR `im`.`type` = "39") AND `iu`.`inOdet`="0" AND `iu`.`inShop`="1" ORDER BY `lastUPD` DESC');
$itmAll=$u->genInv(10,'`iu`.`uid`="'.$u->info['id'].'" AND `iu`.`delete`="0" AND (`im`.`type` = "28" OR `im`.`type` = "38" OR `im`.`type` = "39") AND `iu`.`inOdet`="0" AND `iu`.`inShop`="1" ORDER BY `lastUPD` DESC');
$itmAll=$u->genInv(9,'`iu`.`uid`="'.$u->info['id'].'" AND `iu`.`delete`="0" AND (`im`.`type` = "28" OR `im`.`type` = "38" OR `im`.`type` = "39") AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" ORDER BY `lastUPD` DESC');
$p_now=mysql_fetch_array(mysql_query('SELECT * FROM `users_twink` WHERE `uid` = "'.$u->info['id'].'" AND `twink` = "'.$u->info['twink'].'" LIMIT 1'));
}else{
//Обновляем текущие данные
$p_now['login']=$u->info['login'];
$p_now['level']=$u->info['level'];
$p_now['exp']=$u->info['exp'];
$p_now['upLevel']=$u->info['upLevel'];
$p_now['stats']=$u->info['stats'];
$p_now['time']=time();
$p_now['ability']=$u->info['ability'];
$p_now['skills']=$u->info['skills'];
$p_now['sskills']=$u->info['sskills'];
$p_now['nskills']=$u->info['nskills'];
$p_now['priems']=$u->info['priems'];
$p_now['obraz']=$u->info['obraz'];
$p_now['win']=$u->info['win'];
$p_now['lose']=$u->info['lose'];
$p_now['nich']=$u->info['nich'];
$p_now['stopexp']=$u->info['stopexp'];
mysql_query('UPDATE`users_twink`SET
`login`="' . $u->info['login'] . '",
`level`="' . $u->info['level'] . '",
`exp`="' . $u->info['exp'] . '",
`upLevel`="' . $u->info['upLevel'] . '",
`stats`="' . $u->info['stats'] . '",
`time`="' . $u->info['time'] . '",
`ability`="' . $u->info['ability'] . '",
`skills`="' . $u->info['skills'] . '",
`sskills`="' . $u->info['sskills'] . '",
`nskills`="' . $u->info['nskills'] . '",
`priems`="' . $u->info['priems'] . '",
`obraz`="' . $u->info['obraz'] . '",
`win`="' . $u->info['win'] . '",
`lose`="' . $u->info['lose'] . '",
`nich`="' . $u->info['nich'] . '",
`stopexp`="' . $u->info['stopexp'] . '"
WHERE`id`="' . $p_now['id'] . '"LIMIT1');
}
if(isset($_GET['change_pers'])){
$p_sel=mysql_fetch_array(mysql_query('SELECT * FROM `users_twink` WHERE `uid` = "'.$u->info['id'].'" AND `id` = "'.mysql_real_escape_string($_GET['change_pers']).'" LIMIT 1'));
mysql_query('UPDATE `items_users` SET `uid` = "-91'.$u->info['id'].'" WHERE `uid` = "'.$u->info['id'].'" LIMIT 1');
mysql_query('UPDATE `items_users` SET `uid` = "'.$u->info['id'].'" WHERE `uid` = "-92'.$u->info['id'].'" LIMIT 1');
}else{
//Возвращаем вещи с твинка
mysql_query('UPDATE `items_users` SET `uid` = "-92'.$u->info['id'].'" WHERE `uid` = "'.$u->info['id'].'" LIMIT 1');
mysql_query('UPDATE `items_users` SET `uid` = "'.$u->info['id'].'" WHERE `uid` = "-91'.$u->info['id'].'" LIMIT 1');
}
//
mysql_query('UPDATE `items_users` SET `uid` = "'.$u->info['id'].'" WHERE (`uid` = "-91'.$u->info['id'].'" OR `uid` = "-92'.$u->info['id'].'") AND `inShop` = 1');
if($u->info['admin']>0){
die('UPDATE `items_users` SET `uid` = "'.$u->info['id'].'" WHERE (`uid` = "-91'.$u->info['id'].'" OR `uid` = "-92'.$u->info['id'].'") AND `inShop` = 1');