first commit

This commit is contained in:
2024-07-15 11:28:08 +02:00
commit f52d538ea5
21891 changed files with 6161164 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\View\Log;
use Akeeba\Engine\Factory;
use Awf\Mvc\View;
use Awf\Utils\Template;
use Solo\Model\Log;
use Solo\View\ViewTraits\ProfileIdAndName;
class Html extends View
{
use ProfileIdAndName;
/**
* Big log file threshold: 2Mb
*/
const bigLogSize = 2097152;
/**
* List of available log files
*
* @var array
*/
public $logs = [];
/**
* Currently selected log file tag
*
* @var string
*/
public $tag;
/**
* Is the select log too big for being
*
* @var bool
*/
public $logTooBig = false;
/**
* Size of the log file
*
* @var int
*/
public $logSize = 0;
/**
* Setup the main log page
*
* @return boolean
*/
public function onBeforeMain()
{
/** @var Log $model */
$model = $this->getModel();
$this->logs = $model->getLogList();
$tag = $model->getState('tag', '', 'string');
if (empty($tag))
{
$tag = null;
}
$this->tag = $tag;
// Let's check if the file is too big to display
if ($this->tag)
{
$logFile = Factory::getLog()->getLogFilename($this->tag);
if (!@is_file($logFile) && @file_exists(substr($logFile, 0, -4)))
{
/**
* Bad host: the log file akeeba.tag.log.php may not exist but the akeeba.tag.log does.
*/
$logFile = substr($logFile, 0, -4);
}
if (@file_exists($logFile))
{
$this->logSize = filesize($logFile);
$this->logTooBig = ($this->logSize >= self::bigLogSize);
}
}
// Load the Javascript
Template::addJs('media://js/solo/log.min.js');
$document = $this->container->application->getDocument();
$src = $this->container->router->route('index.php?view=Log&task=iframe&format=raw&tag=' . urlencode($this->tag));
$document->addScriptOptions('akeeba.Log.iFrameSrc', $src);
$this->getProfileIdAndName();
return true;
}
/**
* Setup the iframe display
*
* @return boolean
*/
public function onBeforeIframe()
{
/** @var Log $model */
$model = $this->getModel();
$tag = $model->getState('tag', '', 'string');
if (empty($tag))
{
$tag = null;
}
$this->tag = $tag;
$this->setLayout('raw');
$this->container->application->getDocument()->setMimeType('text/html');
return true;
}
}

View File

@@ -0,0 +1,12 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2022 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Solo\View\Log;
class Raw extends Html
{
}

View File

@@ -0,0 +1,63 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2019 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU GPL version 3 or later
*/
use Awf\Html;
use Awf\Text\Text;
defined('_AKEEBA') or die();
// Used for type hinting
/** @var \Solo\View\Log\Html $this */
$router = $this->container->router;
$inCMS = $this->container->segment->get('insideCMS', false);
?>
<?php if(count($this->logs)): ?>
<form name="adminForm" id="adminForm" action="<?php echo $router->route('index.php?view=log') ?>" method="POST"
class="akeeba-form--inline">
<div class="akeeba-form-group">
<label for="tag">
<?php echo Text::_('COM_AKEEBA_LOG_CHOOSE_FILE_TITLE'); ?>
</label>
<?php echo Html\Select::genericList($this->logs, 'tag', 'onchange=this.form.submit()', 'value', 'text', $this->tag, 'tag') ?>
</div>
<?php if(!empty($this->tag)): ?>
<div class="akeeba-form-group--actions">
<button class="akeeba-btn--teal" onclick="window.location='<?php echo $router->route('index.php?view=log&format=raw&task=download&tag=' . urlencode($this->tag)); ?>'; return false;">
<span class="akion-android-download"></span>
<?php echo Text::_('COM_AKEEBA_LOG_LABEL_DOWNLOAD'); ?>
</button>
</div>
<br/>
<hr/>
<div class="iframe-holder" id="frame-holder">
<?php if ($this->logTooBig):?>
<p class="alert alert-info">
<?php echo Text::sprintf('COM_AKEEBA_LOG_SIZE_WARNING', number_format($this->logSize / (1024 * 1024), 2))?>
</p>
<span class="akeeba-btn--orange" id="showlog">
<?php echo Text::_('COM_AKEEBA_LOG_SHOW_LOG')?>
</span>
<?php else:?>
<iframe
src="<?php echo $router->route('index.php?view=log&task=iframe&tmpl=component&layout=raw&tag=' . urlencode($this->tag)) ?>"
width="99%" height="500px">
</iframe>
<?php endif;?>
</div>
<?php endif; ?>
<input type="hidden" name="token" value="<?php echo $this->container->session->getCsrfToken()->getValue() ?>" >
</form>
<?php else: ?>
<div class="alert alert-danger">
<?php echo Text::_('COM_AKEEBA_LOG_NONE_FOUND') ?>
</div>
<?php endif; ?>

View File

@@ -0,0 +1,76 @@
<?php
/**
* @package solo
* @copyright Copyright (c)2014-2019 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU GPL version 3 or later
*/
use Awf\Text\Text;
defined('_AKEEBA') or die();
// Used for type hinting
/** @var \Solo\View\Log\Html $this */
$router = $this->container->router;
// -- Get the log's file name
$tag = $this->tag;
$logName = \Akeeba\Engine\Factory::getLog()->getLogFilename($tag);
if(!@file_exists($logName))
{
// Oops! The log doesn't exist!
echo '<p>' . Text::sprintf('SOLO_LOG_ERR_LOGFILENOTEXISTS', $logName).'</p>';
return;
}
else
{
// Allright, let's load and render it
$fp = fopen( $logName, "rt" );
if ($fp === FALSE)
{
// Oops! The log isn't readable?!
echo '<p>'.Text::_('COM_AKEEBA_LOG_ERROR_UNREADABLE').'</p>';
return;
}
echo "<table class='akeeba-table-striped'>\n";
echo "<thead><tr><th width='80'>Type</th><th width='150'>Time</th><th>Message</th></tr></thead>";
while( !feof($fp) )
{
$line = fgets( $fp );
if(!$line) return;
$exploded = explode( "|", $line, 3 );
unset( $line );
$class = '';
switch( trim($exploded[0]) )
{
case "ERROR":
$fmtString = "<span class='akeeba-label--red'>ERROR</span>";
$class = 'bg-danger';
break;
case "WARNING":
$fmtString = "<span class='akeeba-label--orange'>WARNING</span>";
$class = 'bg-warning';
break;
case "INFO":
$fmtString = "<span class='akeeba-label--teal'>INFO</span>";
$class = 'bg-info';
break;
case "DEBUG":
$fmtString = "<span class='akeeba-label--grey'>DEBUG</span>";
$class = 'text-muted';
break;
default:
$fmtString = "";
break;
}
echo '<tr class="' . $class . '"><td>' . $fmtString . '</td><td>' . $exploded[1] . '</td><td>' . htmlspecialchars($exploded[2]) . "</td></tr>\n";
unset( $exploded );
unset( $fmtString );
}
echo "</table>";
}

View File

@@ -0,0 +1,3 @@
{
"show": []
}