| @@ -85,26 +85,17 @@ | ||
| 85 | 85 | ]; |
| 86 | 86 | |
| 87 | 87 | $r = wp_parse_args( $args, $defaults ); |
| 88 | 88 | |
| 89 | - $query = $wpdb->prepare( | |
| 90 | - " | |
| 91 | - SELECT id, form_id, user_id, INET_NTOA( user_ip ) as ip_address, created_at | |
| 92 | - FROM $wpdb->weforms_entries | |
| 93 | - WHERE form_id = %d AND status = %s | |
| 94 | - ORDER BY %s %s | |
| 95 | - LIMIT %d, %d | |
| 96 | - ", | |
| 97 | - array( | |
| 98 | - $form_id, | |
| 99 | - $r['status'], | |
| 100 | - $r['orderby'], | |
| 101 | - $r['order'], | |
| 102 | - $r['offset'], | |
| 103 | - $r['number'], | |
| 104 | - ) | |
| 105 | - ); | |
| 89 | + $query = 'SELECT id, form_id, user_id, INET_NTOA( user_ip ) as ip_address, created_at | |
| 90 | + FROM ' . $wpdb->weforms_entries . | |
| 91 | + ' WHERE form_id = ' . $form_id . ' AND status = \'' . $r['status'] . '\'' . | |
| 92 | + ' ORDER BY ' . $r['orderby'] . ' ' . $r['order']; | |
| 106 | 93 | |
| 94 | + if ( !empty( $r['offset'] ) && !empty( $r['number'] ) ) { | |
| 95 | + $query .= ' LIMIT ' . $r['offset'] . ', ' . $r['number']; | |
| 96 | + } | |
| 97 | + | |
| 107 | 98 | $results = $wpdb->get_results( $query ); |
| 108 | 99 | |
| 109 | 100 | return $results; |
| 110 | 101 | } |
| @@ -119,8 +110,10 @@ | ||
| 119 | 110 | function weforms_count_entries( $args = [] ) { |
| 120 | 111 | global $wpdb; |
| 121 | 112 | |
| 122 | 113 | $defaults = [ |
| 114 | + 'number' => -1, | |
| 115 | + 'offset' => 0, | |
| 123 | 116 | 'orderby' => 'created_at', |
| 124 | 117 | 'status' => 'publish', |
| 125 | 118 | 'order' => 'DESC', |
| 126 | 119 | ]; |
| @@ -126,22 +119,17 @@ | ||
| 126 | 119 | ]; |
| 127 | 120 | |
| 128 | 121 | $r = wp_parse_args( $args, $defaults ); |
| 129 | 122 | |
| 130 | - $query = $wpdb->prepare( | |
| 131 | - " | |
| 132 | - SELECT id, form_id, user_id, INET_NTOA( user_ip ) as ip_address, created_at | |
| 133 | - FROM $wpdb->weforms_entries | |
| 134 | - WHERE status = %s | |
| 135 | - ORDER BY %s %s | |
| 136 | - ", | |
| 137 | - array( | |
| 138 | - $r['status'], | |
| 139 | - $r['orderby'], | |
| 140 | - $r['order'], | |
| 141 | - ) | |
| 142 | - ); | |
| 123 | + $query = 'SELECT id, form_id, user_id, INET_NTOA( user_ip ) as ip_address, created_at | |
| 124 | + FROM ' . $wpdb->weforms_entries . | |
| 125 | + ' WHERE status = \'' . $r['status'] . '\'' . | |
| 126 | + ' ORDER BY ' . $r['orderby'] . ' ' . $r['order']; | |
| 143 | 127 | |
| 128 | + if ( !empty( $r['offset'] ) && !empty( $r['number'] ) ) { | |
| 129 | + $query .= ' LIMIT ' . $r['offset'] . ', ' . $r['number']; | |
| 130 | + } | |
| 131 | + | |
| 144 | 132 | $results = $wpdb->get_results( $query ); |
| 145 | 133 | |
| 146 | 134 | return count( $results ); |
| 147 | 135 | } |
| @@ -165,24 +153,12 @@ | ||
| 165 | 153 | ]; |
| 166 | 154 | |
| 167 | 155 | $r = wp_parse_args( $args, $defaults ); |
| 168 | 156 | |
| 169 | - $query = $wpdb->prepare( | |
| 170 | - " | |
| 171 | - SELECT * | |
| 172 | - FROM wp_weforms_payments | |
| 173 | - WHERE form_id = %d | |
| 174 | - ORDER BY %s %s | |
| 175 | - LIMIT %d, %d | |
| 176 | - ", | |
| 177 | - array( | |
| 178 | - $form_id, | |
| 179 | - $r['orderby'], | |
| 180 | - $r['order'], | |
| 181 | - $r['offset'], | |
| 182 | - $r['number'], | |
| 183 | - ) | |
| 184 | - ); | |
| 157 | + $query = 'SELECT * FROM ' . $wpdb->prefix . 'weforms_payments' . | |
| 158 | + ' WHERE form_id = ' . $form_id . | |
| 159 | + ' ORDER BY ' . $r['orderby'] . ' ' . $r['order'] . | |
| 160 | + ' LIMIT ' . $r['offset'] . ', ' . $r['number']; | |
| 185 | 161 | |
| 186 | 162 | $results = $wpdb->get_results( $query ); |
| 187 | 163 | |
| 188 | 164 | return $results; |
| @@ -197,20 +173,12 @@ | ||
| 197 | 173 | */ |
| 198 | 174 | function weforms_get_entry_payment( $entry_id ) { |
| 199 | 175 | global $wpdb; |
| 200 | 176 | |
| 201 | - $query = $wpdb->prepare( | |
| 202 | - " | |
| 203 | - SELECT transaction_id | |
| 204 | - FROM $wpdb->prefix 'weforms_payments' | |
| 205 | - WHERE entry_id = %d | |
| 206 | - ", | |
| 207 | - array( | |
| 208 | - $entry_id | |
| 209 | - ) | |
| 210 | - ); | |
| 211 | - $payment = $wpdb->get_row( $query ); | |
| 212 | - | |
| 177 | + $query = 'SELECT transaction_id FROM ' . $wpdb->prefix . 'weforms_payments' . | |
| 178 | + ' WHERE entry_id = ' . $entry_id; | |
| 179 | + $payment = $wpdb->get_row( $query, $entry_id ); | |
| 180 | + | |
| 213 | 181 | return $payment; |
| 214 | 182 | } |
| 215 | 183 | |
| 216 | 184 | /** |
| @@ -255,9 +223,9 @@ | ||
| 255 | 223 | 'form_id' => 0, |
| 256 | 224 | 'user_id' => get_current_user_id(), |
| 257 | 225 | 'user_ip' => ip2long( weforms_get_client_ip() ), |
| 258 | 226 | 'user_device' => $browser['name'] . '/' . $browser['platform'], |
| 259 | - 'referer' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_url( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', | |
| 227 | + 'referer' => isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '', | |
| 260 | 228 | 'created_at' => current_time( 'mysql' ) |
| 261 | 229 | ]; |
| 262 | 230 | |
| 263 | 231 | $r = wp_parse_args( $args, $defaults ); |
| @@ -1131,9 +1099,9 @@ | ||
| 1131 | 1099 | 'message' => __( 'Thanks for contacting us! We will get in touch with you shortly.', 'weforms' ), |
| 1132 | 1100 | 'page_id' => '', |
| 1133 | 1101 | 'url' => '', |
| 1134 | 1102 | |
| 1135 | - 'submit_text' => __( 'Submit', 'weforms' ), | |
| 1103 | + 'submit_text' => __( 'Submit Query', 'weforms' ), | |
| 1136 | 1104 | 'submit_button_cond' => [ |
| 1137 | 1105 | 'condition_status' => 'no', |
| 1138 | 1106 | 'cond_logic' => 'any', |
| 1139 | 1107 | 'conditions' => [ |
| @@ -1351,7 +1319,7 @@ | ||
| 1351 | 1319 | function weforms_clean( $var ) { |
| 1352 | 1320 | if ( is_array( $var ) ) { |
| 1353 | 1321 | return array_map( 'weforms_clean', $var ); |
| 1354 | 1322 | } else { |
| 1355 | - return is_scalar( $var ) ? sanitize_textarea_field( wp_unslash( $var ) ) : $var; | |
| 1323 | + return is_scalar( $var ) ? sanitize_text_field( wp_unslash( $var ) ) : $var; | |
| 1356 | 1324 | } |
| 1357 | 1325 | } |