PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.3.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.3.0
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / admin-legacy-core / inc / log-status.php

log-status.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.3.0, at admin-legacy-core/inc/log-status.php

83 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CartFlows Log status.
4 *
5 * @package CartFlows
6 */
7
8 namespace CartflowsAdmin\AdminLegacyCore\Inc;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class LogStatus.
17 *
18 * Reads the log directory for the debug UI. The download/delete handlers live in
19 * ajax/debugger.php, which resolves the filename through get_log_files() and adds a
20 * realpath containment check; the unreferenced copies that used to sit here took
21 * $_REQUEST['handle'] straight onto the log path and were removed.
22 */
23 class LogStatus {
24
25 /**
26 * Instance
27 *
28 * @access private
29 * @var object Class object.
30 * @since 1.0.0
31 */
32 private static $instance;
33
34 /**
35 * Initiator
36 *
37 * @since 1.0.0
38 * @return object initialized object of class.
39 */
40 public static function get_instance() {
41 if ( ! isset( self::$instance ) ) {
42 self::$instance = new self();
43 }
44 return self::$instance;
45 }
46
47 /**
48 * Constructor
49 *
50 * @since 1.0.0
51 */
52 public function __construct() {
53 }
54
55 /**
56 * Get all log files in the log directory.
57 *
58 * @return array
59 */
60 public function get_log_files() {
61 // Condition for multisite instances:
62 // Return empty array if log directory doesn't exist yet or is not readable.
63 if ( ! is_dir( CARTFLOWS_LOG_DIR ) || ! is_readable( CARTFLOWS_LOG_DIR ) ) {
64 return array();
65 }
66
67 $files = scandir( CARTFLOWS_LOG_DIR );
68 $result = array();
69
70 if ( ! empty( $files ) ) {
71 foreach ( $files as $key => $file ) {
72 if ( ! is_dir( $file ) && strstr( $file, '.log' ) ) {
73 $result[ pathinfo( $file, PATHINFO_FILENAME ) ] = $file;
74 }
75 }
76 }
77
78 return $result;
79 }
80 }
81
82 LogStatus::get_instance();
83