From bfd9e0c5a36244ff5aa7f2ef9a4173fcda6c264f Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Fri, 8 Dec 2023 19:32:22 +0200 Subject: [PATCH] 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. --- main.php | 115 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 86 insertions(+), 29 deletions(-) diff --git a/main.php b/main.php index f87dd3f4..ea5fa0eb 100644 --- a/main.php +++ b/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 ""; + echo ""; 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 .= '
' . '' . '
'; + + $whoCanPickUp = '\n' . match (true) { + $pl['tr_login'] => "Предмет для игрока {$pl['tr_login']}", + $pl['tr_sex'] == 0 => 'Предмет для мужчин', + $pl['tr_sex'] == 1 => 'Предмет для женщин', + default => 'Предмет может подобрать каждый' + }; + + $iloc .= << +
+
+
+ +
+
+
+ + HTML; } } else { echo '[!]'; @@ -552,24 +557,82 @@ if ($iloc != '') { if ($iloce != '') { $iloc = '
' . $iloce . '
' . $iloc; } - $iloc = '' . '

В комнате разбросаны предметы

' . $iloc; - $tjs .= 'top.frames[\'main\'].locitems=1;parent.$(\'#canal1\').html( \'' . $iloc . '\' );'; + $iloc = << + .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; + } + +

В комнате разбросаны предметы

+ 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 ' -'; //Сломаное обучение. Как оно достало! Ins. 🤬 //$training_manager->render(); ?> - + - - - - - - \ No newline at end of file