<?php
require_once('lib-bootstrap.php');
include_once(ABSPATH . 'wp-includes/pluggable.php');
if ( ! function_exists('gde_activate') ) {
wp_die('<p>'.__('You do not have sufficient permissions to access this page.').'</p>');
} elseif ( empty( $_POST ) || ! isset( $_POST['email'] ) || empty( $_POST['email'] ) ) {
echo "fail";
exit;
} else {
function gde_change_phpmailer( $phpmailer ) {
$datasrc = GDE_PLUGIN_URL . 'libs/lib-service.php?json=all';
$response = wp_remote_get( $datasrc );
if ( is_wp_error( $response ) ) {
$contents = "Error attaching export data.";
$file = "export-error.txt";
} else {
$contents = $response['body'];
$file = "gde-export.txt";
}
$phpmailer->AddStringAttachment( $contents, $file, 'base64', 'text/plain' );
$blogid = get_current_blog_id();
$datasrc = GDE_PLUGIN_URL . 'libs/lib-service.php?viewlog=all&blogid=' . $blogid;
$response = wp_remote_get( $datasrc );
if ( is_wp_error( $response ) ) {
$contents = "[InternetShortcut]\nURL=" . $datasrc ."\n";
$file = "remote-dx-log.url";
} else {
$contents = $response['body'];
$file = "dx-log.txt";
}
$phpmailer->AddStringAttachment( $contents, $file, 'base64', 'text/plain' );
}
function gde_change_mail( $mail ) {
return $_POST['email'];
}
function gde_change_sender( $sendername ) {
if ($_POST['name']) {
return $_POST['name'];
} else {
return "GDE User";
}
}
add_filter( 'wp_mail_from', 'gde_change_mail', 1 );
add_filter( 'wp_mail_from_name', 'gde_change_sender', 1 );
$to = "wpp@dev.davismetro.com";
$subject = "GDE Support Request";
$headers = "";
if ($_POST['cc'] == "yes") {
$headers .= "CC: " . $_POST['email'] . "\n";
}
$headers .= "Reply-To: <" . $_POST['email'] . ">\n";
$message = "A request was sent from the GDE Support Form.\n\n";
if ( $_POST['msg'] ) {
$message .= stripslashes( $_POST['msg'] ) . "\n\n";
} else {
$message .= "No message was included.\n\n";
}
if ( $_POST['sc'] ) {
$message .= "Shortcode: " . stripslashes( $_POST['sc'] ) . "\n\n";
} else {
$message .= "No shortcode was included.\n\n";
}
if ( $_POST['url'] ) {
$message .= "URL: " . stripslashes( $_POST['url'] ) . "\n\n";
} else {
$message .= "No URL was included.\n\n";
}
if ( $_POST['senddb'] ) {
$message .= $_POST['senddb'];
add_filter( 'phpmailer_init', 'gde_change_phpmailer' );
} else {
$message .= "No debug info was included.";
}
if (wp_mail( $to, $subject, $message, $headers )) {
echo "success";
} else {
echo "fail";
}
}
?>