2022-06-06 21:30:34 +00:00
< ? php
2023-04-15 22:54:07 +00:00
use Core\ConversionHelper ;
2022-08-25 11:23:36 +00:00
header ( 'Expires: Mon, 26 Jul 1970 05:00:00 GMT' );
header ( 'Last-Modified: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' );
header ( 'Cache-Control: no-store, no-cache, must-revalidate' );
header ( 'Cache-Control: post-check=0, pre-check=0' , false );
header ( 'Pragma: no-cache' );
2023-01-10 17:26:14 +00:00
2022-08-25 11:23:36 +00:00
if ( $_SERVER [ 'HTTP_X_REQUESTED_WITH' ] == 'XMLHttpRequest' ) {
define ( 'GAME' , true );
include ( '_incl_data/__config.php' );
include ( '_incl_data/class/__db_connect.php' );
$u = User :: start ();
2022-06-06 21:30:34 +00:00
2022-08-25 11:23:36 +00:00
if ( $u -> info [ 'repass' ] > 0 ) {
die ();
}
if ( isset ( $u -> tfer [ 'id' ]) && $u -> info [ 'align' ] != 2 ) {
if ( $u -> tfer [ 'finish1' ] == 0 && $u -> tfer [ 'finish2' ] == 0 ) {
$js = '' ;
$mn = 0 ;
if ( isset ( $_POST [ 'cancel2' ])) {
$u -> tfer [ 'r0' ] = time ();
$u -> tfer [ 'good1' ] = 0 ;
$u -> tfer [ 'good2' ] = 0 ;
$_POST [ 'id' ] = 'reflesh' ;
mysql_query (
'UPDATE `transfers` SET `r0` = "' . $u -> tfer [ 'r0' ] . '",`r1` = "0",`r2` = "0",`good1` = "0",`good2` = "0" WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
} elseif ( isset ( $_POST [ 'start2' ])) {
2023-01-10 16:29:32 +00:00
//сохраняем обмен
2022-08-25 11:23:36 +00:00
if ( $u -> tfer [ 'good1' ] > 0 && $u -> tfer [ 'good2' ] > 0 ) {
2023-01-10 16:29:32 +00:00
//завершаем обмен
2022-08-25 11:23:36 +00:00
$u -> tfer [ 'cancel1' ] = time ();
$u -> tfer [ 'cancel2' ] = time ();
$u -> tfer [ 'finish1' ] = time ();
$u -> tfer [ 'finish2' ] = time ();
2023-01-10 16:29:32 +00:00
//меняем вещи + передаем К Р и завершаем передачи, переход на лог передач
2022-08-25 11:23:36 +00:00
$upd2 = mysql_query (
'UPDATE `transfers` SET `cancel1` = "' . $u -> tfer [ 'cancel1' ] . '",`cancel2` = "' . $u -> tfer [ 'cancel2' ] . '",`finish1` = "' . $u -> tfer [ 'finish1' ] . '",`finish2` = "' . $u -> tfer [ 'finish2' ] . '" WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
2023-01-10 16:29:32 +00:00
//Обмениваем деньги
2022-08-25 11:23:36 +00:00
$mn1 = 0 ;
$mn2 = 0 ;
$inf = [];
$inf [ $u -> tfer [ 'uid1' ]] = mysql_fetch_array (
mysql_query ( 'SELECT * FROM `users` WHERE `id` = "' . $u -> tfer [ 'uid1' ] . '" LIMIT 1' )
);
$inf [ $u -> tfer [ 'uid2' ]] = mysql_fetch_array (
mysql_query ( 'SELECT * FROM `users` WHERE `id` = "' . $u -> tfer [ 'uid2' ] . '" LIMIT 1' )
);
if ( $inf [ $u -> tfer [ 'uid1' ]][ 'money' ] < $u -> tfer [ 'money1' ]) {
$u -> tfer [ 'money1' ] = $inf [ $u -> tfer [ 'uid1' ]][ 'money' ];
}
if ( $inf [ $u -> tfer [ 'uid2' ]][ 'money' ] < $u -> tfer [ 'money2' ]) {
$u -> tfer [ 'money2' ] = $inf [ $u -> tfer [ 'uid2' ]][ 'money' ];
}
$mn1 = $u -> tfer [ 'money1' ];
$mn2 = $u -> tfer [ 'money2' ];
if ( $mn1 < 0 ) {
$mn1 = 0 ;
}
if ( $mn2 < 0 ) {
$mn2 = 0 ;
}
if ( $mn1 > 0 ) {
2023-01-10 16:29:32 +00:00
//игрок 1 передает деньги игроку 2
2022-08-25 11:23:36 +00:00
$upd = mysql_query (
'UPDATE `users` SET `money` = `money` - "' . $mn1 . '" WHERE `id` = "' . $inf [ $u -> tfer [ 'uid1' ]][ 'id' ] . '" LIMIT 1'
);
if ( $upd ) {
$upd = mysql_query (
'UPDATE `users` SET `money` = `money` + "' . $mn1 . '" WHERE `id` = "' . $inf [ $u -> tfer [ 'uid2' ]][ 'id' ] . '" LIMIT 1'
);
if ( $upd ) {
$u -> addDelo (
2 , $inf [ $u -> tfer [ 'uid1' ]][ 'id' ],
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer.MONEY</font>": Передано ' . $mn1 . ' кр. персонажу "' . $inf [ $u -> tfer [ 'uid2' ]][ 'login' ] . '" (' . $inf [ $u -> tfer [ 'uid2' ]][ 'id' ] . ').' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
$u -> addDelo (
2 , $inf [ $u -> tfer [ 'uid2' ]][ 'id' ],
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer.MONEY</font>": Получено ' . $mn1 . ' кр. от персонажа "' . $inf [ $u -> tfer [ 'uid1' ]][ 'login' ] . '" (' . $inf [ $u -> tfer [ 'uid1' ]][ 'id' ] . ').' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
} else {
$u -> addDelo (
2 , $inf [ $u -> tfer [ 'uid1' ]][ 'id' ],
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer.MONEY</font>": Передано ' . $mn1 . ' кр. персонажу "' . $inf [ $u -> tfer [ 'uid2' ]][ 'login' ] . '" (' . $inf [ $u -> tfer [ 'uid2' ]][ 'id' ] . '), ошибка во время передачи.' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
}
}
}
if ( $mn2 > 0 ) {
2023-01-10 16:29:32 +00:00
//игрок 2 передает деньги игроку 1
2022-08-25 11:23:36 +00:00
$upd = mysql_query (
'UPDATE `users` SET `money` = `money` - "' . $mn2 . '" WHERE `id` = "' . $inf [ $u -> tfer [ 'uid2' ]][ 'id' ] . '" LIMIT 1'
);
if ( $upd ) {
$upd = mysql_query (
'UPDATE `users` SET `money` = `money` + "' . $mn2 . '" WHERE `id` = "' . $inf [ $u -> tfer [ 'uid1' ]][ 'id' ] . '" LIMIT 1'
);
if ( $upd ) {
$u -> addDelo (
2 , $inf [ $u -> tfer [ 'uid2' ]][ 'id' ],
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer.MONEY</font>": Передано ' . $mn2 . ' кр. персонажу "' . $inf [ $u -> tfer [ 'uid1' ]][ 'login' ] . '" (' . $inf [ $u -> tfer [ 'uid1' ]][ 'id' ] . ').' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
$u -> addDelo (
2 , $inf [ $u -> tfer [ 'uid1' ]][ 'id' ],
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer.MONEY</font>": Получено ' . $mn2 . ' кр. от персонажа "' . $inf [ $u -> tfer [ 'uid2' ]][ 'login' ] . '" (' . $inf [ $u -> tfer [ 'uid2' ]][ 'id' ] . ').' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
} else {
$u -> addDelo (
2 , $inf [ $u -> tfer [ 'uid2' ]][ 'id' ],
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer.MONEY</font>": Передано ' . $mn2 . ' кр. персонажу "' . $inf [ $u -> tfer [ 'uid1' ]][ 'login' ] . '" (' . $inf [ $u -> tfer [ 'uid1' ]][ 'id' ] . '), ошибка во время передачи.' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
}
}
}
2023-01-10 16:29:32 +00:00
//Обмениваем предметы
2022-08-25 11:23:36 +00:00
$sp = mysql_query (
'SELECT `u`.*,`m`.`price1`,`m`.`price2`,`m`.`name` FROM `items_users` AS `u` LEFT JOIN `items_main` AS `m` ON `m`.`id` = `u`.`item_id` WHERE (`u`.`uid`="' . $u -> tfer [ 'uid1' ] . '" OR `u`.`uid`="' . $u -> tfer [ 'uid2' ] . '") AND `u`.`delete`="0" AND `u`.`inOdet`="0" AND `u`.`inShop`="0" AND `u`.`inTransfer` > "0" AND `u`.`data` NOT LIKE "%|zazuby=%"'
);
$nalog = 0 ;
$fu = 0 ;
$x = 0 ;
$uus = [];
while ( $pl = mysql_fetch_array ( $sp )) {
$x = $u -> itemsX ( $pl [ 'id' ], $pl [ 'uid' ]);
$fu = $pl [ 'uid' ];
if ( $pl [ 'uid' ] == $u -> tfer [ 'uid1' ]) {
$pl [ 'uid' ] = $u -> tfer [ 'uid2' ];
} elseif ( $pl [ 'uid' ] == $u -> tfer [ 'uid2' ]) {
$pl [ 'uid' ] = $u -> tfer [ 'uid1' ];
}
$us = $inf [ $pl [ 'uid' ]];
$uus = $inf [ $fu ];
if ( $pl [ 'inTransfer' ] == 1 ) {
2023-01-10 16:29:32 +00:00
//подарок
2022-08-25 11:23:36 +00:00
$pl [ 'gift' ] = $uus [ 'login' ];
} else {
2023-01-10 16:29:32 +00:00
//налог
2022-08-25 11:23:36 +00:00
$nalog += 1 ;
}
$upd = mysql_query (
'UPDATE `items_users` SET `uid` = "' . $pl [ 'uid' ] . '",`gift` = "' . $pl [ 'gift' ] . '" WHERE `id` = "' . $pl [ 'id' ] . '" AND `inShop` = "0" AND `delete` < "1234567891" AND `inOdet` = "0" AND `data` NOT LIKE "%|zazuby=%"'
);
if ( $upd ) {
if ( $pl [ '2price' ] == 0 && $pl [ '1price' ] == 0 ) {
$pl [ '2price' ] = $pl [ 'price2' ];
}
if ( $pl [ '1price' ] == 0 && $pl [ '2price' ] == 0 ) {
$pl [ '1price' ] = $pl [ 'price1' ];
}
2023-04-15 22:54:07 +00:00
$po = ConversionHelper :: dataStringToArray ( $pl [ 'data' ]);
2022-08-25 11:23:36 +00:00
$i_s = '' ;
if ( isset ( $po [ 'frompisher' ]) && $po [ 'frompisher' ] > 0 ) {
2023-01-10 16:29:32 +00:00
$i_s = '[Предмет из подземелья]' ;
2022-08-25 11:23:36 +00:00
}
2023-01-10 16:29:32 +00:00
//заносим в личные дела
2022-08-25 11:23:36 +00:00
$u -> addDelo (
2 , $fu ,
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer</font>": Предмет "<b>' . $pl [ 'name' ] . '</b> (стоимость: ' . $pl [ '1price' ] . ' кр. , ' . $pl [ '2price' ] . ' екр.) (x' . $x . ')" [itm:' . $pl [ 'id' ] . '] ' . $i_s . ' был передан персонажу "' . $us [ 'login' ] . '"(' . $pl [ 'uid' ] . '), Тип передачи: ' . $pl [ 'inTransfer' ] . '.' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
$u -> addDelo (
2 , $pl [ 'uid' ],
2023-01-10 16:29:32 +00:00
'"<font color="green">System.transfer</font>": Персонаж "' . $uus [ 'login' ] . '"(' . $uus [ 'id' ] . ') передал предмет "<b>' . $pl [ 'name' ] . '</b> ' . $i_s . ' (стоимость: ' . $pl [ '1price' ] . ' кр. , ' . $pl [ '2price' ] . ' екр.) (x' . $x . ')" [itm:' . $pl [ 'id' ] . '], Тип передачи: ' . $pl [ 'inTransfer' ] . '.' ,
2022-08-25 11:23:36 +00:00
time (), $u -> info [ 'city' ], 'System.transfer' , 0 , 0
);
} else {
2023-01-10 16:29:32 +00:00
echo 'Ошибка передачи предмета' ;
2022-08-25 11:23:36 +00:00
}
}
$upd1 = mysql_query (
'UPDATE `items_users` SET `inTransfer` = "0" WHERE (`uid`="' . $u -> tfer [ 'uid1' ] . '" OR `uid`="' . $u -> tfer [ 'uid2' ] . '") AND `delete` < "1234567891" AND `inOdet`="0" AND `inShop`="0" AND `inTransfer` > "0" AND `data` NOT LIKE "%|zazuby=%"'
);
if ( $upd1 && $upd2 ) {
$js .= 'location = location;' ;
}
unset ( $upd1 , $upd2 , $fu , $nalog , $x , $us , $uus , $inf );
} else {
2023-01-10 16:29:32 +00:00
//подтверждение обмена
2022-08-25 11:23:36 +00:00
$u -> tfer [ 'r0' ] = time ();
if ( $u -> tfer [ 'uid1' ] == $u -> info [ 'id' ]) {
$u -> tfer [ 'good1' ] = time ();
$mn = 1 ;
mysql_query (
'UPDATE `transfers` SET `r0` = "' . $u -> tfer [ 'r0' ] . '",`r1` = "0",`r2` = "0",`good1` = "' . $u -> tfer [ 'good1' ] . '" WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
} else {
$u -> tfer [ 'good2' ] = time ();
$mn = 1 ;
mysql_query (
'UPDATE `transfers` SET `r0` = "' . $u -> tfer [ 'r0' ] . '",`r1` = "0",`r2` = "0",`good2` = "' . $u -> tfer [ 'good2' ] . '" WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
}
$_POST [ 'id' ] = 'reflesh' ;
}
} elseif ( $_POST [ 'id' ] == 'sale' && isset ( $_POST [ 'cancelid' ]) && $u -> tfer [ 'good1' ] == 0 && $u -> tfer [ 'good2' ] == 0 ) {
$upd = mysql_query (
'UPDATE `items_users` SET `inTransfer` = "0" WHERE `id` = "' . mysql_real_escape_string (
$_POST [ 'cancelid' ]
) . '" AND `uid`="' . $u -> info [ 'id' ] . '" AND `delete`="0" AND `inOdet`="0" AND `inShop`="0" AND `inTransfer` > "0" AND `data` NOT LIKE "%|zazuby=%" LIMIT 1'
);
if ( $upd ) {
$u -> tfer [ 'r0' ] = time ();
mysql_query (
'UPDATE `transfers` SET `r0` = "' . $u -> tfer [ 'r0' ] . '" WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
$_POST [ 'id' ] = 'reflesh' ;
}
} elseif ( $_POST [ 'id' ] == 'sale' && isset ( $_POST [ 'itemid' ]) && $u -> tfer [ 'good1' ] == 0 && $u -> tfer [ 'good2' ] == 0 ) {
$g = 1 ;
$itm = mysql_fetch_array (
mysql_query (
'SELECT `im`.*,`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`id` = "' . mysql_real_escape_string (
$_POST [ 'itemid' ]
) . '" AND `iu`.`uid`="' . $u -> info [ 'id' ] . '" AND `iu`.`delete`="0" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" AND `iu`.`inTransfer` = "0" AND `iu`.`data` NOT LIKE "%|zazuby=%" LIMIT 1'
)
);
if ( isset ( $itm [ 'id' ])) {
2023-04-15 22:54:07 +00:00
$po = ConversionHelper :: dataStringToArray ( $itm [ 'data' ]);
2022-08-25 11:23:36 +00:00
if ( isset ( $po [ 'sudba' ]) && $po [ 'sudba' ] != '0' ) {
$g = 0 ;
}
if ( $itm [ 'inTransfer' ] > 0 ) {
$g = 0 ;
}
} else {
$g = 0 ;
}
if ( $g == 1 ) {
if ( $_POST [ 'saletype' ] == 2 ) {
$g = 2 ;
} else {
$g = 1 ;
}
mysql_query (
'UPDATE `items_users` SET `inTransfer` = "' . (( int ) $g ) . '",`inGroup` = "0" WHERE `id` = "' . $itm [ 'id' ] . '" LIMIT 1'
);
$u -> tfer [ 'r0' ] = time ();
mysql_query (
'UPDATE `transfers` SET `r0` = "' . $u -> tfer [ 'r0' ] . '" WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
$_POST [ 'id' ] = 'reflesh' ;
}
}
if ( $_POST [ 'id' ] == 'reflesh' ) {
2023-01-10 16:29:32 +00:00
//обновление инвентаря
2022-08-25 11:23:36 +00:00
$i = 1 ;
while ( $i <= 6 ) {
$itmAll = '' ;
$itmAllSee = '' ;
$itmAll = $u -> genInv (
5 ,
'`iu`.`uid` = "' . $u -> info [ 'id' ] . '" AND `iu`.`data` NOT LIKE "%toclan=' . $u -> info [ 'clan' ] . '#%" AND `iu`.`delete` = 0 AND `iu`.`inOdet` =0 AND `iu`.`inShop` = 0 AND `im`.`inRazdel` = "' . $i . '" AND `iu`.`inTransfer` = 0 ORDER BY `lastUPD` DESC'
);
if ( $itmAll [ 0 ] == 0 ) {
2023-01-10 16:29:32 +00:00
$itmAllSee = '<tr><td align="center" bgcolor="#e2e0e0">ПУСТО</td></tr>' ;
2022-08-25 11:23:36 +00:00
} else {
$itmAllSee = $itmAll [ 2 ];
}
$itmAllSee = str_replace ( " ' " , " " , $itmAllSee );
$itmAllSee = str_replace ( '"' , '"' , $itmAllSee );
$itmAllSee = str_replace ( " \n " , '' , $itmAllSee );
$itmAllSee = str_replace ( " \r " , '' , $itmAllSee );
$js .= '$(\'#inv' . $i . '\').html(\'' . $itmAllSee . '\');' ;
$i ++ ;
}
unset ( $itmAll , $itmAllSee );
}
if ( $_POST [ 'id' ] == 'minireflesh' || $_POST [ 'id' ] == 'reflesh' ) {
2023-01-10 16:29:32 +00:00
//Мини обновление
2022-08-25 11:23:36 +00:00
if (( $u -> tfer [ 'start2' ] > 0 && $u -> info [ 'id' ] == $u -> tfer [ 'uid1' ]) || ( $u -> tfer [ 'start1' ] > 0 && $u -> info [ 'id' ] == $u -> tfer [ 'uid2' ])) {
$js .= 's2g();' ;
}
2023-01-10 16:29:32 +00:00
//Обновляем предметы
2022-08-25 11:23:36 +00:00
$f = 1 ;
if ( $u -> info [ 'id' ] == $u -> tfer [ 'uid2' ]) {
$f = 2 ;
}
if ( $u -> tfer [ 'r' . $f ] != $u -> tfer [ 'r0' ]) {
function itmInfotf ( $pl , $cl )
{
global $u , $c , $code ;
$x = $u -> itemsX ( $pl [ 'id' ], $pl [ 'uid' ]);
if ( $x > 1 ) {
$x = ' (x' . $x . ')' ;
} else {
$x = '' ;
}
$r = '' ;
if ( $pl [ 'uid' ] == $u -> info [ 'id' ]) {
2023-03-31 18:30:14 +00:00
$r .= '<img width="13" height="13" onClick="cancelitm(' . $pl [ 'id' ] . ');" class="clr" src="//img.new-combats.tech/i/clear.gif" />' ;
2022-08-25 11:23:36 +00:00
}
$r .= '<a href="items_info.php?id=' . $pl [ 'item_id' ] . '&rnd=' . $code . '" target="_blank">' . $pl [ 'name' ] . '' . $x . '</a><br>' ;
if ( $pl [ 'inTransfer' ] == 1 ) {
2023-03-31 18:30:14 +00:00
$r .= '<img width="16" height="18" title="Этот предмет будет подарен" src="//img.new-combats.tech/i/podarok.gif" />' ;
2022-08-25 11:23:36 +00:00
} else {
2023-01-10 16:29:32 +00:00
$r .= '<small style="font-size:10px">(налог: 1кр .)</small>' ;
2022-08-25 11:23:36 +00:00
}
2023-03-31 18:30:14 +00:00
$r = '<table width="100%" border="0" cellspacing="0" cellpadding="5"><tr><td width="50" align="center"><img src="//img.new-combats.tech/i/items/' . $pl [ 'img' ] . '" class="tfii"/></td><td valign="top" class="tfid">' . $r . '</td></tr></table>' ;
2022-08-25 11:23:36 +00:00
$r = '<div class="tfitm' . $cl . '">' . $r . '</div>' ;
unset ( $x );
return $r ;
}
2023-01-10 16:29:32 +00:00
//Точно обновляем :)
2022-08-25 11:23:36 +00:00
$itm = [ 1 => '' , 2 => '' ];
2023-01-10 16:29:32 +00:00
//предметы персонажа 1
2022-08-25 11:23:36 +00:00
$sp = mysql_query (
'SELECT `im`.*,`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`uid`="' . $u -> tfer [ 'uid1' ] . '" AND `iu`.`delete`="0" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" AND `iu`.`inTransfer` > "0" AND `iu`.`data` NOT LIKE "%|zazuby=%" ORDER BY `iu`.`lastUPD` DESC'
);
$cl = 2 ;
while ( $pl = mysql_fetch_array ( $sp )) {
if ( $cl == 2 ) {
$cl = 1 ;
} else {
$cl = 2 ;
}
$itm [ 1 ] .= itmInfotf ( $pl , $cl );
}
2023-01-10 16:29:32 +00:00
//предметы персонажа 2
2022-08-25 11:23:36 +00:00
$sp = mysql_query (
'SELECT `im`.*,`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`uid`="' . $u -> tfer [ 'uid2' ] . '" AND `iu`.`delete`="0" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" AND `iu`.`inTransfer` > "0" AND `iu`.`data` NOT LIKE "%|zazuby=%" ORDER BY `iu`.`lastUPD` DESC'
);
$cl = 2 ;
while ( $pl = mysql_fetch_array ( $sp )) {
if ( $cl == 2 ) {
$cl = 1 ;
} else {
$cl = 2 ;
}
$itm [ 2 ] .= itmInfotf ( $pl , $cl );
}
unset ( $cl );
if ( $itm [ 1 ] == '' ) {
$itm [ 1 ] = ' ' ;
}
if ( $itm [ 2 ] == '' ) {
$itm [ 2 ] = ' ' ;
}
if ( $u -> info [ 'id' ] == $u -> tfer [ 'uid1' ]) {
$js .= '$("#s2g3").html(\'' . $itm [ 1 ] . '\');$("#s2g2").html(\'' . $itm [ 2 ] . '\');' ;
} else {
$js .= '$("#s2g3").html(\'' . $itm [ 2 ] . '\');$("#s2g2").html(\'' . $itm [ 1 ] . '\');' ;
}
$u -> tfer [ 'r' . $f ] = $u -> tfer [ 'r0' ];
mysql_query (
'UPDATE `transfers` SET `r' . $f . '` = "' . $u -> tfer [ 'r' . $f ] . '" WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
}
if (( $u -> tfer [ 'good1' ] > 0 && $u -> info [ 'id' ] == $u -> tfer [ 'uid1' ]) || ( $u -> tfer [ 'good2' ] > 0 && $u -> info [ 'id' ] == $u -> tfer [ 'uid2' ])) {
2023-01-10 16:29:32 +00:00
$js .= '$(\'#btn1\').html(\'Обменять\');' ;
2022-08-25 11:23:36 +00:00
if ( $u -> tfer [ 'good1' ] > 0 && $u -> tfer [ 'good2' ] > 0 ) {
$js .= '$(\'#btn1\').attr(\'disabled\',\'\');' ;
} else {
$js .= '$(\'#btn1\').attr(\'disabled\',\'disabled\');' ;
}
} else {
2023-01-10 16:29:32 +00:00
$js .= '$(\'#btn1\').html(\'Готов к обмену\');$(\'#btn1\').attr(\'disabled\',\'\');' ;
2022-08-25 11:23:36 +00:00
}
2023-01-10 16:29:32 +00:00
//Обновляем деньги в кассе :)
2022-08-25 11:23:36 +00:00
if ( $u -> tfer [ 'uid1' ] == $u -> info [ 'id' ]) {
if ( $u -> tfer [ 'good1' ] > 0 ) {
$js .= '$(\'#gd2\').css(\'display\',\'\');' ;
} else {
$js .= '$(\'#gd2\').css(\'display\',\'none\');' ;
2023-01-10 16:29:32 +00:00
} //вы
2022-08-25 11:23:36 +00:00
if ( $u -> tfer [ 'good2' ] > 0 ) {
$js .= '$(\'#gd1\').css(\'display\',\'\');' ;
} else {
$js .= '$(\'#gd1\').css(\'display\',\'none\');' ;
}
if (( $u -> tfer [ 'good1' ] == 0 && $u -> tfer [ 'good2' ] == 0 ) || $mn == 1 ) {
if ( $u -> tfer [ 'money1' ] != round ( $_POST [ 'money' ], 2 )) {
$u -> tfer [ 'money1' ] = round ( $_POST [ 'money' ], 2 );
if ( $u -> tfer [ 'money1' ] > $u -> info [ 'money' ]) {
$u -> tfer [ 'money1' ] = $u -> info [ 'money' ];
}
if ( $u -> tfer [ 'money1' ] < 0 ) {
$u -> tfer [ 'money1' ] = 0 ;
}
mysql_query (
'UPDATE `transfers` SET `money1` = "' . mysql_real_escape_string (
$u -> tfer [ 'money1' ]
) . '",`good1` = 0,`good2` = 0 WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
}
}
} else {
if ( $u -> tfer [ 'good2' ] > 0 ) {
$js .= '$(\'#gd2\').css(\'display\',\'\');' ;
} else {
$js .= '$(\'#gd2\').css(\'display\',\'none\');' ;
2023-01-10 16:29:32 +00:00
} //вы
2022-08-25 11:23:36 +00:00
if ( $u -> tfer [ 'good1' ] > 0 ) {
$js .= '$(\'#gd1\').css(\'display\',\'\');' ;
} else {
$js .= '$(\'#gd1\').css(\'display\',\'none\');' ;
}
if (( $u -> tfer [ 'good1' ] == 0 && $u -> tfer [ 'good2' ] == 0 ) || $mn == 1 ) {
if ( $u -> tfer [ 'money2' ] != round ( $_POST [ 'money' ], 2 )) {
$u -> tfer [ 'money2' ] = round ( $_POST [ 'money' ], 2 );
if ( $u -> tfer [ 'money2' ] > $u -> info [ 'money' ]) {
$u -> tfer [ 'money2' ] = $u -> info [ 'money' ];
}
if ( $u -> tfer [ 'money1' ] < 0 ) {
$u -> tfer [ 'money1' ] = 0 ;
}
mysql_query (
'UPDATE `transfers` SET `money2` = "' . mysql_real_escape_string (
$u -> tfer [ 'money2' ]
) . '",`good1` = 0,`good2` = 0 WHERE `id` = "' . $u -> tfer [ 'id' ] . '" LIMIT 1'
);
}
}
}
if ( $u -> info [ 'id' ] == $u -> tfer [ 'uid1' ]) {
$js .= 'refmoney(' . $u -> round2 ( $u -> tfer [ 'money2' ]) . ',' . $u -> round2 ( $u -> tfer [ 'money1' ]) . ');' ;
} else {
$js .= 'refmoney(' . $u -> round2 ( $u -> tfer [ 'money1' ]) . ',' . $u -> round2 ( $u -> tfer [ 'money2' ]) . ');' ;
}
}
if ( $js != '' ) {
echo '<script>' . $js . '</script>' ;
}
} else {
echo '<script>location="main.php?transfer&rnd=' . $code . '";</script>' ;
}
} else {
echo '<script>location="main.php?transfer&exit_transfer&rnd=' . $code . '";</script>' ;
}
2022-06-06 21:30:34 +00:00
}