188 lines
6.1 KiB
PHP
188 lines
6.1 KiB
PHP
|
<?php
|
||
|
// panel_view.php
|
||
|
// Extract all the variables we need from $viewData
|
||
|
extract($viewData);
|
||
|
|
||
|
function get_anime_year($raw_year) {
|
||
|
switch($raw_year) {
|
||
|
case -1:
|
||
|
return 'pre-2009';
|
||
|
case -2:
|
||
|
return 're-watch';
|
||
|
case -3:
|
||
|
return 'manga';
|
||
|
default:
|
||
|
return $raw_year;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Calculate pagination details
|
||
|
$total_pages = ($total_logs > 0) ? ceil($total_logs / $per_page) : 1;
|
||
|
|
||
|
?>
|
||
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<title>Control Panel</title>
|
||
|
<style>
|
||
|
/* Existing styles */
|
||
|
table {
|
||
|
border-collapse: collapse;
|
||
|
width: 100%;
|
||
|
}
|
||
|
th, td {
|
||
|
border: 1px solid #ddd;
|
||
|
padding: 8px;
|
||
|
}
|
||
|
th {
|
||
|
background-color: #ddd;
|
||
|
text-align: left;
|
||
|
}
|
||
|
/* Style for the links */
|
||
|
.action-links {
|
||
|
margin-bottom: 15px;
|
||
|
}
|
||
|
.action-links a {
|
||
|
margin-right: 15px;
|
||
|
text-decoration: none;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
.clear-logs-link {
|
||
|
color: red;
|
||
|
}
|
||
|
/* Pagination styles */
|
||
|
.pagination {
|
||
|
margin-top: 15px;
|
||
|
}
|
||
|
.pagination a {
|
||
|
margin: 0 5px;
|
||
|
text-decoration: none;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
.pagination span.current-page {
|
||
|
font-weight: bold;
|
||
|
margin: 0 5px;
|
||
|
}
|
||
|
/* Per-page form */
|
||
|
.per-page-form {
|
||
|
margin-bottom: 15px;
|
||
|
}
|
||
|
</style>
|
||
|
|
||
|
<script>
|
||
|
function confirmClearLogs() {
|
||
|
return confirm('Are you sure you want to clear all logs?');
|
||
|
}
|
||
|
</script>
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>Action Logs</h1>
|
||
|
|
||
|
<div class="action-links">
|
||
|
<!-- Link to refresh logs -->
|
||
|
<a href="panel.php?per_page=<?php echo $per_page; ?>" class="refresh-logs-link">Refresh</a>
|
||
|
|
||
|
<!-- Link to clear logs -->
|
||
|
<a href="panel.php?action=clear_logs&token=<?php echo $csrf_token; ?>&per_page=<?php echo $per_page; ?>" class="clear-logs-link" onclick="return confirmClearLogs();">Clear Logs</a>
|
||
|
</div>
|
||
|
|
||
|
<!-- Per-page selection form -->
|
||
|
<form class="per-page-form" method="get" action="panel.php">
|
||
|
<label for="per_page">Show per page:</label>
|
||
|
<select name="per_page" id="per_page">
|
||
|
<?php foreach ($allowed_per_page as $option): ?>
|
||
|
<option value="<?php echo $option; ?>" <?php if ($option == $per_page) echo 'selected'; ?>><?php echo $option; ?></option>
|
||
|
<?php endforeach; ?>
|
||
|
</select>
|
||
|
<button type="submit">Apply</button>
|
||
|
</form>
|
||
|
|
||
|
<table>
|
||
|
<tr>
|
||
|
<th>Date and Time (GMT+5)</th>
|
||
|
<th>IP Address</th>
|
||
|
<th>Anime Name</th>
|
||
|
<th>Action</th>
|
||
|
</tr>
|
||
|
<?php if (count($logs) > 0): ?>
|
||
|
<?php foreach ($logs as $log): ?>
|
||
|
<tr>
|
||
|
<td><?php echo htmlspecialchars($log['action_time']); ?></td>
|
||
|
<td><?php echo htmlspecialchars($log['ip_address']); ?></td>
|
||
|
<td>
|
||
|
<?php
|
||
|
echo htmlspecialchars($log['anime_name']);
|
||
|
echo ' (' . get_anime_year(htmlspecialchars($log['year'])) . ')';
|
||
|
?>
|
||
|
</td>
|
||
|
<td><?php echo htmlspecialchars($log['action_type']); ?></td>
|
||
|
</tr>
|
||
|
<?php endforeach; ?>
|
||
|
<?php else: ?>
|
||
|
<tr>
|
||
|
<td colspan="4">No logs available.</td>
|
||
|
</tr>
|
||
|
<?php endif; ?>
|
||
|
</table>
|
||
|
<hr>
|
||
|
|
||
|
<!-- Pagination Links -->
|
||
|
<?php if ($total_logs > 0 && $total_pages > 1): ?>
|
||
|
<div class="pagination">
|
||
|
<?php if ($page > 1): ?>
|
||
|
<a href="panel.php?page=<?php echo $page - 1; ?>&per_page=<?php echo $per_page; ?>">« Prev</a>
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<?php for ($i = 1; $i <= $total_pages; $i++): ?>
|
||
|
<?php if ($i == $page): ?>
|
||
|
<span class="current-page"><?php echo $i; ?></span>
|
||
|
<?php else: ?>
|
||
|
<a href="panel.php?page=<?php echo $i; ?>&per_page=<?php echo $per_page; ?>"><?php echo $i; ?></a>
|
||
|
<?php endif; ?>
|
||
|
<?php endfor; ?>
|
||
|
|
||
|
<?php if ($page < $total_pages): ?>
|
||
|
<a href="panel.php?page=<?php echo $page + 1; ?>&per_page=<?php echo $per_page; ?>">Next »</a>
|
||
|
<?php endif; ?>
|
||
|
</div>
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<h1>Stats</h1>
|
||
|
<p><strong>Total Entries:</strong> <?php echo $stats['total_entries']; ?></p>
|
||
|
<p><strong>Completed:</strong> <?php echo $stats['completed_anime']; ?> (<?php echo ceil(($stats['completed_anime'] / $stats['total_entries']) * 100); ?>%)</p>
|
||
|
<p><strong>Database size: </strong><?php echo number_format($size_in_kilobytes, 2); ?> Kb.</p>
|
||
|
<p><strong>Image cache size: </strong><?php echo $cache_size_mb; ?>Mb.</p>
|
||
|
<p><strong>Number of cached images: </strong><?php echo $image_count; ?></p>
|
||
|
|
||
|
<h3>Count by Type</h3>
|
||
|
<?php if (!empty($stats['by_type'])): ?>
|
||
|
<ul>
|
||
|
<?php foreach ($stats['by_type'] as $type): ?>
|
||
|
<li><?php echo htmlspecialchars($type['type'] ?: 'Unknown'); ?>: <?php echo $type['count']; ?></li>
|
||
|
<?php endforeach; ?>
|
||
|
</ul>
|
||
|
<?php endif; ?>
|
||
|
|
||
|
<p><strong>Most Recent Completion Date:</strong>
|
||
|
<?php if ($stats['most_recent_completion']):
|
||
|
$date = new DateTime($stats['most_recent_completion']);
|
||
|
echo $date->format('F j, Y');
|
||
|
else:
|
||
|
echo "No date found.";
|
||
|
endif; ?>
|
||
|
</p>
|
||
|
|
||
|
<h1>Options</h1>
|
||
|
<form method="post" action="panel.php">
|
||
|
<div>
|
||
|
<label>
|
||
|
<input type="checkbox" name="auto_add_completed_date" <?php if ($autoAddCompletedDate === '1') echo 'checked'; ?>>
|
||
|
Automatically add current date when anime is completed
|
||
|
</label>
|
||
|
</div>
|
||
|
<button type="submit" name="update_options">Save</button>
|
||
|
</form>
|
||
|
|
||
|
</body>
|
||
|
</html>
|