mirror of
https://github.com/slawkens/myaac.git
synced 2025-09-14 12:33:35 +02:00
Compare commits
77 Commits
0.9
...
feature/ne
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a8c65a7ab9 | ||
![]() |
b60f345ae5 | ||
![]() |
b82c021ff7 | ||
![]() |
d0c479d11d | ||
![]() |
577f9b7373 | ||
![]() |
3700875c47 | ||
![]() |
5747fb5723 | ||
![]() |
a846d8a7e7 | ||
![]() |
3fb30f6391 | ||
![]() |
91c6ef1ddf | ||
![]() |
098beb9d46 | ||
![]() |
fb17d2e060 | ||
![]() |
513ca3830b | ||
![]() |
17eb5426e3 | ||
![]() |
b918f88776 | ||
![]() |
4eb9bbbbcf | ||
![]() |
56bd2c86b7 | ||
![]() |
94719b45b2 | ||
![]() |
958681bdc9 | ||
![]() |
c1eb7d4f52 | ||
![]() |
ea09b6a91b | ||
![]() |
58bc0a7c28 | ||
![]() |
35a660be7d | ||
![]() |
07a03c38b3 | ||
![]() |
6b54ac65ca | ||
![]() |
070b04afa9 | ||
![]() |
039ddc7967 | ||
![]() |
9fa65ce7a4 | ||
![]() |
6aa28a3002 | ||
![]() |
938d01eb00 | ||
![]() |
e0347f252c | ||
![]() |
bf3362dc1b | ||
![]() |
ec38a79235 | ||
![]() |
eaec00122b | ||
![]() |
7e62bd74a3 | ||
![]() |
6c5215a8ed | ||
![]() |
eb4ea48641 | ||
![]() |
a0ccbbe8c2 | ||
![]() |
63d2c5c6b5 | ||
![]() |
7d38945e8d | ||
![]() |
53732005aa | ||
![]() |
c4a5cae988 | ||
![]() |
69a92fb859 | ||
![]() |
9fadba7d07 | ||
![]() |
a080b21408 | ||
![]() |
11768424a3 | ||
![]() |
07887423c6 | ||
![]() |
35928fe576 | ||
![]() |
60f64e21d8 | ||
![]() |
7bfa21a239 | ||
![]() |
8af786902d | ||
![]() |
ba04536169 | ||
![]() |
c646dc124b | ||
![]() |
2eb9f4d284 | ||
![]() |
cdc06056c8 | ||
![]() |
1be1bc9178 | ||
![]() |
48d561ac6f | ||
![]() |
731755f05a | ||
![]() |
de3eaacf60 | ||
![]() |
bb699ffef2 | ||
![]() |
34fa672c0f | ||
![]() |
f74c1ac247 | ||
![]() |
0af595a5a6 | ||
![]() |
10eb9e7ff0 | ||
![]() |
1d163279ce | ||
![]() |
8cac9af966 | ||
![]() |
7008c9f4d8 | ||
![]() |
468f59fbec | ||
![]() |
bebe6892d0 | ||
![]() |
a8e65b72a4 | ||
![]() |
e52a301d9e | ||
![]() |
cf04c1df02 | ||
![]() |
98f6b03747 | ||
![]() |
9d5665a476 | ||
![]() |
3eb5810526 | ||
![]() |
26d0c2a359 | ||
![]() |
073cf80812 |
6
.gitattributes
vendored
6
.gitattributes
vendored
@@ -3,12 +3,8 @@
|
||||
.gitignore export-ignore
|
||||
.github export-ignore
|
||||
.editorconfig export-ignore
|
||||
.travis.yml export-ignore
|
||||
_config.yml export-ignore
|
||||
release.sh export-ignore
|
||||
|
||||
# cypress
|
||||
cypress export-ignore
|
||||
cypress.config.js export-ignore
|
||||
cypress.env.json
|
||||
|
||||
*.sh text eol=lf
|
||||
|
120
.github/workflows/cypress.yml
vendored
120
.github/workflows/cypress.yml
vendored
@@ -1,120 +0,0 @@
|
||||
name: Cypress
|
||||
on:
|
||||
pull_request:
|
||||
branches: [0.9]
|
||||
push:
|
||||
branches: [0.9]
|
||||
|
||||
jobs:
|
||||
cypress:
|
||||
runs-on: ubuntu-latest
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: myaac
|
||||
MYSQL_USER: myaac
|
||||
MYSQL_PASSWORD: myaac
|
||||
ports:
|
||||
- 3306/tcp
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: [ '7.4', '8.0', '8.1' ]
|
||||
name: MyAAC on PHP ${{ matrix.php-versions }}
|
||||
steps:
|
||||
- name: 📌 MySQL Start & init & show db
|
||||
run: |
|
||||
sudo /etc/init.d/mysql start
|
||||
mysql -e 'CREATE DATABASE myaac;' -uroot -proot
|
||||
mysql -e "SHOW DATABASES" -uroot -proot
|
||||
|
||||
- name: Checkout MyAAC
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: 0.9
|
||||
|
||||
- name: Checkout TFS
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: otland/forgottenserver
|
||||
ref: 1.4
|
||||
path: tfs
|
||||
|
||||
- name: Import TFS Schema
|
||||
run: |
|
||||
mysql -uroot -proot myaac < tfs/schema.sql
|
||||
|
||||
- name: Rename config.lua
|
||||
run: mv tfs/config.lua.dist tfs/config.lua
|
||||
|
||||
- name: Replace mysqlUser
|
||||
uses: jacobtomlinson/gha-find-replace@v2
|
||||
with:
|
||||
find: 'mysqlUser = "forgottenserver"'
|
||||
replace: 'mysqlUser = "root"'
|
||||
regex: false
|
||||
include: 'tfs/config.lua'
|
||||
|
||||
- name: Replace mysqlPass
|
||||
uses: jacobtomlinson/gha-find-replace@v2
|
||||
with:
|
||||
find: 'mysqlPass = ""'
|
||||
replace: 'mysqlPass = "root"'
|
||||
regex: false
|
||||
include: 'tfs/config.lua'
|
||||
|
||||
- name: Replace mysqlDatabase
|
||||
uses: jacobtomlinson/gha-find-replace@v2
|
||||
with:
|
||||
find: 'mysqlDatabase = "forgottenserver"'
|
||||
replace: 'mysqlDatabase = "myaac"'
|
||||
regex: false
|
||||
include: 'tfs/config.lua'
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: mbstring, dom, fileinfo, mysql, json, xml, pdo, pdo_mysql
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
# Use composer.json for key, if composer.lock is not committed.
|
||||
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: ${{ runner.os }}-composer-
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: composer install --no-progress --prefer-dist --optimize-autoloader
|
||||
|
||||
- name: Run PHP server
|
||||
run: nohup php -S localhost:8080 > php.log 2>&1 &
|
||||
|
||||
- name: Cypress Run
|
||||
uses: cypress-io/github-action@v5
|
||||
env:
|
||||
CYPRESS_URL: http://localhost:8080
|
||||
CYPRESS_SERVER_PATH: /home/runner/work/myaac/myaac/tfs
|
||||
|
||||
- name: Save screenshots
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: cypress-screenshots
|
||||
path: cypress/screenshots
|
||||
|
||||
- name: Upload Cypress Videos
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: cypress-videos
|
||||
path: cypress/videos
|
11
.github/workflows/phplint.yml
vendored
11
.github/workflows/phplint.yml
vendored
@@ -1,16 +1,13 @@
|
||||
name: PHP Linting
|
||||
on:
|
||||
pull_request:
|
||||
branches: [develop]
|
||||
branches: [master, develop]
|
||||
push:
|
||||
branches: [develop]
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
phplint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: overtrue/phplint@8.2
|
||||
with:
|
||||
path: .
|
||||
options: --exclude=*.log
|
||||
- uses: actions/checkout@v1
|
||||
- uses: michaelw90/PHP-Lint@master
|
||||
|
13
.gitignore
vendored
13
.gitignore
vendored
@@ -2,9 +2,6 @@ Thumbs.db
|
||||
.DS_Store
|
||||
.idea
|
||||
|
||||
#
|
||||
/.htaccess
|
||||
|
||||
# composer
|
||||
composer.lock
|
||||
vendor
|
||||
@@ -12,10 +9,6 @@ vendor
|
||||
# npm
|
||||
node_modules
|
||||
|
||||
# cypress
|
||||
cypress.env.json
|
||||
cypress/e2e/2-advanced-examples
|
||||
|
||||
# created by release.sh
|
||||
releases
|
||||
tmp
|
||||
@@ -35,12 +28,6 @@ images/guilds/*
|
||||
images/editor/*
|
||||
!images/editor/index.html
|
||||
|
||||
# gallery images
|
||||
images/gallery/*
|
||||
!images/gallery/index.html
|
||||
!images/gallery/demon.jpg
|
||||
!images/gallery/demon_thumb.gif
|
||||
|
||||
# cache
|
||||
system/cache/*
|
||||
!system/cache/index.html
|
||||
|
@@ -6,10 +6,6 @@
|
||||
Options -MultiViews
|
||||
</IfModule>
|
||||
|
||||
<FilesMatch "^(CHANGELOG\.md|README\.md|composer\.json|composer\.lock|package\.json|package-lock\.json|cypress\.env\.json)$">
|
||||
Require all denied
|
||||
</FilesMatch>
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
18
.travis.yml
Normal file
18
.travis.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
language: php
|
||||
php:
|
||||
- 7.1
|
||||
- 7.2
|
||||
- 7.3
|
||||
- 7.4
|
||||
- 8.0
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache
|
||||
|
||||
before_script:
|
||||
- composer require php-parallel-lint/php-parallel-lint --no-suggest --no-progress --no-interaction --no-ansi --quiet --optimize-autoloader
|
||||
|
||||
script:
|
||||
- php vendor/bin/parallel-lint --no-progress --no-colors --exclude vendor --exclude "system/libs/pot/OTS_DB_PDOQuery.php" .
|
48
CHANGELOG.md
48
CHANGELOG.md
@@ -1,55 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## [0.9.0-alpha - 02.06.2023]
|
||||
|
||||
Minimum PHP version for this release is 7.2.5.
|
||||
## [0.9.0 - x.x.2020]
|
||||
|
||||
### Added
|
||||
* reworked Admin Panel (@Leesneaks, @gpedro, @slawkens)
|
||||
* updated to Bootstrap v4
|
||||
* new Menu
|
||||
* new Dashboard: statistics, server status
|
||||
* new Admin Bar showed on top when admin logged in
|
||||
* new page: Server Data, to reload server data
|
||||
* new pages: mass account & teleport tools
|
||||
* changelogs editor
|
||||
* revised Accounts & Players editors
|
||||
* option to add/modify menus with plugins
|
||||
* option to enable/disable plugins
|
||||
* better, updated TinyMCE editor (v6.x)
|
||||
* with option to upload images
|
||||
* list of open source libraries used in project
|
||||
* brand new charming installation page (by @fernandomatos)
|
||||
* using Bootstrap
|
||||
* new pages router: nikic/fast-route, allowing for better customisation
|
||||
* Guild Wars support (available as plugin)
|
||||
* support for login and create account only by email (configurable)
|
||||
* with no need for account name
|
||||
* Google ReCAPTCHA v3 support (available as plugin)
|
||||
* automatically load towns names from .OTBM file
|
||||
* support for Account Number
|
||||
* suggest account number option
|
||||
* many new functions, hooks and configurables
|
||||
* better Exception Handler (Whoops - https://github.com/filp/whoops)
|
||||
* add Cypress testing
|
||||
|
||||
### Changed
|
||||
* Composer is now used for external libraries like: Twig, PHPMailer, fast-route etc.
|
||||
* mail support is disabled on fresh install, can be manually enabled by user
|
||||
* disable add php pages in admin panel for security. Option to disable plugins upload
|
||||
* visitors counter shows now user browser, and also if its bot
|
||||
* changes in required and optional PHP extensions
|
||||
* reworked Pages:
|
||||
* Bans
|
||||
* works now for TFS 1.x
|
||||
* Highscores
|
||||
* frags works for TFS 1.x
|
||||
* cached
|
||||
* creatures
|
||||
* moved pages to Twig:
|
||||
* experience stages
|
||||
* update player_deaths entries on name change
|
||||
* change_password email to be more informal
|
||||
|
||||
### Fixed
|
||||
* hundrets of bug fixes, mostly patched from 0.8, so it makes no sense writing them again here
|
||||
|
2
CREDITS
2
CREDITS
@@ -1,3 +1,3 @@
|
||||
* Gesior.pl (2007 - 2008)
|
||||
* Slawkens (2009 - 2023)
|
||||
* Slawkens (2009 - 2022)
|
||||
* Contributors listed in CONTRIBUTORS.txt
|
||||
|
34
README.md
34
README.md
@@ -1,29 +1,23 @@
|
||||
# [MyAAC](https://my-aac.org)
|
||||
|
||||
[](https://travis-ci.org/github/slawkens/myaac)
|
||||
[](https://opensource.org/licenses/gpl-license)
|
||||
[](https://github.com/slawkens/myaac/releases)
|
||||
[](https://github.com/slawkens/myaac/blob/d8b3b4135827ee17e3c6d41f08a925e718c587ed/.travis.yml#L3)
|
||||
[](https://discord.gg/2J39Wus)
|
||||
[](https://github.com/slawkens/myaac/issues?q=is%3Aissue+is%3Aclosed)
|
||||
|
||||
MyAAC is a free and open-source Automatic Account Creator (AAC) written in PHP. It is a fork of the [Gesior](https://github.com/gesior/Gesior2012) project. It supports only MySQL databases.
|
||||
|
||||
Official website: https://my-aac.org
|
||||
|
||||
[](https://github.com/slawkens/myaac/actions)
|
||||
[](https://opensource.org/licenses/gpl-license)
|
||||
[](https://github.com/slawkens/myaac/releases)
|
||||
[](https://discord.gg/2J39Wus)
|
||||
[](https://github.com/slawkens/myaac/issues?q=is%3Aissue+is%3Aclosed)
|
||||
|
||||
| Version | Status | Branch | Requirements |
|
||||
|:-----------|:------------------------------------------|:--------|:---------------|
|
||||
| **0.10.x** | **Active development** | develop | **PHP >= 8.0** |
|
||||
| 0.9.x | Active support | 0.9 | PHP >= 7.2.5 |
|
||||
| 0.8.x | Active support | master | PHP >= 7.2.5 |
|
||||
| 0.7.x | End Of Life | 0.7 | PHP >= 5.3.3 |
|
||||
|
||||
### Requirements
|
||||
|
||||
- PHP 7.2.5 or later
|
||||
- PHP 5.6 or later
|
||||
- MySQL database
|
||||
- PDO PHP Extension
|
||||
- XML PHP Extension
|
||||
- (optional) ZIP PHP Extension
|
||||
- ZIP PHP Extension
|
||||
- (optional) mod_rewrite to use friendly_urls
|
||||
|
||||
### Installation
|
||||
@@ -42,7 +36,7 @@ Official website: https://my-aac.org
|
||||
chmod 660 images/guilds
|
||||
chmod 660 images/houses
|
||||
chmod 660 images/gallery
|
||||
chmod -R 760 system/cache
|
||||
chmod -R 770 system/cache
|
||||
|
||||
Visit http://your_domain/install (http://localhost/install) and follow instructions in the browser.
|
||||
|
||||
@@ -77,13 +71,7 @@ Look: [Contributing](https://github.com/otsoft/myaac/wiki/Contributing) in our w
|
||||
|
||||
### Other Notes
|
||||
|
||||
If you have a great idea or want contribute to the project - visit our website at https://www.my-aac.org
|
||||
|
||||
## Project supported by JetBrains
|
||||
|
||||
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
|
||||
|
||||
[](https://www.jetbrains.com/?from=https://github.com/slawkens)
|
||||
If you have a great idea or want contribute to the project - visit our website at https://www.my-aac.org
|
||||
|
||||
### License
|
||||
|
||||
|
@@ -1,2 +1 @@
|
||||
<?php
|
||||
// nothing yet here
|
||||
<?php
|
@@ -29,11 +29,6 @@ define('PAGE', $page);
|
||||
require SYSTEM . 'functions.php';
|
||||
require SYSTEM . 'init.php';
|
||||
|
||||
// verify myaac tables exists in database
|
||||
if(!$db->hasTable('myaac_account_actions')) {
|
||||
throw new RuntimeException('Seems that the table <strong>myaac_account_actions</strong> of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting <a href="' . BASE_URL . 'install">this</a> url.');
|
||||
}
|
||||
|
||||
if(config('env') === 'dev') {
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
@@ -75,9 +70,7 @@ if(!@file_exists($file)) {
|
||||
}
|
||||
|
||||
ob_start();
|
||||
if($hooks->trigger(HOOK_ADMIN_BEFORE_PAGE)) {
|
||||
require $file;
|
||||
}
|
||||
include($file);
|
||||
|
||||
$content .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
@@ -10,17 +10,12 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$title = 'Account editor';
|
||||
$admin_base = ADMIN_URL . '?p=accounts';
|
||||
$admin_base = BASE_URL . 'admin/?p=accounts';
|
||||
$use_datatable = true;
|
||||
|
||||
if ($config['account_country'])
|
||||
require SYSTEM . 'countries.conf.php';
|
||||
|
||||
$nameOrNumberColumn = 'name';
|
||||
if (USE_ACCOUNT_NUMBER) {
|
||||
$nameOrNumberColumn = 'number';
|
||||
}
|
||||
|
||||
$hasSecretColumn = $db->hasColumn('accounts', 'secret');
|
||||
$hasCoinsColumn = $db->hasColumn('accounts', 'coins');
|
||||
$hasPointsColumn = $db->hasColumn('accounts', 'premium_points');
|
||||
@@ -53,16 +48,16 @@ else if (isset($_REQUEST['search'])) {
|
||||
if (strlen($search_account) < 3 && !Validator::number($search_account)) {
|
||||
echo_error('Player name is too short.');
|
||||
} else {
|
||||
$query = $db->query('SELECT `id` FROM `accounts` WHERE `' . $nameOrNumberColumn . '` = ' . $db->quote($search_account));
|
||||
$query = $db->query('SELECT `id` FROM `accounts` WHERE `name` = ' . $db->quote($search_account));
|
||||
if ($query->rowCount() == 1) {
|
||||
$query = $query->fetch();
|
||||
$id = (int)$query['id'];
|
||||
} else {
|
||||
$query = $db->query('SELECT `id`, `' . $nameOrNumberColumn . '` FROM `accounts` WHERE `' . $nameOrNumberColumn . '` LIKE ' . $db->quote('%' . $search_account . '%'));
|
||||
$query = $db->query('SELECT `id`, `name` FROM `accounts` WHERE `name` LIKE ' . $db->quote('%' . $search_account . '%'));
|
||||
if ($query->rowCount() > 0 && $query->rowCount() <= 10) {
|
||||
$str_construct = 'Do you mean?<ul class="mb-0">';
|
||||
foreach ($query as $row)
|
||||
$str_construct .= '<li><a href="' . $admin_base . '&id=' . $row['id'] . '">' . $row[$nameOrNumberColumn] . '</a></li>';
|
||||
$str_construct .= '<li><a href="' . $admin_base . '&id=' . $row['id'] . '">' . $row['name'] . '</a></li>';
|
||||
$str_construct .= '</ul>';
|
||||
echo_error($str_construct);
|
||||
} else if ($query->rowCount() > 10)
|
||||
@@ -150,7 +145,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
$web_lastlogin = strtotime($_POST['web_lastlogin']);
|
||||
verify_number($web_lastlogin, 'Web Last login', 11);
|
||||
|
||||
if (!$error && $hooks->trigger(HOOK_ADMIN_ACCOUNTS_SAVE_POST, ['account_id' => $account->getId(), 'account_email' => $account->getEMail()])) {
|
||||
if (!$error) {
|
||||
if (USE_ACCOUNT_NAME) {
|
||||
$account->setName($name);
|
||||
}
|
||||
@@ -208,7 +203,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
}
|
||||
}
|
||||
} else if ($id == 0) {
|
||||
$accounts_db = $db->query('SELECT `id`, `' . $nameOrNumberColumn . '`' . ($hasTypeColumn ? ',type' : ($hasGroupColumn ? ',group_id' : '')) . ' FROM `accounts` ORDER BY `id` ASC');
|
||||
$accounts_db = $db->query('SELECT `id`, `name`' . ($hasTypeColumn ? ',type' : ($hasGroupColumn ? ',group_id' : '')) . ' FROM `accounts` ORDER BY `id` ASC');
|
||||
?>
|
||||
<div class="col-12 col-sm-12 col-lg-10">
|
||||
<div class="card card-info card-outline">
|
||||
@@ -220,7 +215,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th><?= ($nameOrNumberColumn == 'number' ? 'Number' : 'Name'); ?></th>
|
||||
<th>Name</th>
|
||||
<?php if($hasTypeColumn || $hasGroupColumn): ?>
|
||||
<th>Position</th>
|
||||
<?php endif; ?>
|
||||
@@ -231,7 +226,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
<?php foreach ($accounts_db as $account_lst): ?>
|
||||
<tr>
|
||||
<th><?php echo $account_lst['id']; ?></th>
|
||||
<td><?php echo $account_lst[$nameOrNumberColumn]; ?></a></td>
|
||||
<td><?php echo $account_lst['name']; ?></a></td>
|
||||
<?php if($hasTypeColumn || $hasGroupColumn): ?>
|
||||
<td>
|
||||
<?php if ($hasTypeColumn) {
|
||||
@@ -272,7 +267,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
</li>
|
||||
<?php endif;
|
||||
|
||||
if ($db->hasTable('store_history') && $db->hasColumn('store_history', 'time')) : ?>
|
||||
if ($db->hasTable('store_history')) : ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="accounts-store-tab" data-toggle="pill" href="#accounts-store">Store History</a>
|
||||
</li>
|
||||
@@ -289,11 +284,6 @@ else if (isset($_REQUEST['search'])) {
|
||||
<label for="name">Account Name:</label>
|
||||
<input type="text" class="form-control" id="name" name="name" autocomplete="off" value="<?php echo $account->getName(); ?>"/>
|
||||
</div>
|
||||
<?php elseif (USE_ACCOUNT_NUMBER): ?>
|
||||
<div class="col-12 col-sm-12 col-lg-4">
|
||||
<label for="name">Account Number:</label>
|
||||
<input type="text" class="form-control" id="name" name="name" autocomplete="off" value="<?php echo $account->getNumber(); ?>"/>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="col-12 col-sm-12 col-lg-5">
|
||||
<div class="form-check">
|
||||
@@ -523,7 +513,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
} ?>
|
||||
</div>
|
||||
<?php endif;
|
||||
if ($db->hasTable('store_history') && $db->hasColumn('store_history', 'time')) { ?>
|
||||
if ($db->hasTable('store_history')) { ?>
|
||||
<div class="tab-pane fade" id="accounts-store">
|
||||
<?php $store_history = $db->query('SELECT * FROM `store_history` WHERE `account_id` = "' . $account->getId() . '" ORDER BY `time` DESC')->fetchAll(); ?>
|
||||
<table class="table table-striped table-condensed table-responsive d-md-table">
|
||||
|
@@ -10,12 +10,6 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
$title = 'Login';
|
||||
|
||||
require PAGES . 'account/login.php';
|
||||
if ($logged) {
|
||||
header('Location: ' . (admin() ? ADMIN_URL : BASE_URL));
|
||||
return;
|
||||
}
|
||||
|
||||
$twig->display('admin.login.html.twig', [
|
||||
'logout' => (ACTION == 'logout' ? 'You have been logged out!' : ''),
|
||||
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
|
||||
|
@@ -16,7 +16,7 @@ if (!hasFlag(FLAG_CONTENT_MAILER) && !superAdmin()) {
|
||||
}
|
||||
|
||||
if (!config('mail_enabled')) {
|
||||
echo 'Mail support disabled in config.';
|
||||
echo 'Mail support disabled.';
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,6 @@ if (isset($_REQUEST['template'])) {
|
||||
if ($cache->enabled()) {
|
||||
$cache->delete('template_menus');
|
||||
}
|
||||
|
||||
success('Saved at ' . date('H:i'));
|
||||
}
|
||||
|
||||
@@ -57,7 +56,6 @@ if (isset($_REQUEST['template'])) {
|
||||
echo 'Cannot find template config.php file.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($config['menu_categories'])) {
|
||||
echo "No menu categories set in template config.php.<br/>This template doesn't support dynamic menus.";
|
||||
return;
|
||||
@@ -93,16 +91,15 @@ if (isset($_REQUEST['template'])) {
|
||||
<ul class="sortable" id="sortable-<?php echo $id ?>">
|
||||
<?php
|
||||
if (isset($menus[$id])) {
|
||||
$i = 0;
|
||||
foreach ($menus[$id] as $menu):
|
||||
foreach ($menus[$id] as $i => $menu):
|
||||
?>
|
||||
<li class="ui-state-default" id="list-<?php echo $id ?>-<?php echo $i ?>"><label>Name:</label> <input type="text" name="menu[<?php echo $id ?>][]" value="<?php echo escapeHtml($menu['name']); ?>"/>
|
||||
<label>Link:</label> <input type="text" name="menu_link[<?php echo $id ?>][]" value="<?php echo $menu['link'] ?>"/>
|
||||
<input type="hidden" name="menu_blank[<?php echo $id ?>][]" value="0"/>
|
||||
<label><input class="blank-checkbox" type="checkbox" <?php echo($menu['blank'] == 1 ? 'checked' : '') ?>/><span title="Open in New Window">New Window</span></label>
|
||||
<input class="color-picker" type="text" name="menu_color[<?php echo $id ?>][]" value="<?php echo (empty($menu['color']) ? ($config['menu_default_color'] ?? '#ffffff') : $menu['color']); ?>"/>
|
||||
<input class="color-picker" type="text" name="menu_color[<?php echo $id ?>][]" value="#<?php echo $menu['color'] ?>"/>
|
||||
<a class="remove-button" id="remove-button-<?php echo $id ?>-<?php echo $i ?>"><i class="fas fa-trash"></a></i></li>
|
||||
<?php $i++; $last_id[$id] = $i;
|
||||
<?php $last_id[$id] = $i;
|
||||
endforeach;
|
||||
} ?>
|
||||
</ul>
|
||||
@@ -123,8 +120,7 @@ if (isset($_REQUEST['template'])) {
|
||||
<?php
|
||||
$twig->display('admin.menus.js.html.twig', array(
|
||||
'menus' => $menus,
|
||||
'last_id' => $last_id,
|
||||
'menu_default_color' => $config['menu_default_color'] ?? '#ffffff'
|
||||
'last_id' => $last_id
|
||||
));
|
||||
?>
|
||||
<?php
|
||||
|
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$balance = ($db->hasColumn('players', 'balance') ? $db->query('SELECT `balance`, `id`, `name`,`level` FROM `players` ORDER BY `balance` DESC LIMIT 10;') : 0);
|
||||
|
||||
$twig->display('balance.html.twig', array(
|
||||
|
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$coins = ($db->hasColumn('accounts', 'coins') ? $db->query('SELECT `coins`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `coins` DESC LIMIT 10;') : 0);
|
||||
|
||||
$twig->display('coins.html.twig', array(
|
||||
|
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$players = ($db->hasColumn('accounts', 'created') ? $db->query('SELECT `created`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `created` DESC LIMIT 10;') : 0);
|
||||
|
||||
$twig->display('created.html.twig', array(
|
||||
|
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$players = ($db->hasColumn('players', 'lastlogin') ? $db->query('SELECT name, level, lastlogin FROM players ORDER BY lastlogin DESC LIMIT 10;') : 0);
|
||||
$twig->display('lastlogin.html.twig', array(
|
||||
'players' => $players,
|
||||
|
@@ -1,6 +1,4 @@
|
||||
<?php
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$points = ($db->hasColumn('accounts', 'premium_points') ? $db->query('SELECT `premium_points`, `' . (USE_ACCOUNT_NAME ? 'name' : 'id') . '` as `name` FROM `accounts` ORDER BY `premium_points` DESC LIMIT 10;') : 0);
|
||||
|
||||
$twig->display('points.html.twig', array(
|
||||
|
@@ -76,18 +76,18 @@ if (!empty($action)) {
|
||||
$enable_tinymce = $_page['enable_tinymce'] == '1';
|
||||
$access = $_page['access'];
|
||||
} else {
|
||||
if(Pages::update($id, $name, $p_title, $body, $player_id, $php, $enable_tinymce, $access, $errors)) {
|
||||
if(Pages::update($id, $name, $p_title, $body, $player_id, $php, $enable_tinymce, $access)) {
|
||||
$action = $name = $p_title = $body = '';
|
||||
$player_id = 1;
|
||||
$access = 0;
|
||||
$php = false;
|
||||
$enable_tinymce = true;
|
||||
success('Updated successful.');
|
||||
success("Updated successful.");
|
||||
}
|
||||
}
|
||||
} else if ($action == 'hide') {
|
||||
Pages::toggleHidden($id, $errors, $status);
|
||||
success(($status == 1 ? 'Show' : 'Hide') . ' successful.');
|
||||
success(($status == 1 ? 'Show' : 'Hide') . " successful.");
|
||||
}
|
||||
|
||||
if (!empty($errors))
|
||||
@@ -152,10 +152,6 @@ class Pages
|
||||
$errors[] = 'Enable PHP is wrong.';
|
||||
return false;
|
||||
}
|
||||
if ($php == 1 && !getBoolean(config('admin_pages_php_enable'))) {
|
||||
$errors[] = 'PHP pages disabled on this server. To enable go to config.php and change admin_pages_php_enable to "yes".';
|
||||
return false;
|
||||
}
|
||||
if(!isset($enable_tinymce) || ($enable_tinymce != 0 && $enable_tinymce != 1)) {
|
||||
$errors[] = 'Enable TinyMCE is wrong.';
|
||||
return false;
|
||||
@@ -204,7 +200,7 @@ class Pages
|
||||
return !count($errors);
|
||||
}
|
||||
|
||||
static public function update($id, $name, $title, $body, $player_id, $php, $enable_tinymce, $access, &$errors)
|
||||
static public function update($id, $name, $title, $body, $player_id, $php, $enable_tinymce, $access)
|
||||
{
|
||||
if(!self::verify($name, $title, $body, $player_id, $php, $enable_tinymce, $access, $errors)) {
|
||||
return false;
|
||||
@@ -258,3 +254,5 @@ class Pages
|
||||
return !count($errors);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -16,4 +16,4 @@ if (!function_exists('phpinfo')) { ?>
|
||||
<?php return;
|
||||
}
|
||||
?>
|
||||
<iframe src="<?php echo ADMIN_URL; ?>tools/phpinfo.php" width="1024" height="550"></iframe>
|
||||
<iframe src="<?php echo BASE_URL; ?>admin/tools/phpinfo.php" width="1024" height="550"></iframe>
|
||||
|
@@ -10,7 +10,7 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
$title = 'Player editor';
|
||||
$player_base = ADMIN_URL . '?p=players';
|
||||
$player_base = BASE_URL . 'admin/?p=players';
|
||||
|
||||
$use_datatable = true;
|
||||
require_once LIBS . 'forum.php';
|
||||
@@ -663,14 +663,7 @@ else if (isset($_REQUEST['search'])) {
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-lg-6">
|
||||
<label for="lastip" class="control-label">Last IP:</label>
|
||||
<input type="text" class="form-control" id="lastip" name="lastip" autocomplete="off" maxlength="10" value="<?php
|
||||
if (strlen($player->getLastIP()) > 11) {
|
||||
echo inet_ntop($player->getLastIP());
|
||||
}
|
||||
else {
|
||||
echo longToIp($player->getLastIP());
|
||||
}
|
||||
?>" readonly/>
|
||||
<input type="text" class="form-control" id="lastip" name="lastip" autocomplete="off" maxlength="10" value="<?php echo longToIp($player->getLastIP()); ?>" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($db->hasColumn('players', 'loss_experience')): ?>
|
||||
|
@@ -13,13 +13,9 @@ $use_datatable = true;
|
||||
|
||||
require_once LIBS . 'plugins.php';
|
||||
|
||||
if (!getBoolean(config('admin_plugins_manage_enable'))) {
|
||||
warning('Plugin installation and management is disabled in config.<br/>If you wish to enable, go to config.php and change <b>admin_plugins_manage_enable</b> to "yes".');
|
||||
}
|
||||
else {
|
||||
$twig->display('admin.plugins.form.html.twig');
|
||||
$twig->display('admin.plugins.form.html.twig');
|
||||
|
||||
if (isset($_REQUEST['uninstall'])) {
|
||||
if (isset($_REQUEST['uninstall'])) {
|
||||
$uninstall = $_REQUEST['uninstall'];
|
||||
|
||||
if (Plugins::uninstall($uninstall)) {
|
||||
@@ -27,27 +23,13 @@ else {
|
||||
} else {
|
||||
error('Error while uninstalling plugin ' . $uninstall . ': ' . Plugins::getError());
|
||||
}
|
||||
} else if (isset($_REQUEST['enable'])) {
|
||||
$enable = $_REQUEST['enable'];
|
||||
if (Plugins::enable($enable)) {
|
||||
success('Successfully enabled plugin ' . $enable);
|
||||
} else {
|
||||
error('Error while enabling plugin ' . $enable . ': ' . Plugins::getError());
|
||||
}
|
||||
} else if (isset($_REQUEST['disable'])) {
|
||||
$disable = $_REQUEST['disable'];
|
||||
if (Plugins::disable($disable)) {
|
||||
success('Successfully disabled plugin ' . $disable);
|
||||
} else {
|
||||
error('Error while disabling plugin ' . $disable . ': ' . Plugins::getError());
|
||||
}
|
||||
} else if (isset($_FILES['plugin']['name'])) {
|
||||
$file = $_FILES['plugin'];
|
||||
$filename = $file['name'];
|
||||
$tmp_name = $file['tmp_name'];
|
||||
$type = $file['type'];
|
||||
} else if (isset($_FILES["plugin"]["name"])) {
|
||||
$file = $_FILES["plugin"];
|
||||
$filename = $file["name"];
|
||||
$tmp_name = $file["tmp_name"];
|
||||
$type = $file["type"];
|
||||
|
||||
$name = explode('.', $filename);
|
||||
$name = explode(".", $filename);
|
||||
$accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed', 'application/octet-stream', 'application/zip-compressed');
|
||||
|
||||
if (isset($file['error'])) {
|
||||
@@ -105,27 +87,24 @@ else {
|
||||
error('Error uploading file - unknown error.');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$plugins = array();
|
||||
foreach (get_plugins(true) as $plugin) {
|
||||
foreach (get_plugins() as $plugin) {
|
||||
$string = file_get_contents(BASE . 'plugins/' . $plugin . '.json');
|
||||
$string = Plugins::removeComments($string);
|
||||
$plugin_info = json_decode($string, true);
|
||||
|
||||
if (!$plugin_info) {
|
||||
if ($plugin_info == false) {
|
||||
warning('Cannot load plugin info ' . $plugin . '.json');
|
||||
} else {
|
||||
$disabled = (strpos($plugin, 'disabled.') !== false);
|
||||
$pluginOriginal = ($disabled ? str_replace('disabled.', '', $plugin) : $plugin);
|
||||
$plugins[] = array(
|
||||
'name' => $plugin_info['name'] ?? '',
|
||||
'description' => $plugin_info['description'] ?? '',
|
||||
'version' => $plugin_info['version'] ?? '',
|
||||
'author' => $plugin_info['author'] ?? '',
|
||||
'contact' => $plugin_info['contact'] ?? '',
|
||||
'file' => $pluginOriginal,
|
||||
'enabled' => !$disabled,
|
||||
'name' => isset($plugin_info['name']) ? $plugin_info['name'] : '',
|
||||
'description' => isset($plugin_info['description']) ? $plugin_info['description'] : '',
|
||||
'version' => isset($plugin_info['version']) ? $plugin_info['version'] : '',
|
||||
'author' => isset($plugin_info['author']) ? $plugin_info['author'] : '',
|
||||
'contact' => isset($plugin_info['contact']) ? $plugin_info['contact'] : '',
|
||||
'file' => $plugin,
|
||||
'uninstall' => isset($plugin_info['uninstall'])
|
||||
);
|
||||
}
|
||||
|
@@ -36,3 +36,4 @@ $twig->display('admin.statistics.html.twig', array(
|
||||
'account_type' => (USE_ACCOUNT_NAME ? 'name' : 'number'),
|
||||
'points' => $points
|
||||
));
|
||||
?>
|
@@ -47,3 +47,4 @@ function version_revert($version)
|
||||
$release = $version;
|
||||
return $major . '.' . $minor . '.' . $release;
|
||||
}*/
|
||||
?>
|
||||
|
@@ -8,11 +8,6 @@
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
use DeviceDetector\DeviceDetector;
|
||||
use DeviceDetector\Parser\Client\Browser;
|
||||
use DeviceDetector\Parser\OperatingSystem;
|
||||
|
||||
$title = 'Visitors';
|
||||
$use_datatable = true;
|
||||
|
||||
@@ -35,31 +30,6 @@ function compare($a, $b)
|
||||
$tmp = $visitors->getVisitors();
|
||||
usort($tmp, 'compare');
|
||||
|
||||
foreach ($tmp as &$visitor) {
|
||||
$userAgent = $visitor['user_agent'] ?? '';
|
||||
if (!strlen($userAgent) || $userAgent == 'unknown') {
|
||||
$browser = 'Unknown';
|
||||
}
|
||||
else {
|
||||
$dd = new DeviceDetector($userAgent);
|
||||
$dd->parse();
|
||||
|
||||
if ($dd->isBot()) {
|
||||
$bot = $dd->getBot();
|
||||
$message = '(Bot) %s, <a href="%s" target="_blank">%s</a>';
|
||||
$browser = sprintf($message, $bot['category'], $bot['url'], $bot['name']);
|
||||
}
|
||||
else {
|
||||
$osFamily = OperatingSystem::getOsFamily($dd->getOs('name'));
|
||||
$browserFamily = Browser::getBrowserFamily($dd->getClient('name'));
|
||||
|
||||
$browser = $osFamily . ', ' . $browserFamily;
|
||||
}
|
||||
}
|
||||
|
||||
$visitor['browser'] = $browser;
|
||||
}
|
||||
|
||||
$twig->display('admin.visitors.html.twig', array(
|
||||
'config_visitors_counter_ttl' => $config['visitors_counter_ttl'],
|
||||
'visitors' => $tmp
|
||||
|
@@ -2,7 +2,6 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<?php $hooks->trigger(HOOK_ADMIN_HEAD_START); ?>
|
||||
<?php echo template_header(true); ?>
|
||||
<title><?php echo (isset($title) ? $title . ' - ' : '') . $config['lua']['serverName'];?></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
@@ -17,10 +16,8 @@
|
||||
<script src="<?php echo BASE_URL; ?>tools/js/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
|
||||
<?php $hooks->trigger(HOOK_ADMIN_HEAD_END); ?>
|
||||
</head>
|
||||
<body class="sidebar-mini ">
|
||||
<?php $hooks->trigger(HOOK_ADMIN_BODY_START); ?>
|
||||
<?php if ($logged && admin()) { ?>
|
||||
<div class="wrapper">
|
||||
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
|
||||
@@ -68,7 +65,7 @@
|
||||
if (!$has_child) { ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link<?php echo(strpos($menu['link'], $page) !== false ? ' active' : '') ?>" href="?p=<?php echo $menu['link'] ?>">
|
||||
<i class="nav-icon fas fa-<?php echo($menu['icon'] ?? 'link') ?>"></i>
|
||||
<i class="nav-icon fas fa-<?php echo(isset($menu['icon']) ? $menu['icon'] : 'link') ?>"></i>
|
||||
<p><?php echo $menu['name'] ?></p>
|
||||
</a>
|
||||
</li>
|
||||
@@ -76,9 +73,9 @@
|
||||
} else if ($has_child) {
|
||||
$used_menu = null;
|
||||
$nav_construct = '';
|
||||
foreach ($menu['link'] as $sub_category => $sub_menu) {
|
||||
foreach ($menu['link'] as $category => $sub_menu) {
|
||||
$nav_construct .= '<li class="nav-item"><a href="?p=' . $sub_menu['link'] . '" class="nav-link';
|
||||
if ($_SERVER['QUERY_STRING'] == 'p=' . $sub_menu['link']) {
|
||||
if ($page == $sub_menu['link']) {
|
||||
$nav_construct .= ' active';
|
||||
$used_menu = true;
|
||||
}
|
||||
@@ -198,6 +195,5 @@ if ($logged && admin()) {
|
||||
<script src="<?php echo BASE_URL; ?>tools/js/datatables.bs.min.js"></script>
|
||||
<?php } ?>
|
||||
<script src="<?php echo BASE_URL; ?>tools/js/adminlte.min.js"></script>
|
||||
<?php $hooks->trigger(HOOK_ADMIN_BODY_END); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -13,3 +13,4 @@ if(!function_exists('phpinfo'))
|
||||
die('phpinfo() disabled on this web server.');
|
||||
|
||||
phpinfo();
|
||||
?>
|
||||
|
@@ -26,8 +26,8 @@
|
||||
if (version_compare(phpversion(), '7.2.5', '<')) die('PHP version 7.2.5 or higher is required.');
|
||||
|
||||
const MYAAC = true;
|
||||
const MYAAC_VERSION = '0.9.0-alpha';
|
||||
const DATABASE_VERSION = 35;
|
||||
const MYAAC_VERSION = '0.9.0-dev';
|
||||
const DATABASE_VERSION = 33;
|
||||
const TABLE_PREFIX = 'myaac_';
|
||||
define('START_TIME', microtime(true));
|
||||
define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||
@@ -138,9 +138,11 @@ if(!IS_CLI) {
|
||||
|
||||
define('SERVER_URL', 'http' . (isset($_SERVER['HTTPS'][0]) && strtolower($_SERVER['HTTPS']) === 'on' ? 's' : '') . '://' . $baseHost);
|
||||
define('BASE_URL', SERVER_URL . BASE_DIR . '/');
|
||||
define('ADMIN_URL', SERVER_URL . BASE_DIR . '/' . ADMIN_PANEL_FOLDER . '/');
|
||||
define('ADMIN_URL', SERVER_URL . BASE_DIR . '/admin/');
|
||||
|
||||
//define('CURRENT_URL', BASE_URL . $_SERVER['REQUEST_URI']);
|
||||
|
||||
require SYSTEM . 'exception.php';
|
||||
}
|
||||
|
||||
$autoloadFile = VENDOR . 'autoload.php';
|
||||
|
@@ -10,10 +10,6 @@
|
||||
"composer/semver": "^3.2",
|
||||
"twig/twig": "^2.0",
|
||||
"erusev/parsedown": "^1.7",
|
||||
"nikic/fast-route": "^1.3",
|
||||
"matomo/device-detector": "^6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"filp/whoops": "^2.15"
|
||||
"nikic/fast-route": "^1.3"
|
||||
}
|
||||
}
|
||||
|
16
config.php
16
config.php
@@ -142,6 +142,18 @@ $config = array(
|
||||
'smtp_secure' => '', // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' (GMail) or 'tls' (Microsoft Outlook)
|
||||
'smtp_debug' => false, // set true to debug (you will see more info in error.log)
|
||||
|
||||
// Google reCAPTCHA (prevent spam bots)
|
||||
'recaptcha_enabled' => false, // enable recaptcha verification code
|
||||
'recaptcha_type' => 'v3', // 'v2-checkbox', 'v2-invisible', 'v3'
|
||||
'recaptcha_site_key' => '', // get your own site and secret keys at https://www.google.com/recaptcha
|
||||
'recaptcha_secret_key' => '',
|
||||
// following option apply only for ReCaptcha v2-checkbox
|
||||
'recaptcha_v2_theme' => 'light', // light, dark
|
||||
// following option apply only for ReCaptcha v3
|
||||
// min score for validation, between 0 - 1.0
|
||||
// https://developers.google.com/recaptcha/docs/v3#interpreting_the_score
|
||||
'recaptcha_v3_min_score' => 0.5,
|
||||
|
||||
//
|
||||
'generate_new_reckey' => true, // let player generate new recovery key, he will receive e-mail with new rec key (not display on page, hacker can't generate rec key)
|
||||
'generate_new_reckey_price' => 20, // price for new recovery key
|
||||
@@ -299,10 +311,6 @@ $config = array(
|
||||
'status_interval' => 60,
|
||||
|
||||
// admin panel
|
||||
'admin_plugins_manage_enable' => 'yes', // you can disable possibility to upload and uninstall plugins, for security
|
||||
// enable support for plain php pages in admin panel, for security
|
||||
// existing pages still will be working, so you need to delete them manually
|
||||
'admin_pages_php_enable' => 'no',
|
||||
'admin_panel_modules' => 'statistics,web_status,server_status,lastlogin,created,points,coins,balance', // default - statistics,web_status,server_status,lastlogin,created,points,coins,balance
|
||||
|
||||
// other
|
||||
|
@@ -1,9 +0,0 @@
|
||||
const { defineConfig } = require("cypress");
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
},
|
||||
},
|
||||
});
|
@@ -1,75 +0,0 @@
|
||||
describe('Install MyAAC', () => {
|
||||
beforeEach(() => {
|
||||
// Cypress starts out with a blank slate for each test
|
||||
// so we must tell it to visit our website with the `cy.visit()` command.
|
||||
// Since we want to visit the same URL at the start of all our tests,
|
||||
// we include it in our beforeEach function so that it runs before each test
|
||||
cy.visit(Cypress.env('URL'))
|
||||
})
|
||||
|
||||
it('Go through installer', () => {
|
||||
cy.visit(Cypress.env('URL') + '/install/?step=welcome')
|
||||
cy.wait(1000)
|
||||
|
||||
cy.screenshot('install-welcome')
|
||||
|
||||
// step 1 - Welcome
|
||||
cy.get('select[name="lang"]').select('en')
|
||||
|
||||
//cy.get('input[type=button]').contains('Next »').click()
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
// step 2 - License
|
||||
// just skip
|
||||
cy.contains('GNU/GPL License');
|
||||
cy.get('form').submit()
|
||||
|
||||
// step 3 - Requirements
|
||||
cy.contains('Requirements check');
|
||||
|
||||
cy.get('#step').then(elem => {
|
||||
elem.val('config');
|
||||
});
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
// step 4 - Configuration
|
||||
cy.contains('Basic configuration');
|
||||
|
||||
cy.get('#vars_server_path').click().clear().type(Cypress.env('SERVER_PATH'))
|
||||
cy.get('#vars_mail_admin').click().clear().type('noone@example.net')
|
||||
|
||||
cy.get('[type="checkbox"]').uncheck() // usage statistics uncheck
|
||||
|
||||
cy.wait(1000)
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
// check if there is any error
|
||||
|
||||
|
||||
// step 5 - Import Schema
|
||||
cy.contains('Import MySQL schema');
|
||||
|
||||
// AAC is not installed yet, this message should not come
|
||||
cy.contains('Seems AAC is already installed. Skipping importing MySQL schema..').should('not.exist')
|
||||
|
||||
cy.contains('[class="alert alert-success"]', 'Local configuration has been saved into file: config.local.php').should('be.visible')
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
// step 6 - Admin Account
|
||||
cy.get('#vars_email').click().clear().type('admin@my-aac.org')
|
||||
cy.get('#vars_account').click().clear().type('admin')
|
||||
cy.get('#vars_password').click().clear().type('test1234')
|
||||
cy.get('#vars_password_confirm').click().clear().type('test1234')
|
||||
cy.get('#vars_player_name').click().clear().type('Admin')
|
||||
|
||||
cy.get('form').submit()
|
||||
|
||||
cy.contains('[class="alert alert-success"]', 'Congratulations', { timeout: 30000 }).should('be.visible')
|
||||
|
||||
cy.screenshot('install-finish')
|
||||
})
|
||||
})
|
@@ -1,33 +0,0 @@
|
||||
describe('Create Account Page', () => {
|
||||
beforeEach(() => {
|
||||
// Cypress starts out with a blank slate for each test
|
||||
// so we must tell it to visit our website with the `cy.visit()` command.
|
||||
// Since we want to visit the same URL at the start of all our tests,
|
||||
// we include it in our beforeEach function so that it runs before each test
|
||||
cy.visit(Cypress.env('URL') + '/index.php/account/create')
|
||||
})
|
||||
|
||||
it('Create Test Account', () => {
|
||||
cy.screenshot('create-account-page')
|
||||
|
||||
cy.get('#account_input').type('tester')
|
||||
cy.get('#email').type('tester@example.com')
|
||||
|
||||
cy.get('#password').type('test1234')
|
||||
cy.get('#password2').type('test1234')
|
||||
|
||||
cy.get('#character_name').type('Slaw')
|
||||
|
||||
cy.get('#sex1').check()
|
||||
cy.get('#vocation1').check()
|
||||
cy.get('#accept_rules').check()
|
||||
|
||||
cy.get('#createaccount').submit()
|
||||
|
||||
// no errors please
|
||||
cy.contains('The Following Errors Have Occurred:').should('not.exist')
|
||||
|
||||
// ss of post page
|
||||
cy.screenshot('create-account-page-post')
|
||||
})
|
||||
})
|
@@ -1,174 +0,0 @@
|
||||
describe('Check Public Pages', () => {
|
||||
|
||||
/// news
|
||||
it('Go to news page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/news',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to news archive page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/news/archive',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to changelog page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/changelog',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
/// account management
|
||||
it('Go to account manage page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/manage',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to account create page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/create',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to account lost page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/lost',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to rules page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/rules',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
// community
|
||||
it('Go to online page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/online',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to characters list page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/characters',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to guilds page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/guilds',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to highscores page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/highscores',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to last kills page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/lastkills',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to houses page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/houses',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to bans page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/bans',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to forum page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/forum',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to team page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/team',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
// library
|
||||
it('Go to creatures page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/creatures',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to spells page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/spells',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to server info page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/serverInfo',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to commands page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/commands',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to downloads page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/downloads',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to gallery page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/gallery',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to experience table page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/experienceTable',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
|
||||
it('Go to faq page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/faq',
|
||||
method: 'GET',
|
||||
})
|
||||
})
|
||||
})
|
@@ -1,81 +0,0 @@
|
||||
const REQUIRED_LOGIN_MESSAGE = 'Please enter your account name and your password.';
|
||||
const YOU_ARE_NOT_LOGGEDIN = 'You are not logged in.';
|
||||
|
||||
describe('Check Protected Pages', () => {
|
||||
|
||||
// character actions
|
||||
it('Go to accouht character creation page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/character/create',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(REQUIRED_LOGIN_MESSAGE)
|
||||
})
|
||||
|
||||
it('Go to accouht character deletion page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/character/delete',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(REQUIRED_LOGIN_MESSAGE)
|
||||
})
|
||||
|
||||
// account actions
|
||||
it('Go to accouht email change page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/email',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(REQUIRED_LOGIN_MESSAGE)
|
||||
})
|
||||
|
||||
it('Go to accouht password change page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/password',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(REQUIRED_LOGIN_MESSAGE)
|
||||
})
|
||||
|
||||
it('Go to accouht info change page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/info',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(REQUIRED_LOGIN_MESSAGE)
|
||||
})
|
||||
|
||||
it('Go to accouht logout change page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/account/logout',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(REQUIRED_LOGIN_MESSAGE)
|
||||
})
|
||||
|
||||
// guild actions
|
||||
it('Go to guild creation page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/?subtopic=guilds&action=create',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(YOU_ARE_NOT_LOGGEDIN)
|
||||
})
|
||||
|
||||
it('Go to guilds cleanup players action page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/?subtopic=guilds&action=cleanup_players',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(YOU_ARE_NOT_LOGGEDIN)
|
||||
})
|
||||
|
||||
it('Go to guilds cleanup guilds action page', () => {
|
||||
cy.visit({
|
||||
url: Cypress.env('URL') + '/?subtopic=guilds&action=cleanup_guilds',
|
||||
method: 'GET',
|
||||
})
|
||||
cy.contains(YOU_ARE_NOT_LOGGEDIN)
|
||||
})
|
||||
|
||||
})
|
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
@@ -1,25 +0,0 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
@@ -1,20 +0,0 @@
|
||||
// ***********************************************************
|
||||
// This example support/e2e.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
@@ -166,7 +166,6 @@ if($config['backward_support']) {
|
||||
$config['site'] = &$config;
|
||||
$config['server'] = &$config['lua'];
|
||||
$config['site']['shop_system'] = $config['gifts_system'];
|
||||
$config['site']['gallery_page'] = true;
|
||||
|
||||
if(!isset($config['vdarkborder']))
|
||||
$config['vdarkborder'] = '#505050';
|
||||
|
@@ -38,3 +38,4 @@ if(!isset($error) || !$error) {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
?>
|
@@ -1,4 +1,4 @@
|
||||
SET @myaac_database_version = 35;
|
||||
SET @myaac_database_version = 33;
|
||||
|
||||
CREATE TABLE `myaac_account_actions`
|
||||
(
|
||||
@@ -203,7 +203,6 @@ CREATE TABLE `myaac_monsters` (
|
||||
`mana` int(11) NOT NULL DEFAULT 0,
|
||||
`exp` int(11) NOT NULL,
|
||||
`health` int(11) NOT NULL,
|
||||
`look` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`speed_lvl` int(11) NOT NULL default 1,
|
||||
`use_haste` tinyint(1) NOT NULL,
|
||||
`voices` text NOT NULL,
|
||||
@@ -331,7 +330,6 @@ CREATE TABLE `myaac_visitors`
|
||||
`ip` VARCHAR(45) NOT NULL,
|
||||
`lastvisit` INT(11) NOT NULL DEFAULT 0,
|
||||
`page` VARCHAR(2048) NOT NULL,
|
||||
`user_agent` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
UNIQUE (`ip`)
|
||||
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
We have detected that you don't have access to write to the system/cache directory. Under linux you can fix it by using this two command, where first one should be enough (for apache):<br/><br/><span class="console">chown -R www-data.www-data /var/www/*</span><br/><span class="console">chmod -R 760 system/cache</span>
|
||||
We have detected that you don't have access to write to the system/cache directory. Under linux you can fix it by using this two command, where first one should be enough (for apache):<br/><br/><span class="console">chown -R www-data.www-data /var/www/*</span><br/><span class="console">chmod -R 660 system/cache</span>
|
||||
|
||||
<style type="text/css">
|
||||
.console {
|
||||
|
@@ -26,13 +26,13 @@ $twig = new Twig_Environment($twig_loader, array(
|
||||
));
|
||||
|
||||
// load installation status
|
||||
$step = $_REQUEST['step'] ?? 'welcome';
|
||||
$step = isset($_POST['step']) ? $_POST['step'] : 'welcome';
|
||||
|
||||
$install_status = array();
|
||||
if(file_exists(CACHE . 'install.txt')) {
|
||||
$install_status = unserialize(file_get_contents(CACHE . 'install.txt'));
|
||||
|
||||
if(!isset($_REQUEST['step'])) {
|
||||
if(!isset($_POST['step'])) {
|
||||
$step = isset($install_status['step']) ? $install_status['step'] : '';
|
||||
}
|
||||
}
|
||||
@@ -70,7 +70,7 @@ if($step == 'database') {
|
||||
|
||||
$key = str_replace('var_', '', $key);
|
||||
|
||||
if(in_array($key, array('account', 'account_id', 'password', 'password_confirm', 'email', 'player_name'))) {
|
||||
if(in_array($key, array('account', 'password', 'password_confirm', 'email', 'player_name'))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -110,11 +110,13 @@ if($step == 'database') {
|
||||
}
|
||||
}
|
||||
else if($step == 'admin') {
|
||||
if(!file_exists(BASE . 'config.local.php') || !isset($config['installed']) || !$config['installed']) {
|
||||
$step = 'database';
|
||||
$config_failed = true;
|
||||
if(file_exists(BASE . 'config.local.php') && isset($config['installed']) && $config['installed'] && isset($_SESSION['saved'])) {
|
||||
$config_failed = false;
|
||||
}
|
||||
else {
|
||||
$_SESSION['saved'] = true;
|
||||
|
||||
if($config_failed) {
|
||||
$step = 'database';
|
||||
}
|
||||
}
|
||||
else if($step == 'finish') {
|
||||
|
@@ -5,3 +5,4 @@ $twig->display('install.license.html.twig', array(
|
||||
'license' => file_get_contents(BASE . 'LICENSE'),
|
||||
'buttons' => next_buttons()
|
||||
));
|
||||
?>
|
||||
|
@@ -18,3 +18,4 @@ $twig->display('install.config.html.twig', array(
|
||||
'errors' => isset($errors) ? $errors : null,
|
||||
'buttons' => next_buttons()
|
||||
));
|
||||
?>
|
@@ -55,30 +55,12 @@ if(!$error) {
|
||||
error($database_error);
|
||||
}
|
||||
else {
|
||||
if(!$db->hasTable('accounts')) {
|
||||
$tmp = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
|
||||
error($tmp);
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if(!$db->hasTable('players')) {
|
||||
$tmp = str_replace('$TABLE$', 'players', $locale['step_database_error_table']);
|
||||
error($tmp);
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if(!$db->hasTable('guilds')) {
|
||||
$tmp = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']);
|
||||
error($tmp);
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if(!$error) {
|
||||
$twig->display('install.installer.html.twig', array(
|
||||
'url' => 'tools/5-database.php',
|
||||
'message' => $locale['loading_spinner']
|
||||
));
|
||||
|
||||
if(!$error) {
|
||||
if(!Validator::email($_SESSION['var_mail_admin'])) {
|
||||
error($locale['step_config_mail_admin_error']);
|
||||
$error = true;
|
||||
@@ -104,7 +86,7 @@ if(!$error) {
|
||||
unset($_SESSION['saved']);
|
||||
|
||||
$locale['step_database_error_file'] = str_replace('$FILE$', '<b>' . BASE . 'config.local.php</b>', $locale['step_database_error_file']);
|
||||
error($locale['step_database_error_file'] . '<br/>
|
||||
warning($locale['step_database_error_file'] . '<br/>
|
||||
<textarea cols="70" rows="10">' . $content . '</textarea>');
|
||||
}
|
||||
}
|
||||
@@ -116,7 +98,7 @@ if(!$error) {
|
||||
<div class="text-center m-3">
|
||||
<form action="<?php echo BASE_URL; ?>install/" method="post">
|
||||
<input type="hidden" name="step" id="step" value="admin" />
|
||||
<?php echo next_buttons(true, !$error);
|
||||
<?php echo next_buttons(true, $error ? false : true);
|
||||
?>
|
||||
</form>
|
||||
</div>
|
@@ -8,7 +8,7 @@ if(isset($config['installed']) && $config['installed'] && !isset($_SESSION['save
|
||||
else {
|
||||
require SYSTEM . 'init.php';
|
||||
if(!$error) {
|
||||
if(USE_ACCOUNT_NAME || USE_ACCOUNT_NUMBER)
|
||||
if(USE_ACCOUNT_NAME)
|
||||
$account = isset($_SESSION['var_account']) ? $_SESSION['var_account'] : null;
|
||||
else
|
||||
$account_id = isset($_SESSION['var_account_id']) ? $_SESSION['var_account_id'] : null;
|
||||
@@ -65,6 +65,7 @@ else {
|
||||
$new_account->setPassword(encrypt($password));
|
||||
$new_account->setEMail($email);
|
||||
|
||||
$new_account->unblock();
|
||||
$new_account->save();
|
||||
|
||||
$new_account->setCustomField('created', time());
|
||||
@@ -122,7 +123,6 @@ else {
|
||||
));
|
||||
|
||||
if(!isset($_SESSION['installed'])) {
|
||||
if (!array_key_exists('CI', getenv())) {
|
||||
$report_url = 'https://my-aac.org/report_install.php?v=' . MYAAC_VERSION . '&b=' . urlencode(BASE_URL);
|
||||
if (function_exists('curl_version'))
|
||||
{
|
||||
@@ -135,8 +135,6 @@ else {
|
||||
else if (ini_get('allow_url_fopen') ) {
|
||||
file_get_contents($report_url);
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION['installed'] = true;
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $locale['encoding']; ?>" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>MyAAC - <?php echo $locale['installation']; ?></title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
|
||||
<link rel="stylesheet" type="text/css" href="template/style.css" />
|
||||
<script type="text/javascript" src="<?php echo BASE_URL; ?>tools/js/jquery.min.js"></script>
|
||||
</head>
|
||||
@@ -29,7 +29,7 @@
|
||||
$progress = ($i == 6) ? 100 : $i * 16;
|
||||
}
|
||||
|
||||
echo '<li class="list-group-item' . ($step == $value ? ' active' : '') . '">' . ++$i . '. ' . $locale['step_' . $value] . '</li>';
|
||||
echo '<li' . ($step == $value ? ' class="list-group-item active"' : ' class="list-group-item"') . '>' . ++$i . '. ' . $locale['step_' . $value] . '</li>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -23,6 +23,24 @@ if(!$error) {
|
||||
}
|
||||
}
|
||||
|
||||
if(!$db->hasTable('accounts')) {
|
||||
$locale['step_database_error_table'] = str_replace('$TABLE$', 'accounts', $locale['step_database_error_table']);
|
||||
error($locale['step_database_error_table']);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$db->hasTable('players')) {
|
||||
$locale['step_database_error_table'] = str_replace('$TABLE$', 'players', $locale['step_database_error_table']);
|
||||
error($locale['step_database_error_table']);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!$db->hasTable('guilds')) {
|
||||
$locale['step_database_error_table'] = str_replace('$TABLE$', 'guilds', $locale['step_database_error_table']);
|
||||
error($locale['step_database_error_table']);
|
||||
return;
|
||||
}
|
||||
|
||||
if($db->hasTable(TABLE_PREFIX . 'account_actions')) {
|
||||
$locale['step_database_error_table_exist'] = str_replace('$TABLE$', TABLE_PREFIX . 'account_actions', $locale['step_database_error_table_exist']);
|
||||
warning($locale['step_database_error_table_exist']);
|
||||
@@ -55,8 +73,13 @@ else {
|
||||
success($locale['step_database_adding_field'] . ' accounts.key...');
|
||||
}
|
||||
|
||||
if(!$db->hasColumn('accounts', 'blocked')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `blocked` TINYINT(1) NOT NULL DEFAULT FALSE COMMENT 'internal usage' AFTER `key`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.blocked...');
|
||||
}
|
||||
|
||||
if(!$db->hasColumn('accounts', 'created')) {
|
||||
if(query("ALTER TABLE `accounts` ADD `created` INT(11) NOT NULL DEFAULT 0 AFTER `" . ($db->hasColumn('accounts', 'group_id') ? 'group_id' : 'key') . "`;"))
|
||||
if(query("ALTER TABLE `accounts` ADD `created` INT(11) NOT NULL DEFAULT 0 AFTER `" . ($db->hasColumn('accounts', 'group_id') ? 'group_id' : 'blocked') . "`;"))
|
||||
success($locale['step_database_adding_field'] . ' accounts.created...');
|
||||
}
|
||||
|
||||
|
@@ -7,23 +7,6 @@ server {
|
||||
# increase max file upload
|
||||
client_max_body_size 10M;
|
||||
|
||||
# this is very important, be sure its in your nginx conf - it prevents access to logs etc.
|
||||
location ~ /system {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
|
||||
# block .htaccess
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
# block git files and folders
|
||||
location ~ /\.git {
|
||||
return 404;
|
||||
deny all;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php;
|
||||
}
|
||||
@@ -32,6 +15,15 @@ server {
|
||||
include snippets/fastcgi-php.conf;
|
||||
fastcgi_read_timeout 240;
|
||||
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
|
||||
# for ubuntu 22.04+ it will be php8.1-fpm.sock
|
||||
# for ubuntu 22.04+ it will be php8.1-sock
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location /system {
|
||||
deny all;
|
||||
return 404;
|
||||
}
|
||||
}
|
||||
|
1927
package-lock.json
generated
1927
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"scripts": {
|
||||
"cypress:open": "cypress open"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cypress": "^12.12.0"
|
||||
}
|
||||
}
|
@@ -1,3 +1,11 @@
|
||||
<IfModule mod_autoindex.c>
|
||||
Options -Indexes
|
||||
</IfModule>
|
||||
|
||||
<IfVersion < 2.4>
|
||||
order allow,deny
|
||||
deny from all
|
||||
</IfVersion>
|
||||
<IfVersion >= 2.4>
|
||||
Require all denied
|
||||
</IfVersion>
|
||||
|
@@ -1,3 +1,3 @@
|
||||
To play on {{ config.lua.serverName }} you need an account.
|
||||
All you have to do to create your new account is to enter an account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %}, password{% if config.account_country %}, country{% endif %} and your email address.
|
||||
All you have to do to create your new account is to enter an account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %}, password{% if config.recaptcha_enabled %}, confirm reCAPTCHA{% endif %}{% if config.account_country %}, country{% endif %} and your email address.
|
||||
Also you have to agree to the terms presented below. If you have done so, your account {% if constant('USE_ACCOUNT_NAME') %}name{% else %}number{% endif %} will be shown on the following page and your account password will be sent to your email address along with further instructions. If you do not receive the email with your password, please check your spam filter.<br/><br/>
|
||||
|
@@ -22,7 +22,7 @@ if [ $1 = "prepare" ]; then
|
||||
mkdir -p tmp
|
||||
|
||||
# get myaac from git archive
|
||||
git archive --format zip --output tmp/myaac.zip 0.9
|
||||
git archive --format zip --output tmp/myaac.zip master
|
||||
|
||||
cd tmp/ || exit
|
||||
|
||||
@@ -35,11 +35,6 @@ if [ $1 = "prepare" ]; then
|
||||
unzip -q myaac.zip -d $dir
|
||||
rm myaac.zip
|
||||
|
||||
cd $dir || exit
|
||||
|
||||
# dependencies
|
||||
composer install --no-dev
|
||||
|
||||
echo "Now you can make changes to $dir. When you are ready, type 'release.sh pack'"
|
||||
exit
|
||||
fi
|
||||
|
206
system/autoload.php
Normal file
206
system/autoload.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?php
|
||||
namespace MyAAC;
|
||||
|
||||
$loader = new \MyAAC\Psr4AutoloaderClass;
|
||||
|
||||
// register the autoloader
|
||||
$loader->register();
|
||||
|
||||
// register the base directories for the namespace prefix
|
||||
$loader->addNamespace('Composer\Semver', LIBS . 'semver');
|
||||
$loader->addNamespace('Twig', LIBS . 'Twig');
|
||||
/**
|
||||
* An example of a general-purpose implementation that includes the optional
|
||||
* functionality of allowing multiple base directories for a single namespace
|
||||
* prefix.
|
||||
*
|
||||
* Given a foo-bar package of classes in the file system at the following
|
||||
* paths ...
|
||||
*
|
||||
* /path/to/packages/foo-bar/
|
||||
* src/
|
||||
* Baz.php # Foo\Bar\Baz
|
||||
* Qux/
|
||||
* Quux.php # Foo\Bar\Qux\Quux
|
||||
* tests/
|
||||
* BazTest.php # Foo\Bar\BazTest
|
||||
* Qux/
|
||||
* QuuxTest.php # Foo\Bar\Qux\QuuxTest
|
||||
*
|
||||
* ... add the path to the class files for the \Foo\Bar\ namespace prefix
|
||||
* as follows:
|
||||
*
|
||||
* <?php
|
||||
* // instantiate the loader
|
||||
* $loader = new \Example\Psr4AutoloaderClass;
|
||||
*
|
||||
* // register the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // register the base directories for the namespace prefix
|
||||
* $loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/src');
|
||||
* $loader->addNamespace('Foo\Bar', '/path/to/packages/foo-bar/tests');
|
||||
*
|
||||
* The following line would cause the autoloader to attempt to load the
|
||||
* \Foo\Bar\Qux\Quux class from /path/to/packages/foo-bar/src/Qux/Quux.php:
|
||||
*
|
||||
* <?php
|
||||
* new \Foo\Bar\Qux\Quux;
|
||||
*
|
||||
* The following line would cause the autoloader to attempt to load the
|
||||
* \Foo\Bar\Qux\QuuxTest class from /path/to/packages/foo-bar/tests/Qux/QuuxTest.php:
|
||||
*
|
||||
* <?php
|
||||
* new \Foo\Bar\Qux\QuuxTest;
|
||||
*/
|
||||
class Psr4AutoloaderClass
|
||||
{
|
||||
/**
|
||||
* An associative array where the key is a namespace prefix and the value
|
||||
* is an array of base directories for classes in that namespace.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $prefixes = array();
|
||||
|
||||
/**
|
||||
* Register loader with SPL autoloader stack.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a base directory for a namespace prefix.
|
||||
*
|
||||
* @param string $prefix The namespace prefix.
|
||||
* @param string $base_dir A base directory for class files in the
|
||||
* namespace.
|
||||
* @param bool $prepend If true, prepend the base directory to the stack
|
||||
* instead of appending it; this causes it to be searched first rather
|
||||
* than last.
|
||||
* @return void
|
||||
*/
|
||||
public function addNamespace($prefix, $base_dir, $prepend = false)
|
||||
{
|
||||
// normalize namespace prefix
|
||||
$prefix = trim($prefix, '\\') . '\\';
|
||||
|
||||
// normalize the base directory with a trailing separator
|
||||
$base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/';
|
||||
|
||||
// initialize the namespace prefix array
|
||||
if (isset($this->prefixes[$prefix]) === false) {
|
||||
$this->prefixes[$prefix] = array();
|
||||
}
|
||||
|
||||
// retain the base directory for the namespace prefix
|
||||
if ($prepend) {
|
||||
array_unshift($this->prefixes[$prefix], $base_dir);
|
||||
} else {
|
||||
array_push($this->prefixes[$prefix], $base_dir);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the class file for a given class name.
|
||||
*
|
||||
* @param string $class The fully-qualified class name.
|
||||
* @return mixed The mapped file name on success, or boolean false on
|
||||
* failure.
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if (0 === strpos($class, 'Twig_')) {
|
||||
$file = LIBS . 'Twig/' . str_replace(array('_', "\0"), array('/', ''), $class).'.php';
|
||||
|
||||
if((config('env') === 'dev') && !is_file($file)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require $file;
|
||||
return false;
|
||||
}
|
||||
|
||||
// the current namespace prefix
|
||||
$prefix = $class;
|
||||
|
||||
// work backwards through the namespace names of the fully-qualified
|
||||
// class name to find a mapped file name
|
||||
while (false !== $pos = strrpos($prefix, '\\')) {
|
||||
|
||||
// retain the trailing namespace separator in the prefix
|
||||
$prefix = substr($class, 0, $pos + 1);
|
||||
|
||||
// the rest is the relative class name
|
||||
$relative_class = substr($class, $pos + 1);
|
||||
|
||||
// try to load a mapped file for the prefix and relative class
|
||||
$mapped_file = $this->loadMappedFile($prefix, $relative_class);
|
||||
if ($mapped_file) {
|
||||
return $mapped_file;
|
||||
}
|
||||
|
||||
// remove the trailing namespace separator for the next iteration
|
||||
// of strrpos()
|
||||
$prefix = rtrim($prefix, '\\');
|
||||
}
|
||||
|
||||
// never found a mapped file
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the mapped file for a namespace prefix and relative class.
|
||||
*
|
||||
* @param string $prefix The namespace prefix.
|
||||
* @param string $relative_class The relative class name.
|
||||
* @return mixed Boolean false if no mapped file can be loaded, or the
|
||||
* name of the mapped file that was loaded.
|
||||
*/
|
||||
protected function loadMappedFile($prefix, $relative_class)
|
||||
{
|
||||
// are there any base directories for this namespace prefix?
|
||||
if (isset($this->prefixes[$prefix]) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// look through base directories for this namespace prefix
|
||||
foreach ($this->prefixes[$prefix] as $base_dir) {
|
||||
|
||||
// replace the namespace prefix with the base directory,
|
||||
// replace namespace separators with directory separators
|
||||
// in the relative class name, append with .php
|
||||
$file = $base_dir
|
||||
. str_replace('\\', '/', $relative_class)
|
||||
. '.php';
|
||||
|
||||
// if the mapped file exists, require it
|
||||
if ($this->requireFile($file)) {
|
||||
// yes, we're done
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// never found it
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a file exists, require it from the file system.
|
||||
*
|
||||
* @param string $file The file to require.
|
||||
* @return bool True if the file exists, false if not.
|
||||
*/
|
||||
protected function requireFile($file)
|
||||
{
|
||||
if (config('env') !== 'dev' || file_exists($file)) {
|
||||
require $file;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -99,10 +99,4 @@ $config['clients'] = [
|
||||
1291,
|
||||
|
||||
1300,
|
||||
1310,
|
||||
1311,
|
||||
1312,
|
||||
1316,
|
||||
1320,
|
||||
1321,
|
||||
];
|
||||
|
@@ -9,30 +9,7 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
class Account extends OTS_Account {
|
||||
public function loadById($id) {
|
||||
$this->load($id);
|
||||
}
|
||||
public function loadByName($name) {
|
||||
$this->find($name);
|
||||
}
|
||||
}
|
||||
|
||||
class Player extends OTS_Player {
|
||||
public function loadById($id) {
|
||||
$this->load($id);
|
||||
}
|
||||
public function loadByName($name) {
|
||||
$this->find($name);
|
||||
}
|
||||
}
|
||||
class Guild extends OTS_Guild {
|
||||
public function loadById($id) {
|
||||
$this->load($id);
|
||||
}
|
||||
public function loadByName($name) {
|
||||
$this->find($name);
|
||||
}
|
||||
}
|
||||
class Player extends OTS_Player {}
|
||||
class Guild extends OTS_Guild {}
|
||||
class GuildRank extends OTS_GuildRank {}
|
||||
class House extends OTS_House {}
|
||||
|
@@ -10,10 +10,6 @@
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
switch($page)
|
||||
{
|
||||
case 'adminpanel':
|
||||
header('Location: ' . ADMIN_URL);
|
||||
die;
|
||||
|
||||
case 'createaccount':
|
||||
$page = 'account/create';
|
||||
break;
|
||||
@@ -34,7 +30,6 @@ switch($page)
|
||||
$page = 'news';
|
||||
break;
|
||||
|
||||
case 'archive':
|
||||
case 'newsarchive':
|
||||
$page = 'news/archive';
|
||||
break;
|
||||
|
@@ -51,3 +51,4 @@ else
|
||||
updateDatabaseConfig('views_counter', $views_counter); // update counter
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -1,25 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Exception handler
|
||||
*
|
||||
* @package MyAAC
|
||||
* @author Slawkens <slawkens@gmail.com>
|
||||
* @copyright 2023 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
|
||||
if (class_exists(\Whoops\Run::class)) {
|
||||
$whoops = new \Whoops\Run;
|
||||
if(IS_CLI) {
|
||||
$whoops->pushHandler(new \Whoops\Handler\PlainTextHandler);
|
||||
}
|
||||
else {
|
||||
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
}
|
||||
|
||||
$whoops->register();
|
||||
return;
|
||||
}
|
||||
|
||||
require LIBS . 'SensitiveException.php';
|
||||
|
||||
@@ -44,8 +23,6 @@ function exception_handler($exception) {
|
||||
|
||||
$backtrace_formatted = nl2br($exception->getTraceAsString());
|
||||
|
||||
$message = $message . "<br/><br/>File: {$exception->getFile()}<br/>Line: {$exception->getLine()}";
|
||||
|
||||
// display basic error message without template
|
||||
// template is missing, why? probably someone deleted templates dir, or it wasn't downloaded right
|
||||
$template_file = SYSTEM . 'templates/exception.html.twig';
|
||||
|
@@ -7,11 +7,12 @@
|
||||
* @copyright 2019 MyAAC
|
||||
* @link https://my-aac.org
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use Twig\Loader\ArrayLoader as Twig_ArrayLoader;
|
||||
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
function message($message, $type, $return)
|
||||
{
|
||||
if(IS_CLI) {
|
||||
@@ -125,13 +126,14 @@ function getHouseLink($name, $generate = true)
|
||||
|
||||
function getGuildLink($name, $generate = true)
|
||||
{
|
||||
global $config;
|
||||
global $db, $config;
|
||||
|
||||
if(is_numeric($name)) {
|
||||
$name = getGuildNameById($name);
|
||||
if ($name === false) {
|
||||
$name = 'Unknown';
|
||||
}
|
||||
if(is_numeric($name))
|
||||
{
|
||||
$guild = $db->query(
|
||||
'SELECT `name` FROM `guilds` WHERE `id` = ' . (int)$name);
|
||||
if($guild->rowCount() > 0)
|
||||
$name = $guild->fetchColumn();
|
||||
}
|
||||
|
||||
$url = BASE_URL . ($config['friendly_urls'] ? '' : 'index.php/') . 'guilds/' . urlencode($name);
|
||||
@@ -754,10 +756,10 @@ function get_browser_languages()
|
||||
{
|
||||
$ret = array();
|
||||
|
||||
if(empty($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
||||
$acceptLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
if(!isset($acceptLang[0]))
|
||||
return $ret;
|
||||
|
||||
$acceptLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
|
||||
$languages = strtolower($acceptLang);
|
||||
// $languages = 'pl,en-us;q=0.7,en;q=0.3 ';
|
||||
// need to remove spaces from strings to avoid error
|
||||
@@ -790,21 +792,16 @@ function get_templates()
|
||||
* Generates list of installed plugins
|
||||
* @return array $plugins
|
||||
*/
|
||||
function get_plugins($disabled = false): array
|
||||
function get_plugins()
|
||||
{
|
||||
$ret = [];
|
||||
$ret = array();
|
||||
|
||||
$path = PLUGINS;
|
||||
foreach(scandir($path, SCANDIR_SORT_ASCENDING) as $file) {
|
||||
foreach(scandir($path, 0) as $file) {
|
||||
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||
$file_name = pathinfo($file, PATHINFO_FILENAME);
|
||||
if ($file === '.' || $file === '..' || $file === 'example.json' || $file_ext !== 'json' || is_dir($path . $file)) {
|
||||
if ($file === '.' || $file === '..' || $file === 'disabled' || $file === 'example.json' || $file_ext !== 'json' || is_dir($path . $file))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$disabled && strpos($file, 'disabled.') !== false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ret[] = str_replace('.json', '', $file_name);
|
||||
}
|
||||
@@ -929,8 +926,8 @@ function load_config_lua($filename)
|
||||
$config_file = $filename;
|
||||
if(!@file_exists($config_file))
|
||||
{
|
||||
log_append('error.log', '[load_config_file] Fatal error: Cannot load config.lua (' . $filename . ').');
|
||||
throw new RuntimeException('ERROR: Cannot find ' . $filename . ' file.');
|
||||
log_append('error.log', '[load_config_file] Fatal error: Cannot load config.lua (' . $filename . '). Error: ' . print_r(error_get_last(), true));
|
||||
throw new RuntimeException('ERROR: Cannot find ' . $filename . ' file. More info in system/logs/error.log');
|
||||
}
|
||||
|
||||
$result = array();
|
||||
@@ -1192,7 +1189,7 @@ function getCustomPageInfo($page)
|
||||
|
||||
return null;
|
||||
}
|
||||
function getCustomPage($page, &$success): string
|
||||
function getCustomPage($page, &$success)
|
||||
{
|
||||
global $db, $twig, $title, $ignore, $logged_access;
|
||||
|
||||
@@ -1362,48 +1359,39 @@ function getChangelogWhere($v)
|
||||
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
function getPlayerNameByAccountId($id)
|
||||
function getPlayerNameByAccount($id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if (!is_numeric($id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$account = new OTS_Account();
|
||||
$account->load($id);
|
||||
if ($account->isLoaded()) {
|
||||
$query = $db->query('SELECT `name` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;');
|
||||
|
||||
if (!$query || !$query->rowCount()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $query->fetch(PDO::FETCH_ASSOC)['name'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getPlayerNameByAccount($account) {
|
||||
if (is_numeric($account)) {
|
||||
return getPlayerNameByAccountId($account);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function getPlayerNameById($id)
|
||||
{
|
||||
if (!is_numeric($id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
global $vowels, $ots, $db;
|
||||
if(is_numeric($id))
|
||||
{
|
||||
$player = new OTS_Player();
|
||||
$player->load($id);
|
||||
if ($player->isLoaded()) {
|
||||
if($player->isLoaded())
|
||||
return $player->getName();
|
||||
else
|
||||
{
|
||||
$playerQuery = $db->query('SELECT `id` FROM `players` WHERE `account_id` = ' . $id . ' ORDER BY `lastlogin` DESC LIMIT 1;')->fetch();
|
||||
|
||||
$tmp = "*Error*";
|
||||
/*
|
||||
$acco = new OTS_Account();
|
||||
$acco->load($id);
|
||||
if(!$acco->isLoaded())
|
||||
return "Unknown name";
|
||||
|
||||
foreach($acco->getPlayersList() as $p)
|
||||
{
|
||||
$player= new OTS_Player();
|
||||
$player->find($p);*/
|
||||
$player->load($playerQuery['id']);
|
||||
//echo 'id gracza = ' . $p . '<br/>';
|
||||
if($player->isLoaded())
|
||||
$tmp = $player->getName();
|
||||
// break;
|
||||
//}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
@@ -1411,13 +1399,13 @@ function getPlayerNameById($id)
|
||||
|
||||
function echo_success($message)
|
||||
{
|
||||
echo '<div class="col-12 alert alert-success mb-2">' . $message . '</div>';
|
||||
echo '<div class="col-12 success mb-2">' . $message . '</div>';
|
||||
}
|
||||
|
||||
function echo_error($message)
|
||||
{
|
||||
global $error;
|
||||
echo '<div class="col-12 alert alert-error mb-2">' . $message . '</div>';
|
||||
echo '<div class="col-12 error mb-2">' . $message . '</div>';
|
||||
$error = true;
|
||||
}
|
||||
|
||||
@@ -1556,47 +1544,6 @@ function escapeHtml($html) {
|
||||
return htmlentities($html, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
}
|
||||
|
||||
function getGuildNameById($id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$guild = $db->query('SELECT `name` FROM `guilds` WHERE `id` = ' . (int)$id);
|
||||
|
||||
if($guild->rowCount() > 0) {
|
||||
return $guild->fetchColumn();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function getGuildLogoById($id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
$logo = 'default.gif';
|
||||
|
||||
$query = $db->query('SELECT `logo_name` FROM `guilds` WHERE `id` = ' . (int)$id);
|
||||
if ($query->rowCount() == 1) {
|
||||
|
||||
$query = $query->fetch(PDO::FETCH_ASSOC);
|
||||
$guildLogo = $query['logo_name'];
|
||||
|
||||
if (!empty($guildLogo) && file_exists(GUILD_IMAGES_DIR . $guildLogo)) {
|
||||
$logo = $guildLogo;
|
||||
}
|
||||
}
|
||||
|
||||
return BASE_URL . GUILD_IMAGES_DIR . $logo;
|
||||
}
|
||||
|
||||
function displayErrorBoxWithBackButton($errors, $action = null) {
|
||||
global $twig;
|
||||
$twig->display('error_box.html.twig', ['errors' => $errors]);
|
||||
$twig->display('account.back_button.html.twig', [
|
||||
'action' => $action ?: getLink('')
|
||||
]);
|
||||
}
|
||||
|
||||
// validator functions
|
||||
require_once LIBS . 'validator.php';
|
||||
require_once SYSTEM . 'compat/base.php';
|
||||
|
@@ -30,7 +30,6 @@ define('HOOK_CHARACTERS_AFTER_CHARACTERS', ++$i);
|
||||
define('HOOK_LOGIN', ++$i);
|
||||
define('HOOK_LOGIN_ATTEMPT', ++$i);
|
||||
define('HOOK_LOGOUT', ++$i);
|
||||
define('HOOK_ACCOUNT_CHANGE_PASSWORD_POST', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_FORM', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_BOXES', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BETWEEN_BOXES_1', ++$i);
|
||||
@@ -40,8 +39,8 @@ define('HOOK_ACCOUNT_CREATE_BEFORE_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_EMAIL', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_COUNTRY', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_PASSWORD', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_PASSWORDS', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_RECAPTCHA', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_CHARACTER_NAME', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_CHARACTER_NAME', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_SEX', ++$i);
|
||||
@@ -49,30 +48,11 @@ define('HOOK_ACCOUNT_CREATE_AFTER_VOCATION', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_TOWNS', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_BEFORE_SUBMIT_BUTTON', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_FORM', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_POST', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_BEFORE_PAGE', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_BEFORE_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_ACCOUNT', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_BEFORE_PASSWORD', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_PASSWORD', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_REMEMBER_ME', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_AFTER_PAGE', ++$i);
|
||||
define('HOOK_ACCOUNT_LOGIN_POST', ++$i);
|
||||
define('HOOK_ADMIN_HEAD_END', ++$i);
|
||||
define('HOOK_ADMIN_HEAD_START', ++$i);
|
||||
define('HOOK_ADMIN_BODY_START', ++$i);
|
||||
define('HOOK_ADMIN_BODY_END', ++$i);
|
||||
define('HOOK_ADMIN_BEFORE_PAGE', ++$i);
|
||||
define('HOOK_ACCOUNT_CREATE_AFTER_SUBMIT', ++$i);
|
||||
define('HOOK_ADMIN_MENU', ++$i);
|
||||
define('HOOK_ADMIN_LOGIN_AFTER_ACCOUNT', ++$i);
|
||||
define('HOOK_ADMIN_LOGIN_AFTER_PASSWORD', ++$i);
|
||||
define('HOOK_ADMIN_LOGIN_AFTER_SIGN_IN', ++$i);
|
||||
define('HOOK_ADMIN_ACCOUNTS_SAVE_POST', ++$i);
|
||||
define('HOOK_EMAIL_CONFIRMED', ++$i);
|
||||
define('HOOK_GUILDS_AFTER_INVITED_CHARACTERS', ++$i);
|
||||
|
||||
const HOOK_FIRST = HOOK_STARTUP;
|
||||
define('HOOK_LAST', $i);
|
||||
define('HOOK_FIRST', HOOK_STARTUP);
|
||||
define('HOOK_LAST', HOOK_EMAIL_CONFIRMED);
|
||||
|
||||
require_once LIBS . 'plugins.php';
|
||||
class Hook
|
||||
|
@@ -18,10 +18,6 @@ if(!isset($config['installed']) || !$config['installed']) {
|
||||
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
|
||||
}
|
||||
|
||||
if(config('env') === 'dev') {
|
||||
require SYSTEM . 'exception.php';
|
||||
}
|
||||
|
||||
date_default_timezone_set($config['date_timezone']);
|
||||
// take care of trailing slash at the end
|
||||
if($config['server_path'][strlen($config['server_path']) - 1] !== '/')
|
||||
@@ -122,7 +118,7 @@ if(!isset($foundValue)) {
|
||||
$config['data_path'] = $foundValue;
|
||||
unset($foundValue);
|
||||
|
||||
// new config values for compatibility
|
||||
// new config values for compability
|
||||
if(!isset($config['highscores_ids_hidden']) || count($config['highscores_ids_hidden']) == 0) {
|
||||
$config['highscores_ids_hidden'] = array(0);
|
||||
}
|
||||
|
@@ -58,3 +58,4 @@ function outputItem($id = 100, $count = 1)
|
||||
$file_name = Items_Images::$outputDir . $file_name . '.gif';
|
||||
readfile($file_name);
|
||||
}
|
||||
?>
|
||||
|
@@ -138,7 +138,7 @@ class CreateCharacter
|
||||
|
||||
if(empty($errors))
|
||||
{
|
||||
$number_of_players_on_account = $account->getPlayersList(true)->count();
|
||||
$number_of_players_on_account = $account->getPlayersList(false)->count();
|
||||
if($number_of_players_on_account >= config('characters_per_account'))
|
||||
$errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.config('characters_per_account').')</b>!';
|
||||
}
|
||||
@@ -251,13 +251,11 @@ class CreateCharacter
|
||||
}
|
||||
}
|
||||
|
||||
if ($db->hasTable('player_items') && $db->hasColumn('player_items', 'pid') && $db->hasColumn('player_items', 'sid') && $db->hasColumn('player_items', 'itemtype')) {
|
||||
$loaded_items_to_copy = $db->query("SELECT * FROM player_items WHERE player_id = ".$char_to_copy->getId()."");
|
||||
foreach($loaded_items_to_copy as $save_item) {
|
||||
$blob = $db->quote($save_item['attributes']);
|
||||
$db->query("INSERT INTO `player_items` (`player_id` ,`pid` ,`sid` ,`itemtype`, `count`, `attributes`) VALUES ('".$player->getId()."', '".$save_item['pid']."', '".$save_item['sid']."', '".$save_item['itemtype']."', '".$save_item['count']."', $blob);");
|
||||
}
|
||||
}
|
||||
|
||||
global $twig;
|
||||
$twig->display('success.html.twig', array(
|
||||
|
84
system/libs/GoogleReCAPTCHA.php
Normal file
84
system/libs/GoogleReCAPTCHA.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
class GoogleReCAPTCHA
|
||||
{
|
||||
private static $errorMessage = '';
|
||||
private static $errorType;
|
||||
|
||||
const ERROR_MISSING_RESPONSE = 1;
|
||||
const ERROR_INVALID_ACTION = 2;
|
||||
const ERROR_LOW_SCORE = 3;
|
||||
const ERROR_NO_SUCCESS = 4;
|
||||
|
||||
public static function verify($action = '')
|
||||
{
|
||||
if (!isset($_POST['g-recaptcha-response']) || empty($_POST['g-recaptcha-response'])) {
|
||||
self::$errorType = self::ERROR_MISSING_RESPONSE;
|
||||
self::$errorMessage = "Please confirm that you're not a robot.";
|
||||
return false;
|
||||
}
|
||||
|
||||
$recaptchaApiUrl = 'https://www.google.com/recaptcha/api/siteverify';
|
||||
$secretKey = config('recaptcha_secret_key');
|
||||
|
||||
$recaptchaResponse = $_POST['g-recaptcha-response'];
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
$params = 'secret='.$secretKey.'&response='.$recaptchaResponse.'&remoteip='.$ip;
|
||||
|
||||
if (function_exists('curl_version')) {
|
||||
$curl_connection = curl_init($recaptchaApiUrl);
|
||||
|
||||
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 5);
|
||||
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0);
|
||||
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $params);
|
||||
|
||||
$response = curl_exec($curl_connection);
|
||||
curl_close($curl_connection);
|
||||
} else {
|
||||
$response = file_get_contents($recaptchaApiUrl . '?' . $params);
|
||||
}
|
||||
|
||||
$json = json_decode($response);
|
||||
|
||||
$recaptchaType = config('recaptcha_type');
|
||||
if ($recaptchaType === 'v3') { // score based
|
||||
//log_append('recaptcha.log', 'recaptcha_score: ' . $json->score . ', action:' . $json->action);
|
||||
|
||||
if (!isset($json->action) || $json->action !== $action) {
|
||||
self::$errorType = self::ERROR_INVALID_ACTION;
|
||||
self::$errorMessage = 'Google ReCaptcha returned invalid action.';
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($json->score) || $json->score < config('recaptcha_v3_min_score')) {
|
||||
self::$errorType = self::ERROR_LOW_SCORE;
|
||||
self::$errorMessage = 'Your Google ReCaptcha score was too low.';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($json->success) || !$json->success) {
|
||||
self::$errorType = self::ERROR_NO_SUCCESS;
|
||||
self::$errorMessage = "Please confirm that you're not a robot.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getErrorMessage() {
|
||||
return self::$errorMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public static function getErrorType() {
|
||||
return self::$errorType;
|
||||
}
|
||||
}
|
@@ -110,21 +110,4 @@ class Cache
|
||||
* @return bool
|
||||
*/
|
||||
public function enabled() {return false;}
|
||||
|
||||
public static function remember($key, $ttl, $callback)
|
||||
{
|
||||
$cache = self::getInstance();
|
||||
if(!$cache->enabled()) {
|
||||
return $callback();
|
||||
}
|
||||
|
||||
$value = null;
|
||||
if ($cache->fetch($key, $value)) {
|
||||
return unserialize($value);
|
||||
}
|
||||
|
||||
$value = $callback();
|
||||
$cache->set($key, serialize($value),$ttl);
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
@@ -82,9 +82,6 @@ class Creatures {
|
||||
$armor = $monster->getArmor();
|
||||
$defensev = $monster->getDefense();
|
||||
|
||||
//load look
|
||||
$look = $monster->getLook();
|
||||
|
||||
//load monster flags
|
||||
$flags = $monster->getFlags();
|
||||
if(!isset($flags['summonable']))
|
||||
@@ -150,7 +147,6 @@ class Creatures {
|
||||
'armor' => $armor,
|
||||
'race' => $race,
|
||||
'loot' => json_encode($loot),
|
||||
'look' => json_encode($look),
|
||||
'summons' => json_encode($summons)
|
||||
));
|
||||
|
||||
|
@@ -41,3 +41,4 @@ class Data
|
||||
return $db->update($this->table, $data, $where);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -10,7 +10,7 @@
|
||||
*/
|
||||
defined('MYAAC') or die('Direct access not allowed!');
|
||||
|
||||
function is_sub_dir($path = NULL, $parent_folder = BASE) {
|
||||
function is_sub_dir($path = NULL, $parent_folder = SITE_PATH) {
|
||||
|
||||
//Get directory path minus last folder
|
||||
$dir = dirname($path);
|
||||
@@ -41,9 +41,9 @@ function is_sub_dir($path = NULL, $parent_folder = BASE) {
|
||||
use Composer\Semver\Semver;
|
||||
|
||||
class Plugins {
|
||||
private static $warnings = [];
|
||||
private static $warnings = array();
|
||||
private static $error = null;
|
||||
private static $plugin_json = [];
|
||||
private static $plugin_json = array();
|
||||
|
||||
public static function getRoutes()
|
||||
{
|
||||
@@ -56,8 +56,22 @@ class Plugins {
|
||||
}
|
||||
|
||||
$routes = [];
|
||||
foreach(self::getAllPluginsJson() as $plugin) {
|
||||
$warningPreTitle = 'Plugin: ' . $plugin['name'] . ' - ';
|
||||
foreach(get_plugins() as $filename) {
|
||||
$string = file_get_contents(PLUGINS . $filename . '.json');
|
||||
$string = self::removeComments($string);
|
||||
$plugin = json_decode($string, true);
|
||||
self::$plugin_json = $plugin;
|
||||
if ($plugin == null) {
|
||||
self::$warnings[] = 'Cannot load ' . $filename . '.json. File might be not a valid json code.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isset($plugin['enabled']) && !getBoolean($plugin['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
continue;
|
||||
}
|
||||
|
||||
$warningPreTitle = 'Plugin: ' . $filename . ' - ';
|
||||
|
||||
if (isset($plugin['routes'])) {
|
||||
foreach ($plugin['routes'] as $_name => $info) {
|
||||
@@ -66,8 +80,7 @@ class Plugins {
|
||||
if ($method !== '*') {
|
||||
$methods = is_string($method) ? explode(',', $info['method']) : $method;
|
||||
foreach ($methods as $method) {
|
||||
$method = strtolower($method);
|
||||
if (!in_array($method, ['get', 'post', 'put', 'patch', 'delete', 'head'])) {
|
||||
if (!in_array($method, ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'])) {
|
||||
self::$warnings[] = $warningPreTitle . 'Not allowed method ' . $method . '... Disabling this route...';
|
||||
}
|
||||
}
|
||||
@@ -148,18 +161,28 @@ class Plugins {
|
||||
}
|
||||
|
||||
$hooks = [];
|
||||
foreach(self::getAllPluginsJson() as $plugin) {
|
||||
if (isset($plugin['hooks'])) {
|
||||
foreach ($plugin['hooks'] as $_name => $info) {
|
||||
if (strpos($info['type'], 'HOOK_') !== false) {
|
||||
$info['type'] = str_replace('HOOK_', '', $info['type']);
|
||||
foreach(get_plugins() as $filename) {
|
||||
$string = file_get_contents(PLUGINS . $filename . '.json');
|
||||
$string = self::removeComments($string);
|
||||
$plugin = json_decode($string, true);
|
||||
self::$plugin_json = $plugin;
|
||||
if ($plugin == null) {
|
||||
self::$warnings[] = 'Cannot load ' . $filename . '.json. File might be not a valid json code.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isset($plugin['enabled']) && !getBoolean($plugin['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($plugin['hooks'])) {
|
||||
foreach ($plugin['hooks'] as $_name => $info) {
|
||||
if (defined('HOOK_'. $info['type'])) {
|
||||
$hook = constant('HOOK_'. $info['type']);
|
||||
$hooks[] = ['name' => $_name, 'type' => $hook, 'file' => $info['file']];
|
||||
} else {
|
||||
self::$warnings[] = 'Plugin: ' . $plugin['name'] . '. Unknown event type: ' . $info['type'];
|
||||
self::$warnings[] = 'Plugin: ' . $filename . '. Unknown event type: ' . $info['type'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,41 +195,6 @@ class Plugins {
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
public static function getAllPluginsJson($disabled = false)
|
||||
{
|
||||
$cache = Cache::getInstance();
|
||||
if ($cache->enabled()) {
|
||||
$tmp = '';
|
||||
if ($cache->fetch('plugins', $tmp)) {
|
||||
return unserialize($tmp);
|
||||
}
|
||||
}
|
||||
|
||||
$plugins = [];
|
||||
foreach (get_plugins($disabled) as $filename) {
|
||||
$string = file_get_contents(PLUGINS . $filename . '.json');
|
||||
$plugin = json_decode($string, true);
|
||||
self::$plugin_json = $plugin;
|
||||
if ($plugin == null) {
|
||||
self::$warnings[] = 'Cannot load ' . $filename . '.json. File might be not a valid json code.';
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isset($plugin['enabled']) && !getBoolean($plugin['enabled'])) {
|
||||
self::$warnings[] = 'Skipping ' . $filename . '... The plugin is disabled.';
|
||||
continue;
|
||||
}
|
||||
|
||||
$plugins[] = $plugin;
|
||||
}
|
||||
|
||||
if ($cache->enabled()) {
|
||||
$cache->set('plugins', serialize($plugins), 600);
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
public static function install($file) {
|
||||
global $db;
|
||||
|
||||
@@ -247,6 +235,7 @@ class Plugins {
|
||||
}
|
||||
|
||||
$string = file_get_contents($file_name);
|
||||
$string = self::removeComments($string);
|
||||
$plugin_json = json_decode($string, true);
|
||||
self::$plugin_json = $plugin_json;
|
||||
if ($plugin_json == null) {
|
||||
@@ -446,35 +435,7 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function enable($pluginFileName): bool
|
||||
{
|
||||
return self::enableDisable($pluginFileName, true);
|
||||
}
|
||||
|
||||
public static function disable($pluginFileName): bool
|
||||
{
|
||||
return self::enableDisable($pluginFileName, false);
|
||||
}
|
||||
|
||||
private static function enableDisable($pluginFileName, $enable): bool
|
||||
{
|
||||
$filenameJson = $pluginFileName . '.json';
|
||||
$fileExist = is_file(PLUGINS . ($enable ? 'disabled.' : '') . $filenameJson);
|
||||
if (!$fileExist) {
|
||||
self::$error = 'Cannot ' . ($enable ? 'enable' : 'disable') . ' plugin: ' . $pluginFileName . '. File does not exist.';
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = rename(PLUGINS . ($enable ? 'disabled.' : '') . $filenameJson, PLUGINS . ($enable ? '' : 'disabled.') . $filenameJson);
|
||||
if (!$result) {
|
||||
self::$error = 'Cannot ' . ($enable ? 'enable' : 'disable') . ' plugin: ' . $pluginFileName . '. Permission problem.';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function uninstall($plugin_name): bool
|
||||
public static function uninstall($plugin_name)
|
||||
{
|
||||
$filename = BASE . 'plugins/' . $plugin_name . '.json';
|
||||
if(!file_exists($filename)) {
|
||||
@@ -482,8 +443,9 @@ class Plugins {
|
||||
return false;
|
||||
}
|
||||
$string = file_get_contents($filename);
|
||||
$string = self::removeComments($string);
|
||||
$plugin_info = json_decode($string, true);
|
||||
if(!$plugin_info) {
|
||||
if($plugin_info == false) {
|
||||
self::$error = 'Cannot load plugin info ' . $plugin_name . '.json';
|
||||
return false;
|
||||
}
|
||||
@@ -565,6 +527,22 @@ class Plugins {
|
||||
return self::$plugin_json;
|
||||
}
|
||||
|
||||
public static function removeComments($string) {
|
||||
$string = preg_replace('!/\*.*?\*/!s', '', $string);
|
||||
$string = preg_replace('/\n\s*\n/', "\n", $string);
|
||||
// Removes multi-line comments and does not create
|
||||
// a blank line, also treats white spaces/tabs
|
||||
$string = preg_replace('!^[ \t]*/\*.*?\*/[ \t]*[\r\n]!s', '', $string);
|
||||
|
||||
// Removes single line '//' comments, treats blank characters
|
||||
$string = preg_replace('![ \t]*//.*[ \t]*[\r\n]!', '', $string);
|
||||
|
||||
// Strip blank lines
|
||||
$string = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);
|
||||
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install menus
|
||||
* Helper function for plugins
|
||||
|
@@ -32,3 +32,5 @@ class E_OTS_ErrorCode extends Exception
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -36,3 +36,5 @@ class E_OTS_Generic extends E_OTS_ErrorCode
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -22,3 +22,5 @@ class E_OTS_NotAContainer extends Exception
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -32,3 +32,5 @@ class E_OTS_OTBMError extends E_OTS_ErrorCode
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -22,3 +22,5 @@ class E_OTS_ReadOnly extends Exception
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -37,3 +37,5 @@ interface IOTS_Cipher
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -89,3 +89,5 @@ interface IOTS_DataDisplay
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -96,3 +96,5 @@ interface IOTS_Display
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -67,3 +67,5 @@ interface IOTS_GuildAction
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -21,6 +21,7 @@
|
||||
* @property string $password Password.
|
||||
* @property string $eMail Email address.
|
||||
* @property int $premiumEnd Timestamp of PACC end.
|
||||
* @property bool $blocked Blocked flag state.
|
||||
* @property bool $deleted Deleted flag state.
|
||||
* @property bool $warned Warned flag state.
|
||||
* @property bool $banned Ban state.
|
||||
@@ -38,7 +39,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @var array
|
||||
* @version 0.1.5
|
||||
*/
|
||||
private $data = array('email' => '', 'rlname' => '','location' => '', 'country' => '','web_flags' => 0, 'lastday' => 0, 'premdays' => 0, 'created' => 0);
|
||||
private $data = array('email' => '', 'blocked' => false, 'rlname' => '','location' => '', 'country' => '','web_flags' => 0, 'lastday' => 0, 'premdays' => 0, 'created' => 0);
|
||||
|
||||
public static $cache = array();
|
||||
|
||||
@@ -230,22 +231,26 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
* @param int $id Account number.
|
||||
* @throws PDOException On PDO operation error.
|
||||
*/
|
||||
public function load($id, $fresh = false)
|
||||
public function load($id, $fresh = false, $searchOnlyById = false)
|
||||
{
|
||||
if(!$fresh && isset(self::$cache[$id])) {
|
||||
$this->data = self::$cache[$id];
|
||||
return;
|
||||
}
|
||||
|
||||
$numberColumn = 'id';
|
||||
$nameOrNumber = '';
|
||||
if (!$searchOnlyById) {
|
||||
if (USE_ACCOUNT_NAME) {
|
||||
$nameOrNumber = '`name`,';
|
||||
} else if (USE_ACCOUNT_NUMBER) {
|
||||
$nameOrNumber = '`number`,';
|
||||
$numberColumn = 'number';
|
||||
}
|
||||
}
|
||||
|
||||
// SELECT query on database
|
||||
$this->data = $this->db->query('SELECT `id`, ' . $nameOrNumber . '`password`, `email`, `rlname`, `location`, `country`, `web_flags`, ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays`, ' : '') . ($this->db->hasColumn('accounts', 'lastday') ? '`lastday`, ' : ($this->db->hasColumn('accounts', 'premend') ? '`premend`,' : ($this->db->hasColumn('accounts', 'premium_ends_at') ? '`premium_ends_at`,' : ''))) . '`created` FROM `accounts` WHERE `id` = ' . (int) $id)->fetch();
|
||||
$this->data = $this->db->query('SELECT `id`, ' . $nameOrNumber . '`password`, `email`, `blocked`, `rlname`, `location`, `country`, `web_flags`, ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays`, ' : '') . ($this->db->hasColumn('accounts', 'lastday') ? '`lastday`, ' : ($this->db->hasColumn('accounts', 'premend') ? '`premend`,' : ($this->db->hasColumn('accounts', 'premium_ends_at') ? '`premium_ends_at`,' : ''))) . '`created` FROM `accounts` WHERE `' . $numberColumn . '` = ' . (int) $id)->fetch();
|
||||
self::$cache[$id] = $this->data;
|
||||
}
|
||||
|
||||
@@ -263,13 +268,8 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
*/
|
||||
public function find($name)
|
||||
{
|
||||
$nameOrNumberColumn = 'name';
|
||||
if (USE_ACCOUNT_NUMBER) {
|
||||
$nameOrNumberColumn = 'number';
|
||||
}
|
||||
|
||||
// finds player's ID
|
||||
$id = $this->db->query('SELECT `id` FROM `accounts` WHERE `' . $nameOrNumberColumn . '` = ' . $this->db->quote($name) )->fetch();
|
||||
$id = $this->db->query('SELECT `id` FROM `accounts` WHERE `name` = ' . $this->db->quote($name) )->fetch();
|
||||
|
||||
// if anything was found
|
||||
if( isset($id['id']) )
|
||||
@@ -345,7 +345,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
// UPDATE query on database
|
||||
$this->db->exec('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `country` = ' . $this->db->quote($this->data['country']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
$this->db->exec('UPDATE `accounts` SET ' . ($this->db->hasColumn('accounts', 'name') ? '`name` = ' . $this->db->quote($this->data['name']) . ',' : '') . '`password` = ' . $this->db->quote($this->data['password']) . ', `email` = ' . $this->db->quote($this->data['email']) . ', `blocked` = ' . (int) $this->data['blocked'] . ', `rlname` = ' . $this->db->quote($this->data['rlname']) . ', `location` = ' . $this->db->quote($this->data['location']) . ', `country` = ' . $this->db->quote($this->data['country']) . ', `web_flags` = ' . (int) $this->data['web_flags'] . ', ' . ($this->db->hasColumn('accounts', 'premdays') ? '`premdays` = ' . (int) $this->data['premdays'] . ',' : '') . '`' . $field . '` = ' . (int) $this->data[$field] . ' WHERE `id` = ' . $this->data['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -650,6 +650,53 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$this->data['email'] = (string) $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if account is blocked.
|
||||
*
|
||||
* <p>
|
||||
* Note: Since 0.0.3 version this method throws {@link E_OTS_NotLoaded E_OTS_NotLoaded} exception instead of triggering E_USER_WARNING.
|
||||
* </p>
|
||||
*
|
||||
* @version 0.0.3
|
||||
* @return bool Blocked state.
|
||||
* @throws E_OTS_NotLoaded If account is not loaded.
|
||||
*/
|
||||
public function isBlocked()
|
||||
{
|
||||
if( !isset($this->data['blocked']) )
|
||||
{
|
||||
throw new E_OTS_NotLoaded();
|
||||
}
|
||||
|
||||
return $this->data['blocked'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Unblocks account.
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in database you need to use {@link OTS_Account::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*/
|
||||
public function unblock()
|
||||
{
|
||||
$this->data['blocked'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks account.
|
||||
*
|
||||
* <p>
|
||||
* This method only updates object state. To save changes in databaseed to use {@link OTS_Account::save() save() method} to flush changed to database.
|
||||
* </p>
|
||||
*/
|
||||
public function block()
|
||||
{
|
||||
$this->data['blocked'] = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reads custom field.
|
||||
*
|
||||
@@ -994,7 +1041,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$access = 0;
|
||||
|
||||
// finds ranks of all characters
|
||||
foreach($this->getPlayersList(false) as $player)
|
||||
foreach($this->getPlayersList() as $player)
|
||||
{
|
||||
$rank = $player->getRank();
|
||||
|
||||
@@ -1100,6 +1147,9 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
case 'playersList':
|
||||
return $this->getPlayersList();
|
||||
|
||||
case 'blocked':
|
||||
return $this->isBlocked();
|
||||
|
||||
case 'deleted':
|
||||
return $this->isDeleted();
|
||||
|
||||
@@ -1145,6 +1195,17 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
$this->setPremiumEnd($value);
|
||||
break;
|
||||
|
||||
case 'blocked':
|
||||
if($value)
|
||||
{
|
||||
$this->block();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->unblock();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'deleted':
|
||||
if($value)
|
||||
{
|
||||
@@ -1198,3 +1259,5 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -34,3 +34,5 @@ class OTS_AccountBans_List extends OTS_Bans_List
|
||||
$this->setFilter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -735,3 +735,5 @@ class OTS_Admin
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -100,3 +100,5 @@ class OTS_Bans_List extends OTS_Base_List
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -265,3 +265,5 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -146,3 +146,5 @@ class OTS_BinaryTools
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -149,3 +149,5 @@ class OTS_Container extends OTS_Item implements IteratorAggregate
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -357,3 +357,5 @@ class OTS_FileLoader
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -671,3 +671,5 @@ class OTS_Group extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -837,3 +837,5 @@ class OTS_Guild extends OTS_Row_DAO implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -72,3 +72,5 @@ class OTS_GuildRanks_List extends OTS_Base_List
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -529,3 +529,5 @@ class OTS_House extends OTS_Row_DAO
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -34,3 +34,5 @@ class OTS_IPBans_List extends OTS_Bans_List
|
||||
$this->setFilter($filter);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -387,3 +387,5 @@ class OTS_InfoRespond extends DOMDocument
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -676,3 +676,5 @@ class OTS_ItemsList extends OTS_FileLoader implements IteratorAggregate, Countab
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -130,3 +130,5 @@ class OTS_MapCoords
|
||||
}
|
||||
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
@@ -36,7 +36,6 @@
|
||||
* @property-read int $armor Armor rate.
|
||||
* @property-read array $defenses List of defenses.
|
||||
* @property-read array $attacks List of attacks.
|
||||
* @property-read array $look List of looks.
|
||||
*/
|
||||
class OTS_Monster extends DOMDocument
|
||||
{
|
||||
@@ -274,34 +273,6 @@ class OTS_Monster extends DOMDocument
|
||||
return $loot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns look of the monster.
|
||||
*
|
||||
* @return array Look with all the attributes of the look.
|
||||
* @throws DOMException On DOM operation error.
|
||||
*/
|
||||
public function getLook()
|
||||
{
|
||||
$look = array();
|
||||
|
||||
$element = $this->documentElement->getElementsByTagName('look')->item(0);
|
||||
|
||||
if (!$element) {
|
||||
return $look;
|
||||
}
|
||||
|
||||
$look['type'] = $element->getAttribute('type');
|
||||
$look['typeex'] = $element->getAttribute('typeex');
|
||||
$look['head'] = $element->getAttribute('head');
|
||||
$look['body'] = $element->getAttribute('body');
|
||||
$look['legs'] = $element->getAttribute('legs');
|
||||
$look['feet'] = $element->getAttribute('feet');
|
||||
$look['addons'] = $element->getAttribute('addons');
|
||||
$look['corpse'] = $element->getAttribute('corpse');
|
||||
|
||||
return $look;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all monster summons.
|
||||
*
|
||||
@@ -589,9 +560,6 @@ class OTS_Monster extends DOMDocument
|
||||
case 'attacks':
|
||||
return $this->getAttacks();
|
||||
|
||||
case 'look':
|
||||
return $this->getLook();
|
||||
|
||||
default:
|
||||
throw new OutOfBoundsException();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user