Issues (2873)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

ui/fields/attachment.php (5 issues)

Upgrade to new PHP Analysis Engine

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
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
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
Silencing errors is discouraged
Loading history...
The use of PHP session function session_id() is prohibited.
Loading history...
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 = '&amp;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
The method markup cannot be called on $field_file (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
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
The method markup cannot be called on $field_file (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
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