PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.1
JetFormBuilder — Dynamic Blocks Form Builder v2.1.1
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 3 years ago file.php 3 years ago media-block-value.php 3 years ago sanitize-file-exception.php 3 years ago upload-dir.php 3 years ago upload-exception.php 3 years ago upload-permission-exception.php 3 years ago uploaded-collection.php 3 years ago uploaded-file-path.php 3 years ago uploaded-file.php 3 years ago
upload-dir.php
110 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Classes\Resources;
5
6 use Jet_Form_Builder\Live_Form;
7
8 class Upload_Dir {
9
10 /**
11 * Change upload directory for JetEngine uploads
12 *
13 * @param [type] $pathdata [description]
14 *
15 * @return [type] [description]
16 */
17 public static function apply_upload_dir( $pathdata ) {
18 // jet-form-builder
19 $base = static::upload_base();
20
21 // user-based dynamic dirname
22 $dir = static::get_upload_dir();
23
24 if ( empty( $pathdata['subdir'] ) ) {
25 $path = $pathdata['path'] . '/' . $base;
26
27 $pathdata['subdir'] = '/' . $base . '/' . $dir;
28 $pathdata['path'] = $pathdata['path'] . $pathdata['subdir'];
29 $pathdata['url'] = $pathdata['url'] . $pathdata['subdir'];
30 } else {
31 $path = $pathdata['basedir'] . '/' . $base;
32
33 $pathdata['subdir'] = '/' . $base . '/' . $dir . $pathdata['subdir'];
34 $pathdata['path'] = $pathdata['basedir'] . $pathdata['subdir'];
35 $pathdata['url'] = $pathdata['baseurl'] . $pathdata['subdir'];
36 }
37 self::create_index( $path );
38 self::create_index( $pathdata['path'] );
39
40 self::create_htaccess( $path );
41
42 return $pathdata;
43 }
44
45 /**
46 * Returns upload subdirectory
47 *
48 * @return [type] [description]
49 */
50 public static function get_upload_dir() {
51 $user_id = get_current_user_id();
52 $user_dir_name = md5( $user_id . Live_Form::instance()->form_id );
53
54 return apply_filters( 'jet-form-builder/file-upload/user-dir-name', $user_dir_name );
55 }
56
57 /**
58 * Returns upload base directory
59 *
60 * @return [type] [description]
61 */
62 public static function upload_base() {
63 return apply_filters( 'jet-form-builder/file-upload/dir', 'jet-form-builder' );
64 }
65
66 public static function create_index( $path ) {
67 if ( ! is_dir( $path ) ) {
68 return false;
69 }
70
71 $path = trailingslashit( $path ) . 'index.html';
72 $index = wp_normalize_path( $path );
73
74 if ( file_exists( $index ) ) {
75 return false;
76 }
77
78 // phpcs:ignore WordPress.WP.AlternativeFunctions
79 return file_put_contents( $index, '' );
80 }
81
82 public static function create_htaccess( $path ) {
83 if ( ! is_dir( $path ) ) {
84 return false;
85 }
86
87
88 $path = trailingslashit( $path ) . '.htaccess';
89 $index = wp_normalize_path( $path );
90
91 if ( file_exists( $index ) ) {
92 return false;
93 }
94
95 // phpcs:ignore WordPress.WP.AlternativeFunctions
96 return file_put_contents( $index, static::htaccess_content() );
97 }
98
99 protected static function htaccess_content(): string {
100 return '
101 # Disable directory browsing
102 Options -Indexes
103
104 # Hide the contents of directories
105 IndexIgnore *
106 ';
107 }
108
109 }
110