PluginProbe
Yatra – Travel Booking & Tour Operator Software / 2.2.10
Yatra – Travel Booking & Tour Operator Software v2.2.10
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / includes / modules / status / sections / class-yatra-module-section-logs.php

class-yatra-module-section-logs.php in Yatra – Travel Booking & Tour Operator Software 2.2.10, at includes/modules/status/sections/class-yatra-module-section-logs.php

139 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Yatra_Module_Section_Logs
4 {
5 public static function get_log_file_handle($filename)
6 {
7 return substr($filename, 0, strlen($filename) > 48 ? strlen($filename) - 48 : strlen($filename) - 4);
8 }
9
10 public static function scan_log_files()
11 {
12 return Yatra_Log_Handler_File::get_log_files();
13 }
14
15 public static function remove_log()
16 {
17 if (empty($_REQUEST['_wpnonce']) || !wp_verify_nonce(wp_unslash($_REQUEST['_wpnonce']), 'remove_log')) { // WPCS: input var ok, sanitization ok.
18 wp_die(esc_html__('Action failed. Please refresh the page and retry.', 'yatra'));
19 }
20
21 if (!empty($_REQUEST['handle'])) { // WPCS: input var ok.
22 $log_handler = new Yatra_Log_Handler_File();
23 $log_handler->remove(wp_unslash($_REQUEST['handle'])); // WPCS: input var ok, sanitization ok.
24 }
25
26 wp_safe_redirect(esc_url_raw(admin_url('admin.php?page=yatra-status&tab=logs')));
27 exit();
28 }
29
30 public static function status_logs_file_actions()
31 {
32 if (!empty($_REQUEST['handle'])) { // WPCS: input var ok, CSRF ok.
33 self::remove_log();
34 }
35 }
36
37 public static function status_logs_file_template()
38 {
39 $logs = self::scan_log_files();
40
41 if (!empty($_REQUEST['log_file']) && isset($logs[sanitize_title(wp_unslash($_REQUEST['log_file']))])) { // WPCS: input var ok, CSRF ok.
42 $viewed_log = $logs[sanitize_title(wp_unslash($_REQUEST['log_file']))]; // WPCS: input var ok, CSRF ok.
43 } elseif (!empty($logs)) {
44 $viewed_log = current($logs);
45 }
46 $handle = !empty($viewed_log) ? self::get_log_file_handle($viewed_log) : '';
47
48 include YATRA_ABSPATH . 'includes/modules/status/templates/html-admin-page-status-logs.php';
49 }
50
51 private static function flush_db_logs()
52 {
53 if (empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'yatra-status-logs')) { // WPCS: input var ok, sanitization ok.
54 wp_die(esc_html__('Action failed. Please refresh the page and retry.', 'yatra'));
55 }
56 Yatra_Log_Handler_DB::flush();
57
58 wp_safe_redirect(esc_url_raw(admin_url('admin.php?page=yatra-status&tab=logs')));
59 exit();
60 }
61
62 private static function log_table_bulk_actions()
63 {
64 if (empty($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'yatra-status-logs')) { // WPCS: input var ok, sanitization ok.
65 wp_die(esc_html__('Action failed. Please refresh the page and retry.', 'yatra'));
66 }
67
68 $log_ids = array_map('absint', (array)isset($_REQUEST['log']) ? wp_unslash($_REQUEST['log']) : array()); // WPCS: input var ok, sanitization ok.
69
70 if ((isset($_REQUEST['action']) && 'delete' === $_REQUEST['action']) || (isset($_REQUEST['action2']) && 'delete' === $_REQUEST['action2'])) { // WPCS: input var ok, sanitization ok.
71 Yatra_Log_Handler_DB::delete($log_ids);
72 wp_safe_redirect(esc_url_raw(admin_url('admin.php?page=yatra-status&tab=logs')));
73 exit();
74 }
75 }
76
77 public static function status_log_database_actions()
78 {
79 if (!empty($_REQUEST['yatra-flush-logs'])) { // WPCS: input var ok, CSRF ok.
80 self::flush_db_logs();
81 }
82
83 if (isset($_REQUEST['action']) && isset($_REQUEST['log'])) { // WPCS: input var ok, CSRF ok.
84 self::log_table_bulk_actions();
85 }
86
87 }
88
89 public static function status_log_database_template()
90 {
91 include_once YATRA_ABSPATH . 'includes/modules/status/list-tables/class-yatra-admin-log-list-table.php';
92
93 $log_table_list = new Yatra_Admin_Log_List_Table();
94 $log_table_list->prepare_items();
95
96 include YATRA_ABSPATH . 'includes/modules/status/templates/html-admin-page-status-logs-db.php';
97 }
98
99 public static function log_template()
100 {
101 $log_options = $log_options = get_option('yatra_log_options', 'db');
102
103 if ($log_options === 'db') {
104
105 $log_handler = 'Yatra_Log_Handler_DB';
106 } else {
107 $log_handler = 'Yatra_Log_Handler_File';
108 }
109
110 if ('Yatra_Log_Handler_DB' === $log_handler) {
111
112 self::status_log_database_template();
113
114 } else {
115 self::status_logs_file_template();
116 }
117 }
118
119 public static function log_actions()
120 {
121 $log_options = $log_options = get_option('yatra_log_options', 'db');
122
123 if ($log_options === 'db') {
124
125 $log_handler = 'Yatra_Log_Handler_DB';
126 } else {
127 $log_handler = 'Yatra_Log_Handler_File';
128 }
129
130 if ('Yatra_Log_Handler_DB' === $log_handler) {
131
132 self::status_log_database_actions();
133
134 } else {
135 self::status_logs_file_actions();
136 }
137 }
138
139 }