Оптимизация логики, минус один запрос в БД.
This commit is contained in:
parent
d5bafe4e77
commit
71b3a1c946
@ -1201,56 +1201,50 @@ FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`
|
||||
return $bus['login_BIG'];
|
||||
}
|
||||
|
||||
public function microLogin(int $id, $t, $nnz = 1): string
|
||||
public function microLogin(int $id, int $t, int $nnz = 1): string
|
||||
{
|
||||
if ($t == 1) {
|
||||
$inf = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT
|
||||
`u`.`id`,
|
||||
`u`.`align`,`u`.`align2`,
|
||||
`u`.`login`,
|
||||
`u`.`clan`,
|
||||
`u`.`level`,
|
||||
`u`.`city`,
|
||||
`u`.`online`,
|
||||
`u`.`sex`,`u`.`autospell`,`u`.`noplaw`,
|
||||
`u`.`cityreg`,
|
||||
`u`.`palpro`,
|
||||
`u`.`invis`,
|
||||
`st`.`hpNow` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`id`="' . mysql_real_escape_string(
|
||||
$id
|
||||
) . '" OR `u`.`login` = "' . mysql_real_escape_string((int)$id) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
if ($t !== 1) {
|
||||
$inf['id'] = $id;
|
||||
} else {
|
||||
$inf = Db::getRow(
|
||||
'select
|
||||
users.id,
|
||||
invis,
|
||||
users.align,
|
||||
align2,
|
||||
clan,
|
||||
cityreg,
|
||||
login,
|
||||
users.level,
|
||||
c.name_mini
|
||||
from users left join clan as c on c.id = users.clan
|
||||
where users.id = ?',
|
||||
[$id]
|
||||
);
|
||||
}
|
||||
$r = '';
|
||||
if (isset($inf['id']) && (($inf['invis'] < time(
|
||||
) && $inf['invis'] != 1) || ($this->info['id'] == $inf['id'] && $nnz == 1))) {
|
||||
if (
|
||||
isset($inf['id']) &&
|
||||
(
|
||||
($inf['invis'] < time() && $inf['invis'] !== 1) ||
|
||||
($this->info['id'] == $inf['id'] && $nnz === 1)
|
||||
)
|
||||
) {
|
||||
if ($inf['align'] > 0) {
|
||||
$r .= '<img src="https://img.new-combats.com/i/align/align' . $inf['align'] . '.gif" />';
|
||||
$r .= '<img src="https://' . Config::get('img') . '/i/align/align' . $inf['align'] . '.gif" />';
|
||||
}
|
||||
if ($inf['align2'] > 0) {
|
||||
$r .= '<img src="https://img.new-combats.com/i/align/align' . $inf['align2'] . '.gif" />';
|
||||
$r .= '<img src="https://' . Config::get('img') . '/i/align/align' . $inf['align2'] . '.gif" />';
|
||||
}
|
||||
if ($inf['clan'] > 0) {
|
||||
$cln = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`name`,`name_mini`,`align`,`type_m`,`money1`,`exp` FROM `clan` WHERE `id` = "' . $inf['clan'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($cln['id'])) {
|
||||
$r .= '<img src="https://img.new-combats.com/i/clan/' . $cln['name_mini'] . '.gif" />';
|
||||
}
|
||||
if ($inf['name_mini']) {
|
||||
$r .= '<img src="https://' . Config::get('img') . '/i/clan/' . $inf['name_mini'] . '.gif" />';
|
||||
}
|
||||
if ($inf['cityreg'] == '') {
|
||||
$inf['cityreg'] = 'capitalcity';
|
||||
}
|
||||
$r .= ' <strong>' . $inf['login'] . '</strong> [' . $inf['level'] . ']<a target="_blank" href="https://new-combats.com/info/' . $inf['id'] . '"><img src="https://img.new-combats.com/i/inf_' . $inf['cityreg'] . '.gif" /></a>';
|
||||
$r .= '<strong>' . $inf['login'] . '</strong> [' . $inf['level'] . ']<a target="_blank" href="' . Config::get('https') . '/info/' . $inf['id'] . '"><img src="https://' . Config::get('img') . '/i/inf_' . $inf['cityreg'] . '.gif" /></a>';
|
||||
} else {
|
||||
$r = '<strong><i>Íåâèäèìêà</i></strong> [??]<a target="_blank" href="https://new-combats.com/info/0"><img src="https://img.new-combats.com/i/inf_capitalcity.gif" /></a>';
|
||||
$r = '<strong><i>Íåâèäèìêà</i></strong> [??]';
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user