Refactor and optimize main.php script
The code cleanup included removing unnecessary lines and optimizing existing code snippets for better performance and readability. The script now uses a more efficient method of item generation and item pickup. The image loading process was revamped to provide a more efficient and user-friendly experience. Lastly, the HTML was reformatted into HEREDOC syntax for better readability.
This commit is contained in:
parent
f614e5ef83
commit
bfd9e0c5a3
115
main.php
115
main.php
@ -80,8 +80,6 @@ if ($u->info['banned'] > 0) {
|
||||
die();
|
||||
}
|
||||
|
||||
$tjs = '';
|
||||
|
||||
if ($u->info['bithday'] == '01.01.1800' && $u->info['inTurnirnew'] == 0) {
|
||||
unset($_GET, $_POST);
|
||||
}
|
||||
@ -419,10 +417,7 @@ if (isset($_GET['security']) && !isset($u->tfer['id']) && $trololo == 1) {
|
||||
|
||||
} else {
|
||||
if (isset($_GET['talk']) && !isset($u->tfer['id'])) {
|
||||
echo "<script>
|
||||
let elem = document.getElementById('se-pre-con');
|
||||
elem.parentNode.removeChild(elem);
|
||||
</script>";
|
||||
echo "<script>document.getElementById('se-pre-con').parentNode.removeChild(document.getElementById('se-pre-con'));</script>";
|
||||
if ($u->info['dnow'] > 0) {
|
||||
$d = new Dungeon;
|
||||
}
|
||||
@ -471,6 +466,8 @@ if (in_array(
|
||||
|
||||
$iloc = '';
|
||||
$iloce = '';
|
||||
$img = Config::img();
|
||||
|
||||
$sp = Db::getRows(
|
||||
'select * from items_local where (room = ? or room = -1) and `delete` = 0 and user_take = 0 and tr_login = ?',
|
||||
[$u->info['room'], $u->info['login']]
|
||||
@ -530,17 +527,25 @@ foreach ($sp as $pl) {
|
||||
if ($tk == 1 && $pl['tr_login'] == '0') {
|
||||
$tk = 2;
|
||||
}
|
||||
$iloc .= '<a class="tolobf' . $tk . '" href="main.php?take_loc_item=' . $pl['id'] . '" target="main"><div class="outer"><div class="middle"><div class="inner">' . '<img title="Забрать "' . $itmo['name'] . '"';
|
||||
if ($pl['tr_login']) {
|
||||
$iloc .= '\n' . 'Предмет для игрока "' . $pl['tr_login'] . '"';
|
||||
} elseif ($pl['tr_sex'] == 0) {
|
||||
$iloc .= '\n' . 'Предмет для мужчин';
|
||||
} elseif ($pl['tr_sex'] == 1) {
|
||||
$iloc .= '\n' . 'Предмет для женщин';
|
||||
} else {
|
||||
$iloc .= '\n' . 'Предмет может подобрать каждый';
|
||||
}
|
||||
$iloc .= '" src="//img.new-combats.tech/i/items/' . $itmo['img'] . '">' . '</div></div></div></a> ';
|
||||
|
||||
$whoCanPickUp = '\n' . match (true) {
|
||||
$pl['tr_login'] => "Предмет для игрока {$pl['tr_login']}",
|
||||
$pl['tr_sex'] == 0 => 'Предмет для мужчин',
|
||||
$pl['tr_sex'] == 1 => 'Предмет для женщин',
|
||||
default => 'Предмет может подобрать каждый'
|
||||
};
|
||||
|
||||
$iloc .= <<<HTML
|
||||
<a class="tolobf$tk" href="/main.php?take_loc_item{$pl['id']}" target="main">
|
||||
<div class="outer">
|
||||
<div class="middle">
|
||||
<div class="inner">
|
||||
<img src="$img/i/items/{$itmo['img']}" title="Забрать «{$itmo['name']}». $whoCanPickUp" alt="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
HTML;
|
||||
}
|
||||
} else {
|
||||
echo '[!]';
|
||||
@ -552,24 +557,82 @@ if ($iloc != '') {
|
||||
if ($iloce != '') {
|
||||
$iloc = '<div style="padding:10px; color: red;">' . $iloce . '</div>' . $iloc;
|
||||
}
|
||||
$iloc = '<style>' . '.tolobf0 { display:inline-block; width:80px; height:80px; background-color:#e5e5e5; text-align:center; }.tolobf0:hover { background-color:#d5d5d5; text-align:center; }.tolobf2 { display:inline-block; width:80px; height:80px; background-color:#FFD700; text-align:center; }.tolobf2:hover { background-color:#DAA520; text-align:center; }.tolobf1 { display:inline-block; width:80px; height:80px; background-color:#d5d5e5; text-align:center; }.tolobf1:hover { background-color:#d5d5d5; text-align:center; }.outer { display: table; position: absolute; height: 80px; width: 80px;}.middle { display: table-cell; vertical-align: middle;}.inner { margin-left: auto; margin-right: auto; width: 80px; }' . '</style>' . '<h3>В комнате разбросаны предметы</h3>' . $iloc;
|
||||
$tjs .= 'top.frames[\'main\'].locitems=1;parent.$(\'#canal1\').html( \'' . $iloc . '\' );';
|
||||
$iloc = <<<HTML
|
||||
<style>
|
||||
.tolobf0 {
|
||||
display:inline-block;
|
||||
width:80px;
|
||||
height:80px;
|
||||
background-color:#e5e5e5;
|
||||
text-align:center;
|
||||
}
|
||||
.tolobf0:hover {
|
||||
background-color:#d5d5d5;
|
||||
text-align:center;
|
||||
}
|
||||
.tolobf2 {
|
||||
display:inline-block;
|
||||
width:80px;
|
||||
height:80px;
|
||||
background-color:#FFD700;
|
||||
text-align:center;
|
||||
}
|
||||
.tolobf2:hover {
|
||||
background-color:#DAA520;
|
||||
text-align:center;
|
||||
}
|
||||
.tolobf1 {
|
||||
display:inline-block;
|
||||
width:80px;
|
||||
height:80px;
|
||||
background-color:#d5d5e5;
|
||||
text-align:center;
|
||||
}
|
||||
.tolobf1:hover {
|
||||
background-color:#d5d5d5;
|
||||
text-align:center;
|
||||
}
|
||||
.outer {
|
||||
display: table;
|
||||
position: absolute;
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
}
|
||||
.middle {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.inner {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 80px;
|
||||
}
|
||||
</style>
|
||||
<h3>В комнате разбросаны предметы</h3>
|
||||
HTML;
|
||||
|
||||
$tjs = $iloc;
|
||||
} else {
|
||||
$tjs .= 'top.frames[\'main\'].locitems=1;parent.$(\'#canal1\').html( \'\' );';
|
||||
$tjs = '';
|
||||
}
|
||||
|
||||
unset($iloc, $iloce);
|
||||
/*-----------------------*/
|
||||
$spl = Db::getValue('select exp from levels where nextLevel = ? order by exp limit 1', [$u->info['level'] + 1]);
|
||||
|
||||
echo '<script>top.myexpLineTop27(' . $u->info['exp'] . ',' . $spl . ')' . $tjs . ';top.sd4key="' . $u->info['nextAct'] . '"; var battle = ' . (0 + $u->info['battle']) . '; top.hic();</script></body>
|
||||
</html>';
|
||||
|
||||
//Сломаное обучение. Как оно достало! Ins. 🤬
|
||||
//$training_manager->render();
|
||||
?>
|
||||
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>-->
|
||||
|
||||
<script>
|
||||
top.myexpLineTop27('<?= $u->info['exp'] ?>', '<?= $spl ?>');
|
||||
top.frames['main'].locitems = 1;
|
||||
parent.$('#canal1').html('<?= $tjs ?>')
|
||||
top.sd4key = "<?= $u->info['nextAct'] ?>";
|
||||
var battle = <?= (int)$u->info['battle'] ?>;
|
||||
top.hic();
|
||||
|
||||
//Loader
|
||||
// Wait for window load
|
||||
$(window).load(function () {
|
||||
@ -578,9 +641,3 @@ echo '<script>top.myexpLineTop27(' . $u->info['exp'] . ',' . $spl . ')' . $tjs .
|
||||
});
|
||||
</script>
|
||||
|
||||
<!--<script src="//ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>-->
|
||||
<!--<script>-->
|
||||
<!-- $(window).load(function() {-->
|
||||
<!-- $(".se-pre-con").fadeOut("slow");-->
|
||||
<!-- })-->
|
||||
<!--</script>-->
|
Loading…
Reference in New Issue
Block a user