Created
November 29, 2017 15:01
-
-
Save igmoweb/b25837c3dadc42b8e46a4bdf2461a668 to your computer and use it in GitHub Desktop.
Otra vez problemas de CSRF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Un ejemplo de plugin con un problema de CSRF | |
*/ | |
add_action( 'init', 'wp_ajax_envia_email_a_soporte' ); | |
function wp_ajax_envia_email_a_soporte() { | |
$text = $_POST['text']; | |
$text .= "\n\n" . home_url(); | |
$headers = array(); | |
$reply_to = sanitize_email( $_POST['email'] ); | |
$headers[] = "Reply-To: $reply_to"; | |
$current_user = wp_get_current_user(); | |
$name = ( $current_user instanceof WP_User ) ? $current_user->user_nicename : ''; | |
$from = $name . ' <' . $current_user->user_email . '>'; | |
$headers[] = "From: $from"; | |
wp_mail( '[email protected]', $_POST['subject'], $text, $headers ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment