Issues (1282)

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.

includes/emails/functions.php (2 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
 * Email Functions
4
 *
5
 * @package     Give
6
 * @subpackage  Emails
7
 * @copyright   Copyright (c) 2016, GiveWP
8
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
9
 * @since       1.0
10
 */
11
12
// Exit if accessed directly.
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * Email Donation Receipt.
19
 *
20
 * Email the donation confirmation to the donor via the customizable "Donation Receipt" settings.
21
 *
22
 * @param int  $payment_id   Payment ID.
23
 * @param bool $admin_notice Whether to send the admin email notification or not (default: true).
24
 *
25
 * @return void
26
 * @since 1.0
27
 *
28
 */
29
function give_email_donation_receipt( $payment_id, $admin_notice = true ) {
30
	/**
31
	 * Fire the action
32
	 */
33
	do_action( 'give_donation-receipt_email_notification', $payment_id );
34
35
	// If admin notifications are on, send the admin notice.
36
	if ( $admin_notice && give_is_setting_enabled( Give_Email_Notification::get_instance( 'new-donation' )->get_notification_status() ) ) {
37
		/**
38
		 * Fires in the donation email receipt.
39
		 *
40
		 * When admin email notices are not disabled, you can add new email notices.
41
		 *
42
		 * @param int   $payment_id   Payment id.
43
		 * @param mixed $payment_data Payment meta data.
44
		 *
45
		 * @since 1.0
46
		 *
47
		 */
48
		do_action( 'give_new-donation_email_notification', $payment_id, give_get_payment_meta( $payment_id ) );
49
	}
50
}
51
52
/**
53
 * Sends the Admin Sale Notification Email
54
 *
55
 * @param int $payment_id Payment ID (default: 0)
56
 *
57
 * @return void
58
 * @since 1.0
59
 *
60
 */
61
function give_admin_email_notice( $payment_id ) {
62
	/**
63
	 * Fires in the donation email receipt.
64
	 *
65
	 * When admin email notices are not disabled, you can add new email notices.
66
	 *
67
	 * @param int   $payment_id   Payment id.
68
	 * @param mixed $payment_data Payment meta data.
69
	 *
70
	 * @since 1.0
71
	 *
72
	 */
73
	do_action( 'give_new-donation_email_notification', $payment_id );
74
}
75
76
add_action( 'give_admin_donation_email', 'give_admin_email_notice' );
77
78
79
/**
80
 * Get default donation notification email text
81
 *
82
 * Returns the stored email text if available, the standard email text if not
83
 *
84
 * @return string $message
85
 * @since  1.0
86
 */
87
function give_get_default_donation_notification_email() {
88
89
	$default_email_body = __( 'Hi there,', 'give' ) . "\n\n";
90
	$default_email_body .= __( 'This email is to inform you that a new donation has been made on your website:', 'give' ) . ' {site_url}' . ".\n\n";
91
	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {name}' . "\n";
92
	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
93
	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
94
	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n\n";
95
	$default_email_body .= __( 'Thank you,', 'give' ) . "\n\n";
96
	$default_email_body .= '{sitename}' . "\n";
97
98
	return apply_filters( 'give_default_donation_notification_email', $default_email_body );
99
}
100
101
102
/**
103
 * Get default donation receipt email text
104
 *
105
 * Returns the stored email text if available, the standard email text if not
106
 *
107
 * @return string $message
108
 * @since  1.3.7
109
 */
110
function give_get_default_donation_receipt_email() {
111
112
	$default_email_body = __( 'Dear', 'give' ) . " {name},\n\n";
113
	$default_email_body .= __( 'Thank you for your donation. Your generosity is appreciated! Here are the details of your donation:', 'give' ) . "\n\n";
114
	$default_email_body .= '<strong>' . __( 'Donor:', 'give' ) . '</strong> {fullname}' . "\n";
115
	$default_email_body .= '<strong>' . __( 'Donation:', 'give' ) . '</strong> {donation}' . "\n";
116
	$default_email_body .= '<strong>' . __( 'Donation Date:', 'give' ) . '</strong> {date}' . "\n";
117
	$default_email_body .= '<strong>' . __( 'Amount:', 'give' ) . '</strong> {amount}' . "\n";
118
	$default_email_body .= '<strong>' . __( 'Payment Method:', 'give' ) . '</strong> {payment_method}' . "\n";
119
	$default_email_body .= '<strong>' . __( 'Payment ID:', 'give' ) . '</strong> {payment_id}' . "\n\n";
120
	$default_email_body .= '{receipt_link}' . "\n\n";
121
	$default_email_body .= "\n\n";
122
	$default_email_body .= __( 'Sincerely,', 'give' ) . "\n";
123
	$default_email_body .= '{sitename}' . "\n";
124
125
	return apply_filters( 'give_default_donation_receipt_email', $default_email_body );
126
}
127
128
/**
129
 * Get various correctly formatted names used in emails
130
 *
131
 * @param array             $user_info List of User Information.
132
 * @param Give_Payment|bool $payment   Payment Object.
133
 *
134
 * @return array $email_names
135
 * @since 1.0
136
 *
137
 */
138
function give_get_email_names( $user_info, $payment = false ) {
139
	$email_names = array();
140
141
	if ( is_a( $payment, 'Give_Payment' ) ) {
142
143
		if ( $payment->user_id > 0 ) {
144
145
			$user_data               = get_userdata( $payment->user_id );
146
			$email_names['name']     = $payment->first_name;
147
			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
148
			$email_names['username'] = $user_data->user_login;
149
150
		} elseif ( ! empty( $payment->first_name ) ) {
151
152
			$email_names['name']     = $payment->first_name;
153
			$email_names['fullname'] = trim( $payment->first_name . ' ' . $payment->last_name );
154
			$email_names['username'] = $payment->first_name;
155
156
		} else {
157
158
			$email_names['name']     = $payment->email;
159
			$email_names['username'] = $payment->email;
160
161
		}
162
	} else {
163
164
		// Support for old serialized data.
165
		if ( is_serialized( $user_info ) ) {
166
167
			// Security check.
168
			preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $user_info, $matches );
169
			if ( ! empty( $matches ) ) {
170
				return array(
171
					'name'     => '',
172
					'fullname' => '',
173
					'username' => '',
174
				);
175
			} else {
176
				$user_info = maybe_unserialize( $user_info );
177
			}
178
		}
179
180
		if ( isset( $user_info['id'] ) && $user_info['id'] > 0 && isset( $user_info['first_name'] ) ) {
181
			$user_data               = get_userdata( $user_info['id'] );
182
			$email_names['name']     = $user_info['first_name'];
183
			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
184
			$email_names['username'] = $user_data->user_login;
185
		} elseif ( isset( $user_info['first_name'] ) ) {
186
			$email_names['name']     = $user_info['first_name'];
187
			$email_names['fullname'] = $user_info['first_name'] . ' ' . $user_info['last_name'];
188
			$email_names['username'] = $user_info['first_name'];
189
		} else {
190
			$email_names['name']     = $user_info['email'];
191
			$email_names['username'] = $user_info['email'];
192
		}
193
	} // End if().
194
195
	// Set title prefix to name, if non empty.
196 View Code Duplication
	if ( ! empty( $user_info['title'] ) && ! empty( $user_info['last_name'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
197
		$email_names['name'] = give_get_donor_name_with_title_prefixes( $user_info['title'], $user_info['last_name'] );
198
	}
199
200
	// Set title prefix to fullname, if non empty.
201 View Code Duplication
	if ( ! empty( $user_info['title'] ) && ! empty( $email_names['fullname'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
202
		$email_names['fullname'] = give_get_donor_name_with_title_prefixes( $user_info['title'], $email_names['fullname'] );
203
	}
204
205
	return $email_names;
206
}
207