diff --git a/app/Config/Autoload.php b/app/Config/Autoload.php index 5e6c90c9..52a978de 100755 --- a/app/Config/Autoload.php +++ b/app/Config/Autoload.php @@ -97,5 +97,5 @@ class Autoload extends AutoloadConfig * @var string[] * @phpstan-var list */ - public $helpers = ['date_picker']; + public $helpers = ['date_picker','utility']; } diff --git a/app/Config/Routes.php b/app/Config/Routes.php index d94e8852..dc81c505 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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'); diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index 978eeb03..dd4ebaf0 100755 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -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(); } } diff --git a/app/Controllers/Payment.php b/app/Controllers/Payment.php index 1aab5832..30bdc0c0 100644 --- a/app/Controllers/Payment.php +++ b/app/Controllers/Payment.php @@ -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.'); +} + + +} + diff --git a/app/Helpers/utility_helper.php b/app/Helpers/utility_helper.php new file mode 100644 index 00000000..dbff196c --- /dev/null +++ b/app/Helpers/utility_helper.php @@ -0,0 +1,18 @@ + $hostname, + 'server_name' => $serverName, + ]; + } +} diff --git a/app/Views/log_content_view.php b/app/Views/log_content_view.php new file mode 100644 index 00000000..4e8a5724 --- /dev/null +++ b/app/Views/log_content_view.php @@ -0,0 +1,32 @@ + + + + + + View Log: <?= esc($fileName) ?> + + +
+
+

Log File:

+
+ +
+ +
+
+
+
+
     
+                        
+                    
+
+
+
+
+ + Back to Logs + + diff --git a/app/Views/log_view.php b/app/Views/log_view.php new file mode 100644 index 00000000..df1df885 --- /dev/null +++ b/app/Views/log_view.php @@ -0,0 +1,49 @@ + +Log Files + + + +

Log Files

+ +getFlashdata('error')): ?> +

getFlashdata('error') ?>

+ + + + + + + + + + + + + $log): ?> + + + + + + + + + + + + +
S.No.Log FileActions
+ View | + Download +
No log files found.