PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / classes / resources / upload-dir.php
jetformbuilder / includes / classes / resources Last commit date
file-collection.php 1 year ago file-tools.php 4 months ago file.php 1 year ago has-error-file.php 2 years ago media-block-value.php 1 year ago sanitize-file-exception.php 2 years ago upload-dir.php 1 week ago upload-exception.php 2 years ago upload-permission-exception.php 2 years ago uploaded-collection.php 1 year ago uploaded-file-path.php 2 years ago uploaded-file.php 3 months ago
upload-dir.php
142 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Classes\Resources;
5
6 use Jet_Form_Builder\Live_Form;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 class Upload_Dir {
14
15 /**
16 * Change upload directory for JetEngine uploads
17 *
18 * @param [type] $pathdata [description]
19 *
20 * @return [type] [description]
21 */
22 public static function apply_upload_dir( $pathdata ) {
23 // jet-form-builder
24 $base = static::upload_base();
25
26 // user-based dynamic dirname
27 $dir = static::get_upload_dir();
28
29 if ( empty( $pathdata['subdir'] ) ) {
30 $path = $pathdata['path'] . '/' . $base;
31
32 $pathdata['subdir'] = '/' . $base . '/' . $dir;
33 $pathdata['path'] = $pathdata['path'] . $pathdata['subdir'];
34 $pathdata['url'] = $pathdata['url'] . $pathdata['subdir'];
35 } else {
36 $path = $pathdata['basedir'] . '/' . $base;
37
38 $pathdata['subdir'] = '/' . $base . '/' . $dir . $pathdata['subdir'];
39 $pathdata['path'] = $pathdata['basedir'] . $pathdata['subdir'];
40 $pathdata['url'] = $pathdata['baseurl'] . $pathdata['subdir'];
41 }
42 self::create_index( $path );
43 self::create_index( $pathdata['path'] );
44
45 self::create_htaccess( $path );
46
47 return apply_filters(
48 'jet-form-builder/file-upload/upload-dir',
49 $pathdata,
50 jet_fb_context()->get_request()
51 );
52 }
53
54 public static function apply_temp_dir( $pathdata ) {
55 // jet-form-builder
56 $base = static::upload_base();
57
58 $pathdata['subdir'] = '/' . $base . '/temp';
59 $pathdata['path'] = $pathdata['path'] . $pathdata['subdir'];
60 $pathdata['url'] = $pathdata['url'] . $pathdata['subdir'];
61
62 return $pathdata;
63 }
64
65 /**
66 * Returns upload subdirectory
67 *
68 * @return [type] [description]
69 */
70 public static function get_upload_dir() {
71 $user_id = get_current_user_id();
72 $user_dir_name = md5( $user_id . Live_Form::instance()->form_id );
73
74 return apply_filters( 'jet-form-builder/file-upload/user-dir-name', $user_dir_name );
75 }
76
77 /**
78 * Returns upload base directory
79 *
80 * @return [type] [description]
81 */
82 public static function upload_base() {
83 return apply_filters( 'jet-form-builder/file-upload/dir', 'jet-form-builder' );
84 }
85
86 public static function create_index( $path ) {
87 if ( ! is_dir( $path ) ) {
88 return false;
89 }
90
91 $path = trailingslashit( $path ) . 'index.html';
92 $index = wp_normalize_path( $path );
93
94 if ( file_exists( $index ) ) {
95 return false;
96 }
97
98 // phpcs:ignore WordPress.WP.AlternativeFunctions
99 return file_put_contents( $index, '' );
100 }
101
102 public static function create_htaccess( $path ) {
103 if ( ! is_dir( $path ) ) {
104 return false;
105 }
106
107 $content = apply_filters(
108 'jet-form-builder/file-upload/htaccess-content',
109 self::htaccess_content()
110 );
111
112 if ( ! $content ) {
113 return false;
114 }
115
116 $path = trailingslashit( $path ) . '.htaccess';
117 $index = wp_normalize_path( $path );
118
119 if ( file_exists( $index ) ) {
120 return false;
121 }
122
123 // phpcs:ignore WordPress.WP.AlternativeFunctions
124 return file_put_contents( $index, $content );
125 }
126
127 protected static function htaccess_content(): string {
128 return '
129 # Disable directory browsing
130 Options -Indexes
131
132 # Hide the contents of directories
133 IndexIgnore *
134
135 <IfModule mod_headers.c>
136 Header set X-Robots-Tag "noindex, nofollow"
137 </IfModule>
138 ';
139 }
140
141 }
142