* @todo проверить на конфликты с cshop_returnToOwner. * @todo Вернуть запросы взад и вывести их из циклов. "нормальный крон", ёпт, под какими веществами я это делал? */ const TIME_LAST = 86400; // 1 day const AUC = 'Филиал Аукциона'; const AUC_WIN = 'Вы выиграли торги. Предмет "%s" за %s кр. был добавлен к вам в инвентарь.'; const AUC_SELL = 'Предмет "%s" был продан на торгах, %s кр. за товар отправлены вам по почте.'; const AUC_SELL_LOG = 'Филиал Аукциона: Предмет "%s" был продан за %s кр.'; const AUC_NOT_SELL = 'Предмет "%s" не был продан, он возвращен вам в инвентарь.'; $query = [ //all queries 'insert into chat (new, login, `to`, text, time, type) values (1, ?, ?, ?, unix_timestamp(), 6)', 'select * from items_auc where time_end = 0 and time < unix_timestamp() - ? order by user_buy', 'select login from users where id = ?', 'select count(*) from users where id = ?', 'update items_users set uid = ?, lastUPD = unix_timestamp() where (id = ? or inGroup = ?) and uid = 0', 'insert into items_users (`delete`, item_id, 1price, uid, lastUPD, `data`) values (0, 1220, ?, ?, unix_timestamp(), ?)', 'insert into post (uid, sender_id, time, money, text) values (?, 0, unix_timestamp(), ?, ?)', 'update items_auc set time_end = unix_timestamp() where id = ?', ]; $sp = Db::getRow($query[1], [TIME_LAST]); foreach ($sp as $pl) { if ($pl['x'] > 0) { $pl['name'] .= ' (x' . $pl['x'] . ')'; } $userLogin = Db::getValue($query[2], [$pl['uid']]); if ($pl['user_buy'] && Db::getValue($query[3], [$pl['user_buy']])) { Db::sql($query[4], [$pl['user_buy'], $pl['item_id'], $pl['item_id']]); Db::sql($query[0], [AUC, $pl['user_buy'], sprintf(AUC_WIN, $pl['name'], $pl['price'])]); if ($userLogin) { Db::sql($query[0], [AUC, $userLogin, sprintf(AUC_SELL, $pl['name'], $pl['price'])]); Db::sql($query[5], [$pl['price'], '-51' . $pl['uid'], '']); Db::sql($query[6], [$pl['uid'], $pl['price'], sprintf(AUC_SELL_LOG, $pl['name'], $pl['price'])]); } } elseif ($userLogin) { Db::sql($query[4], [$pl['uid'], $pl['item_id'], $pl['item_id']]); Db::sql($query[0], [AUC, $userLogin, sprintf(AUC_NOT_SELL, $pl['name'])]); } Db::sql($query[7], [$pl['id']]); }