PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.0.5
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.0.5
3.6.0 3.5.3 3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / admin / class-evf-admin-tools.php
everest-forms / includes / admin Last commit date
builder 1 year ago form-migrator 2 years ago plugin-updates 8 years ago settings 1 year ago views 1 year ago class-evf-admin-addons.php 2 years ago class-evf-admin-assets.php 1 year ago class-evf-admin-builder.php 8 years ago class-evf-admin-dashboard.php 2 years ago class-evf-admin-deactivation-feedback.php 3 years ago class-evf-admin-editor.php 4 years ago class-evf-admin-embed-wizard.php 2 years ago class-evf-admin-entries-table-list.php 2 years ago class-evf-admin-entries.php 2 years ago class-evf-admin-form-templates.php 1 year ago class-evf-admin-forms-table-list.php 2 years ago class-evf-admin-forms.php 2 years ago class-evf-admin-import-export.php 4 years ago class-evf-admin-menus.php 2 years ago class-evf-admin-notices.php 1 year ago class-evf-admin-preview-confirmation.php 2 years ago class-evf-admin-settings.php 1 year ago class-evf-admin-tools.php 2 years ago class-evf-admin-welcome.php 3 years ago class-evf-admin.php 2 years ago evf-admin-functions.php 1 year ago
class-evf-admin-tools.php
231 lines
1 <?php
2 /**
3 * Debug/Status page
4 *
5 * @package EverestForms/Admin/Tools
6 * @version 1.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Admin_Tools Class.
13 */
14 class EVF_Admin_Tools {
15
16 /**
17 * Handles output of the reports page in admin.
18 */
19 public static function output() {
20 include_once __DIR__ . '/views/html-admin-page-tools.php';
21 }
22
23 /**
24 * Show the import page.
25 */
26 public static function import() {
27 include_once __DIR__ . '/views/html-admin-page-import.php';
28 }
29
30 /**
31 * Show the export page.
32 */
33 public static function export() {
34 include_once __DIR__ . '/views/html-admin-page-export.php';
35 }
36 /**
37 * Show the Form migrator page.
38 *
39 * @since 2.0.6
40 */
41 public static function form_migrator() {
42 // Form object list.
43 $forms_object = array(
44 'contactform7' => class_exists( 'EVF_Fm_Contactform7' ) ? new EVF_Fm_Contactform7() : '',
45 'wpforms' => class_exists( 'EVF_Fm_wpforms' ) ? new EVF_Fm_Wpforms() : '',
46 );
47 // Forms status.
48 $forms_status = array();
49 foreach ( $forms_object as $form_id => $form_obj ) {
50 $forms_status[] = $form_obj->register( array() );
51 // For dismiss the notification.
52 if ( ! $form_obj->is_dimissed() ) {
53 $option_id = 'evf_fm_dismiss_xnotice_' . $form_obj->slug;
54 update_option( $option_id, true );
55 }
56 }
57
58 include_once __DIR__ . '/views/html-admin-page-form-migrator.php';
59 }
60
61 /**
62 * Show the setting page.
63 */
64 public static function setting() {
65 include_once __DIR__ . '/views/html-admin-page-setting.php';
66 }
67
68
69 /**
70 * Show the logs page.
71 */
72 public static function status_logs() {
73 self::status_logs_file();
74 }
75
76 /**
77 * Show the log page contents for file log handler.
78 */
79 public static function status_logs_file() {
80 $logs = self::scan_log_files();
81
82 if ( ! empty( $_REQUEST['log_file'] ) && isset( $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
83 $viewed_log = $logs[ sanitize_title( wp_unslash( $_REQUEST['log_file'] ) ) ]; // phpcs:ignore WordPress.Security.NonceVerification
84 } elseif ( ! empty( $logs ) ) {
85 $viewed_log = current( $logs );
86 }
87
88 if ( ! empty( $_REQUEST['handle'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
89 self::remove_log();
90 }
91
92 // Remove All Logs.
93 if ( ! empty( $_REQUEST['handle_all'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
94 self::remove_all_logs();
95 }
96
97 include_once 'views/html-admin-page-tools-logs.php';
98 }
99
100 /**
101 * Retrieve metadata from a file. Based on WP Core's get_file_data function.
102 *
103 * @since 1.0.0
104 * @param string $file Path to the file.
105 * @return string
106 */
107 public static function get_file_version( $file ) {
108 // Avoid notices if file does not exist.
109 if ( ! file_exists( $file ) ) {
110 return '';
111 }
112
113 // We don't need to write to the file, so just open for reading.
114 $fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine
115
116 // Pull only the first 8kiB of the file in.
117 $file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine
118
119 // PHP will close file handle, but we are good citizens.
120 fclose( $fp ); // @codingStandardsIgnoreLine
121
122 // Make sure we catch CR-only line endings.
123 $file_data = str_replace( "\r", "\n", $file_data );
124 $version = '';
125
126 if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
127 $version = _cleanup_header_comment( $match[1] );
128 }
129
130 return $version;
131 }
132
133 /**
134 * Return the log file handle.
135 *
136 * @param string $filename Filename to get the handle for.
137 * @return string
138 */
139 public static function get_log_file_handle( $filename ) {
140 return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 );
141 }
142
143 /**
144 * Scan the template files.
145 *
146 * @param string $template_path Path to the template directory.
147 * @return array
148 */
149 public static function scan_template_files( $template_path ) {
150 $files = @scandir( $template_path ); // @codingStandardsIgnoreLine
151 $result = array();
152
153 if ( ! empty( $files ) ) {
154
155 foreach ( $files as $key => $value ) {
156
157 if ( ! in_array( $value, array( '.', '..' ), true ) ) {
158
159 if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
160 $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
161 foreach ( $sub_files as $sub_file ) {
162 $result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
163 }
164 } else {
165 $result[] = $value;
166 }
167 }
168 }
169 }
170 return $result;
171 }
172
173 /**
174 * Scan the log files.
175 *
176 * @return array
177 */
178 public static function scan_log_files() {
179 $files = @scandir( EVF_LOG_DIR ); // @codingStandardsIgnoreLine
180 $result = array();
181
182 if ( ! empty( $files ) ) {
183
184 foreach ( $files as $key => $value ) {
185
186 if ( ! in_array( $value, array( '.', '..' ), true ) ) {
187 if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) {
188 $result[ sanitize_title( $value ) ] = $value;
189 }
190 }
191 }
192 }
193
194 return $result;
195 }
196
197 /**
198 * Remove/delete the chosen file.
199 */
200 public static function remove_log() {
201 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'remove_log' ) ) {
202 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'everest-forms' ) );
203 }
204
205 if ( ! empty( $_REQUEST['handle'] ) ) {
206 $log_handler = new EVF_Log_Handler_File();
207 $log_handler->remove( sanitize_text_field( wp_unslash( $_REQUEST['handle'] ) ) );
208 }
209
210 wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=evf-tools&tab=logs' ) ) );
211 exit();
212 }
213
214 /**
215 * Remove/delete all logs.
216 */
217 public static function remove_all_logs() {
218 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'remove_all_logs' ) ) {
219 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'everest-forms' ) );
220 }
221
222 if ( ! empty( $_REQUEST['handle_all'] ) ) {
223 $log_handler = new EVF_Log_Handler_File();
224 $log_handler->remove_all();
225 }
226
227 wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=evf-tools&tab=logs' ) ) );
228 exit();
229 }
230 }
231