PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / redux / ReduxCore / inc / class.redux_instances.php

class.redux_instances.php in QuadMenu – Mega Menu 3.3.8, at redux/ReduxCore/inc/class.redux_instances.php

176 lines 5.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Redux Framework Instance Container Class
5 * Automatically captures and stores all instances
6 * of ReduxFrameworkLegacy at instantiation.
7 *
8 * @package Redux_Framework
9 * @subpackage Core
10 */
11 class ReduxFrameworkInstancesLegacy {
12
13 /**
14 * ReduxFrameworkInstancesLegacy
15 *
16 * @var object
17 */
18 private static $instance;
19
20 /**
21 * ReduxFrameworkLegacy instances
22 *
23 * @var array
24 */
25 private static $instances;
26
27
28 /**
29 * @var array
30 */
31 private $options = array();
32
33 /**
34 * Get Instance
35 * Get ReduxFrameworkInstancesLegacy instance
36 * OR an instance of ReduxFrameworkLegacy by [opt_name]
37 *
38 * @param string $opt_name the defined opt_name
39 *
40 * @return object class instance
41 */
42 public static function get_instance( $opt_name = false ) {
43
44 if ( is_null( self::$instance ) ) {
45 self::$instance = new self();
46 }
47
48 if ( $opt_name && ! empty( self::$instances[ $opt_name ] ) ) {
49 return self::$instances[ $opt_name ];
50 }
51
52 return self::$instance;
53 }
54
55 /**
56 * Get all instantiated ReduxFrameworkLegacy instances (so far)
57 *
58 * @return [type] [description]
59 */
60 public static function get_all_instances() {
61 return self::$instances;
62 }
63
64 private function __construct() {
65
66 add_action( 'redux/construct', array( $this, 'capture' ), 5, 1 );
67
68 $hash = md5( trailingslashit( network_site_url() ) . '-redux' );
69 add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'tracking_arg' ) );
70 add_action( 'wp_ajax_' . $hash, array( $this, 'tracking_arg' ) );
71
72 /**
73 * Fix https://www.wordfence.com/blog/2021/09/over-1-million-sites-affected-by-redux-framework-vulnerabilities/
74 *
75 * // if (!class_exists('ReduxLegacy_Tracking') || !method_exists('ReduxLegacy_Tracking', 'trackingObject')) {
76 * $hash = md5( md5( ReduxLegacy_Helpers::get_auth_key_secret_key() . '-redux' ) . '-support' );
77 * add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'support_args' ) );
78 * add_action( 'wp_ajax_' . $hash, array( $this, 'support_args' ) );
79 * }
80 */
81 }
82
83 function tracking_arg() {
84 echo md5( ReduxLegacy_Helpers::get_auth_key_secret_key() . '-redux' );
85 die();
86 }
87
88 function support_args() {
89
90 $this->options = get_option( 'redux-framework-tracking' );
91 $this->options['dev_mode'] = false;
92
93 if ( ! isset( $this->options['hash'] ) || ! $this->options['hash'] || empty( $this->options['hash'] ) ) {
94 $this->options['hash'] = md5( network_site_url() . '-' . $_SERVER['REMOTE_ADDR'] );
95 update_option( 'redux-framework-tracking', $this->options );
96 }
97
98 if ( isset( $_GET['redux_framework_disable_tracking'] ) && ! empty( $_GET['redux_framework_disable_tracking'] ) ) {
99 $this->options['allow_tracking'] = false;
100 update_option( 'redux-framework-tracking', $this->options );
101 }
102
103 if ( isset( $_GET['redux_framework_enable_tracking'] ) && ! empty( $_GET['redux_framework_enable_tracking'] ) ) {
104 $this->options['allow_tracking'] = true;
105 update_option( 'redux-framework-tracking', $this->options );
106 }
107
108 header( 'Expires: Mon, 26 Jul 1997 05:00:00 GMT' );
109 header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . 'GMT' );
110 header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' );
111 header( 'Cache-Control: no-store, no-cache, must-revalidate' );
112 header( 'Cache-Control: post-check=0, pre-check=0', false );
113 header( 'Pragma: no-cache' );
114 $instances = self::get_all_instances();
115
116 $array = array();
117
118 if ( isset( $_REQUEST['i'] ) && ! empty( $_REQUEST['i'] ) ) {
119 if ( is_array( $instances ) && ! empty( $instances ) ) {
120 foreach ( $instances as $opt_name => $data ) {
121 if ( md5( $opt_name . '-debug' ) == $_REQUEST['i'] ) {
122 $array = $instances[ $opt_name ];
123 }
124 if ( $data->args['dev_mode'] ) {
125 $this->options['dev_mode'] = $data->args['dev_mode'];
126 }
127 }
128 }
129 if ( isset( $array ) ) {
130 if ( isset( $array->extensions ) && is_array( $array->extensions ) && ! empty( $array->extensions ) ) {
131 foreach ( $array->extensions as $key => $extension ) {
132 if ( isset( $extension->version ) ) {
133 $array->extensions[ $key ] = $extension->version;
134 } else {
135 $array->extensions[ $key ] = true;
136 }
137 }
138 }
139
140 if ( isset( $array->import_export ) ) {
141 unset( $array->import_export );
142 }
143
144 if ( isset( $array->debug ) ) {
145 unset( $array->debug );
146 }
147 } else {
148 die();
149 }
150 } else {
151 $array = ReduxLegacy_Helpers::trackingObject();
152 if ( is_array( $instances ) && ! empty( $instances ) ) {
153 $array['instances'] = array();
154 foreach ( $instances as $opt_name => $data ) {
155 $array['instances'][] = $opt_name;
156 }
157 }
158 $array['key'] = md5( ReduxLegacy_Helpers::get_auth_key_secret_key() );
159 }
160
161 echo @json_encode( $array, true );
162 die();
163 }
164
165 function capture( $ReduxFrameworkLegacy ) {
166 $this->store( $ReduxFrameworkLegacy );
167 }
168
169 private function store( $ReduxFrameworkLegacy ) {
170 if ( $ReduxFrameworkLegacy instanceof ReduxFrameworkLegacy ) {
171 $key = $ReduxFrameworkLegacy->args['opt_name'];
172 self::$instances[ $key ] = $ReduxFrameworkLegacy;
173 }
174 }
175 }
176