fix extendedgitgraph live output
This commit is contained in:
parent
0d0b8f64b1
commit
15f6d121de
@ -2,21 +2,41 @@
|
||||
|
||||
global $CONFIG;
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
|
||||
|
||||
$svar = $CONFIG['extendedgitgraph']['session_var'];
|
||||
|
||||
if (isset($_GET['clear'])) if (key_exists($svar, $_SESSION)) $_SESSION[$svar] = '';
|
||||
|
||||
if (key_exists($svar, $_SESSION))
|
||||
if ($CONFIG['extendedgitgraph']['output_file'])
|
||||
{
|
||||
if ($_SESSION[$svar] === '') echo '[[ NO OUTPUT ]]';
|
||||
else echo $_SESSION[$svar] === '';
|
||||
$lfile = $CONFIG['extendedgitgraph']['output_filepath'];
|
||||
|
||||
if (file_exists($lfile))
|
||||
{
|
||||
$data = file_get_contents($lfile);
|
||||
|
||||
if ($data === '') echo '[[ EMPTY ]]';
|
||||
else echo $data;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '[[ FILE NOT FOUND ]]';
|
||||
}
|
||||
}
|
||||
else if ($CONFIG['extendedgitgraph']['output_file'])
|
||||
{
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
|
||||
|
||||
$svar = $CONFIG['extendedgitgraph']['session_var'];
|
||||
|
||||
if (isset($_GET['clear'])) if (key_exists($svar, $_SESSION)) $_SESSION[$svar] = '';
|
||||
|
||||
if (key_exists($svar, $_SESSION))
|
||||
{
|
||||
if ($_SESSION[$svar] === '') echo '[[ NO OUTPUT ]]';
|
||||
else echo $_SESSION[$svar];
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '[[ NO SESSION STARTED ]]';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '[[ NO SESSION STARTED ]]';
|
||||
echo '[[ NO USEFUL LOGGER CONFIGURED ]]';
|
||||
}
|
||||
|
||||
|
||||
return;
|
@ -25,3 +25,5 @@ $content = "REQUEST: " . $uri . "\r\n\r\n" .
|
||||
"OUTPUT: " . $std . "\r\n\r\n";
|
||||
|
||||
sendMail("Webhook '$hook' triggered", $content, 'virtualadmin@mikescher.de', 'webserver-info@mikescher.com');
|
||||
|
||||
echo "{ 'status': 'ok', 'message': 'Webhook '$hook' triggered' }";
|
1
www/extern/egg/ExtendedGitGraph2.php
vendored
1
www/extern/egg/ExtendedGitGraph2.php
vendored
@ -30,6 +30,7 @@ class ExtendedGitGraph2 implements ILogger
|
||||
if ($config['output_session']) $this->logger []= new SessionLogger($config['session_var']);
|
||||
if ($config['output_stdout']) $this->logger []= new OutputLogger();
|
||||
if ($config['output_logfile']) $this->logger []= new FileLogger($config['logfile'], $config['logfile_count']);
|
||||
if ($config['output_file']) $this->logger []= new SingleFileLogger($config['output_filepath']);
|
||||
|
||||
$this->sources = [];
|
||||
|
||||
|
22
www/extern/egg/Logger.php
vendored
22
www/extern/egg/Logger.php
vendored
@ -42,6 +42,26 @@ class FileLogger implements ILogger
|
||||
}
|
||||
}
|
||||
|
||||
class SingleFileLogger implements ILogger
|
||||
{
|
||||
/** @var string $path */
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* @var string $filename
|
||||
*/
|
||||
public function __construct($filename)
|
||||
{
|
||||
$this->path = $filename;
|
||||
file_put_contents($this->path, '', FILE_TEXT);
|
||||
}
|
||||
|
||||
public function proclog($text)
|
||||
{
|
||||
file_put_contents($this->path, $text . PHP_EOL , FILE_APPEND | LOCK_EX);
|
||||
}
|
||||
}
|
||||
|
||||
class SessionLogger implements ILogger
|
||||
{
|
||||
/** @var string $sessionvar */
|
||||
@ -64,6 +84,8 @@ class SessionLogger implements ILogger
|
||||
{
|
||||
if (session_status() === PHP_SESSION_DISABLED) return;
|
||||
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
|
||||
if (session_status() !== PHP_SESSION_ACTIVE) session_start();
|
||||
$_SESSION[$this->sessionvar] .= $text . "\r\n";
|
||||
session_commit();
|
||||
}
|
||||
|
@ -76,7 +76,6 @@ $API_OPTIONS = [];
|
||||
foreach ($_GET as $k => $v) $API_OPTIONS[strtolower($k)] = $v;
|
||||
foreach ($OPTIONS['_urlparams'] as $k => $v) $API_OPTIONS[strtolower($k)] = $v;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
@ -86,4 +85,13 @@ catch (exception $e)
|
||||
{
|
||||
print("API Command failed with exception");
|
||||
print($e);
|
||||
|
||||
$content =
|
||||
"REQUEST: " . var_export($_REQUEST) . "\r\n\r\n" .
|
||||
"IP: " . get_client_ip() . "\r\n\r\n" .
|
||||
"ERROR: " . $e . "\r\n\r\n";
|
||||
|
||||
sendMail("Website API call failed", $content, 'virtualadmin@mikescher.de', 'webserver-info@mikescher.com');
|
||||
|
||||
httpDie(500, 'Error.');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user