PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
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 11 months ago file-tools.php 3 months ago file.php 11 months ago has-error-file.php 2 years ago media-block-value.php 11 months ago sanitize-file-exception.php 2 years ago upload-dir.php 1 year ago upload-exception.php 2 years ago upload-permission-exception.php 2 years ago uploaded-collection.php 11 months ago uploaded-file-path.php 2 years ago uploaded-file.php 2 months ago
upload-dir.php
138 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 $pathdata;
48 }
49
50 public static function apply_temp_dir( $pathdata ) {
51 // jet-form-builder
52 $base = static::upload_base();
53
54 $pathdata['subdir'] = '/' . $base . '/temp';
55 $pathdata['path'] = $pathdata['path'] . $pathdata['subdir'];
56 $pathdata['url'] = $pathdata['url'] . $pathdata['subdir'];
57
58 return $pathdata;
59 }
60
61 /**
62 * Returns upload subdirectory
63 *
64 * @return [type] [description]
65 */
66 public static function get_upload_dir() {
67 $user_id = get_current_user_id();
68 $user_dir_name = md5( $user_id . Live_Form::instance()->form_id );
69
70 return apply_filters( 'jet-form-builder/file-upload/user-dir-name', $user_dir_name );
71 }
72
73 /**
74 * Returns upload base directory
75 *
76 * @return [type] [description]
77 */
78 public static function upload_base() {
79 return apply_filters( 'jet-form-builder/file-upload/dir', 'jet-form-builder' );
80 }
81
82 public static function create_index( $path ) {
83 if ( ! is_dir( $path ) ) {
84 return false;
85 }
86
87 $path = trailingslashit( $path ) . 'index.html';
88 $index = wp_normalize_path( $path );
89
90 if ( file_exists( $index ) ) {
91 return false;
92 }
93
94 // phpcs:ignore WordPress.WP.AlternativeFunctions
95 return file_put_contents( $index, '' );
96 }
97
98 public static function create_htaccess( $path ) {
99 if ( ! is_dir( $path ) ) {
100 return false;
101 }
102
103 $content = apply_filters(
104 'jet-form-builder/file-upload/htaccess-content',
105 self::htaccess_content()
106 );
107
108 if ( ! $content ) {
109 return false;
110 }
111
112 $path = trailingslashit( $path ) . '.htaccess';
113 $index = wp_normalize_path( $path );
114
115 if ( file_exists( $index ) ) {
116 return false;
117 }
118
119 // phpcs:ignore WordPress.WP.AlternativeFunctions
120 return file_put_contents( $index, $content );
121 }
122
123 protected static function htaccess_content(): string {
124 return '
125 # Disable directory browsing
126 Options -Indexes
127
128 # Hide the contents of directories
129 IndexIgnore *
130
131 <IfModule mod_headers.c>
132 Header set X-Robots-Tag "noindex, nofollow"
133 </IfModule>
134 ';
135 }
136
137 }
138