mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-29 10:49:22 +02:00
Merge branch 'develop' into feature/migrations-up-down
This commit is contained in:
commit
cc8b0dba7f
@ -26,7 +26,7 @@ if (!hasFlag(FLAG_CONTENT_PAGES) && !superAdmin()) {
|
|||||||
|
|
||||||
header('X-XSS-Protection:0');
|
header('X-XSS-Protection:0');
|
||||||
|
|
||||||
// some constants, used mainly by database (cannot by modified without schema changes)
|
// some constants, used mainly by database (cannot be modified without schema changes)
|
||||||
const NEWS_TITLE_LIMIT = 100;
|
const NEWS_TITLE_LIMIT = 100;
|
||||||
const NEWS_BODY_LIMIT = 65535; // maximum news body length
|
const NEWS_BODY_LIMIT = 65535; // maximum news body length
|
||||||
const ARTICLE_TEXT_LIMIT = 300;
|
const ARTICLE_TEXT_LIMIT = 300;
|
||||||
@ -136,9 +136,18 @@ if($action == 'edit' || $action == 'new') {
|
|||||||
|
|
||||||
$query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news'));
|
$query = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'news'));
|
||||||
$newses = array();
|
$newses = array();
|
||||||
|
|
||||||
|
$cachePlayers = [];
|
||||||
foreach ($query as $_news) {
|
foreach ($query as $_news) {
|
||||||
$_player = new OTS_Player();
|
$playerId = $_news['player_id'];
|
||||||
$_player->load($_news['player_id']);
|
if (isset($cachePlayers[$playerId])) {
|
||||||
|
$_player = $cachePlayers[$playerId];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$_player = new OTS_Player();
|
||||||
|
$_player->load($playerId);
|
||||||
|
$cachePlayers[$playerId] = $_player;
|
||||||
|
}
|
||||||
|
|
||||||
$newses[$_news['type']][] = array(
|
$newses[$_news['type']][] = array(
|
||||||
'id' => $_news['id'],
|
'id' => $_news['id'],
|
||||||
@ -147,7 +156,7 @@ foreach ($query as $_news) {
|
|||||||
'title' => $_news['title'],
|
'title' => $_news['title'],
|
||||||
'date' => $_news['date'],
|
'date' => $_news['date'],
|
||||||
'player_name' => $_player->isLoaded() ? $_player->getName() : '',
|
'player_name' => $_player->isLoaded() ? $_player->getName() : '',
|
||||||
'player_link' => $_player->isLoaded() ? getPlayerLink($_player->getName(), false) : '',
|
'player_link' => $_player->isLoaded() ? getPlayerLink($_player, false) : '',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.0",
|
"php": "^8.1",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-pdo_mysql": "*",
|
"ext-pdo_mysql": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
|
@ -89,13 +89,18 @@ function getForumBoardLink($board_id, $page = NULL): string {
|
|||||||
|
|
||||||
function getPlayerLink($name, $generate = true, bool $colored = false): string
|
function getPlayerLink($name, $generate = true, bool $colored = false): string
|
||||||
{
|
{
|
||||||
$player = new OTS_Player();
|
if (is_object($name) and $name instanceof OTS_Player) {
|
||||||
|
$player = $name;
|
||||||
if(is_numeric($name)) {
|
|
||||||
$player->load((int)$name);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$player->find($name);
|
$player = new OTS_Player();
|
||||||
|
|
||||||
|
if(is_numeric($name)) {
|
||||||
|
$player->load((int)$name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$player->find($name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$player->isLoaded()) {
|
if (!$player->isLoaded()) {
|
||||||
|
@ -39,7 +39,7 @@ if($config['server_path'][strlen($config['server_path']) - 1] !== '/')
|
|||||||
$config['server_path'] .= '/';
|
$config['server_path'] .= '/';
|
||||||
|
|
||||||
// enable gzip compression if supported by the browser
|
// enable gzip compression if supported by the browser
|
||||||
if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false && function_exists('ob_gzhandler'))
|
if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && str_contains($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('ob_gzhandler'))
|
||||||
ob_start('ob_gzhandler');
|
ob_start('ob_gzhandler');
|
||||||
|
|
||||||
// cache
|
// cache
|
||||||
|
@ -53,49 +53,49 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
* @param array $params Connection parameters.
|
* @param array $params Connection parameters.
|
||||||
* @throws PDOException On PDO operation error.
|
* @throws PDOException On PDO operation error.
|
||||||
*/
|
*/
|
||||||
public function __construct($params)
|
public function __construct($params)
|
||||||
{
|
{
|
||||||
$user = null;
|
$user = null;
|
||||||
$password = null;
|
$password = null;
|
||||||
$dns = array();
|
$dns = array();
|
||||||
|
|
||||||
// host:port support
|
// host:port support
|
||||||
if( strpos(':', $params['host']) !== false)
|
if( strpos(':', $params['host']) !== false)
|
||||||
{
|
{
|
||||||
$host = explode(':', $params['host'], 2);
|
$host = explode(':', $params['host'], 2);
|
||||||
|
|
||||||
$params['host'] = $host[0];
|
$params['host'] = $host[0];
|
||||||
$params['port'] = $host[1];
|
$params['port'] = $host[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isset($params['database']) )
|
if( isset($params['database']) )
|
||||||
{
|
{
|
||||||
$dns[] = 'dbname=' . $params['database'];
|
$dns[] = 'dbname=' . $params['database'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isset($params['user']) )
|
if( isset($params['user']) )
|
||||||
{
|
{
|
||||||
$user = $params['user'];
|
$user = $params['user'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isset($params['password']) )
|
if( isset($params['password']) )
|
||||||
{
|
{
|
||||||
$password = $params['password'];
|
$password = $params['password'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isset($params['prefix']) )
|
if( isset($params['prefix']) )
|
||||||
{
|
{
|
||||||
$this->prefix = $params['prefix'];
|
$this->prefix = $params['prefix'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isset($params['log']) && $params['log'] )
|
if( isset($params['log']) && $params['log'] )
|
||||||
{
|
{
|
||||||
$this->logged = true;
|
$this->logged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !isset($params['persistent']) ) {
|
if( !isset($params['persistent']) ) {
|
||||||
$params['persistent'] = false;
|
$params['persistent'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
$cache = Cache::getInstance();
|
$cache = Cache::getInstance();
|
||||||
@ -144,10 +144,10 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct('mysql:' . implode(';', $dns), $user, $password, $driverAttributes);
|
parent::__construct('mysql:' . implode(';', $dns), $user, $password, $driverAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$cache = Cache::getInstance();
|
$cache = Cache::getInstance();
|
||||||
@ -165,7 +165,8 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($this->logged) {
|
if($this->logged) {
|
||||||
log_append('database.log', $_SERVER['REQUEST_URI'] . PHP_EOL . $this->getLog());
|
$currentScript = $_SERVER['REQUEST_URI'] ?? $_SERVER['SCRIPT_FILENAME'];
|
||||||
|
log_append('database.log', $currentScript . PHP_EOL . $this->getLog());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,10 +176,10 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
* @param string $name Field name.
|
* @param string $name Field name.
|
||||||
* @return string Quoted name.
|
* @return string Quoted name.
|
||||||
*/
|
*/
|
||||||
public function fieldName($name)
|
public function fieldName($name)
|
||||||
{
|
{
|
||||||
return '`' . $name . '`';
|
return '`' . $name . '`';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LIMIT/OFFSET clause for queries.
|
* LIMIT/OFFSET clause for queries.
|
||||||
@ -187,26 +188,26 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
|||||||
* @param int|bool $offset Number of rows to be skipped before applying query effects (false if no offset).
|
* @param int|bool $offset Number of rows to be skipped before applying query effects (false if no offset).
|
||||||
* @return string LIMIT/OFFSET SQL clause for query.
|
* @return string LIMIT/OFFSET SQL clause for query.
|
||||||
*/
|
*/
|
||||||
public function limit($limit = false, $offset = false)
|
public function limit($limit = false, $offset = false)
|
||||||
{
|
{
|
||||||
// by default this is empty part
|
// by default this is empty part
|
||||||
$sql = '';
|
$sql = '';
|
||||||
|
|
||||||
if($limit !== false)
|
if($limit !== false)
|
||||||
{
|
{
|
||||||
$sql = ' LIMIT ';
|
$sql = ' LIMIT ';
|
||||||
|
|
||||||
// OFFSET has no effect if there is no LIMIT
|
// OFFSET has no effect if there is no LIMIT
|
||||||
if($offset !== false)
|
if($offset !== false)
|
||||||
{
|
{
|
||||||
$sql .= $offset . ', ';
|
$sql .= $offset . ', ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql .= $limit;
|
$sql .= $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasTable($name) {
|
public function hasTable($name) {
|
||||||
if(isset($this->has_table_cache[$name])) {
|
if(isset($this->has_table_cache[$name])) {
|
||||||
|
5
system/src/Cache.php
Normal file
5
system/src/Cache.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace MyAAC;
|
||||||
|
|
||||||
|
class Cache extends Cache\Cache {}
|
@ -766,22 +766,21 @@ class Plugins {
|
|||||||
* Helper function for plugins
|
* Helper function for plugins
|
||||||
*
|
*
|
||||||
* @param string $templateName
|
* @param string $templateName
|
||||||
* @param array $categories
|
* @param array $menus
|
||||||
*/
|
*/
|
||||||
public static function installMenus($templateName, $categories, $clearOld = true)
|
public static function installMenus($templateName, $menus, $clearOld = false)
|
||||||
{
|
{
|
||||||
global $db;
|
|
||||||
if (!$db->hasTable(TABLE_PREFIX . 'menu')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($clearOld) {
|
if ($clearOld) {
|
||||||
Menu::where('template', $templateName)->delete();
|
Menu::where('template', $templateName)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($categories as $category => $menus) {
|
if (Menu::where('template', $templateName)->count()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($menus as $category => $_menus) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($menus as $name => $link) {
|
foreach ($_menus as $name => $link) {
|
||||||
$color = '';
|
$color = '';
|
||||||
$blank = 0;
|
$blank = 0;
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ use Twig\Loader\FilesystemLoader as Twig_FilesystemLoader;
|
|||||||
use Twig\TwigFilter;
|
use Twig\TwigFilter;
|
||||||
use Twig\TwigFunction;
|
use Twig\TwigFunction;
|
||||||
|
|
||||||
|
global $twig, $twig_loader;
|
||||||
|
|
||||||
$dev_mode = (config('env') === 'dev');
|
$dev_mode = (config('env') === 'dev');
|
||||||
$twig_loader = new Twig_FilesystemLoader(SYSTEM . 'templates');
|
$twig_loader = new Twig_FilesystemLoader(SYSTEM . 'templates');
|
||||||
$twig = new Twig_Environment($twig_loader, array(
|
$twig = new Twig_Environment($twig_loader, array(
|
||||||
|
@ -291,7 +291,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% set title = 'Account logs' %}
|
{% set title = 'Account Logs' %}
|
||||||
{% set tableClass = 'Table3' %}
|
{% set tableClass = 'Table3' %}
|
||||||
{% set content %}
|
{% set content %}
|
||||||
<table style="width:100%;">
|
<table style="width:100%;">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user