Compare commits

..

10 Commits

Author SHA1 Message Date
slawkens
94a61f32ae Merge branch 'develop' into feature/debug-bar 2023-11-11 11:11:13 +01:00
slawkens
8227303b89 1.0 will be our next release
we are starting to follow semantic versioning
2023-11-11 11:04:09 +01:00
slawkens
7a402ec0e0 fix #225 2023-11-11 11:00:28 +01:00
Slawomir Boczek
790d85a88a CSRF Protection (#235)
* Fix alert class name

* feature: csrf protection

* Cosmetics

* Fix token generate

* Admin Panel: changelogs csrf protection

* news/id route

* Refactor admin newses + add csrf

* Use admin.links instead

* Admin panel: Pages csrf

* Menus: better csrf + add success message on reset colors

* Plugins csrf

* Move definitions

* add info function, same as note($message)

* Update mailer.php

* Fix new page/news links

* clear_cache & maintenance csrf

* Formatting

* Fix news type

* Fix changelog link

* Add new changelog link

* More info to confirm dialog

* This is always true
2023-11-11 10:57:57 +01:00
slawkens
577725690d Add option to enable debugbar, even if dev mode is disabled 2023-08-21 11:08:12 +02:00
slawkens
c227fd4e96 Merge branch 'develop' into feature/debug-bar 2023-08-21 10:20:04 +02:00
slawkens
9fef84bffe Fix debugBar mysql logs (Thanks @gpedro) 2023-08-11 06:39:50 +02:00
slawkens
dedd54286f Log PDO queries, as stated in docs, but doesn't work yet (don't know the reason) 2023-08-10 13:21:36 +02:00
slawkens
7403a24030 Use dev-master, cause of some bugs appearing 2023-08-10 13:21:20 +02:00
slawkens
cc7aec8e28 Init debugBar 2023-08-10 13:05:02 +02:00
7 changed files with 50 additions and 5 deletions

View File

@@ -30,6 +30,27 @@ 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.');
}
$hooks->register('debugbar_admin_head_end', HOOK_ADMIN_HEAD_END, function ($params) {
global $debugBar;
if (!isset($debugBar)) {
return;
}
$debugBarRenderer = $debugBar->getJavascriptRenderer();
echo $debugBarRenderer->renderHead();
});
$hooks->register('debugbar_admin_body_end', HOOK_ADMIN_BODY_END, function ($params) {
global $debugBar;
if (!isset($debugBar)) {
return;
}
$debugBarRenderer = $debugBar->getJavascriptRenderer();
echo $debugBarRenderer->render();
});
require SYSTEM . 'status.php';
require SYSTEM . 'login.php';
require __DIR__ . '/includes/functions.php';

View File

@@ -26,7 +26,7 @@
if (version_compare(phpversion(), '8.0', '<')) die('PHP version 8.0 or higher is required.');
const MYAAC = true;
const MYAAC_VERSION = '0.10.0-dev';
const MYAAC_VERSION = '1.0-dev';
const DATABASE_VERSION = 36;
const TABLE_PREFIX = 'myaac_';
define('START_TIME', microtime(true));

View File

@@ -16,7 +16,8 @@
"peppeocchi/php-cron-scheduler": "4.*"
},
"require-dev": {
"filp/whoops": "^2.15"
"filp/whoops": "^2.15",
"maximebf/debugbar": "dev-master"
},
"autoload": {
"psr-4": {

View File

@@ -469,20 +469,30 @@ function tickers()
*/
function template_place_holder($type): string
{
global $twig, $template_place_holders;
global $twig, $template_place_holders, $debugBar;
$ret = '';
if (isset($debugBar)) {
$debugBarRenderer = $debugBar->getJavascriptRenderer();
}
if(array_key_exists($type, $template_place_holders) && is_array($template_place_holders[$type]))
$ret = implode($template_place_holders[$type]);
if($type === 'head_start') {
$ret .= template_header();
if (isset($debugBar)) {
$ret .= $debugBarRenderer->renderHead();
}
}
elseif ($type === 'body_start') {
$ret .= $twig->render('browsehappy.html.twig');
}
elseif($type === 'body_end') {
$ret .= template_ga_code();
if (isset($debugBar)) {
$ret .= $debugBarRenderer->render();
}
}
return $ret;

View File

@@ -16,10 +16,16 @@ if(!isset($config['installed']) || !$config['installed']) {
throw new RuntimeException('MyAAC has not been installed yet or there was error during installation. Please install again.');
}
use DebugBar\StandardDebugBar;
if(config('env') === 'dev') {
require SYSTEM . 'exception.php';
}
if (config('env') === 'dev' || getBoolean(config('enable_debugbar'))) {
$debugBar = new StandardDebugBar();
}
if(empty($config['server_path'])) {
throw new RuntimeException('Server Path has been not set. Go to config.php and set it.');
}

View File

@@ -370,7 +370,14 @@ class POT
throw new RuntimeException('Please install PHP pdo extension. MyAAC will not work without it.');
}
$this->db = new OTS_DB_MySQL($params);
global $debugBar;
if (isset($debugBar)) {
$this->db = new DebugBar\DataCollector\PDO\TraceablePDO(new OTS_DB_MySQL($params));
$debugBar->addCollector(new DebugBar\DataCollector\PDO\PDOCollector($this->db));
}
else {
$this->db = new OTS_DB_MySQL($params);
}
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}

View File

@@ -123,7 +123,7 @@ if(isset($config['boxes']))
document.getElementById("submenu_"+activeSubmenuItem).style.color = "white";
document.getElementById("ActiveSubmenuItemIcon_"+activeSubmenuItem).style.visibility = "visible";
menus = localStorage.getItem('menus');
if(menus.lastIndexOf("&") === -1) {
if(menus == null || menus.lastIndexOf("&") === -1) {
menus = "news=1&account=0&community=0&library=0&forum=0<?php if (setting('core.gifts_system')) echo '&shops=0'; ?>&";
}
FillMenuArray();