PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 3.5.2
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v3.5.2
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 3 weeks ago form-migrator 3 weeks ago plugin-updates 8 years ago settings 3 weeks ago views 3 weeks ago class-evf-admin-addons.php 4 months ago class-evf-admin-assets.php 4 days ago class-evf-admin-builder.php 2 months ago class-evf-admin-dashboard.php 3 weeks 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 months ago class-evf-admin-entries.php 2 months ago class-evf-admin-form-templates.php 3 weeks ago class-evf-admin-forms-table-list.php 4 months ago class-evf-admin-forms.php 4 months ago class-evf-admin-import-export.php 3 weeks ago class-evf-admin-menus.php 3 weeks ago class-evf-admin-notices.php 4 months ago class-evf-admin-preview-confirmation.php 11 months ago class-evf-admin-settings.php 3 weeks ago class-evf-admin-tools.php 2 months ago class-evf-admin-welcome.php 2 years ago class-evf-admin.php 2 months ago class-evf-base-list-table.php 4 months ago evf-admin-functions.php 3 weeks ago
class-evf-admin-tools.php
289 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 // Download Log.
98 if ( ! empty( $_REQUEST['handle_download'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
99 self::download_log();
100 }
101
102 include_once 'views/html-admin-page-tools-logs.php';
103 }
104
105 /**
106 * Retrieve metadata from a file. Based on WP Core's get_file_data function.
107 *
108 * @since 1.0.0
109 * @param string $file Path to the file.
110 * @return string
111 */
112 public static function get_file_version( $file ) {
113 // Avoid notices if file does not exist.
114 if ( ! file_exists( $file ) ) {
115 return '';
116 }
117
118 // We don't need to write to the file, so just open for reading.
119 $fp = fopen( $file, 'r' ); // @codingStandardsIgnoreLine
120
121 // Pull only the first 8kiB of the file in.
122 $file_data = fread( $fp, 8192 ); // @codingStandardsIgnoreLine
123
124 // PHP will close file handle, but we are good citizens.
125 fclose( $fp ); // @codingStandardsIgnoreLine
126
127 // Make sure we catch CR-only line endings.
128 $file_data = str_replace( "\r", "\n", $file_data );
129 $version = '';
130
131 if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( '@version', '/' ) . '(.*)$/mi', $file_data, $match ) && $match[1] ) {
132 $version = _cleanup_header_comment( $match[1] );
133 }
134
135 return $version;
136 }
137
138 /**
139 * Return the log file handle.
140 *
141 * @param string $filename Filename to get the handle for.
142 * @return string
143 */
144 public static function get_log_file_handle( $filename ) {
145 return substr( $filename, 0, strlen( $filename ) > 48 ? strlen( $filename ) - 48 : strlen( $filename ) - 4 );
146 }
147
148 /**
149 * Scan the template files.
150 *
151 * @param string $template_path Path to the template directory.
152 * @return array
153 */
154 public static function scan_template_files( $template_path ) {
155 $files = @scandir( $template_path ); // @codingStandardsIgnoreLine
156 $result = array();
157
158 if ( ! empty( $files ) ) {
159
160 foreach ( $files as $key => $value ) {
161
162 if ( ! in_array( $value, array( '.', '..' ), true ) ) {
163
164 if ( is_dir( $template_path . DIRECTORY_SEPARATOR . $value ) ) {
165 $sub_files = self::scan_template_files( $template_path . DIRECTORY_SEPARATOR . $value );
166 foreach ( $sub_files as $sub_file ) {
167 $result[] = $value . DIRECTORY_SEPARATOR . $sub_file;
168 }
169 } else {
170 $result[] = $value;
171 }
172 }
173 }
174 }
175 return $result;
176 }
177
178 /**
179 * Scan the log files.
180 *
181 * @return array
182 */
183 public static function scan_log_files() {
184 $files = @scandir( EVF_LOG_DIR ); // @codingStandardsIgnoreLine
185 $result = array();
186
187 if ( ! empty( $files ) ) {
188
189 foreach ( $files as $key => $value ) {
190
191 if ( ! in_array( $value, array( '.', '..' ), true ) ) {
192 if ( ! is_dir( $value ) && strstr( $value, '.log' ) ) {
193 $result[ sanitize_title( $value ) ] = $value;
194 }
195 }
196 }
197 }
198
199 return $result;
200 }
201
202 /**
203 * Remove/delete the chosen file.
204 */
205 public static function remove_log() {
206 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'remove_log' ) ) {
207 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'everest-forms' ) );
208 }
209
210 if ( ! empty( $_REQUEST['handle'] ) ) {
211 $log_handler = new EVF_Log_Handler_File();
212 $log_handler->remove( sanitize_text_field( wp_unslash( $_REQUEST['handle'] ) ) );
213 }
214
215 wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=evf-tools&tab=logs' ) ) );
216 exit();
217 }
218
219 /**
220 * Download the chosen log file.
221 */
222 public static function download_log() {
223 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'download_log' ) ) {
224 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'everest-forms' ) );
225 }
226
227 $logs = self::scan_log_files();
228 $log_key = sanitize_title( wp_unslash( $_REQUEST['handle_download'] ) );
229
230 if ( ! isset( $logs[ $log_key ] ) ) {
231 wp_die( esc_html__( 'Log file not found.', 'everest-forms' ) );
232 }
233
234 $log_file = EVF_LOG_DIR . $logs[ $log_key ];
235
236 if ( ! file_exists( $log_file ) ) {
237 wp_die( esc_html__( 'Log file not found.', 'everest-forms' ) );
238 }
239
240 while ( ob_get_level() ) {
241 ob_end_clean();
242 }
243
244 header( 'Content-Description: File Transfer' );
245 header( 'Content-Type: text/plain' );
246 header( 'Content-Disposition: attachment; filename="' . sanitize_file_name( basename( $log_file ) ) . '"' );
247 header( 'Content-Length: ' . filesize( $log_file ) );
248 header( 'Cache-Control: must-revalidate' );
249 header( 'Pragma: public' );
250 readfile( $log_file ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_readfile
251 exit();
252 }
253
254 /**
255 * Remove/delete all logs.
256 */
257 public static function remove_all_logs() {
258 if ( empty( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['_wpnonce'] ) ), 'remove_all_logs' ) ) {
259 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'everest-forms' ) );
260 }
261
262 if ( ! empty( $_REQUEST['handle_all'] ) ) {
263 $log_handler = new EVF_Log_Handler_File();
264 $log_handler->remove_all();
265 }
266
267 wp_safe_redirect( esc_url_raw( admin_url( 'admin.php?page=evf-tools&tab=logs' ) ) );
268 exit();
269 }
270
271 /**
272 * Roles and permission.
273 *
274 * @since 3.0.8
275 */
276 public static function roles_and_permission() {
277 echo '<div id="evf-roles-and-permission"></div>';
278 }
279
280 /**
281 * Handles output of the Smart SMTP Settings Page.
282 *
283 * @since 3.0.8
284 */
285 public static function evf_smart_smtp_setup() {
286 include_once __DIR__ . '/views/html-admin-page-smart-smtp-setup.php';
287 }
288 }
289