This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | global $post_ID; |
||
0 ignored issues
–
show
|
|||
3 | |||
4 | wp_enqueue_script( 'pods-handlebars' ); |
||
5 | wp_enqueue_script( 'jquery-ui-core' ); |
||
6 | wp_enqueue_script( 'jquery-ui-sortable' ); |
||
7 | wp_enqueue_script( 'thickbox' ); |
||
8 | wp_enqueue_script( 'pods-attach' ); |
||
9 | |||
10 | wp_enqueue_style( 'thickbox' ); |
||
11 | wp_enqueue_style( 'pods-attach' ); |
||
12 | |||
13 | $field_file = PodsForm::field_loader( 'file' ); |
||
14 | |||
15 | $attributes = array(); |
||
16 | $attributes = PodsForm::merge_attributes( $attributes, $name, $form_field_type, $options ); |
||
17 | |||
18 | $css_id = $attributes['id']; |
||
19 | |||
20 | $uri_hash = wp_create_nonce( 'pods_uri_' . $_SERVER['REQUEST_URI'] ); |
||
21 | |||
22 | $uid = @session_id(); |
||
0 ignored issues
–
show
|
|||
23 | |||
24 | if ( is_user_logged_in() ) { |
||
25 | $uid = 'user_' . get_current_user_id(); |
||
26 | } |
||
27 | |||
28 | $field_nonce = wp_create_nonce( 'pods_upload_' . ( ! is_object( $pod ) ? '0' : $pod->pod_id ) . '_' . $uid . '_' . $uri_hash . '_' . $options['id'] ); |
||
29 | |||
30 | $limit_file_type = pods_var( $form_field_type . '_type', $options, 'images' ); |
||
31 | |||
32 | $title_editable = pods_var( $form_field_type . '_edit_title', $options, 0 ); |
||
33 | $linked = pods_var( $form_field_type . '_linked', $options, 0 ); |
||
34 | |||
35 | if ( 'images' === $limit_file_type ) { |
||
36 | $limit_types = 'jpg,jpeg,png,gif'; |
||
37 | } elseif ( 'video' === $limit_file_type ) { |
||
38 | $limit_types = 'mpg,mov,flv,mp4'; |
||
39 | } elseif ( 'audio' === $limit_file_type ) { |
||
40 | $limit_types = 'mp3,m4a,wav,wma'; |
||
41 | } elseif ( 'text' === $limit_file_type ) { |
||
42 | $limit_types = 'txt,rtx,csv,tsv'; |
||
43 | } elseif ( 'any' === $limit_file_type ) { |
||
44 | $limit_types = ''; |
||
45 | } else { |
||
46 | $limit_types = pods_var( $form_field_type . '_allowed_extensions', $options, '' ); |
||
47 | } |
||
48 | |||
49 | $limit_types = str_replace( ' ', '', $limit_types ); |
||
50 | |||
51 | $tab = pods_var( $form_field_type . '_attachment_tab', $options, 'type', null, true ); |
||
52 | |||
53 | if ( 'upload' === $tab ) { |
||
54 | $tab = 'type'; |
||
55 | } elseif ( 'browse' === $tab ) { |
||
56 | $tab = 'library'; |
||
57 | } |
||
58 | |||
59 | $file_limit = 1; |
||
60 | |||
61 | if ( 'multi' == pods_var( $form_field_type . '_format_type', $options, 'single' ) ) { |
||
62 | $file_limit = (int) pods_var( $form_field_type . '_limit', $options, 0 ); |
||
63 | } |
||
64 | |||
65 | $data = array( |
||
66 | 'limit-types' => $limit_types, |
||
67 | 'limit-files' => $file_limit, |
||
68 | ); |
||
69 | |||
70 | $the_post_id = ''; |
||
71 | |||
72 | if ( is_admin() && ! empty( $post_ID ) ) { |
||
73 | $the_post_id = '&post_id=' . (int) $post_ID; |
||
74 | } |
||
75 | |||
76 | if ( empty( $value ) ) { |
||
77 | $value = array(); |
||
78 | } else { |
||
79 | $value = (array) $value; |
||
80 | } |
||
81 | ?> |
||
82 | <div |
||
83 | <?php |
||
84 | PodsForm::attributes( |
||
85 | array( |
||
86 | 'class' => $attributes['class'], |
||
87 | 'id' => $attributes['id'], |
||
88 | ), $name, $form_field_type, $options |
||
89 | ); |
||
90 | ?> |
||
91 | > |
||
92 | <ul class="pods-files pods-files-list"> |
||
93 | <?php |
||
94 | |||
95 | // no extra space in ul or CSS:empty won't work |
||
96 | foreach ( $value as $val ) { |
||
97 | $attachment = get_post( $val, ARRAY_A ); |
||
98 | |||
99 | if ( empty( $attachment ) ) { |
||
100 | continue; |
||
101 | } |
||
102 | |||
103 | $attachment['filename'] = basename( $attachment['guid'] ); |
||
104 | |||
105 | $thumb = wp_get_attachment_image_src( $attachment['ID'], 'thumbnail', true ); |
||
106 | $attachment['thumbnail'] = $thumb[0]; |
||
107 | |||
108 | $attachment['link'] = ''; |
||
109 | |||
110 | if ( $linked ) { |
||
111 | $attachment['link'] = wp_get_attachment_url( $attachment['ID'] ); |
||
112 | } |
||
113 | |||
114 | $attachment = apply_filters( 'pods_media_attachment', $attachment ); |
||
115 | |||
116 | echo $field_file->markup( $attributes, $file_limit, $title_editable, $attachment['ID'], $attachment['thumbnail'], $attachment['post_title'] ); |
||
0 ignored issues
–
show
|
|||
117 | }//end foreach |
||
118 | ?> |
||
119 | </ul> |
||
120 | |||
121 | <a class="button pods-file-add pods-media-add" href="<?php echo esc_url( admin_url( 'media-upload.php?inlineId=pods_media_attachment' . $the_post_id . '&tab=' . $tab . '&TB_iframe=1&width=640&height=1500&pods_pod=' . $pod->pod . '&pods_pod_id=' . $pod->pod . '&pods_field=' . $options['name'] . '&pods_field_id=' . $options['id'] . '&pods_uri_hash=' . $uri_hash . '&pods_field_nonce=' . $field_nonce ) ); ?>"><?php echo pods_v( $form_field_type . '_add_button', $options, __( 'Add File', 'pods' ) ); ?></a> |
||
122 | </div> |
||
123 | |||
124 | <script type="text/x-handlebars" id="<?php echo $css_id; ?>-handlebars"> |
||
125 | <?php echo $field_file->markup( $attributes, $file_limit, $title_editable ); ?> |
||
0 ignored issues
–
show
|
|||
126 | |||
127 | </script> |
||
128 | |||
129 | <script type="text/javascript"> |
||
130 | jQuery( function ( $ ) { |
||
131 | // init sortable |
||
132 | $( '#<?php echo esc_js( $css_id ); ?> ul.pods-files' ) |
||
133 | .sortable( { |
||
134 | containment : 'parent', |
||
135 | axis : 'y', |
||
136 | scrollSensitivity : 40, |
||
137 | tolerance : 'pointer', |
||
138 | opacity : 0.6 |
||
139 | } ); |
||
140 | |||
141 | // hook delete links |
||
142 | $( '#<?php echo esc_js( $css_id ); ?>' ).on( 'click', 'li.pods-file-delete a', function ( e ) { |
||
143 | e.preventDefault(); |
||
144 | |||
145 | var podsfile = $( this ).parent().parent().parent(); |
||
146 | podsfile.slideUp( function () { |
||
147 | |||
148 | // check to see if this was the only entry |
||
149 | if ( podsfile.parent().children().length == 1 ) { // 1 because we haven't removed our target yet |
||
150 | podsfile.parent().hide(); |
||
151 | } |
||
152 | |||
153 | // remove the entry |
||
154 | $( this ).remove(); |
||
155 | |||
156 | } ); |
||
157 | } ); |
||
158 | |||
159 | var maxFiles_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?> = <?php echo esc_js( $file_limit ); ?>; |
||
160 | |||
161 | // hook the add link |
||
162 | $( '#<?php echo esc_js( $css_id ); ?>' ).on( 'click', 'a.pods-file-add', function ( e ) { |
||
163 | e.preventDefault(); |
||
164 | var trigger = $( this ); |
||
165 | var href = trigger.attr( 'href' ), width = $( window ).width(), H = $( window ).height(), |
||
166 | W = ( 720 < width ) ? 720 : width; |
||
167 | if ( !href ) { |
||
168 | return; |
||
169 | } |
||
170 | href = href.replace( /&width=[0-9]+/g, '' ); |
||
171 | href = href.replace( /&height=[0-9]+/g, '' ); |
||
172 | trigger.attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) ); |
||
173 | |||
174 | pods_file_context = trigger.parent().find( 'ul.pods-files' ); |
||
175 | pods_file_thickbox_modder = setInterval( function () { |
||
176 | if ( pods_file_context )pods_attachments( '<?php echo esc_js( $css_id ); ?>', maxFiles_<?php echo esc_js( pods_js_name( $attributes['id'] ) ); ?> ); |
||
177 | }, 500 ); |
||
178 | |||
179 | tb_show( 'Attach a file', e.target.href, false ); |
||
180 | return false; |
||
181 | } ); |
||
182 | } ); |
||
183 | </script> |
||
184 |
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state