Gazelle/sections/log/index.php

211 lines
6.1 KiB
PHP
Raw Permalink Normal View History

2011-03-28 14:21:28 +00:00
<?
enforce_login();
if (!defined('LOG_ENTRIES_PER_PAGE')) {
2012-08-30 08:00:17 +00:00
define('LOG_ENTRIES_PER_PAGE', 100);
2011-03-28 14:21:28 +00:00
}
2012-10-11 08:00:15 +00:00
View::show_header("Site log");
2011-03-28 14:21:28 +00:00
2012-10-01 08:00:23 +00:00
include(SERVER_ROOT.'/sections/log/sphinx.php');
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2012-08-19 08:00:19 +00:00
<div class="header">
2012-10-01 08:00:23 +00:00
<h2>Site log</h2>
2012-08-19 08:00:19 +00:00
</div>
2012-10-01 08:00:23 +00:00
<div class="box pad">
2012-09-15 08:00:25 +00:00
<form class="search_form" name="log" action="" method="get">
2012-09-01 08:00:24 +00:00
<table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
2011-03-28 14:21:28 +00:00
<tr>
<td class="label"><strong>Search for:</strong></td>
<td>
2014-03-23 08:00:50 +00:00
<input type="search" name="search" size="60"<?=(!empty($_GET['search']) ? ' value="'.display_str($_GET['search']).'"' : '')?> />
2011-03-28 14:21:28 +00:00
&nbsp;
<input type="submit" value="Search log" />
</td>
</tr>
2012-10-11 08:00:15 +00:00
</table>
2011-03-28 14:21:28 +00:00
</form>
</div>
2012-08-30 08:00:17 +00:00
2013-06-25 08:00:52 +00:00
<? if ($TotalMatches > LOG_ENTRIES_PER_PAGE) { ?>
2011-03-28 14:21:28 +00:00
<div class="linkbox">
<?
2013-05-15 08:00:54 +00:00
$Pages = Format::get_pages($Page, $TotalMatches, LOG_ENTRIES_PER_PAGE, 9);
2012-09-01 08:00:24 +00:00
echo $Pages;?>
2011-03-28 14:21:28 +00:00
</div>
2013-06-25 08:00:52 +00:00
<? } ?>
2012-10-01 08:00:23 +00:00
<table cellpadding="6" cellspacing="1" border="0" class="log_table border" id="log_table" width="100%">
2011-03-28 14:21:28 +00:00
<tr class="colhead">
<td style="width: 180px;"><strong>Time</strong></td>
<td><strong>Message</strong></td>
</tr>
2013-06-25 08:00:52 +00:00
<? if ($QueryStatus) { ?>
2012-08-30 08:00:17 +00:00
<tr class="nobr"><td colspan="2">Search request failed (<?=$QueryError?>).</td></tr>
2013-07-10 00:08:53 +00:00
<? } elseif (!$DB->has_results()) { ?>
2012-08-30 08:00:17 +00:00
<tr class="nobr"><td colspan="2">Nothing found!</td></tr>
2013-06-25 08:00:52 +00:00
<?
}
2011-03-28 14:21:28 +00:00
$Row = 'a';
$Usernames = array();
2013-05-06 08:00:32 +00:00
while (list($ID, $Message, $LogTime) = $DB->next_record()) {
2013-06-25 08:00:52 +00:00
$MessageParts = explode(' ', $Message);
$Message = '';
2011-03-28 14:21:28 +00:00
$Color = $Colon = false;
for ($i = 0, $PartCount = sizeof($MessageParts); $i < $PartCount; $i++) {
2013-08-28 23:08:41 +00:00
if ((strpos($MessageParts[$i], 'https://'.SSL_SITE_URL) === 0
&& $Offset = strlen('https://'.SSL_SITE_URL.'/'))
|| (strpos($MessageParts[$i], 'http://'.NONSSL_SITE_URL) === 0
&& $Offset = strlen('http://'.NONSSL_SITE_URL.'/'))
) {
$MessageParts[$i] = '<a href="'.substr($MessageParts[$i], $Offset).'">'.substr($MessageParts[$i], $Offset).'</a>';
2011-03-28 14:21:28 +00:00
}
switch ($MessageParts[$i]) {
2013-06-25 08:00:52 +00:00
case 'Torrent':
case 'torrent':
2012-01-28 08:00:29 +00:00
$TorrentID = $MessageParts[$i + 1];
2011-03-28 14:21:28 +00:00
if (is_numeric($TorrentID)) {
2013-06-25 08:00:52 +00:00
$Message = $Message.' '.$MessageParts[$i]." <a href=\"torrents.php?torrentid=$TorrentID\">$TorrentID</a>";
2012-01-28 08:00:29 +00:00
$i++;
2011-03-28 14:21:28 +00:00
} else {
2012-01-28 08:00:29 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
}
break;
2013-06-25 08:00:52 +00:00
case 'Request':
2012-01-28 08:00:29 +00:00
$RequestID = $MessageParts[$i + 1];
2011-03-28 14:21:28 +00:00
if (is_numeric($RequestID)) {
2013-06-25 08:00:52 +00:00
$Message = $Message.' '.$MessageParts[$i]." <a href=\"requests.php?action=view&amp;id=$RequestID\">$RequestID</a>";
2012-01-28 08:00:29 +00:00
$i++;
2011-03-28 14:21:28 +00:00
} else {
2012-01-28 08:00:29 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
}
break;
2013-06-25 08:00:52 +00:00
case 'Artist':
case 'artist':
2012-01-28 08:00:29 +00:00
$ArtistID = $MessageParts[$i + 1];
2011-03-28 14:21:28 +00:00
if (is_numeric($ArtistID)) {
2013-06-25 08:00:52 +00:00
$Message = $Message.' '.$MessageParts[$i]." <a href=\"artist.php?id=$ArtistID\">$ArtistID</a>";
2012-01-28 08:00:29 +00:00
$i++;
2011-03-28 14:21:28 +00:00
} else {
2012-01-28 08:00:29 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
}
break;
2013-06-25 08:00:52 +00:00
case 'group':
case 'Group':
2012-01-28 08:00:29 +00:00
$GroupID = $MessageParts[$i + 1];
if (is_numeric($GroupID)) {
2013-06-25 08:00:52 +00:00
$Message = $Message.' '.$MessageParts[$i]." <a href=\"torrents.php?id=$GroupID\">$GroupID</a>";
2011-03-28 14:21:28 +00:00
} else {
2012-01-28 08:00:29 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
}
2012-01-28 08:00:29 +00:00
$i++;
2011-03-28 14:21:28 +00:00
break;
2013-06-25 08:00:52 +00:00
case 'by':
2011-03-28 14:21:28 +00:00
$UserID = 0;
2013-05-04 08:00:48 +00:00
$User = '';
$URL = '';
2013-05-15 08:00:54 +00:00
if ($MessageParts[$i + 1] == 'user') {
2011-03-28 14:21:28 +00:00
$i++;
if (is_numeric($MessageParts[$i + 1])) {
$UserID = $MessageParts[++$i];
}
2013-06-25 08:00:52 +00:00
$URL = "user $UserID (<a href=\"user.php?id=$UserID\">".substr($MessageParts[++$i], 1, -1).'</a>)';
2013-05-15 08:00:54 +00:00
} elseif (in_array($MessageParts[$i - 1], array('deleted', 'uploaded', 'edited', 'created', 'recovered'))) {
2011-03-28 14:21:28 +00:00
$User = $MessageParts[++$i];
2013-05-15 08:00:54 +00:00
if (substr($User, -1) == ':') {
2011-03-28 14:21:28 +00:00
$User = substr($User, 0, -1);
$Colon = true;
}
2013-05-04 08:00:48 +00:00
if (!isset($Usernames[$User])) {
2013-06-25 08:00:52 +00:00
$DB->query("
SELECT ID
FROM users_main
2014-03-03 08:00:33 +00:00
WHERE Username = _utf8 '" . db_string($User) . "'
2013-06-25 08:00:52 +00:00
COLLATE utf8_bin");
2011-03-28 14:21:28 +00:00
list($UserID) = $DB->next_record();
2012-01-28 08:00:29 +00:00
$Usernames[$User] = $UserID ? $UserID : '';
2011-03-28 14:21:28 +00:00
} else {
$UserID = $Usernames[$User];
}
$DB->set_query_id($Log);
2013-06-25 08:00:52 +00:00
$URL = $Usernames[$User] ? "<a href=\"user.php?id=$UserID\">$User</a>".($Colon ? ':' : '') : $User;
2011-03-28 14:21:28 +00:00
}
2013-05-15 08:00:54 +00:00
$Message = "$Message by $URL";
2011-03-28 14:21:28 +00:00
break;
2013-06-25 08:00:52 +00:00
case 'uploaded':
2011-03-28 14:21:28 +00:00
if ($Color === false) {
$Color = 'green';
}
2013-05-15 08:00:54 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
break;
2013-06-25 08:00:52 +00:00
case 'deleted':
2011-03-28 14:21:28 +00:00
if ($Color === false || $Color === 'green') {
$Color = 'red';
}
2013-05-15 08:00:54 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
break;
2013-06-25 08:00:52 +00:00
case 'edited':
2011-03-28 14:21:28 +00:00
if ($Color === false) {
$Color = 'blue';
}
2013-05-15 08:00:54 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
break;
2013-06-25 08:00:52 +00:00
case 'un-filled':
2011-03-28 14:21:28 +00:00
if ($Color === false) {
$Color = '';
}
2013-05-15 08:00:54 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
break;
2013-06-25 08:00:52 +00:00
case 'marked':
2012-01-28 08:00:29 +00:00
if ($i == 1) {
$User = $MessageParts[$i - 1];
2013-05-04 08:00:48 +00:00
if (!isset($Usernames[$User])) {
2013-06-25 08:00:52 +00:00
$DB->query("
SELECT ID
FROM users_main
2014-03-03 08:00:33 +00:00
WHERE Username = _utf8 '" . db_string($User) . "'
2013-06-25 08:00:52 +00:00
COLLATE utf8_bin");
2012-01-28 08:00:29 +00:00
list($UserID) = $DB->next_record();
$Usernames[$User] = $UserID ? $UserID : '';
$DB->set_query_id($Log);
} else {
$UserID = $Usernames[$User];
}
2013-06-25 08:00:52 +00:00
$URL = $Usernames[$User] ? "<a href=\"user.php?id=$UserID\">$User</a>" : $User;
2012-01-28 08:00:29 +00:00
$Message = $URL." ".$MessageParts[$i];
} else {
$Message = $Message.' '.$MessageParts[$i];
}
break;
2013-06-25 08:00:52 +00:00
case 'Collage':
2012-01-28 08:00:29 +00:00
$CollageID = $MessageParts[$i + 1];
if (is_numeric($CollageID)) {
2013-06-25 08:00:52 +00:00
$Message = $Message.' '.$MessageParts[$i]." <a href=\"collages.php?id=$CollageID\">$CollageID</a>";
2012-01-28 08:00:29 +00:00
$i++;
} else {
$Message = $Message.' '.$MessageParts[$i];
}
break;
2011-03-28 14:21:28 +00:00
default:
2013-05-15 08:00:54 +00:00
$Message = $Message.' '.$MessageParts[$i];
2011-03-28 14:21:28 +00:00
}
}
2013-10-25 08:00:59 +00:00
$Row = $Row === 'a' ? 'b' : 'a';
2011-03-28 14:21:28 +00:00
?>
2012-08-30 08:00:17 +00:00
<tr class="row<?=$Row?>" id="log_<?=$ID?>">
2011-03-28 14:21:28 +00:00
<td class="nobr">
<?=time_diff($LogTime)?>
</td>
<td>
2013-05-04 08:00:48 +00:00
<span<? if ($Color) { ?> style="color: <?=$Color?>;"<? } ?>><?=$Message?></span>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<?
}
?>
</table>
<div class="linkbox">
<?=$Pages?>
</div>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer(); ?>