two_logs.php
326 lines
| 1 | <?php |
| 2 | $two_clear_cache_logs = \TenWebOptimizer\OptimizerLogger::get_logs('clear_cache'); |
| 3 | $two_clear_cache_headlines = [ |
| 4 | 'is_json' => 'Ajax call', |
| 5 | 'excludeCriticalRegeneration' => 'Exclude crit. regen.', |
| 6 | 'delete_tenweb_manager_cache' => 'Delete manager cache', |
| 7 | 'delete_cloudflare_cache' => 'Delete cloudflare cache', |
| 8 | 'critical_regeneration_mode' => 'Crit. regen. mode', |
| 9 | 'clear_critical' => 'Clear crit.', |
| 10 | 'stack_trace' => 'Stack', |
| 11 | 'date' => 'Date' |
| 12 | ]; |
| 13 | |
| 14 | $two_critical_css_logs = \TenWebOptimizer\OptimizerLogger::get_logs('critical_css'); |
| 15 | $two_critical_css_headlines = [ |
| 16 | 'domain_id' => 'Domain ID', |
| 17 | 'notification_id' => 'Notif. ID', |
| 18 | 'newly_connected_website' => 'Newly conn.', |
| 19 | 'flow_id' => 'Flow ID', |
| 20 | 'page_id' => 'Page ID', |
| 21 | 'status_code' => 'Status Code', |
| 22 | 'stack_trace' => 'Stack', |
| 23 | 'date' => 'Date' |
| 24 | ]; |
| 25 | |
| 26 | $two_not_optimized_logs = \TenWebOptimizer\OptimizerLogger::get_logs('not_optimized_pages'); |
| 27 | $two_not_optimized_headlines = [ |
| 28 | 'request_uri' => 'Request URI', |
| 29 | 'reason' => 'Reason', |
| 30 | 'date' => 'Date' |
| 31 | ]; |
| 32 | |
| 33 | $two_performance_requests_logs = \TenWebOptimizer\OptimizerLogger::get_logs('performance_requests'); |
| 34 | $two_performance_requests_headlines = [ |
| 35 | 'url' => 'URL', |
| 36 | 'code' => 'Status code', |
| 37 | 'msg' => 'Msg', |
| 38 | 'date' => 'Date' |
| 39 | ]; |
| 40 | |
| 41 | $two_general_logs = \TenWebOptimizer\OptimizerLogger::get_all_logs(); |
| 42 | $two_general_logs = array_slice($two_general_logs, 0, 20, true); |
| 43 | $two_general_headlines = [ |
| 44 | 'log_type' => 'Log type', |
| 45 | 'request_uri' => 'Request URI', |
| 46 | 'url' => 'URL', |
| 47 | 'stack_trace' => 'Stack', |
| 48 | 'date' => 'Date', |
| 49 | ]; |
| 50 | |
| 51 | ?> |
| 52 | <div class="two_settings_tab two_tab_two_logs"> |
| 53 | |
| 54 | <div> |
| 55 | <h3 style="display: inline-block">General logs</h3> |
| 56 | </div> |
| 57 | <table class="display" style="width:100%"> |
| 58 | <thead> |
| 59 | <tr> |
| 60 | <?php foreach ($two_general_headlines as $headline) { ?> |
| 61 | <th><?php echo esc_html($headline); ?></th> |
| 62 | <?php } ?> |
| 63 | </tr> |
| 64 | </thead> |
| 65 | <tbody> |
| 66 | <?php foreach ($two_general_logs as $log_info) { ?> |
| 67 | <tr> |
| 68 | <?php foreach ($two_general_headlines as $headline => $title) { // phpcs:ignore |
| 69 | if (isset($log_info[$headline])) { |
| 70 | $val = $log_info[$headline]; |
| 71 | |
| 72 | if (is_bool($val)) { |
| 73 | $msg = $val ? 'true' : 'false'; |
| 74 | } elseif ($headline == 'date') { |
| 75 | $msg = date('Y-m-d H:i:s', $val); // phpcs:ignore |
| 76 | } elseif ($headline == 'log_type') { |
| 77 | $msg = str_replace('_', ' ', ucfirst($val)); |
| 78 | } else { |
| 79 | $msg = $val; |
| 80 | } |
| 81 | } else { |
| 82 | $msg = '-'; |
| 83 | } |
| 84 | |
| 85 | if ($headline == 'stack_trace' && is_array($val)) { |
| 86 | echo "<th><code class='two_clear_cache_stack_trace'>"; |
| 87 | |
| 88 | foreach ($val as $frame) { |
| 89 | echo '<div>' . esc_html($frame) . '</div>'; |
| 90 | } |
| 91 | echo '</code></th>'; |
| 92 | } else { |
| 93 | echo '<th>' . esc_html($msg) . '</th>'; |
| 94 | } |
| 95 | } ?> |
| 96 | </tr> |
| 97 | <?php } ?> |
| 98 | </tbody> |
| 99 | <tfoot> |
| 100 | <tr> |
| 101 | <?php foreach ($two_general_headlines as $headline) { ?> |
| 102 | <th><?php echo esc_html($headline); ?></th> |
| 103 | <?php } ?> |
| 104 | </tr> |
| 105 | </tfoot> |
| 106 | </table> |
| 107 | <hr/> |
| 108 | |
| 109 | <div style="margin-top: 40px;"> |
| 110 | <h3 style="display: inline-block">Clear cache logs</h3> |
| 111 | <span style="float: right;" class="button" data-log-type="clear_cache">Delete clear cache logs</span> |
| 112 | </div> |
| 113 | <table class="display" data-log-type="clear_cache" style="width:100%"> |
| 114 | <thead> |
| 115 | <tr> |
| 116 | <?php foreach ($two_clear_cache_headlines as $headline) { ?> |
| 117 | <th><?php echo esc_html($headline); ?></th> |
| 118 | <?php } ?> |
| 119 | </tr> |
| 120 | </thead> |
| 121 | <tbody> |
| 122 | <?php foreach ($two_clear_cache_logs as $log_info) { ?> |
| 123 | <tr> |
| 124 | <?php foreach ($two_clear_cache_headlines as $headline => $title) { // phpcs:ignore |
| 125 | if (isset($log_info[$headline])) { |
| 126 | $val = $log_info[$headline]; |
| 127 | |
| 128 | if (is_bool($val)) { |
| 129 | $msg = $val ? 'true' : 'false'; |
| 130 | } elseif ($headline == 'date') { |
| 131 | $msg = date('Y-m-d H:i:s', $val); // phpcs:ignore |
| 132 | } else { |
| 133 | $msg = $val; |
| 134 | } |
| 135 | } else { |
| 136 | $msg = '-'; |
| 137 | } |
| 138 | |
| 139 | if ($headline == 'stack_trace') { |
| 140 | echo "<th><code class='two_clear_cache_stack_trace'>"; |
| 141 | |
| 142 | foreach ($val as $frame) { |
| 143 | echo '<div>' . esc_html($frame) . '</div>'; |
| 144 | } |
| 145 | echo '</code></th>'; |
| 146 | } else { |
| 147 | echo '<th>' . esc_html($msg) . '</th>'; |
| 148 | } |
| 149 | } ?> |
| 150 | </tr> |
| 151 | <?php } ?> |
| 152 | </tbody> |
| 153 | <tfoot> |
| 154 | <tr> |
| 155 | <?php foreach ($two_clear_cache_headlines as $headline) { ?> |
| 156 | <th><?php echo esc_html($headline); ?></th> |
| 157 | <?php } ?> |
| 158 | </tr> |
| 159 | </tfoot> |
| 160 | </table> |
| 161 | <hr/> |
| 162 | |
| 163 | <div style="margin-top: 40px;"> |
| 164 | <h3 style="display: inline-block">Generate critical CSS Logs</h3> |
| 165 | <span style="float: right;" class="button" data-log-type="critical_css">Delete critical CSS logs</span> |
| 166 | </div> |
| 167 | <table class="display" data-log-type="critical_css" style="width:100%"> |
| 168 | <thead> |
| 169 | <tr> |
| 170 | <?php foreach ($two_critical_css_headlines as $headline) { ?> |
| 171 | <th><?php echo esc_html($headline); ?></th> |
| 172 | <?php } ?> |
| 173 | </tr> |
| 174 | </thead> |
| 175 | <tbody> |
| 176 | <?php foreach ($two_critical_css_logs as $log_info) { ?> |
| 177 | <tr> |
| 178 | <?php foreach ($two_critical_css_headlines as $headline => $title) { // phpcs:ignore |
| 179 | if (isset($log_info[$headline])) { |
| 180 | $val = $log_info[$headline]; |
| 181 | |
| 182 | if (is_bool($val)) { |
| 183 | $msg = $val ? 'true' : 'false'; |
| 184 | } elseif ($headline == 'date') { |
| 185 | $msg = date('Y-m-d H:i:s', $val); // phpcs:ignore |
| 186 | } else { |
| 187 | $msg = $val; |
| 188 | } |
| 189 | } else { |
| 190 | $msg = '-'; |
| 191 | } |
| 192 | |
| 193 | if ($headline == 'stack_trace') { |
| 194 | echo "<th><code class='two_clear_cache_stack_trace'>"; |
| 195 | |
| 196 | foreach ($val as $frame) { |
| 197 | echo '<div>' . esc_html($frame) . '</div>'; |
| 198 | } |
| 199 | echo '</code></th>'; |
| 200 | } else { |
| 201 | echo '<th>' . esc_html($msg) . '</th>'; |
| 202 | } |
| 203 | } ?> |
| 204 | </tr> |
| 205 | <?php } ?> |
| 206 | </tbody> |
| 207 | <tfoot> |
| 208 | <tr> |
| 209 | <?php foreach ($two_critical_css_headlines as $headline) { ?> |
| 210 | <th><?php echo esc_html($headline); ?></th> |
| 211 | <?php } ?> |
| 212 | </tr> |
| 213 | </tfoot> |
| 214 | </table> |
| 215 | <hr/> |
| 216 | |
| 217 | <div style="margin-top: 40px;"> |
| 218 | <h3 style="display: inline-block">Performance responses</h3> |
| 219 | <span style="float: right;" |
| 220 | class="button" data-log-type="performance_requests">Delete performance requests logs </span> |
| 221 | </div> |
| 222 | <table class="display two_performance_requests_logs" data-log-type="performance_requests" style="width:100%"> |
| 223 | <thead> |
| 224 | <tr> |
| 225 | <?php foreach ($two_performance_requests_headlines as $headline) { ?> |
| 226 | <th><?php echo esc_html($headline); ?></th> |
| 227 | <?php } ?> |
| 228 | </tr> |
| 229 | </thead> |
| 230 | <tbody> |
| 231 | <?php foreach ($two_performance_requests_logs as $log_info) { ?> |
| 232 | <tr> |
| 233 | <?php foreach ($two_performance_requests_headlines as $headline => $title) { // phpcs:ignore |
| 234 | if (isset($log_info[$headline])) { |
| 235 | $val = $log_info[$headline]; |
| 236 | |
| 237 | if (is_bool($val)) { |
| 238 | $msg = $val ? 'true' : 'false'; |
| 239 | } elseif ($headline == 'date') { |
| 240 | $msg = date('Y-m-d H:i:s', $val); // phpcs:ignore |
| 241 | } else { |
| 242 | $msg = $val; |
| 243 | } |
| 244 | } else { |
| 245 | $msg = '-'; |
| 246 | } |
| 247 | |
| 248 | if ($headline == 'stack_trace') { |
| 249 | echo "<th><code class='two_clear_cache_stack_trace'>"; |
| 250 | |
| 251 | foreach ($val as $frame) { |
| 252 | echo '<div>' . esc_html($frame) . '</div>'; |
| 253 | } |
| 254 | echo '</code></th>'; |
| 255 | } else { |
| 256 | echo '<th>' . esc_html($msg) . '</th>'; |
| 257 | } |
| 258 | } ?> |
| 259 | </tr> |
| 260 | <?php } ?> |
| 261 | </tbody> |
| 262 | <tfoot> |
| 263 | <tr> |
| 264 | <?php foreach ($two_performance_requests_headlines as $headline) { ?> |
| 265 | <th><?php echo esc_html($headline); ?></th> |
| 266 | <?php } ?> |
| 267 | </tr> |
| 268 | </tfoot> |
| 269 | </table> |
| 270 | <hr/> |
| 271 | |
| 272 | <div style="margin-top: 40px;"> |
| 273 | <h3 style="display: inline-block">Not optimized pages reasons</h3> |
| 274 | <span style="float: right;" |
| 275 | class="button" data-log-type="not_optimized_pages">Delete not optimized pages logs</span> |
| 276 | </div> |
| 277 | <table class="display two_not_optimized_pages_logs" data-log-type="not_optimized_pages" style="width:100%"> |
| 278 | <thead> |
| 279 | <tr> |
| 280 | <?php foreach ($two_not_optimized_headlines as $headline) { ?> |
| 281 | <th><?php echo esc_html($headline); ?></th> |
| 282 | <?php } ?> |
| 283 | </tr> |
| 284 | </thead> |
| 285 | <tbody> |
| 286 | <?php foreach ($two_not_optimized_logs as $log_info) { ?> |
| 287 | <tr> |
| 288 | <?php foreach ($two_not_optimized_headlines as $headline => $title) { // phpcs:ignore |
| 289 | if (isset($log_info[$headline])) { |
| 290 | $val = $log_info[$headline]; |
| 291 | |
| 292 | if (is_bool($val)) { |
| 293 | $msg = $val ? 'true' : 'false'; |
| 294 | } elseif ($headline == 'date') { |
| 295 | $msg = date('Y-m-d H:i:s', $val); // phpcs:ignore |
| 296 | } else { |
| 297 | $msg = $val; |
| 298 | } |
| 299 | } else { |
| 300 | $msg = '-'; |
| 301 | } |
| 302 | |
| 303 | if ($headline == 'stack_trace') { |
| 304 | echo "<th><code class='two_clear_cache_stack_trace'>"; |
| 305 | |
| 306 | foreach ($val as $frame) { |
| 307 | echo '<div>' . esc_html($frame) . '</div>'; |
| 308 | } |
| 309 | echo '</code></th>'; |
| 310 | } else { |
| 311 | echo '<th>' . esc_html($msg) . '</th>'; |
| 312 | } |
| 313 | } ?> |
| 314 | </tr> |
| 315 | <?php } ?> |
| 316 | </tbody> |
| 317 | <tfoot> |
| 318 | <tr> |
| 319 | <?php foreach ($two_not_optimized_headlines as $headline) { ?> |
| 320 | <th><?php echo esc_html($headline); ?></th> |
| 321 | <?php } ?> |
| 322 | </tr> |
| 323 | </tfoot> |
| 324 | </table> |
| 325 | </div> |
| 326 |