merge
This commit is contained in:
commit
0a330cd0ba
5 changed files with 82 additions and 128 deletions
10
composer.lock
generated
10
composer.lock
generated
|
@ -388,12 +388,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/shish/microcrud.git",
|
||||
"reference": "2a7ae6efe5b2c8aa9d68436cfa310cea5ad0e653"
|
||||
"reference": "685e01a22427a83fc5b13cf09c16b1d72e9755f0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/shish/microcrud/zipball/2a7ae6efe5b2c8aa9d68436cfa310cea5ad0e653",
|
||||
"reference": "2a7ae6efe5b2c8aa9d68436cfa310cea5ad0e653",
|
||||
"url": "https://api.github.com/repos/shish/microcrud/zipball/685e01a22427a83fc5b13cf09c16b1d72e9755f0",
|
||||
"reference": "685e01a22427a83fc5b13cf09c16b1d72e9755f0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -429,7 +429,11 @@
|
|||
"crud",
|
||||
"generator"
|
||||
],
|
||||
<<<<<<< HEAD
|
||||
"time": "2019-11-29T21:15:17+00:00"
|
||||
=======
|
||||
"time": "2019-11-29T10:55:02+00:00"
|
||||
>>>>>>> e926b15d5ffeb6f7c0510acacaaa846294212f5c
|
||||
},
|
||||
{
|
||||
"name": "shish/microhtml",
|
||||
|
|
|
@ -1,5 +1,74 @@
|
|||
<?php
|
||||
|
||||
use function MicroHTML\{A,SPAN};
|
||||
use MicroCRUD\Column;
|
||||
use MicroCRUD\DateTimeColumn;
|
||||
use MicroCRUD\TextColumn;
|
||||
use MicroCRUD\Table;
|
||||
|
||||
|
||||
class ActorColumn extends Column {
|
||||
public function __construct($name, $title)
|
||||
{
|
||||
parent::__construct($name, $title, "((username=:$name) OR (address=:$name))");
|
||||
}
|
||||
|
||||
public function display($row)
|
||||
{
|
||||
if ($row['username'] == "Anonymous") {
|
||||
return $row["address"];
|
||||
} else {
|
||||
return A(["href"=>make_link("user/{$row['username']}"), "title"=>$row['address']], $row['username']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MessageColumn extends TextColumn {
|
||||
public function display($row)
|
||||
{
|
||||
$c = "#000";
|
||||
switch ($row['priority']) {
|
||||
case SCORE_LOG_DEBUG: $c = "#999"; break;
|
||||
case SCORE_LOG_INFO: $c = "#000"; break;
|
||||
case SCORE_LOG_WARNING: $c = "#800"; break;
|
||||
case SCORE_LOG_ERROR: $c = "#C00"; break;
|
||||
case SCORE_LOG_CRITICAL: $c = "#F00"; break;
|
||||
}
|
||||
return SPAN(["style"=>"color: $c"], $this->scan_entities($row[$this->name]));
|
||||
}
|
||||
|
||||
protected function scan_entities($line)
|
||||
{
|
||||
return preg_replace_callback("/Image #(\d+)/s", [$this, "link_image"], $line);
|
||||
}
|
||||
|
||||
protected function link_image($id)
|
||||
{
|
||||
$iid = int_escape($id[1]);
|
||||
return "<a href='".make_link("post/view/$iid")."'>Image #$iid</a>";
|
||||
}
|
||||
}
|
||||
|
||||
class LogTable extends Table
|
||||
{
|
||||
public function __construct(\FFSPHP\PDO $db)
|
||||
{
|
||||
parent::__construct($db);
|
||||
$this->table = "score_log";
|
||||
$this->base_query = "SELECT * FROM score_log";
|
||||
$this->size = 100;
|
||||
$this->limit = 1000000;
|
||||
$this->columns = [
|
||||
new DateTimeColumn("date_sent", "Time"),
|
||||
new TextColumn("section", "Module"),
|
||||
new ActorColumn("username_or_address", "User"),
|
||||
new MessageColumn("message", "Message")
|
||||
];
|
||||
$this->order_by = ["date_sent DESC"];
|
||||
$this->table_attrs = ["class" => "zebra"];
|
||||
}
|
||||
}
|
||||
|
||||
class LogDatabase extends Extension
|
||||
{
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
|
|
|
@ -2,133 +2,12 @@
|
|||
|
||||
class LogDatabaseTheme extends Themelet
|
||||
{
|
||||
protected function heie($var)
|
||||
public function display_events($table, $paginator)
|
||||
{
|
||||
if (isset($_GET[$var])) {
|
||||
return html_escape($_GET[$var]);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
protected function ueie($var)
|
||||
{
|
||||
if (isset($_GET[$var])) {
|
||||
return $var."=".url_escape($_GET[$var]);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public function display_events($events, $page_num, $page_total)
|
||||
{
|
||||
$table = "
|
||||
<style>
|
||||
.sizedinputs TD INPUT {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<table class='zebra'>
|
||||
<thead>
|
||||
<tr><th>Time</th><th>Module</th><th>User</th><th colspan='3'>Message</th></tr>
|
||||
".make_form("log/view", "GET")."
|
||||
<tr class='sizedinputs'>
|
||||
<td><input type='date' name='time-start' value='".$this->heie("time-start")."'>
|
||||
<br><input type='date' name='time-end' value='".$this->heie("time-end")."'></td>
|
||||
<td><input type='text' name='module' value='".$this->heie("module")."'></td>
|
||||
<td><input type='text' name='user' value='".$this->heie("user")."'></td>
|
||||
<td><input type='text' name='message' value='".$this->heie("message")."'></td>
|
||||
<td>
|
||||
<select name='priority'>
|
||||
<option value='".SCORE_LOG_DEBUG."' ".($this->heie("priority")==SCORE_LOG_DEBUG ? "selected" : "").">Debug</option>
|
||||
<option value='".SCORE_LOG_INFO."' ".($this->heie("priority")==SCORE_LOG_INFO ? "selected" : "").">Info</option>
|
||||
<option value='".SCORE_LOG_WARNING."' ".($this->heie("priority")==SCORE_LOG_WARNING ? "selected" : "").">Warning</option>
|
||||
<option value='".SCORE_LOG_ERROR."' ".($this->heie("priority")==SCORE_LOG_ERROR ? "selected" : "").">Error</option>
|
||||
<option value='".SCORE_LOG_CRITICAL."' ".($this->heie("priority")==SCORE_LOG_CRITICAL ? "selected" : "").">Critical</option>
|
||||
</select>
|
||||
</td>
|
||||
<td><input type='submit' value='Search'></td>
|
||||
</tr>
|
||||
</form>
|
||||
</thead>
|
||||
<tbody>\n";
|
||||
reset($events); // rewind to first element in array.
|
||||
|
||||
foreach ($events as $event) {
|
||||
$c = $this->pri_to_col($event['priority']);
|
||||
$table .= "<tr style='color: $c'>";
|
||||
$table .= "<td>".str_replace(" ", " ", substr($event['date_sent'], 0, 19))."</td>";
|
||||
$table .= "<td>".$event['section']."</td>";
|
||||
if ($event['username'] == "Anonymous") {
|
||||
$table .= "<td>".$event['address']."</td>";
|
||||
} else {
|
||||
$table .= "<td><span title='".$event['address']."'>".
|
||||
"<a href='".make_link("user/".url_escape($event['username']))."'>".html_escape($event['username'])."</a>".
|
||||
"</span></td>";
|
||||
}
|
||||
$table .= "<td colspan='3'>".$this->scan_entities(html_escape($event['message']))."</td>";
|
||||
$table .= "</tr>\n";
|
||||
}
|
||||
$table .= "</tbody></table>";
|
||||
|
||||
global $page;
|
||||
$page->set_title("Event Log");
|
||||
$page->set_heading("Event Log");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Events", $table));
|
||||
$this->display_paginator($page, "log/view", $this->get_args(), $page_num, $page_total);
|
||||
}
|
||||
|
||||
protected function get_args()
|
||||
{
|
||||
$args = "";
|
||||
// Check if each arg is actually empty and skip it if so
|
||||
if (strlen($this->ueie("time-start"))) {
|
||||
$args .= $this->ueie("time-start")."&";
|
||||
}
|
||||
if (strlen($this->ueie("time-end"))) {
|
||||
$args .= $this->ueie("time-end")."&";
|
||||
}
|
||||
if (strlen($this->ueie("module"))) {
|
||||
$args .= $this->ueie("module")."&";
|
||||
}
|
||||
if (strlen($this->ueie("user"))) {
|
||||
$args .= $this->ueie("user")."&";
|
||||
}
|
||||
if (strlen($this->ueie("message"))) {
|
||||
$args .= $this->ueie("message")."&";
|
||||
}
|
||||
if (strlen($this->ueie("priority"))) {
|
||||
$args .= $this->ueie("priority");
|
||||
}
|
||||
// If there are no args at all, set $args to null to prevent an unnecessary ? at the end of the paginator url
|
||||
if (strlen($args) == 0) {
|
||||
$args = null;
|
||||
}
|
||||
return $args;
|
||||
}
|
||||
|
||||
protected function pri_to_col($pri)
|
||||
{
|
||||
switch ($pri) {
|
||||
case SCORE_LOG_DEBUG: return "#999";
|
||||
case SCORE_LOG_INFO: return "#000";
|
||||
case SCORE_LOG_WARNING: return "#800";
|
||||
case SCORE_LOG_ERROR: return "#C00";
|
||||
case SCORE_LOG_CRITICAL: return "#F00";
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
protected function scan_entities($line)
|
||||
{
|
||||
$line = preg_replace_callback("/Image #(\d+)/s", [$this, "link_image"], $line);
|
||||
return $line;
|
||||
}
|
||||
|
||||
protected function link_image($id)
|
||||
{
|
||||
$iid = int_escape($id[1]);
|
||||
return "<a href='".make_link("post/view/$iid")."'>Image #$iid</a>";
|
||||
$page->add_block(new Block("Events", $table . $paginator));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ class NotATag extends Extension
|
|||
$t = new NotATagTable($database->raw_db());
|
||||
$t->token = $user->get_auth_token();
|
||||
$t->inputs = $_GET;
|
||||
$this->theme->display_bans($page, $t->table($t->query()), $t->paginator());
|
||||
$this->theme->display_untags($page, $t->table($t->query()), $t->paginator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,7 +190,9 @@ class UserPage extends Extension
|
|||
}
|
||||
|
||||
$event->add_stats("Joined: $h_join_date", 10);
|
||||
$event->add_stats("Current IP: {$_SERVER['REMOTE_ADDR']}", 80);
|
||||
if($user->name == $event->display_user->name) {
|
||||
$event->add_stats("Current IP: {$_SERVER['REMOTE_ADDR']}", 80);
|
||||
}
|
||||
$event->add_stats("Class: $h_class", 90);
|
||||
|
||||
$av = $event->display_user->get_avatar_html();
|
||||
|
|
Reference in a new issue