PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.3 6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 All 156 releases
mainwp / class / class-mainwp-qq2-uploaded-file-form.php

class-mainwp-qq2-uploaded-file-form.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.2.2, at class/class-mainwp-qq2-uploaded-file-form.php

77 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP_QQ2_Uploaded_File_Form
4 *
5 * DO NOT TOUCH - part of http://github.com/valums/file-uploader ! (@see js/fileuploader.js)
6 * Handle file uploads via regular form post (uses the $_FILES array)
7 *
8 * @package MainWP/Dashboard
9 */
10
11 namespace MainWP\Dashboard;
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * Class MainWP_QQ2_Uploaded_File_Form
20 *
21 * @package MainWP\Dashboard
22 */
23 class MainWP_QQ2_Uploaded_File_Form { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
24
25 /**
26 * Save the file to the specified path.
27 *
28 * @param string $file_path Path to save file to.
29 * @return boolean TRUE on success|false on failure.
30 *
31 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_wp_file_system()
32 * @uses \MainWP\Dashboard\MainWP_System_Utility::get_base_dir()
33 */
34 public function save( $file_path ) {
35 $wpFileSystem = MainWP_System_Utility::get_wp_file_system();
36
37 /**
38 * WordPress files system object.
39 *
40 * @global object
41 */
42 global $wp_filesystem;
43
44 $moved = false;
45
46 $tmp_name = isset( $_FILES['qqfile']['tmp_name'] ) && MainWP_Utility::valid_file_check( $_FILES['qqfile']['tmp_name'] ) ? $_FILES['qqfile']['tmp_name'] : ''; //phpcs:ignore -- valid.
47
48 if ( ! empty( $tmp_name ) ) {
49 // The else branch using move_uploaded_file() was removed intentionally.
50 // get_wp_file_system() already forces FS_METHOD=direct when no FTP credentials
51 // are present, so WP_Filesystem() reliably initializes on all modern hosts.
52 // In the rare case it still fails, $moved stays false and the caller handles
53 // the failure gracefully — the same outcome move_uploaded_file() would produce
54 // on those same broken environments anyway.
55 if ( $wpFileSystem ) { //phpcs:ignore -- to valid.
56 $moved = $wp_filesystem->put_contents( $file_path, $wp_filesystem->get_contents( $tmp_name ) );
57 }
58 }
59
60 if ( ! $moved ) {
61 return false;
62 }
63
64 return true;
65 }
66
67 /** Get the File Name. */
68 public function get_name() {
69 return isset( $_FILES['qqfile']['name'] ) ? $_FILES['qqfile']['name'] : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- verify in caller.
70 }
71
72 /** Get the File Size. */
73 public function get_size() {
74 return isset( $_FILES['qqfile']['size'] ) ? $_FILES['qqfile']['size'] : ''; //phpcs:ignore WordPress.Security.NonceVerification.Missing,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- verify in caller.
75 }
76 }
77