Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

feature: switch to bootstrap and HTML5 #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git
docker-compose
ad.sql
Dockerfile
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
/.idea/
# игнорим временные файлы
/game/online/u.*
/game/*

# игнорм все кроме .htaccess
!/game/data/clans/.htaccess

# composer files
/vendor/
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM php:8-apache
RUN curl -sS https://getcomposer.org/installer -o composer-setup.php && \
php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
rm composer-setup.php
RUN docker-php-ext-install -j$(nproc) pdo pdo_mysql
COPY --chown=www-data:www-data . /var/www/html
WORKDIR /var/www/html
USER www-data
RUN composer install
USER root
EXPOSE 80
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'
services:
web:
build: .
ports:
- 80:80
# volumes:
# - .:/var/www/html

db:
image: mysql:8
environment:
- MYSQL_DATABASE=amulet
- MYSQL_USER=amulet
- MYSQL_PASSWORD=amulet
- MYSQL_ROOT_PASSWORD=amulet
ports:
- 3306:3306
volumes:
- ./ad.sql:/docker-entrypoint-initdb.d/ad.sql
12 changes: 6 additions & 6 deletions game/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
//=========================

DBConfig::setConfig([
'server' => 'localhost',
'server' => 'db',
'dbname' => 'amulet',
'login' => 'game',
'password' => 'pass',
'login' => 'amulet',
'password' => 'amulet',
]);

//=========================
Expand Down Expand Up @@ -64,7 +64,7 @@
*
* @var string $g_admin
*/
$g_admin = 'u.user';
$g_admin = 'u.computerstein';

/**
* ключ для входа админом
Expand Down Expand Up @@ -129,12 +129,12 @@
*
* Если размер списка превышает его, то будет разбит на несколько с возможностью перелистывания.
*/
$pageOpt->setMaxListSize(5);
$pageOpt->setMaxListSize(30);

/**
* Размер страницы (700..15000)
*/
$pageOpt->setMaxPageSize(2200);
$pageOpt->setMaxPageSize(15000);

/*
* Тип меню.
Expand Down
165 changes: 96 additions & 69 deletions game/f_admin.inc

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion game/f_blank.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function is_castle($fname)
return substr($fname, 0, 2) == "c.";
}

$excluded = [
$excluded = [
".",
"..",
".htaccess",
Expand Down
2 changes: 1 addition & 1 deletion game/f_castle.inc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ if (substr($loc, 3) == ".gate" && $clanc && $clanc != $clan &&
}
}

$tclan = unserialize((file_get_contents("data/clans/" . $clanc)));
$tclan = file_exists("data/clans/" . $clanc) ? unserialize(file_get_contents("data/clans/" . $clanc)) : 0;
if ($tclan) {
$k1 = array_keys($tclan["g"]);
$tclan["m"][$k1[0]] = 1;//глава
Expand Down
4 changes: 2 additions & 2 deletions game/f_castlein.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

// проверка флага лидерства
if ($game["fid"] != $login && intval($game["floc"]{2}) == $loc{2}) {
if ($game["fid"] != $login && intval($game["floc"][2]) == $loc[2]) {
loadloc($game["floc"]);
if ( ! $game["fid"] || ! isset($loc_i[$game["floc"]][$game["fid"]])) {
$loc_i[$loc]["i.flag"] = "флаг лидерства|1|0";
Expand All @@ -32,7 +32,7 @@ if ($clanc) { // инфа
if ($char[8] && $stuk) {
msg("Призраки не могут стучать в ворота");
}
if ($stuk) { // стук в ворота
if (isset($stuk)) { // стук в ворота
if (strpos($d[0], "[") !== false) {
$tmp = substr($d[0], strpos($d[0], "[") + 1, strpos($d[0], "]") - strpos($d[0], "[") - 1);
} else {
Expand Down
20 changes: 12 additions & 8 deletions game/f_cnick.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ $char = explode("|", $loc_i[$loc][$login]["char"]);
if (strpos($char[0], " *") === false) {
$clan = "";
} else {
$clan = substr($char[0], strpos($char[0], " *"));
$clan = substr($char[0], strpos($char[0], " *"));
$char[0] = substr($char[0], 0, strpos($char[0], " *"));
}
$tus = explode("|", $loc_i[$loc][$login]["user"]);

$viewOpt = ViewOptions::getInstance();

if ($cnick == "1") {
$stmp = "<p>Ваше имя: <br/><input name=\"new\" value=\"" . $char[0] . "\"/>
$stmp = "<form action=\"$PHP_SELF\" method=\"get\">
<input name=\"sid\" value=\"" . $sid . "\" type=\"hidden\"/>
<input name=\"cnick\" value=\"" . $char[0] . "\" type=\"hidden\"/>
<p>Ваше имя: <br/><input name=\"new\" value=\"" . $char[0] . "\"/>
<br/>Возраст: <br/><input name=\"age\" value=\"" . intval($tus[3]) . "\" format=\"*N\" maxlength=\"2\"/>
<br/>Размер списков (3..30): <br/><input name=\"list\" value=\"" . $viewOpt->getMaxListSize() . "\" format=\"*N\" maxlength=\"2\"/>
<br/>Размер страницы (700..15000): <br/><input name=\"size\" value=\"" . $viewOpt->getMaxPageSize() . "\" format=\"*N\" maxlength=\"5\"/>
Expand All @@ -33,13 +36,14 @@ if ($cnick == "1") {
<br/>Карта: 0 - нет, 1 - ч/б, 2 - цветная JPEG, 3 - цветная PNG: <br/><input name=\"map\" value=\"" .
$viewOpt->getMapMode() . "\" format=\"*N\" maxlength=\"1\"/>
<br/>Пункты в меню (0-откл,1-магия,2-предмет,3-прием) и кол-во горячих клавиш для каждого пункта (0..9), порядок произвольный. Пример: 332110<br/><input name=\"smenu\" value=\"" .
$viewOpt->getUserMenu() . "\" format=\"*N\" maxlength=\"6\"/>
$viewOpt->getUserMenu() . "\" format=\"*N\" maxlength=\"6\"/>
<br/>Описание локаций (1-вкл,0-выкл): <br/><input name=\"j2go\" value=\"" . $viewOpt->getShowDesc() . "\" format=\"*N\" maxlength=\"1\"/>
<br/>Сообщать о приходящих (1-вкл,0-выкл): <br/><input name=\"j2loc\" value=\"" . $viewOpt->getReportIncoming() . "\" format=\"*N\" maxlength=\"1\"/>
<br/>Звуки рядом с выходами (1-вкл,0-выкл): <br/><input name=\"sounds\" value=\"" . $viewOpt->getSoundsMode() . "\" format=\"*N\" maxlength=\"1\"/>
<br/>Отключить журнал (1-да,0-нет): <br/><input name=\"joff\" value=\"" . $viewOpt->getJournalDisabled() . "\" format=\"*N\" maxlength=\"1\"/>
<br/>Маленький шрифт (1-да,0-нет): <br/><input name=\"smf\" value=\"" . $viewOpt->getUseSmallFont() . "\" format=\"*N\" maxlength=\"1\"/>
<br/><a href=\"$PHP_SELF?sid=$sid&cnick=$(new)&list=$(list)&size=$(size)&j2loc=$(j2loc)&j2go=$(j2go)&menu=$(menu)&smenu=$(smenu)&sounds=$(sounds)&joff=$(joff)&map=$(map)&smf=$(smf)&age=$(age)\">Сохранить</a>
<br/><button class=\"btn btn-primary m-1\"type=\"submit\">Сохранить</button>
</form>
<br/><a href=\"?site=faq&id=err\">Помощь</a>";

} else {
Expand Down Expand Up @@ -99,12 +103,12 @@ if ($cnick == "1") {
$viewOpt->setMapMode($map);
$viewOpt->setUseSmallFont($smf);

$loc_i[$loc][$login]["o"] = $viewOpt->toString();
$char[0] = $cnick . $clan;
$loc_i[$loc][$login]["o"] = $viewOpt->toString();
$char[0] = $cnick . $clan;
$loc_i[$loc][$login]["char"] = implode("|", $char);
$tus[3] = intval($age);
$tus[3] = intval($age);
$loc_i[$loc][$login]["user"] = implode("|", $tus);
$stmp = "Настройки сохранены.";
$stmp = "Настройки сохранены.";
}

msg($stmp, "Настройки", 0);
15 changes: 9 additions & 6 deletions game/f_drop.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ if ($drop) { //linkБросить
$loc1 = $loc;
}
$loc_i[$loc1]["i.flag"] = "флаг лидерства|1|0";
$game["floc"] = $loc1;
$game["fid"] = "";
$game["floc"] = $loc1;
$game["fid"] = "";
calcparam($loc, $login);
msg("Вы бросили флаг лидерства");
}
Expand All @@ -43,12 +43,15 @@ if ($drop) { //linkБросить
// бросаем предмет в локацию
$title = findItemByFullId($drop); // FIXME: dead code?
// проверим кол-во
if ($tcount > 1 && ! $num) { // запросим кол-во
$stmp = "<p>Укажите количество:\n<br/><input name=\"num\" format=\"*N\" maxlength=\"7\" value=\"" .
$tcount . "\"/>\n<br/><a href=\"$PHP_SELF?sid=$sid&drop=$drop&num=$(num)\">Отправить</a>";
if ($tcount > 1 && !$num) { // запросим кол-во
$stmp = "<p>Укажите количество:\n<br/><form action=\"$PHP_SELF\" method=\"get\">" .
"<input name=\"sid\" value=\"" . $sid . "\" type=\"hidden\"/>" .
"<input name=\"drop\" value=\"" . $drop . "\" type=\"hidden\"/>" .
"<input class=\"form-control\" name=\"num\" format=\"*N\" maxlength=\"7\" value=\"" . $tcount .
"\"/>\n<br/><button class=\"btn btn-outline-primary\" type=\"submit\">Отправить</button></form></p>";
msg($stmp, "Бросить", 1, PageType::MSG, "num", $tcount);
}
if ( ! $num || $num < 1) {
if (!$num || $num < 1) {
$num = 1;
} // если не указано, то 1 предмет
if ($num > $tcount) {
Expand Down
25 changes: 13 additions & 12 deletions game/f_listall.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ $stmp = "<p><a href=\"$PHP_SELF?sid=$sid&to=" . $login . "&use=$use\">На се
// по всем предметам в локации
if (count($loc_i[$loc]) > 1) {
$stmp .= "\n<br/>Объекты:";
if ( ! $start) {
if (!$start) {
$start = 0;
}
$keys = array_keys($loc_i[$loc]);
$listEnd = $start + ViewOptions::getInstance()->getMaxListSize();
for ($i = $start; $i < $listEnd && $i < count($keys); $i++) {
if ($keys[$i] != $login) {
$stmp .= "\n<br/><a href=\"$PHP_SELF?sid=$sid&to=" . $keys[$i] . "&use=$use";
if ($glava == 1) {
if (isset($glava) && $glava == 1) {
$stmp .= "&glava=1"; // используется в plugin/i.guildstone.inc
}
$stmp .= "\">";
Expand All @@ -47,7 +47,7 @@ if (count($loc_i[$loc]) > 1) {
}
if (substr($keys[$i], 0, 2) == "n." || substr($keys[$i], 0, 2) == "u.") {
$tmp = explode("|", $loc_i[$loc][$keys[$i]]["char"]);
$k = $tmp[0];
$k = $tmp[0];
if (substr($keys[$i], 0, 2) == "u." && $tmp[12]) {
$k .= " (всадник)";
}
Expand All @@ -73,12 +73,12 @@ if (count($loc_i[$loc]) > 1) {
}
if ($tmp[7] && isset($loc_i[$loc][$tmp[7]])) {
$tmp1 = explode("|", $loc_i[$loc][$tmp[7]]["char"]);
if (substr($tmp[7], 0, 2) != "u." || (substr($tmp[7], 0, 2) != "u." && ! $tmp1[8])) {
if (substr($tmp[7], 0, 2) != "u." || (substr($tmp[7], 0, 2) != "u." && !$tmp1[8])) {
$st .= " атакует " . $tmp1[0];
}
}
if ($st) {
if ($st{0} == ' ') {
if ($st[0] == ' ') {
$st = substr($st, 1);
}
$k .= " [" . $st . "]";
Expand All @@ -92,19 +92,19 @@ if (count($loc_i[$loc]) > 1) {
$stmp .= "\n<br/><a href=\"$PHP_SELF?sid=$sid&list=all&use=$use\">^ </a>";
}
if ($listEnd < count($keys)) {
if ( ! $start) {
if (!$start) {
$stmp .= "\n<br/>";
}
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&list=all&use=$use&start=" . ($listEnd) . "\">+ (" .
(count($keys) - $listEnd) . ")</a>";
(count($keys) - $listEnd) . ")</a>";
}
}

if ($loc_i[$loc][$login]["items"] != "") {
$stmp .= "\n<br/>Инвентори:";
$items = explode("|", $loc_i[$loc][$login]["items"]);

if ( ! $start) {
if (!$start) {
$start = 0;
}
$keys = array_keys($items);
Expand All @@ -121,8 +121,9 @@ if ($loc_i[$loc][$login]["items"] != "") {
$item .= " (" . $k[1] . ")";
}
$tbp = strpos($loc_i[$loc][$login]["equip"], $k[0]);
if ($tbp !== false && ($loc_i[$loc][$login]["equip"]{$tbp + strlen($k[0])} == "|" ||
$loc_i[$loc][$login]["equip"]{$tbp + strlen($k[0])} == "")
if (
$tbp !== false && ($loc_i[$loc][$login]["equip"][$tbp + strlen($k[0])] == "|" ||
$loc_i[$loc][$login]["equip"][$tbp + strlen($k[0])] == "")
) {
$item .= " [одето]";
}
Expand All @@ -133,11 +134,11 @@ if ($loc_i[$loc][$login]["items"] != "") {
$stmp .= "\n<br/><a href=\"$PHP_SELF?sid=$sid&list=all\">^ </a>";
}
if ($listEnd < count($keys)) {
if ( ! $start) {
if (!$start) {
$stmp .= "\n<br/>";
}
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&list=all&use=$use&start=" . ($listEnd) . "\">+ (" .
(count($keys) - ($listEnd)) . ")</a>";
(count($keys) - ($listEnd)) . ")</a>";
}
}
msg($stmp, "Укажите цель");
51 changes: 26 additions & 25 deletions game/f_listinv.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ if ($up || $down) {

// в $to цель, если есть
$stmp = "<p>";
if ( ! $to && ! $start) {
$stmp .= '<a href="#char">Меню</a>';
if (!$to && !$start) {
$stmp .= '<a tabindex="0" class="btn btn-secondary m-1" id="lala" role="button" data-trigger="focus" data-toggle="popover" data-content="char" title="Меню">Меню</a>';
$war = explode("|", $loc_i[$loc][$login]["war"]);
$stmp .= "<br/>Урон: " . $war[1] . "-" . $war[2] . " [" . $war[0] . "%]<br/>Броня: " . ($war[5] + $war[8]);
} else {
Expand All @@ -37,7 +37,7 @@ if ($loc_i[$loc][$login]["items"] == "") {

$items = explode("|", $loc_i[$loc][$login]["items"]);

if ( ! $start) {
if (!$start) {
$start = 0;
}
$keys = array_keys($items);
Expand All @@ -55,52 +55,53 @@ if ($loc_i[$loc][$login]["items"] == "") {
$item .= " (" . $k[1] . ")";
}
$tbp = strpos($loc_i[$loc][$login]["equip"], $k[0]);
if ($tbp !== false && ($loc_i[$loc][$login]["equip"]{$tbp + strlen($k[0])} == "|" ||
$loc_i[$loc][$login]["equip"]{$tbp + strlen($k[0])} == "")
$offset = $tbp + strlen($k[0]);
if ($tbp !== false && isset($loc_i[$loc][$login]["equip"][$offset])) {
$targetChar = $loc_i[$loc][$login]["equip"][$offset];
if ($targetChar == "|" || $targetChar == ""
) {
$item .= " [одето]";
}
}}
if ($to) {
// цель задана - использовать
$stmp .= "\n<br/><a href=\"$PHP_SELF?sid=$sid&to=$to&use=" . $k[0] . "\">" . $item . "</a>";
} else {
// возврат в основное меню
$stmp .= "\n<br/><anchor>" . $item . "<go href=\"#menu\"><setvar name=\"to\" value=\"" . $k[0] .
"\"/></go></anchor>";
$stmp .= "\n" . '<br/><a tabindex="0" class="btn btn-secondary m-1" role="button" data-trigger="focus" data-toggle="popover" data-content="template" title="' . $item . '" label="' . $k[0] . '">' . $item . '</a>';
}
}
}
if ($start) {
$stmp .= "\n<br/><a href=\"$PHP_SELF?sid=$sid&list=inv\">^ </a>";
}
if ($listEnd < count($keys)) {
if ( ! $start) {
if (!$start) {
$stmp .= "\n<br/>";
}
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&list=inv&start=" . ($listEnd) . "\">+ (" .
(count($keys) - $listEnd) . ")</a>";
(count($keys) - $listEnd) . ")</a>";
}

// меню
$stmp .= "\n</p>\n</card>\n<card id=\"menu\" title=\"Меню\">\n<p>\n";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&use=$(to)\">Использовать</a>\n<br/>";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&drop=$(to)\">Бросить</a>";
if (isset($loc_i[$loc][$loc_i[$loc][$login]["trade"]["to"]])) {
$stmp .= "\n<br/><a href=\"$PHP_SELF?sid=$sid&trade=add&id=$(to)\">Добавить в обмен</a>";
$stmp .= "\n</p>\n</div>\n<div id=\"menu\" class=\"d-none\" title=\"Меню\">\n<p>\n";
$stmp .= "<a class=\"btn btn-outline-primary btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&use=$(to)\">Использовать</a>\n<br/>";
$stmp .= "<a class=\"btn btn-outline-danger btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&drop=$(to)\">Бросить</a>";
if (isset($loc_i[$loc][$login]["trade"]) && isset($loc_i[$loc][$loc_i[$loc][$login]["trade"]["to"]])) {
$stmp .= "\n<br/><a class=\"btn btn-outline-primary btn-sm m-1\" href=\"$PHP_SELF?sid=$sid&trade=add&id=" . urlencode($to) . "\">Добавить в обмен</a>";
}
$stmp .= "\n<br/><a href=\"$PHP_SELF?sid=$sid&from=$login&look=$(to)\">Инфо</a>\n<br/>";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&from=$login&list=inv&up=$(to)\">[Вверх</a> | ";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&from=$login&list=inv&down=$(to)\">Вниз</a>]";
$stmp .= "\n<br/><a class=\"btn btn-outline-secondary btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&from=$login&look=$(to)\">Инфо</a>\n<br/>";
$stmp .= "[<a class=\"btn btn-secondary btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&from=$login&list=inv&up=$(to)\">Вверх</a> | ";
$stmp .= "<a class=\"btn btn-secondary btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&from=$login&list=inv&down=$(to)\">Вниз</a>]";

}// items!=""
} // items!=""

// персонаж
$stmp .= "\n</p>\n</card>\n<card id=\"char\" title=\"Меню\">\n<p>";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&list=magic\">Магия</a><br/>";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&list=skill\">Навыки</a><br/>";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&list=priem\">Приемы</a><br/>";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&cnick=1\">Настройки</a><br/>";
$stmp .= "<a href=\"$PHP_SELF?sid=$sid&look=$login\">О себе</a>";
$stmp .= "\n</p>\n</div>\n<div id=\"char\" class=\"d-none\" title=\"Меню\">\n<p>";
$stmp .= "<a class=\"btn btn-outline-primary btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&list=magic\">Магия</a><br/>";
$stmp .= "<a class=\"btn btn-outline-success btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&list=skill\">Навыки</a><br/>";
$stmp .= "<a class=\"btn btn-outline-primary btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&list=priem\">Приемы</a><br/>";
$stmp .= "<a class=\"btn btn-outline-danger btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&cnick=1\">Настройки</a><br/>";
$stmp .= "<a class=\"btn btn-outline-secondary btn-sm m-1 \" href=\"$PHP_SELF?sid=$sid&look=$login\">О себе</a>";

if ($char[12]) {
$stmp .= "<br/><a href=\"$PHP_SELF?sid=$sid&use=i.h\">Покинуть седло</a>";
Expand Down
Loading