Issues (4335)

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.

templates/shortcode-receipt.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
/**
3
 * This template is used to display the donation summary with [give_receipt]
4
 */
5
6
global $give_receipt_args, $donation;
7
8
// Validation: Ensure $donation var is set.
9
if ( empty( $donation ) ) {
10
	$donation = ! empty( $give_receipt_args['id'] ) ? get_post( $give_receipt_args['id'] ) : 0;
11
}
12
13
// Double-Validation: Check for $donation global.
14
if ( empty( $donation ) ) {
15
	Give()->notices->print_frontend_notice( __( 'The specified receipt ID appears to be invalid.', 'give' ) );
16
	return;
17
}
18
19
$donation_id     = $donation->ID;
20
$donation_number = Give()->seq_donation_number->get_serial_code( $donation_id );
21
$form_id         = give_get_payment_meta( $donation_id, '_give_payment_form_id', true );
22
$form_name       = give_get_donation_form_title( $donation_id );
23
$user            = give_get_payment_meta_user_info( $donation_id );
24
$email           = give_get_payment_user_email( $donation_id );
25
$status          = $donation->post_status;
26
$status_label    = give_get_payment_status( $donation_id, true );
27
$company_name    = give_get_payment_meta( $donation_id, '_give_donation_company', true );
28
29
// Update donor name, if title prefix is set.
30
$full_name       = give_get_donor_name_with_title_prefixes( $user['title'], "{$user['first_name']} {$user['last_name']}" );
31
32
/**
33
 * Generate Donation Receipt Arguments.
34
 *
35
 * Added donation receipt array to global variable $give_receipt_args to
36
 * manage it from single variable
37
 *
38
 * @since 1.8.8
39
 */
40
$give_receipt_args['donation_receipt']['donor'] = array(
41
	'name'    => __( 'Donor', 'give' ),
42
	'value'   => $full_name,
43
	'display' => $give_receipt_args['donor'],
44
);
45
46
/**
47
 * Show Company name on Donation receipt Page
48
 *
49
 * @since 2.0.7
50
 *
51
 * @param bool show/hide company name in donation receipt page.
52
 *
53
 * @return bool show/hide company name in donation receipt page.
54
 */
55
$give_receipt_args['donation_receipt']['company_name'] = array(
56
	'name'    => __( 'Company Name', 'give' ),
57
	'value'   => esc_attr( $company_name ),
58
	// Do not show company field if empty
59
	'display' => empty( $company_name ) ? false : $give_receipt_args['company_name'],
60
);
61
62
$give_receipt_args['donation_receipt']['date'] = array(
63
	'name'    => __( 'Date', 'give' ),
64
	'value'   => date_i18n( give_date_format(), strtotime( give_get_payment_completed_date( $donation_id ) ) ),
65
	'display' => $give_receipt_args['date'],
66
);
67
68
$give_receipt_args['donation_receipt']['total_donation'] = array(
69
	'name'    => __( 'Total Donation', 'give' ),
70
	'value'   => give_donation_amount( $donation_id, array( 'currency' => true, 'amount' => true, 'type' => 'receipt' ) ),
71
	'display' => $give_receipt_args['price'],
72
);
73
74
$give_receipt_args['donation_receipt']['donation'] = array(
75
	'name'    => __( 'Donation', 'give' ),
76
	'value'   => $form_name,
77
	'display' => true,
78
);
79
80
$give_receipt_args['donation_receipt']['donation_status'] = array(
81
	'name'    => __( 'Donation Status', 'give' ),
82
	'value'   => esc_attr( $status_label ),
83
	'display' => $give_receipt_args['payment_status'],
84
);
85
86
$give_receipt_args['donation_receipt']['donation_id'] = array(
87
	'name'    => __( 'Donation ID', 'give' ),
88
	'value'   => $donation_number,
89
	'display' => $give_receipt_args['payment_id'],
90
);
91
92
$give_receipt_args['donation_receipt']['payment_method'] = array(
93
	'name'    => __( 'Payment Method', 'give' ),
94
	'value'   => give_get_gateway_checkout_label( give_get_payment_gateway( $donation_id ) ),
95
	'display' => $give_receipt_args['payment_method'],
96
);
97
98
/**
99
 * Extend Give Donation Receipt
100
 *
101
 * You can easily extend the donation receipt argument using the filter give_donation_receipt_args
102
 *
103
 * @params array $give_receipt_args['donation_receipt'] Array of arguments for Donation Receipt.
104
 * @params int   $donation_id                           Donation ID.
105
 * @params int   $form_id                               Donation Form ID.
106
 *
107
 * @since 1.8.8
108
 */
109
$give_receipt_args['donation_receipt'] = apply_filters( 'give_donation_receipt_args', $give_receipt_args['donation_receipt'], $donation_id, $form_id );
110
111
// When the donation were made through offline donation, We won't show receipt and payment status though.
112
if ( 'offline' === give_get_payment_gateway( $donation_id ) && 'pending' === $status ) {
113
114
	/**
115
	 * Before the offline donation receipt content starts.
116
	 *
117
	 * @since 1.8.14
118
	 *
119
	 * @param Give_Payment $donation          Donation object.
120
	 * @param array        $give_receipt_args Receipt Arguments.
121
	 */
122
	do_action( 'give_receipt_before_offline_payment', $donation, $give_receipt_args );
123
	?>
124
	<h2><?php echo apply_filters( 'give_receipt_offline_payment_heading', __( 'Your Donation is Almost Complete!', 'give' ) ); ?></h2>
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'apply_filters'
Loading history...
125
	<div id="give_donation_receipt" class="<?php echo esc_attr( apply_filters( 'give_receipt_offline_payment_classes', 'give_receipt_offline_payment' ) ); ?>">
126
		<?php
127
		// Instruction for offline donation.
128
		$offline_instruction = give_get_offline_payment_instruction( $form_id, true );
129
130
		/**
131
		 * Instruction for the offline donation.
132
		 *
133
		 * @since 1.8.14
134
		 *
135
		 * @param string       $offline_instruction Offline instruction content.
136
		 * @param Give_Payment $donation            Donation object.
137
		 * @param integer      $form_id             Donation form id.
138
		 */
139
		echo apply_filters( 'give_receipt_offline_payment_instruction', $offline_instruction, $donation, $form_id );
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'apply_filters'
Loading history...
140
		?>
141
	</div>
142
	<?php
143
	/**
144
	 * After the offline donation content ends.
145
	 *
146
	 * @since 1.8.14
147
	 *
148
	 * @param Give_Payment $donation          Donation object.
149
	 * @param array        $give_receipt_args Receipt Arguments.
150
	 */
151
	do_action( 'give_receipt_after_offline_payment', $donation, $give_receipt_args );
152
153
	return;
154
}
155
156
// Show payment status notice based on shortcode attribute.
157
if ( filter_var( $give_receipt_args['status_notice'], FILTER_VALIDATE_BOOLEAN ) ) {
158
	$notice_message = '';
159
	$notice_type    = 'warning';
160
161
	switch ( $status ) {
162
		case 'publish':
163
			$notice_message = __( 'Payment Complete: Thank you for your donation.', 'give' );
164
			$notice_type    = 'success';
165
			break;
166
		case 'pending':
167
			$notice_message = __( 'Payment Pending: Your donation is currently processing.', 'give' );
168
			$notice_type    = 'warning';
169
			break;
170
		case 'refunded':
171
			$notice_message = __( 'Payment Refunded: Your donation has been refunded.', 'give' );
172
			$notice_type    = 'warning';
173
			break;
174
		case 'preapproval':
175
			$notice_message = __( 'Payment Preapproved: Thank you for your donation.', 'give' );
176
			$notice_type    = 'warning';
177
			break;
178
		case 'failed':
179
			$notice_message = __( 'Payment Failed: Please contact the site owner for assistance.', 'give' );
180
			$notice_type    = 'error';
181
			break;
182
		case 'cancelled':
183
			$notice_message = __( 'Payment Cancelled: Your donation has been cancelled.', 'give' );
184
			$notice_type    = 'error';
185
			break;
186
		case 'abandoned':
187
			$notice_message = __( 'Payment Abandoned: This donation has not been completed.', 'give' );
188
			$notice_type    = 'error';
189
			break;
190
		case 'revoked':
191
			$notice_message = __( 'Payment Revoked: Please contact the site owner for assistance.', 'give' );
192
			$notice_type    = 'error';
193
			break;
194
	}
195
196
	/**
197
	 * Filters payment status notice for receipts.
198
	 *
199
	 * By default, a success, warning, or error notice appears on the receipt
200
	 * with payment status. This filter allows the HTML markup
201
	 * and messaging for that notice to be customized.
202
	 *
203
	 * @since 1.0
204
	 *
205
	 * @param string $notice HTML markup for the default notice.
206
	 * @param int    $id     Post ID where the notice is displayed.
207
	 * @param string $status Payment status.
208
	 * @param int $donation_id Donation ID.
209
	 */
210
	echo apply_filters( 'give_receipt_status_notice', Give()->notices->print_frontend_notice( $notice_message, false, $notice_type ), $id, $status, $donation_id );
0 ignored issues
show
Expected a sanitizing function (see Codex for 'Data Validation'), but instead saw 'apply_filters'
Loading history...
211
212
}// End if().
213
214
/**
215
 * Fires in the donation receipt shortcode, before the receipt main table.
216
 *
217
 * Allows you to add elements before the table.
218
 *
219
 * @since 1.0
220
 *
221
 * @param object $donation          Donation object.
222
 * @param array  $give_receipt_args Receipt_argument.
223
 */
224
do_action( 'give_payment_receipt_before_table', $donation, $give_receipt_args );
225
?>
226
227
<table id="give_donation_receipt" class="give-table">
228
	<thead>
229
	<?php
230
	/**
231
	 * Fires in the donation receipt shortcode, before the receipt first header item.
232
	 *
233
	 * Allows you to add new <th> elements before the receipt first header item.
234
	 *
235
	 * @since 1.7
236
	 *
237
	 * @param object $donation          Donation object.
238
	 * @param array  $give_receipt_args Receipt_argument.
239
	 */
240
	do_action( 'give_payment_receipt_header_before', $donation, $give_receipt_args );
241
	?>
242
	<tr>
243
		<th scope="colgroup" colspan="2">
244
			<span class="give-receipt-thead-text"><?php esc_html_e( 'Donation Receipt', 'give' ) ?></span>
245
		</th>
246
	</tr>
247
	<?php
248
	/**
249
	 * Fires in the donation receipt shortcode, after the receipt last header item.
250
	 *
251
	 * Allows you to add new <th> elements after the receipt last header item.
252
	 *
253
	 * @since 1.7
254
	 *
255
	 * @param object $donation          Donation object.
256
	 * @param array  $give_receipt_args Receipt_argument.
257
	 */
258
	do_action( 'give_payment_receipt_header_after', $donation, $give_receipt_args );
259
	?>
260
	</thead>
261
262
	<tbody>
263
	<?php
264
	/**
265
	 * Fires in the donation receipt shortcode, before the receipt first item.
266
	 *
267
	 * Allows you to add new <td> elements before the receipt first item.
268
	 *
269
	 * @since 1.7
270
	 *
271
	 * @param object $donation          Donation object.
272
	 * @param array  $give_receipt_args Receipt_argument.
273
	 */
274
	do_action( 'give_payment_receipt_before', $donation, $give_receipt_args );
275
	?>
276
277
	<?php foreach ( $give_receipt_args['donation_receipt'] as $receipt_item ) { ?>
278
		<?php if ( filter_var( $receipt_item['display'], FILTER_VALIDATE_BOOLEAN ) ) : ?>
279
			<tr>
280
				<td scope="row"><strong><?php echo $receipt_item['name']; ?></strong></td>
0 ignored issues
show
Expected next thing to be a escaping function, not '$receipt_item'
Loading history...
281
				<td><?php echo $receipt_item['value']; ?></td>
0 ignored issues
show
Expected next thing to be a escaping function, not '$receipt_item'
Loading history...
282
			</tr>
283
		<?php endif; ?>
284
	<?php } ?>
285
286
	<?php
287
	/**
288
	 * Fires in the donation receipt shortcode, after the receipt last item.
289
	 *
290
	 * Allows you to add new <td> elements after the receipt last item.
291
	 *
292
	 * @since 1.7
293
	 *
294
	 * @param object $donation          Donation object.
295
	 * @param array  $give_receipt_args Receipt_argument.
296
	 */
297
	do_action( 'give_payment_receipt_after', $donation, $give_receipt_args );
298
	?>
299
	</tbody>
300
</table>
301
302
<?php
303
/**
304
 * Fires in the donation receipt shortcode, after the receipt main table.
305
 *
306
 * Allows you to add elements after the table.
307
 *
308
 * @since 1.7
309
 *
310
 * @param object $donation          Donation object.
311
 * @param array  $give_receipt_args Receipt_argument.
312
 */
313
do_action( 'give_payment_receipt_after_table', $donation, $give_receipt_args );
314
?>
315