refactor and custom user entities

This commit is contained in:
2023-11-06 02:40:12 +02:00
parent ce2691971b
commit 1645f58a63
14 changed files with 828 additions and 587 deletions
+49 -41
View File
@@ -67,23 +67,23 @@ if ($u->info['dnow'] == 0) {
//Удаляем обьекты и т.д. из старых пещер
$rb = 321; // Магический портал
$sp = mysql_query('SELECT * FROM `dungeon_now` WHERE `time_finish` = "0" LIMIT 50');
while ($pl = mysql_fetch_array($sp)) {
$cn = mysql_fetch_array(mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $pl['id'] . '" LIMIT 1'));
if (!isset($cn['id'])) {
mysql_query('DELETE FROM `dungeon_bots` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"');
mysql_query('DELETE FROM `dungeon_obj` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"');
mysql_query('DELETE FROM `dungeon_items` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"');
mysql_query('DELETE FROM `dungeon_bots` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"');
mysql_query('DELETE FROM `dungeon_actions` WHERE `dn` = "' . $pl['id'] . '"');
mysql_query('UPDATE `dungeon_now` SET `time_finish` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
}
}
$cn = mysql_fetch_array(mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $d->info['id'] . '" AND `id` != "' . $u->info['id'] . '" ORDER BY `exp` DESC LIMIT 1'));
if (isset($cn['id'])) {
$dungeonIds = Db::getColumn('select id from dungeon_now where time_finish = 0');
$dnowIds = Db::getColumn('select id from stats where dnow in (?)', [implode(',', $dungeonIds)]);
$diff = implode(',', array_diff($dungeonIds, $dnowIds));
Db::sql('delete from dungeon_bots where dn in (?) and for_dn = 0', [$diff]);
Db::sql('delete from dungeon_obj where dn in (?) and for_dn = 0', [$diff]);
Db::sql('delete from dungeon_items where dn in (?) and for_dn = 0', [$diff]);
Db::sql('delete from dungeon_actions where dn in (?)', [$diff]);
Db::sql('update dungeon_now set time_finish = unix_timestamp() where id in (?)', [$diff]);
unset($dungeonIds, $dnowIds, $diff);
$cn1 = Db::getValue('select id from stats where dnow = ? and id != ? order by exp desc limit 1', [$d->info['id'], $u->info['id']]);
if ($cn1) {
if ($d->info['uid'] == $u->info['id']) {
$cn = mysql_fetch_array(mysql_query('SELECT `id`,`login`,`sex` FROM `users` WHERE `id` = "' . $cn['id'] . '" LIMIT 1'));
mysql_query('UPDATE `dungeon_now` SET `uid` = "' . $cn['id'] . '" WHERE `id` = "' . $d->info['id'] . '" LIMIT 1');
$cn = Db::getRow('select id, login, sex from users where id = ?', [$cn1]);
Db::sql('update dungeon_now set uid = ? where id = ?', [$cn['id'], $d->info['id']]);
if ($cn['sex'] == 0) {
if ($u->info['sex'] == 0) {
$d->sys_chat('<b>' . $u->info['login'] . '</b> покинул подземелье, новым лидером группы стал <b>' . $cn['login'] . '</b>');
@@ -105,22 +105,17 @@ if ($u->info['dnow'] == 0) {
}
}
}
unset($cn, $cn1);
$city = mysql_fetch_assoc(mysql_query('SELECT `id`, `city` FROM `room` WHERE `id` = "' . $rb . '" LIMIT 1'));
mysql_query('UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
mysql_query('UPDATE `users` SET `room` = "' . $rb . '", `city`="' . $city['city'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
Db::sql('update users left join stats on users.id = stats.id set dnow = 0, room = ? where users.id = ?', [$rb, $u->info['id']]);
//удаляем все предметы которые пропадают после выхода из пещеры
mysql_query('UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND `dn_delete` = "1" LIMIT 1000');
Db::sql('delete from items_users where uid = ? and (dn_delete = 1 or item_id in (1174,1189,4447))', [$u->info['id']]);
mysql_query('UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND (`item_id` = "1189" OR `item_id` = "4447" OR `item_id` = "1174") LIMIT 1000');
//header("Location: main.php");
echo '<script type="text/javascript">window.location.href="main.php";</script>';
die();
exit('<script>window.location.replace("/main.php")</script>');
}
}
if ($d->point['fileadd'] == 1 && $d->point['file'] != '0' && $d->point['file'] != '') {
if (!empty($d->point['file']) && $d->point['fileadd'] == 1) {
$file = explode('=', $d->point['file']);
if (file_exists('modules_data/location/' . $file[0])) {
$information = '';
@@ -135,7 +130,7 @@ if ($d->point['fileadd'] == 1 && $d->point['file'] != '0' && $d->point['file'] !
}
}
if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] != '') {
if (!empty($d->point['file']) && $d->point['fileadd'] == 0) {
$file = explode('=', $d->point['file']);
if (file_exists('modules_data/location/' . $file[0])) {
require_once('modules_data/location/' . $file[0]);
@@ -526,11 +521,14 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
}
}
zfloor0[rz] = '<img title="' + v[1] + '" onclick="' + actionNow + '" src="<?= Config::img() ?>/1x1.gif" style="cursor: pointer; position: absolute; top: ' + new_top + 'px; left: ' + new_left + 'px; width: ' + new_w + 'px; height: ' + new_h + 'px;" />' + zfloor0[rz];
zfloor0[rz] = '<img title="' + v[1] + '" onclick="' + actionNow + '" src="<?= Config::img(
) ?>/1x1.gif" style="cursor: pointer; position: absolute; top: ' + new_top + 'px; left: ' + new_left + 'px; width: ' + new_w + 'px; height: ' + new_h + 'px;" />' + zfloor0[rz];
} else {
zfloor0[rz] = '<img title="' + v[1] + '" src="<?= Config::img() ?>/1x1.gif" style="position: absolute; top: ' + new_top + 'px; left: ' + new_left + 'px; width: ' + new_w + 'px; height: ' + new_h + 'px;" />' + zfloor0[rz];
zfloor0[rz] = '<img title="' + v[1] + '" src="<?= Config::img(
) ?>/1x1.gif" style="position: absolute; top: ' + new_top + 'px; left: ' + new_left + 'px; width: ' + new_w + 'px; height: ' + new_h + 'px;" />' + zfloor0[rz];
}
r = '<img title="obj" src="<?= Config::img() ?>/i/sprites/' + v[4] + '" class="dObj" style="position: absolute; top: ' + new_top + 'px; left: ' + new_left + 'px; width: ' + new_w + 'px; height: ' + new_h + 'px;" />';
r = '<img title="obj" src="<?= Config::img(
) ?>/i/sprites/' + v[4] + '" class="dObj" style="position: absolute; top: ' + new_top + 'px; left: ' + new_left + 'px; width: ' + new_w + 'px; height: ' + new_h + 'px;" />';
}
return r;
}
@@ -590,11 +588,14 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
if (v[5] == 'bot' || <?=$d->info['bsid'];?> > 0) {
action = 'dialogMenu(' + v[0] + ',' + v[8] + ',' + v[7] + ',0,0,event,' + v[9] + ');';
}
zfloor0[rz] += '<img title="' + v[1] + '" onClick="' + action + '" src="<?= Config::img() ?>/1x1.gif" style="cursor:pointer;position:absolute;top:' + new_top + 'px;left:' + new_left + 'px;width:' + new_w + 'px;height:' + new_h + 'px;" />';
zfloor0[rz] += '<img title="' + v[1] + '" onClick="' + action + '" src="<?= Config::img(
) ?>/1x1.gif" style="cursor:pointer;position:absolute;top:' + new_top + 'px;left:' + new_left + 'px;width:' + new_w + 'px;height:' + new_h + 'px;" />';
} else {
zfloor0[rz] += '<img title="' + v[1] + '" src="<?= Config::img() ?>/1x1.gif" style="position:absolute;top:' + new_top + 'px;left:' + new_left + 'px;width:' + new_w + 'px;height:' + new_h + 'px;" />';
zfloor0[rz] += '<img title="' + v[1] + '" src="<?= Config::img(
) ?>/1x1.gif" style="position:absolute;top:' + new_top + 'px;left:' + new_left + 'px;width:' + new_w + 'px;height:' + new_h + 'px;" />';
}
r = '<img title="user" src="<?= Config::img() ?>/chars/' + v[3] + '/' + v[4] + '.gif" class="dUser" style="position:absolute;top:' + new_top + 'px;left:' + new_left + 'px;width:' + new_w + 'px;height:' + new_h + 'px;" />';
r = '<img title="user" src="<?= Config::img(
) ?>/chars/' + v[3] + '/' + v[4] + '.gif" class="dUser" style="position:absolute;top:' + new_top + 'px;left:' + new_left + 'px;width:' + new_w + 'px;height:' + new_h + 'px;" />';
}
return r;
}
@@ -823,7 +824,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
position: absolute;
top: -8px;
left: -6px;
/ / background-image: url("<?= Config::img() ?> /drgn/bg/r.gif");
/ / background-image: url("<?= Config::img() ?> /drgn/bg/r.gif");
}
</style>
</table>
@@ -879,7 +880,8 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
}
if(!empty($sb1) && $sb1['x'] == $pl['x'] && $sb1['y'] == $pl['y'] ) {
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img(
) . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
}elseif ($u->info['x'] == $pl['x'] && $u->info['y'] == $pl['y']) {
if ($d->info['id2'] == 15) {
$tmbth = 4;
@@ -889,9 +891,11 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
} elseif ($tm['team'] == 2) {
$tmbth = 2;
}
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/p' . $tmbth . '/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img(
) . '/i/move/p' . $tmbth . '/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
} else {
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/p1/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img(
) . '/i/move/p1/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
}
} elseif ($d->info['id2'] == 15) {
$tmbth = 4;
@@ -907,12 +911,15 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
)
);
if (isset($tbshin['id'])) {
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("<img class=\"u_rot' . $u->info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img(
) . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
} else {
echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("<img class=\"u_rot' . $uxy[$pl['x'] . '_' . $pl['y']]['s'] . '\" title=\"' . $uxy[$pl['x'] . '_' . $pl['y']]['login'] . '\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/p' . $tmbth . '/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("<img class=\"u_rot' . $uxy[$pl['x'] . '_' . $pl['y']]['s'] . '\" title=\"' . $uxy[$pl['x'] . '_' . $pl['y']]['login'] . '\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img(
) . '/i/move/p' . $tmbth . '/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
}
}elseif (isset($uxy[$pl['x'] . '_' . $pl['y']])) {
echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("<img class=\"u_rot' . $uxy[$pl['x'] . '_' . $pl['y']]['s'] . '\" title=\"' . $uxy[$pl['x'] . '_' . $pl['y']]['login'] . '\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/p4/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("<img class=\"u_rot' . $uxy[$pl['x'] . '_' . $pl['y']]['s'] . '\" title=\"' . $uxy[$pl['x'] . '_' . $pl['y']]['login'] . '\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img(
) . '/i/move/p4/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");';
} elseif( isset($bxy[$pl['x'] . '_' . $pl['y']]) ) {
$bobrz = $bxy[$pl['x'] . '_' . $pl['y']]['obraz'];
@@ -924,7 +931,8 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] !
}
?>
$("#min_<?=$bxy[$pl['x'] . '_' . $pl['y']]['x']?>_<?=$bxy[$pl['x'] . '_' . $pl['y']]['y']?>").html("<div style='position:relative; display:inline-block; width:1px; height:1px;'><img class='dBot' title='<?=$bxy[$pl['x'] . '_' . $pl['y']]['login']?>' src='<?= Config::img() ?>/chars/<?=$bxy[$pl['x'] . '_' . $pl['y']]['sex']?>/<?=$bobrz?>'></div>");
$("#min_<?=$bxy[$pl['x'] . '_' . $pl['y']]['x']?>_<?=$bxy[$pl['x'] . '_' . $pl['y']]['y']?>").html("<div style='position:relative; display:inline-block; width:1px; height:1px;'><img class='dBot' title='<?=$bxy[$pl['x'] . '_' . $pl['y']]['login']?>' src='<?= Config::img(
) ?>/chars/<?=$bxy[$pl['x'] . '_' . $pl['y']]['sex']?>/<?=$bobrz?>'></div>");
<?php
}
$css = rtrim($css, ',');