FEAT_VIEW_LOG_ADDED_SRINIVAS
This commit is contained in:
parent
06bed22747
commit
01e22f2b93
@ -97,5 +97,5 @@ class Autoload extends AutoloadConfig
|
||||
* @var string[]
|
||||
* @phpstan-var list<string>
|
||||
*/
|
||||
public $helpers = ['date_picker'];
|
||||
public $helpers = ['date_picker','utility'];
|
||||
}
|
||||
|
||||
@ -201,6 +201,17 @@ $routes->get('/payment_failure', 'Payment::payment_failure');
|
||||
$routes->get('/payment_process','Payment::payment_process');
|
||||
$routes->get('payment_success','Payment::payment_success');
|
||||
$routes->match(['get','post'],'/subscription_renewal/(:any)','Payment::index/$1');
|
||||
|
||||
|
||||
|
||||
// Logs
|
||||
|
||||
$routes->get('/list_log','Payment::listLogs');
|
||||
$routes->get('/download_log/(:any)','Payment::downloadLog/$1');
|
||||
$routes->get('/view_log/(:any)','Payment::viewLog/$1');
|
||||
|
||||
|
||||
|
||||
// $routes->group("api", function ($routes) {
|
||||
// // $routes->post("create_products/", "ApiIntegration::save_book_details");
|
||||
// // $routes->match(['put', 'post', 'get', 'delete'], 'products', 'ApiIntegration::book_api_integration');
|
||||
|
||||
@ -65,7 +65,7 @@ abstract class BaseController extends Controller
|
||||
echo "This is a command-line request.";
|
||||
// echo $requestedRoute;
|
||||
} else {
|
||||
if ($requestedRoute !== '/login' && $requestedRoute !== '/authenticate'&& $requestedRoute !== '/pay' && $requestedRoute !== '/auth_confirm_mail' && $requestedRoute !== '/auth_reset_password' && $requestedRoute !== 'auth_reset_password_save' && $requestedRoute !== '/subscription_renewal'&& $requestedRoute !== '/tresponse' && strpos($requestedRoute, '/subscription_renewal/') === false && $requestedRoute !== '/payment_failure'&& $requestedRoute !== '/payment_success' && $requestedRoute !== '/payment_process' && $uri->getSegment(1) != 'getExpCustomerDetail'&& $uri->getSegment(1) != 'download_invoice_pdf') {
|
||||
if ($requestedRoute !== '/login' && $requestedRoute !== '/list_log'&& $requestedRoute !== 'download_log'&& $requestedRoute !=='view_log' && $requestedRoute !== '/authenticate'&& $requestedRoute !== '/pay' && $requestedRoute !== '/auth_confirm_mail' && $requestedRoute !== '/auth_reset_password' && $requestedRoute !== 'auth_reset_password_save' && $requestedRoute !== '/subscription_renewal'&& $requestedRoute !== '/tresponse' && strpos($requestedRoute, '/subscription_renewal/') === false && $requestedRoute !== '/payment_failure'&& $requestedRoute !== '/payment_success' && $requestedRoute !== '/payment_process' && $uri->getSegment(1) != 'getExpCustomerDetail'&& $uri->getSegment(1) != 'download_invoice_pdf') {
|
||||
$this->authData = $this->session_log();
|
||||
}
|
||||
}
|
||||
|
||||
@ -344,4 +344,68 @@ public function payment_success(){
|
||||
return view('payment_success');
|
||||
}
|
||||
|
||||
public function listLogs()
|
||||
{
|
||||
$logPath = WRITEPATH . 'logs/';
|
||||
$logs = [];
|
||||
|
||||
// Check if the log directory exists
|
||||
if (is_dir($logPath)) {
|
||||
$files = array_diff(scandir($logPath), ['.', '..']); // Exclude '.' and '..'
|
||||
|
||||
$files = array_reverse($files);
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (is_file($logPath . $file)) {
|
||||
$logs[] = $file; // Add log files to the list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$data['logs'] = $logs;
|
||||
$data['server_details'] = get_server_details();
|
||||
$data['page_name'] = 'list_log';
|
||||
// $data['company_name'] = "Vijayabharatham Prasuram";
|
||||
// $data['company_short_name']= "VP";
|
||||
|
||||
|
||||
// Pass log files to the view
|
||||
return view('log_view', $data);
|
||||
}
|
||||
|
||||
public function downloadLog($fileName)
|
||||
{
|
||||
$logPath = WRITEPATH . 'logs/' . $fileName;
|
||||
|
||||
// Check if the requested file exists
|
||||
if (file_exists($logPath)) {
|
||||
return $this->response->download($logPath, null)->setFileName($fileName);
|
||||
}
|
||||
|
||||
// Redirect back with an error if file doesn't exist
|
||||
return redirect()->back()->with('error', 'Log file not found.');
|
||||
}
|
||||
|
||||
public function viewLog($fileName)
|
||||
{
|
||||
$logPath = WRITEPATH . 'logs/' . $fileName;
|
||||
|
||||
if (file_exists($logPath)) {
|
||||
$content = file_get_contents($logPath);
|
||||
|
||||
$data['fileName'] = $fileName;
|
||||
$data['content'] = $content;
|
||||
$data['server_details'] = get_server_details();
|
||||
$data['page_name'] = 'View Log';
|
||||
// $data['company_name'] = "Vijayabharatham Prasuram";
|
||||
// $data['company_short_name']= "VP";
|
||||
|
||||
return view('log_content_view', $data);
|
||||
}
|
||||
|
||||
return redirect()->back()->with('error', 'Log file not found.');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
18
app/Helpers/utility_helper.php
Normal file
18
app/Helpers/utility_helper.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
if (!function_exists('get_server_details')) {
|
||||
/**
|
||||
* Get the hostname and server name.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_server_details(): array
|
||||
{
|
||||
$hostname = gethostname(); // Get the hostname of the server
|
||||
$serverName = $_SERVER['SERVER_NAME'] ?? 'Unknown'; // Get the server name
|
||||
|
||||
return [
|
||||
'hostname' => $hostname,
|
||||
'server_name' => $serverName,
|
||||
];
|
||||
}
|
||||
}
|
||||
32
app/Views/log_content_view.php
Normal file
32
app/Views/log_content_view.php
Normal file
@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>View Log: <?= esc($fileName) ?></title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="row">
|
||||
<div class="form-group col-10">
|
||||
<h3> <?= $server_details['hostname'] . '/' . $server_details['server_name'] . ' - ' ?> Log File: <?= esc($fileName) ?></h3>
|
||||
</div>
|
||||
<div class="form-group col-2">
|
||||
<a href="<?= base_url('/list_log') ?>" class="btn btn-primary float-md-right">Back to Logs</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<pre style="background-color: #f5f5f5; padding: 15px; border: 1px solid #ccc;">
|
||||
<?= esc($content) ?>
|
||||
</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="<?= base_url('/list_log') ?>">Back to Logs</a>
|
||||
</body>
|
||||
</html>
|
||||
49
app/Views/log_view.php
Normal file
49
app/Views/log_view.php
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
<title>Log Files</title>
|
||||
<style>
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
table.dataTable tbody td {
|
||||
padding: 4px 4px !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<h3> <?= $server_details['hostname'] . '/' . $server_details['server_name'] . ' - ' ?> Log Files</h3>
|
||||
|
||||
<?php if (session()->getFlashdata('error')): ?>
|
||||
<p style="color: red;"><?= session()->getFlashdata('error') ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th>S.No.</th>
|
||||
<th>Log File</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (!empty($logs)): ?>
|
||||
<?php foreach ($logs as $index => $log): ?>
|
||||
<tr>
|
||||
<td><?= $index + 1 . '.' ?></td>
|
||||
<td><?= esc($log) ?></td>
|
||||
<td>
|
||||
<a href="<?= base_url('view_log/' . urlencode($log)) ?>">View</a> |
|
||||
<a href="<?= base_url('download_log/' . urlencode($log)) ?>">Download</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="2">No log files found.</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
Loading…
Reference in New Issue
Block a user