mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-12-22 13:45:02 +00:00
Add debug action for administrators.
This commit is contained in:
parent
3c14063f0d
commit
a80a2b677f
4 changed files with 149 additions and 20 deletions
|
@ -1,14 +1,6 @@
|
|||
<?php
|
||||
$start_time = time(true);
|
||||
|
||||
// For debugging purposes. Remove or comment out for live sites.
|
||||
// This will always be commented out for a release.
|
||||
if(file_exists("php_error.php"))
|
||||
{
|
||||
require("php_error.php");
|
||||
\php_error\reportErrors([ "error_reporting_on" => E_ALL | E_STRICT ]);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Pepperminty Wiki
|
||||
|
@ -1393,7 +1385,7 @@ register_module([
|
|||
|
||||
register_module([
|
||||
"name" => "Raw page source",
|
||||
"version" => "0.5",
|
||||
"version" => "0.6",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds a 'raw' action that shows you the raw source of a page.",
|
||||
"id" => "action-raw",
|
||||
|
@ -1410,7 +1402,6 @@ register_module([
|
|||
add_action("raw", function() {
|
||||
global $env;
|
||||
|
||||
http_response_code(307);
|
||||
header("x-filename: " . rawurlencode($env->page) . ".md");
|
||||
header("content-type: text/markdown");
|
||||
exit(file_get_contents("$env->storage_prefix$env->page.md"));
|
||||
|
@ -2643,6 +2634,75 @@ register_module([
|
|||
|
||||
|
||||
|
||||
|
||||
register_module([
|
||||
"name" => "Debug Information",
|
||||
"version" => "0.1",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds a debug action for administrator use only that collects a load of useful information to make reporting bugs easier.",
|
||||
"id" => "page-debug-info",
|
||||
"code" => function() {
|
||||
global $settings, $env;
|
||||
|
||||
/*
|
||||
* ██████ ███████ ██████ ██ ██ ██████
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██ ██ █████ ██████ ██ ██ ██ ███
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██████ ███████ ██████ ██████ ██████
|
||||
*/
|
||||
add_action("debug", function() {
|
||||
global $settings, $env, $paths, $version;
|
||||
header("content-type: text/plain");
|
||||
|
||||
if(!$env->is_admin)
|
||||
{
|
||||
exit("You must be logged in as an moderator in order to generate debugging information.");
|
||||
}
|
||||
|
||||
$title = "$settings->sitename debug report";
|
||||
echo("$title\n");
|
||||
echo(str_repeat("=", strlen($title)) . "\n");
|
||||
echo("Powered by Pepperminty Wiki version $version.\n");
|
||||
echo("This report may contain personal information.\n\n");
|
||||
echo("Environment: ");
|
||||
echo(var_export($env, true));
|
||||
echo("\nPaths: ");
|
||||
var_dump(var_export($paths, true));
|
||||
echo("\nServer information:\n");
|
||||
echo("uname -a: " . php_uname() . "\n");
|
||||
echo("Path: " . getenv("PATH") . "\n");
|
||||
echo("Temporary directory: " . sys_get_temp_dir() . "\n");
|
||||
echo("Server: " . $_SERVER["SERVER_SOFTWARE"] . "\n");
|
||||
echo("Web root: " . $_SERVER["DOCUMENT_ROOT"] . "\n");
|
||||
echo("Web server user: " . exec("whoami") . "\n");
|
||||
echo("PHP version: " . phpversion() . "\n");
|
||||
echo("index.php location: " . __FILE__ . "\n");
|
||||
echo("index.php file permissions: " . substr(sprintf('%o', fileperms("./index.php")), -4) . "\n");
|
||||
echo("Current folder permissions: " . substr(sprintf('%o', fileperms(".")), -4) . "\n");
|
||||
echo("Storage directory permissions: " . substr(sprintf('%o', fileperms($env->storage_prefix)), -4) . "\n");
|
||||
echo("Loaded extensions: " . implode(", ", get_loaded_extensions()) . "\n");
|
||||
echo("Settings:\n-----\n");
|
||||
$settings_export = explode("\n", var_export($settings, true));
|
||||
foreach ($settings_export as &$row)
|
||||
{
|
||||
if(preg_match("/(sitesecret|email)/i", $row)) $row = "********* secret *********";
|
||||
}
|
||||
echo(implode("\n", $settings_export));
|
||||
echo("\n-----\n");
|
||||
exit();
|
||||
});
|
||||
|
||||
if($env->is_admin)
|
||||
{
|
||||
add_help_section("810-debug-information", "Gathering debug information", "<p>As a moderator, $settings->sitename gives you the ability to generate a report on $settings->sitename's installation of Pepperminty Wiki for debugging purposes.</p>
|
||||
<p>To generate such a report, visit the <code>debug</code> action or <a href='?action=debug'>click here</a>.</p>");
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
register_module([
|
||||
"name" => "Page deleter",
|
||||
|
|
8
core.php
8
core.php
|
@ -1,14 +1,6 @@
|
|||
<?php
|
||||
$start_time = time(true);
|
||||
|
||||
// For debugging purposes. Remove or comment out for live sites.
|
||||
// This will always be commented out for a release.
|
||||
if(file_exists("php_error.php"))
|
||||
{
|
||||
require("php_error.php");
|
||||
\php_error\reportErrors([ "error_reporting_on" => E_ALL | E_STRICT ]);
|
||||
}
|
||||
|
||||
{settings}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
},
|
||||
{
|
||||
"name": "Raw page source",
|
||||
"version": "0.5",
|
||||
"version": "0.6",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds a 'raw' action that shows you the raw source of a page.",
|
||||
"id": "action-raw",
|
||||
"lastupdate": 1451133673,
|
||||
"lastupdate": 1453559572,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
|
@ -80,6 +80,15 @@
|
|||
"lastupdate": 1451133924,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"name": "Debug Information",
|
||||
"version": "0.1",
|
||||
"author": "Starbeamrainbowlabs",
|
||||
"description": "Adds a debug action for administrator use only that collects a load of useful information to make reporting bugs easier.",
|
||||
"id": "page-debug-info",
|
||||
"lastupdate": 1453562632,
|
||||
"optional": false
|
||||
},
|
||||
{
|
||||
"name": "Page deleter",
|
||||
"version": "0.9",
|
||||
|
|
68
modules/page-debug-info.php
Normal file
68
modules/page-debug-info.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
register_module([
|
||||
"name" => "Debug Information",
|
||||
"version" => "0.1",
|
||||
"author" => "Starbeamrainbowlabs",
|
||||
"description" => "Adds a debug action for administrator use only that collects a load of useful information to make reporting bugs easier.",
|
||||
"id" => "page-debug-info",
|
||||
"code" => function() {
|
||||
global $settings, $env;
|
||||
|
||||
/*
|
||||
* ██████ ███████ ██████ ██ ██ ██████
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██ ██ █████ ██████ ██ ██ ██ ███
|
||||
* ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
* ██████ ███████ ██████ ██████ ██████
|
||||
*/
|
||||
add_action("debug", function() {
|
||||
global $settings, $env, $paths, $version;
|
||||
header("content-type: text/plain");
|
||||
|
||||
if(!$env->is_admin)
|
||||
{
|
||||
exit("You must be logged in as an moderator in order to generate debugging information.");
|
||||
}
|
||||
|
||||
$title = "$settings->sitename debug report";
|
||||
echo("$title\n");
|
||||
echo(str_repeat("=", strlen($title)) . "\n");
|
||||
echo("Powered by Pepperminty Wiki version $version.\n");
|
||||
echo("This report may contain personal information.\n\n");
|
||||
echo("Environment: ");
|
||||
echo(var_export($env, true));
|
||||
echo("\nPaths: ");
|
||||
var_dump(var_export($paths, true));
|
||||
echo("\nServer information:\n");
|
||||
echo("uname -a: " . php_uname() . "\n");
|
||||
echo("Path: " . getenv("PATH") . "\n");
|
||||
echo("Temporary directory: " . sys_get_temp_dir() . "\n");
|
||||
echo("Server: " . $_SERVER["SERVER_SOFTWARE"] . "\n");
|
||||
echo("Web root: " . $_SERVER["DOCUMENT_ROOT"] . "\n");
|
||||
echo("Web server user: " . exec("whoami") . "\n");
|
||||
echo("PHP version: " . phpversion() . "\n");
|
||||
echo("index.php location: " . __FILE__ . "\n");
|
||||
echo("index.php file permissions: " . substr(sprintf('%o', fileperms("./index.php")), -4) . "\n");
|
||||
echo("Current folder permissions: " . substr(sprintf('%o', fileperms(".")), -4) . "\n");
|
||||
echo("Storage directory permissions: " . substr(sprintf('%o', fileperms($env->storage_prefix)), -4) . "\n");
|
||||
echo("Loaded extensions: " . implode(", ", get_loaded_extensions()) . "\n");
|
||||
echo("Settings:\n-----\n");
|
||||
$settings_export = explode("\n", var_export($settings, true));
|
||||
foreach ($settings_export as &$row)
|
||||
{
|
||||
if(preg_match("/(sitesecret|email)/i", $row)) $row = "********* secret *********";
|
||||
}
|
||||
echo(implode("\n", $settings_export));
|
||||
echo("\n-----\n");
|
||||
exit();
|
||||
});
|
||||
|
||||
if($env->is_admin)
|
||||
{
|
||||
add_help_section("810-debug-information", "Gathering debug information", "<p>As a moderator, $settings->sitename gives you the ability to generate a report on $settings->sitename's installation of Pepperminty Wiki for debugging purposes.</p>
|
||||
<p>To generate such a report, visit the <code>debug</code> action or <a href='?action=debug'>click here</a>.</p>");
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
?>
|
Loading…
Reference in a new issue