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 | /** |
||
3 | * Gateway Actions |
||
4 | * |
||
5 | * @package Give |
||
6 | * @subpackage Gateways |
||
7 | * @copyright Copyright (c) 2016, WordImpress |
||
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 | * Processes gateway select on checkout. Only for users without ajax / javascript |
||
19 | * |
||
20 | * @since 1.0 |
||
21 | * |
||
22 | * @param $data |
||
23 | */ |
||
24 | function give_process_gateway_select( $data ) { |
||
0 ignored issues
–
show
|
|||
25 | if ( isset( $_POST['gateway_submit'] ) ) { |
||
0 ignored issues
–
show
|
|||
26 | wp_redirect( esc_url( add_query_arg( 'payment-mode', $_POST['payment-mode'] ) ) ); |
||
0 ignored issues
–
show
|
|||
27 | exit; |
||
28 | } |
||
29 | } |
||
30 | |||
31 | add_action( 'give_gateway_select', 'give_process_gateway_select' ); |
||
32 | |||
33 | /** |
||
34 | * Loads a payment gateway via AJAX. |
||
35 | * |
||
36 | * @since 1.0 |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
40 | function give_load_ajax_gateway() { |
||
41 | |||
42 | $post_data = give_clean( $_POST ); // WPCS: input var ok, CSRF ok. |
||
0 ignored issues
–
show
|
|||
43 | |||
44 | if ( isset( $post_data['give_payment_mode'] ) ) { |
||
45 | |||
46 | $form_id_prefix = ! empty( $post_data['give_form_id_prefix'] ) ? $post_data['give_form_id_prefix'] : ''; |
||
47 | |||
48 | $args = array( |
||
49 | 'id_prefix' => $form_id_prefix, |
||
50 | ); |
||
51 | |||
52 | /** |
||
53 | * Fire to render donation form. |
||
54 | * |
||
55 | * @since 1.7 |
||
56 | */ |
||
57 | do_action( 'give_donation_form', $post_data['give_form_id'], $args ); |
||
58 | |||
59 | exit(); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | add_action( 'wp_ajax_give_load_gateway', 'give_load_ajax_gateway' ); |
||
64 | add_action( 'wp_ajax_nopriv_give_load_gateway', 'give_load_ajax_gateway' ); |
||
65 | |||
66 | /** |
||
67 | * Create wp nonce using Ajax call. |
||
68 | * |
||
69 | * Use give_donation_form_nonce() js fn to create nonce. |
||
70 | * |
||
71 | * @since 2.0 |
||
72 | * |
||
73 | * @return void |
||
74 | */ |
||
75 | function give_donation_form_nonce() { |
||
76 | if ( isset( $_POST['give_form_id'] ) ) { |
||
77 | |||
78 | // Get donation form id. |
||
79 | $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
||
0 ignored issues
–
show
|
|||
80 | |||
81 | // Send nonce json data. |
||
82 | wp_send_json_success( wp_create_nonce( "give_donation_form_nonce_{$form_id}" ) ); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | add_action( 'wp_ajax_give_donation_form_nonce', 'give_donation_form_nonce' ); |
||
87 | add_action( 'wp_ajax_nopriv_give_donation_form_nonce', 'give_donation_form_nonce' ); |
||
88 | |||
89 | |||
90 | /** |
||
91 | * Create all nonce of donation form using Ajax call. |
||
92 | * Note: only for internal use |
||
93 | * |
||
94 | * @since 2.2.0 |
||
95 | * |
||
96 | * @return void |
||
97 | */ |
||
98 | function __give_donation_form_reset_all_nonce() { |
||
99 | if ( isset( $_POST['give_form_id'] ) ) { |
||
100 | |||
101 | // Get donation form id. |
||
102 | $form_id = is_numeric( $_POST['give_form_id'] ) ? absint( $_POST['give_form_id'] ) : 0; |
||
0 ignored issues
–
show
|
|||
103 | |||
104 | $data = array( |
||
105 | 'give_form_hash' => wp_create_nonce( "give_donation_form_nonce_{$form_id}" ), |
||
106 | 'give_form_user_register_hash' => wp_create_nonce( "give_form_create_user_nonce_{$form_id}" ) |
||
107 | ); |
||
108 | |||
109 | /** |
||
110 | * Filter the ajax request data |
||
111 | * |
||
112 | * @since 2.2.0 |
||
113 | * |
||
114 | */ |
||
115 | $data = apply_filters( 'give_donation_form_reset_all_nonce_data', $data ); |
||
116 | |||
117 | // Send nonce json data. |
||
118 | wp_send_json_success( $data ); |
||
119 | } |
||
120 | |||
121 | wp_send_json_error(); |
||
122 | } |
||
123 | |||
124 | add_action( 'wp_ajax_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce' ); |
||
125 | add_action( 'wp_ajax_nopriv_give_donation_form_reset_all_nonce', '__give_donation_form_reset_all_nonce' ); |
||
126 | |||
127 | /** |
||
128 | * Sets an error within the donation form if no gateways are enabled. |
||
129 | * @todo: we can deprecate this function in future because gateways will not empty if get via Give API. |
||
130 | * |
||
131 | * @since 1.0 |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | function give_no_gateway_error() { |
||
136 | $gateways = give_get_enabled_payment_gateways(); |
||
137 | |||
138 | if ( empty( $gateways ) ) { |
||
139 | give_set_error( 'no_gateways', esc_html__( 'You must enable a payment gateway to use Give.', 'give' ) ); |
||
140 | } else { |
||
141 | give_unset_error( 'no_gateways' ); |
||
142 | } |
||
143 | } |
||
144 | |||
145 | add_action( 'init', 'give_no_gateway_error' ); |
||
146 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.