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 3.9 3.9-beta 3.9.1 3.9.2 3.9.3 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1-beta 4.1.1 4.1.2 4.2 4.2-beta 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6 4.6.1 4.7 4.8 4.8.1 4.9 4.9.1 4.9.2 5.0 5.0.1
contact-form-7 / includes / filesystem.php
contact-form-7 / includes Last commit date
block-editor 1 year ago config-validator 11 months ago css 2 weeks ago js 1 year ago swv 9 months ago capabilities.php 7 years ago contact-form-functions.php 11 months ago contact-form-template.php 11 months ago contact-form.php 11 months ago controller.php 11 months ago file.php 9 months ago filesystem.php 11 months ago form-tag.php 7 months ago form-tags-manager.php 11 months ago formatting.php 11 months ago functions.php 9 months ago html-formatter.php 9 months ago integration.php 11 months ago l10n.php 11 months ago mail-tag.php 11 months ago mail.php 3 months ago pipe.php 11 months ago pocket-holder.php 3 years ago rest-api.php 11 months ago shortcodes.php 11 months ago special-mail-tags.php 9 months ago submission.php 9 months ago upgrade.php 11 months ago validation-functions.php 11 months ago validation.php 11 months ago
filesystem.php
128 lines
1 <?php
2
3 /**
4 * Class for filesystem operations.
5 */
6 class WPCF7_Filesystem {
7
8 /**
9 * The singleton instance.
10 *
11 * @var WPCF7_Filesystem
12 */
13 private static $instance;
14
15 /**
16 * Filesystem object.
17 *
18 * @var WP_Filesystem_Base
19 */
20 private $filesystem;
21
22
23 /**
24 * Retrieves the singleton instance.
25 */
26 public static function get_instance() {
27 if ( empty( self::$instance ) ) {
28 self::$instance = new self();
29 }
30
31 return self::$instance;
32 }
33
34
35 /**
36 * Constructor.
37 */
38 private function __construct() {
39 $this->connect();
40 }
41
42
43 /**
44 * Connects to the filesystem.
45 *
46 * @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
47 */
48 private function connect() {
49 global $wp_filesystem;
50
51 if ( $this->filesystem ) {
52 return false;
53 }
54
55 require_once ABSPATH . 'wp-admin/includes/file.php';
56 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php';
57 require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
58
59 ob_start();
60 $credentials = request_filesystem_credentials( '' );
61 ob_end_clean();
62
63 if ( false === $credentials or ! WP_Filesystem( $credentials ) ) {
64 wp_trigger_error(
65 __FUNCTION__,
66 __( 'Could not access filesystem.', 'contact-form-7' )
67 );
68 }
69
70 if ( $wp_filesystem instanceof WP_Filesystem_Base ) {
71 $this->filesystem = $wp_filesystem;
72 } else {
73 $this->filesystem = new WP_Filesystem_Direct( 1 );
74 }
75
76 if ( ! defined( 'FS_CHMOD_DIR' ) ) {
77 define( 'FS_CHMOD_DIR', fileperms( ABSPATH ) & 0777 | 0755 );
78 }
79
80 if ( ! defined( 'FS_CHMOD_FILE' ) ) {
81 define( 'FS_CHMOD_FILE', fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 );
82 }
83 }
84
85
86 /**
87 * Changes filesystem permissions.
88 *
89 * @param string $file Path to the file.
90 * @param int|false $mode Optional. The permissions as octal number.
91 * @param bool $recursive Optional. If set to true,
92 * changes file permissions recursively. Default false.
93 * @return bool True on success, false on failure.
94 */
95 public function chmod( $file, $mode = false, $recursive = false ) {
96 return $this->filesystem->chmod( $file, $mode, $recursive );
97 }
98
99
100 /**
101 * Deletes a file or directory.
102 *
103 * @param string $file Path to the file or directory.
104 * @param bool $recursive Optional. If set to true, deletes
105 * files and folders recursively. Default false.
106 * @param string|false $type Type of resource.
107 * 'f' for file, 'd' for directory. Default false.
108 * @return bool True on success, false on failure.
109 */
110 public function delete( $file, $recursive = false, $type = false ) {
111 return $this->filesystem->delete( $file, $recursive, $type );
112 }
113
114
115 /**
116 * Writes a string to a file.
117 *
118 * @param string $file Path to the file where to write the data.
119 * @param string $contents The data to write.
120 * @param int $mode The file permissions as octal number.
121 * @return bool True on success, false on failure.
122 */
123 public function put_contents( $file, $contents, $mode = false ) {
124 return $this->filesystem->put_contents( $file, $contents, $mode );
125 }
126
127 }
128