This commit is contained in:
2024-12-17 10:40:25 +02:00
106 changed files with 6704 additions and 5723 deletions
+65
View File
@@ -0,0 +1,65 @@
const img = '//img.new-combats.com/i';
const gett = async () => {
let response = await fetch('/api/onlinelist.php');
if (response.ok) {
document.getElementById('onlinelist').innerHTML = '';
const list = await response.json();
list.forEach((user) => {
console.log(user);
document.getElementById('onlinelist').insertAdjacentHTML('beforeend', `${ol.makelogin(user)}<br>`);
});
} else {
document.getElementById('onlinelist').insertAdjacentHTML('beforeend', `Все ушли.<br>`);
}
};
window.addEventListener('load', () => {
const fetchInterval = 10000; // 10 секунд.
gett;
//(get)(); // почему get; или get(); - неправильно?? 🤬😭
setInterval(gett, fetchInterval);
});
ol = {
tochat (login) {
const input = document.getElementById('tochat');
if (input.value === `private [${login}]`) {
return;
}
if (input.value === `to [${login}]`) {
input.value = `private [${login}]`;
return;
}
input.value = `to [${login}]`;
},
makelogin ({id, login, level, align, clan, inbattle, isadmin}) {
let style = '';
if (isadmin) {
//align = 2.9;
style = `color: crimson;`;
}
if (!level || level < 0 || level > 21 && !isadmin || typeof level !== 'number') {
level = '??';
}
let inficon = `<a href="/info/${id}" target="_blank"><img src="${img}/inf.gif" alt="Информация про ${login}"></a>`;
let html = `<span style="${style}; cursor: pointer;" onclick="ol.tochat('${login}');">${login}[${level}]</span>` + inficon;
if (clan) {
html = `<img src="${img}/clan/${clan}.gif" alt="Клан"> ` + html;
}
if (align) {
html = `<img src="${img}/align/align${align}.gif" alt="Склонность"> ` + html;
}
let battleyes = '', battlealt = '';
if (inbattle) {
battleyes = 1;
battlealt = ' (персонаж в поединке)'
}
html = `<img src="${img}/lock${battleyes}.gif" alt="Приват${battlealt}" onclick="ol.tochat('${login}')">` + html;
return html;
}
};
+22
View File
@@ -0,0 +1,22 @@
<?php
$list = [
['id' => 1, 'login' => 'Paladin', 'align' => 1.9, 'level' => 4],
['id' => 2, 'login' => 'ClanUser', 'clan' => 100, 'level' => 5],
['id' => 3, 'login' => 'AlignClanUser', 'align' => 23, 'clan' => 120, 'level' => 'text'],
['id' => 4, 'login' => 'User', 'level' => -1],
['id' => 5, 'login' => 'UserInBattle', 'battle' => true, 'level' => 100500],
['id' => 6, 'login' => 'Admin', 'battle' => true, 'admin' => true],
];
?>
<!DOCTYPE html>
<html lang="ru">
<link rel="stylesheet" href="../i/main.css">
<title>onlinelist</title>
<script src="oltest.js"></script>
<script>
const onlinelist = JSON.parse('<?= json_encode($list) ?>');
</script>
<div id="onlinelist"></div>
<label><input id="tochat"> типа, поле ввода в чат (для отладки клика по логину)</label>
+95
View File
@@ -0,0 +1,95 @@
<?php
use Core\Db;
use Helper\Conversion;
ini_set('xdebug.var_display_max_depth', 10);
ini_set('xdebug.var_display_max_children', 256);
ini_set('xdebug.var_display_max_data', 1024);
require_once '../_incl_data/autoload.php';
class ShowPriems
{
private array $names = [];
private array $parameters = [];
public function __construct() {
foreach (Db::getRows('select sys_name, name from const_stats') as $nrow) {
$this->names[$nrow['sys_name']] = $nrow['name'];
}
// Несовпадения по именам.
$this->names['lvl'] = $this->names['level'];
$this->printAll();
$this->printUnknown();
}
private function printer(array $data, string $title): string
{
$result = '';
foreach ($data as $k=>$v) {
if ($k === array_key_first($data)) {
$result .= "<br><b>$title</b>: ";
}
$result .= $this->namer($k, $v);
}
return $result;
}
private function printAll(): void
{
foreach (Db::getRows('select name, info, date2, date3, id, tr from priems order by name') as $prow) {
$d2 = Conversion::dataStringToArray($prow['date2']);
$d3 = Conversion::dataStringToArray($prow['date3']);
$tr = Conversion::dataStringToArray($prow['tr']);
$d2s = $this->printer($d2, 'date2');
$d3s = $this->printer($d3, 'date3');
$trs = $this->printer($tr, 'Требуется');
$dallk = array_flip(array_keys(array_merge($d2, $d3, $tr)));
$this->parameters = array_merge($dallk, $this->parameters);
echo "<div><b>{$prow['name']}</b> id:{$prow['id']}<br><i>{$prow['info']}</i> $trs $d2s $d3s</div>";
}
}
private function namer($k, $v): string
{
return match (true) {
$this->names[$k] => "<br>$this->names[$k] = $v",
str_starts_with($k, 'add_') && $this->names[str_replace('add_', '', $k)] => "<br>{$this->names[str_replace('add_', '', $k)]} = $v",
str_starts_with($k, 'tr_') && $this->names[str_replace('tr_', '', $k)] => "<br>{$this->names[str_replace('tr_', '', $k)]} = $v",
default => "<br><span style='background-color: lavender; color: crimson;'>$k = $v</span>",
};
}
private function printUnknown(): void
{
$sorted = [];
foreach ($this->parameters as $pa=>$va) {
if ($this->names[str_replace('add_', '', $pa)] || $this->names[str_replace('tr_', '', $pa)]) {
continue;
}
$sorted[] = $pa;
}
echo '<hr>Неизвестные параметры:<br>';
foreach (array_chunk($sorted, 10) as $re) {
echo implode(', ', $re) . '<br>';
}
}
}
echo <<<HTML
<style>
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono&display=swap');
body {font-family: 'JetBrains Mono', monospace; font-size: small; background-color: lavender;}
hr {border: 1px solid darkgreen;}
i {color: dimgrey;}
div {margin: 10px 0; padding: 4px; background-color: ghostwhite;}
div > b:first-child {margin-left: 5px; color: darkslategrey;}
div > b:first-child:before {content: '⭕ '}
</style>
HTML;
$np = new ShowPriems();
+18
View File
@@ -0,0 +1,18 @@
<?php
use Core\Db;
use Helper\Table;
if (!defined('GAME_VERSION')) {
require_once '_incl_data/autoload.php';
}
$users = Db::getRows('select users.id, money, money2 from users inner join stats on users.id = stats.id where `real` > 0 and banned = 0 and bot = 0 order by id desc');
$tbl = [['Логин', 'Стоимость вещей кр', 'Стоимость вещей екр', 'Всего кр с учётом вещей', 'Всего екр с учётом вещей']];
foreach ($users as $user) {
$itemsprices = Db::getRow('select sum(`1price`) as sumkr, sum(`2price`) as sumekr from items_users where uid = ?', [$user['id']]);
$allkr = $user['money'] + $itemsprices['sumkr'];
$allekr = $user['money2'] + $itemsprices['sumekr'];
$tbl[] = [User::getLogin($user['id']), $itemsprices['sumkr'] ?? 0, $itemsprices['sumekr'] ?? 0, $allkr, $allekr];
}
echo Table::get($tbl);
+74
View File
@@ -0,0 +1,74 @@
<?php
use Core\Db;
use User\UserIp;
const GAME = true;
include('_incl_data/__config.php');
include('_incl_data/class/__db_connect.php');
define('IP', UserIp::get());
$u = User::start();
if (isset($_GET['test_login']) || isset($_GET['test_login2'])) {
die();
}
if (isset($_GET['chat'])) {
$sp2 = Db::getRows('select * from chat where spam > 0 order by time desc ');
foreach ($sp2 as $row) {
echo date('d.m.Y H:i', $row['time']) . ' <b>' . $row['login'] . '</b>: ' . $row['text'] . '<hr>';
}
die();
}
if (!$u->info['admin']) {
die('Спамер? :)');
}
?>
<!DOCTYPE HTML>
<html lang="ru">
<head>
<title>Редактирование фильтра от спама</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
<link href="//img.new-combats.tech/css/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery.1.11.js"></script>
<body style="padding-top:0; margin-top:7px; height:100%; background-color:#dedede;">
<strong>Список запрещенных слов\ссылок:</strong> &nbsp;
<input onClick="location.href='/spam.php';" type="button" value="Обновить"><br><br>
<?php
$spam = Db::getValue('select data from spam_word where id = 1');
$spam = explode('|', $spam);
//
if (isset($_GET['del'])) {
echo '<div style="color: red;">Слово &quot;<b>' . $spam[floor(
(int)$_GET['del']
)] . '</b>&quot; удалено.<br><br></div>';
unset($spam[floor((int)$_GET['del'])]);
$spam = implode('|', $spam);
Db::sql('replace into spam_word set id = 1, data = ?', [$spam]);
$spam = explode('|', $spam);
} elseif (isset($_POST['add'])) {
$_POST['add'] = htmlspecialchars($_POST['add'], null);
echo '<div style="color: green">Слово &quot;<b>' . $_POST['add'] . '</b>&quot; добавлено.<br><br></div>';
$spam = implode('|', $spam);
$spam .= '|' . $_POST['add'];
Db::sql('replace into spam_word set id = 1, data = ?', [$spam]);
$spam = explode('|', $spam);
}
if (is_array($spam)) {
$i = 0;
while ($i < count($spam)) {
echo $spam[$i] . ' <a href="/spam.php?del=' . $i . '"><span style="color: red">x</span></a><hr>';
$i++;
}
}
?>
<form method="post">
<label>
<input type="text" name="add" value="" style="width:244px;">
</label> <input type="submit" value="Добавить">
</form>
</body>
</html>
+53
View File
@@ -0,0 +1,53 @@
<?php
use Battle\Fighter;
use Core\Db;
require_once $_SERVER['DOCUMENT_ROOT'] . '/_incl_data/autoload.php';
$a = ['foo' => 'eta', 'bar' => 'bingo', 'baz' => 'quatro', 'mill' => 'buratino erra stupido'];
\Core\Debug::x();
//$f1 = new Fighter(27319412, 4);
$f2 = new Fighter(27205347, 2);
//echo $f1;
echo $f2;
//var_dump($f1);
$u = User::start(27205347);
var_dump($u->stats['items'], $u->stats);
?>
<!--<div id="test"></div>
<div id="app">{{ message }}</div>
-->
<script type="module">
const a = <?= json_encode(['bar' => 'bingo', 'baz' => 'quatro', 'mill' => 'buratino erra stupido']) ?>;
if (a["mill"]) {
const div = document.getElementById('test');
if (a['bar']) {
div.className = a['bar'];
}
div.innerHTML = a["mill"];
document.body.append(div);
}
import { createApp, ref } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
createApp({
setup() {
const message = ref('Hello Vue!')
return {
message
}
}
}).mount('#app')
</script>