new file: src/Controllers/AuthController.php
This commit is contained in:
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
/* Smarty version 5.4.2, created on 2024-12-18 20:10:06
|
||||
from 'file:index.tpl' */
|
||||
|
||||
/* @var \Smarty\Template $_smarty_tpl */
|
||||
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
|
||||
'version' => '5.4.2',
|
||||
'unifunc' => 'content_67632c1ed9f985_55329758',
|
||||
'has_nocache_code' => false,
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'12e7c104d0458c0f98059f5061a369703f954f4a' =>
|
||||
array (
|
||||
0 => 'index.tpl',
|
||||
1 => 1734552581,
|
||||
2 => 'file',
|
||||
),
|
||||
),
|
||||
'includes' =>
|
||||
array (
|
||||
),
|
||||
))) {
|
||||
function content_67632c1ed9f985_55329758 (\Smarty\Template $_smarty_tpl) {
|
||||
$_smarty_current_dir = '/home/upw/clients/kpopping/xbotcontrol/smarty/template';
|
||||
?><!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>XBotControl</title>
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<?php echo '<script'; ?>
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
|
||||
<?php echo '</script'; ?>
|
||||
>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/bootstrap-table.min.css">
|
||||
<?php echo '<script'; ?>
|
||||
src="https://code.jquery.com/jquery-3.7.1.min.js"><?php echo '</script'; ?>
|
||||
>
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<?php echo '<script'; ?>
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/bootstrap-table.min.js"><?php echo '</script'; ?>
|
||||
>
|
||||
<!-- Latest compiled and minified Locales -->
|
||||
<?php echo '<script'; ?>
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/locale/bootstrap-table-en-US.min.js"><?php echo '</script'; ?>
|
||||
>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/extensions/filter-control/bootstrap-table-filter-control.css">
|
||||
<?php echo '<script'; ?>
|
||||
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/extensions/filter-control/bootstrap-table-filter-control.js">
|
||||
<?php echo '</script'; ?>
|
||||
>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/css/all.min.css" rel="stylesheet">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="main-menu " style="background-color: #003366;">
|
||||
|
||||
<div class="container text-center text-light">
|
||||
<nav class="navbar navbar-expand-lg text-light">
|
||||
<div class="container">
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="btn text-light" onclick="initializeTable('latest_requests');">Latest</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="btn text-light" onclick="initializeTable('count_requests_by_ip');">Top by
|
||||
IP</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="btn text-light" onclick="initializeTable('count_requests_by_ua');">Top by
|
||||
UA</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="btn text-light" onclick="initializeTable('top_ip_ua_path');">IP+UA+Path</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="btn text-light" onclick="initializeTable('top_ip_by_load');">IP+Load</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="btn text-light" onclick="initializeTable('top_ip_by_rps');">IP+RPS</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="content">
|
||||
<div id="main-body">
|
||||
<div class="container" style="max-width: 95%;">
|
||||
<div class="row p-3">
|
||||
<div class="col-10">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="toolbar" class="row ">
|
||||
|
||||
<div class="col-auto">
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">Limit</div>
|
||||
|
||||
|
||||
<select id="limit" name="limit" class="form-control mr-3">
|
||||
<option value="10">10</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100" selected>100</option>
|
||||
<option value="200">200</option>
|
||||
<option value="500">500</option>
|
||||
<option value="1000">1000</option>
|
||||
<option value="100000">100000</option>
|
||||
<option value="0">0</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">From</div>
|
||||
|
||||
<input type="datetime-local" id="date-from" name="date-from" class="form-control mr-3">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="input-group">
|
||||
<div class="input-group-text">To</div>
|
||||
|
||||
<input type="datetime-local" id="date-to" name="date-to" class="form-control mr-3">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<table id="table">
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo '<script'; ?>
|
||||
>
|
||||
document.getElementById('date-from').addEventListener('change', refreshTable);
|
||||
|
||||
document.getElementById('limit').addEventListener('change', refreshTable);
|
||||
|
||||
function refreshTable() {
|
||||
$('#table').bootstrapTable('refresh');
|
||||
}
|
||||
window.onload = function() {
|
||||
const dateFrom = document.getElementById('date-from');
|
||||
const dateTo = document.getElementById('date-to');
|
||||
|
||||
const today = new Date();
|
||||
const yesterday = new Date(today);
|
||||
yesterday.setDate(today.getDate() - 1);
|
||||
|
||||
const tomorrow = new Date(today);
|
||||
tomorrow.setDate(today.getDate() + 1);
|
||||
|
||||
dateFrom.value = yesterday.toISOString().slice(0, 16);
|
||||
dateTo.value = tomorrow.toISOString().slice(0, 16);
|
||||
};
|
||||
document.getElementById('date-to').addEventListener('change', refreshTable);
|
||||
|
||||
|
||||
function initializeTable(latest_requests) {
|
||||
var url = location.pathname + '/api/report/' + latest_requests;
|
||||
var $table = $('#table');
|
||||
|
||||
if ($table.length) {
|
||||
$table.bootstrapTable('destroy');
|
||||
}
|
||||
|
||||
$.get(url, function(response) {
|
||||
$table.bootstrapTable({
|
||||
url: url,
|
||||
sortable: true,
|
||||
toolbar: '#toolbar',
|
||||
showRefresh: true,
|
||||
iconsPrefix: 'fa',
|
||||
showColumns: true,
|
||||
classes: ['table', 'table-borderless', 'table-hover', 'table-striped'],
|
||||
filterControl: true,
|
||||
searchable: true,
|
||||
pagination: false,
|
||||
sidePagination: "server",
|
||||
serverSort: false,
|
||||
columns: response.columns,
|
||||
queryParams: queryParams,
|
||||
loadingFontSize: '12px'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function queryParams(params) {
|
||||
const limit = document.getElementById('limit').value;
|
||||
const from = document.getElementById('date-from').value;
|
||||
const to = document.getElementById('date-to').value;
|
||||
|
||||
params.limit = limit;
|
||||
params.from = from;
|
||||
params.to = to;
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function listFormatter(value, row, index) {
|
||||
var editBtn = '<a class="btn" href="<?php echo htmlspecialchars((string) ($_ENV['BASEURI']), ENT_QUOTES, 'UTF-8');?>
|
||||
/lists/edit/' + row.list_id + '" title="Edit"><i class="fa-solid fa-pen-to-square"></i></a> ';
|
||||
|
||||
var showBtn = '<a class="btn" href="<?php echo htmlspecialchars((string) ($_ENV['BASEURI']), ENT_QUOTES, 'UTF-8');?>
|
||||
/lists/show/' + row.list_id + '" title="Show"><i class="fa-solid fa-eye"></i></a>';
|
||||
<?php if ($_SESSION['user_role'] == 'admin') {?>
|
||||
return [showBtn, editBtn, value, ].join('')
|
||||
<?php } else { ?>
|
||||
return [showBtn, value, ].join('')
|
||||
|
||||
<?php }?>
|
||||
}
|
||||
<?php echo '</script'; ?>
|
||||
>
|
||||
|
||||
<?php echo '<script'; ?>
|
||||
>
|
||||
function ipFormatter(value) {
|
||||
return `<span class="ip-address" data-ip="${value}">${value}</span>`;
|
||||
}
|
||||
|
||||
document.addEventListener('mouseover', async (event) => {
|
||||
const target = event.target;
|
||||
if (target.classList.contains('ip-address')) {
|
||||
const ipAddress = target.getAttribute('data-ip');
|
||||
const popupId = `popup-${ipAddress.replace(/\./g, '-')}`;
|
||||
let popup = document.getElementById(popupId);
|
||||
|
||||
if (!popup) {
|
||||
popup = document.createElement('div');
|
||||
popup.id = popupId;
|
||||
popup.style.position = 'absolute';
|
||||
popup.style.background = '#f9f9f9';
|
||||
popup.style.border = '1px solid #ccc';
|
||||
popup.style.padding = '10px';
|
||||
popup.style.borderRadius = '5px';
|
||||
popup.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.2)';
|
||||
popup.style.zIndex = '1000';
|
||||
popup.style.whiteSpace = 'nowrap';
|
||||
popup.style.display = 'none';
|
||||
document.body.appendChild(popup);
|
||||
|
||||
fetch(location.pathname + `/api/ipinfo/${ipAddress}`)
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
const location = data.geo.continent?.names?.en + ' > ' + data.geo.country
|
||||
?.names?.en + ' > ' + data.geo.city?.names?.en || 'Unknown';
|
||||
const reverseDns = data.reverse_dns || 'N/A';
|
||||
popup.innerHTML = `
|
||||
<strong>Location:</strong> ${location}<br>
|
||||
<strong>Reverse DNS:</strong> ${reverseDns}
|
||||
`;
|
||||
})
|
||||
.catch(() => {
|
||||
popup.innerHTML = 'Error fetching data.';
|
||||
});
|
||||
}
|
||||
|
||||
popup.style.display = 'block';
|
||||
popup.style.left = `${event.pageX + 10}px`;
|
||||
popup.style.top = `${event.pageY + 10}px`;
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('mouseout', (event) => {
|
||||
const target = event.target;
|
||||
if (target.classList.contains('ip-address')) {
|
||||
const ipAddress = target.getAttribute('data-ip');
|
||||
const popupId = `popup-${ipAddress.replace(/\./g, '-')}`;
|
||||
const popup = document.getElementById(popupId);
|
||||
if (popup) {
|
||||
popup.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
<?php echo '</script'; ?>
|
||||
>
|
||||
|
||||
<footer class="centro-blue text-white text-center py-3">
|
||||
<div class="footer">
|
||||
<div class="container text-center centro-blue text-light">
|
||||
<h6>Copyright 2024
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body><?php }
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/* Smarty version 5.4.2, created on 2024-12-18 19:19:42
|
||||
from 'file:login.tpl' */
|
||||
|
||||
/* @var \Smarty\Template $_smarty_tpl */
|
||||
if ($_smarty_tpl->getCompiled()->isFresh($_smarty_tpl, array (
|
||||
'version' => '5.4.2',
|
||||
'unifunc' => 'content_6763204e824e49_51557939',
|
||||
'has_nocache_code' => false,
|
||||
'file_dependency' =>
|
||||
array (
|
||||
'b56b63fa35b4c8d6169eae7042db3ea0125ea5bf' =>
|
||||
array (
|
||||
0 => 'login.tpl',
|
||||
1 => 1734549413,
|
||||
2 => 'file',
|
||||
),
|
||||
),
|
||||
'includes' =>
|
||||
array (
|
||||
),
|
||||
))) {
|
||||
function content_6763204e824e49_51557939 (\Smarty\Template $_smarty_tpl) {
|
||||
$_smarty_current_dir = '/home/upw/clients/kpopping/xbotcontrol/smarty/template';
|
||||
?><!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>XBotControl</title>
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
||||
<?php echo '<script'; ?>
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
||||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous">
|
||||
<?php echo '</script'; ?>
|
||||
>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/bootstrap-table.min.css">
|
||||
<?php echo '<script'; ?>
|
||||
src="https://code.jquery.com/jquery-3.7.1.min.js"><?php echo '</script'; ?>
|
||||
>
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<?php echo '<script'; ?>
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/bootstrap-table.min.js"><?php echo '</script'; ?>
|
||||
>
|
||||
<!-- Latest compiled and minified Locales -->
|
||||
<?php echo '<script'; ?>
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/locale/bootstrap-table-zh-CN.min.js"><?php echo '</script'; ?>
|
||||
>
|
||||
<link rel="stylesheet" type="text/css"
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/extensions/filter-control/bootstrap-table-filter-control.css">
|
||||
<?php echo '<script'; ?>
|
||||
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap-table@1.23.5/dist/extensions/filter-control/bootstrap-table-filter-control.js">
|
||||
<?php echo '</script'; ?>
|
||||
>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.1/css/all.min.css" rel="stylesheet">
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<div class="content">
|
||||
|
||||
<div class="d-flex align-items-center justify-content-center vh-100">
|
||||
<form id="form" enctype="multipart/form-data" action="login" method="post" class="p-4 border rounded">
|
||||
<div class="mb-3">
|
||||
<label for="api_key" class="form-label">API Key</label>
|
||||
<input type="text" class="form-control" id="api_key" name="api_key">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success w-100">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<footer class="text-white text-center py-3">
|
||||
<div class="footer">
|
||||
<div class="container text-center text-light">
|
||||
<h6>Copyright 2024
|
||||
</h6>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</body><?php }
|
||||
}
|
||||
Reference in New Issue
Block a user